I've tried several different methods, some of which I found on here which include making a Node class and nested dictionaries, but I can't seem to get them to work.
My code currently takes in several lines of DNA (a,t,g,c) and stores then as a numpy array. It then finds the attribute that gives the most gain and splits the data into 4 new numpy arrays (dependent upon an a, t, g, or c being present at the attribute).
I'm unable to make a recursive function which can build the tree. I'm quite new to python and programming itself, so please describe with detail what I should do.
If you are looking to use a decision tree with python you can use the decision tree module from Sci-kit learn rather than write your own decision tree class and logic: http://scikit-learn.org/stable/modules/tree.html. Using the Scikit Learn decision tree module you can save the decision tree objects to memory or perhaps write certain attributes of the tree to a file or database.
Sci-kit learn, as well as the other python libraries that are a part of the Anacondas package are pretty much the standard in data exploration and analysis in python. You can get the Anaconda package from Continuum here: http://continuum.io/downloads
EDIT 1
I came across this on Hacker News. It's about building a decision tree in Python using PostgreSQL as the database you pull values from. Might be interesting to checkout: http://www.garysieling.com/blog/building-decision-tree-python-postgres-data