]> git.donarmstrong.com Git - mothur.git/blob - phylotree.h
some changes while testing 1.9
[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 #include "mothurout.h"
15
16 /**************************************************************************************************/
17
18 struct TaxNode {
19         vector<string> accessions;      //names of seqs in this branch of tree
20         map<string, int> children;  //childs name to index in tree
21         int parent, childNumber, level;
22         string name, heirarchyID;
23         
24         TaxNode(string n) : name(n), level(0), parent(-1) {             }
25         TaxNode(){}
26 };
27
28 /**************************************************************************************************/
29
30 class PhyloTree {
31
32 public:
33         PhyloTree();
34         PhyloTree(string);  //pass it a taxonomy file and it makes the tree
35         ~PhyloTree() {};
36         int addSeqToTree(string, string);
37         void assignHeirarchyIDs(int);
38         void print(ofstream&);
39         vector<int> getGenusNodes();
40         void binUnclassified();
41                 
42         TaxNode get(int i)                              {       return tree[i];                                                 }
43         TaxNode get(string seqName)             {       return tree[name2Taxonomy[seqName]];    }
44         int getIndex(string seqName)    {       return name2Taxonomy[seqName];                  }
45         string getName(int i)                   {       return tree[i].name;                                    }
46         string getFullTaxonomy(string);  //pass a sequence name return taxonomy
47         int getMaxLevel()                               {       return maxLevel;                                                }
48         
49 private:
50         string getNextTaxon(string&);
51         vector<TaxNode> tree;
52         vector<int> genusIndex; //holds the indexes in tree where the genus level taxonomies are stored
53         map<string, int> name2Taxonomy;  //maps name to index in tree
54         map<int, int> uniqueTaxonomies;  //map of unique taxonomies
55         void print(int, ofstream&);
56         int numNodes;
57         int numSeqs;
58         int maxLevel;
59         MothurOut* m;
60 };
61
62 /**************************************************************************************************/
63
64 #endif
65
66