]> git.donarmstrong.com Git - mothur.git/blob - phylotree.h
added phylotype command which reads a taxonomy file and creates a .list, .rabund...
[mothur.git] / phylotree.h
1 #ifndef DOTAXONOMY_H
2 #define DOTAXONOMY_H
3
4 /*
5  * phylotree.h
6  *  
7  *
8  *  Created by Pat Schloss on 6/17/09.
9  *  Copyright 2009 Patrick D. Schloss. All rights reserved.
10  *
11  */
12
13 #include "mothur.h"
14
15 /**************************************************************************************************/
16
17 struct TaxNode {
18         vector<string> accessions;      //names of seqs in this branch of tree
19         map<string, int> children;  //childs name to index in tree
20         int parent, childNumber, level;
21         string name, heirarchyID;
22         
23         TaxNode(string n) : name(n), level(0), parent(-1) {             }
24         TaxNode(){}
25 };
26
27 /**************************************************************************************************/
28
29 class PhyloTree {
30
31 public:
32         PhyloTree();
33         PhyloTree(string);  //pass it a taxonomy file and it makes the tree
34         ~PhyloTree() {};
35         void addSeqToTree(string, string);
36         void assignHeirarchyIDs(int);
37         void print(ofstream&);
38         vector<int> getGenusNodes();    
39         TaxNode get(int i)                              {       return tree[i]; }
40         TaxNode get(string seqName)             {       return tree[name2Taxonomy[seqName]];    }
41         int getIndex(string seqName)    {       return name2Taxonomy[seqName];  }
42         string getName(int i)                   {       return tree[i].name;    }
43 private:
44         string getNextTaxon(string&);
45         vector<TaxNode> tree;
46         vector<int> genusIndex; //holds the indexes in tree where the genus level taxonomies are stored
47         map<string, int> name2Taxonomy;  //maps name to index in tree
48         map<int, int> uniqueTaxonomies;  //map of unique taxonomies
49         void print(int, ofstream&);
50         int numNodes;
51         int numSeqs;
52 };
53
54 /**************************************************************************************************/
55
56 #endif
57
58