]> git.donarmstrong.com Git - mothur.git/blob - phylotree.h
fixes while testing 1.33.0
[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(ifstream&, string);  //pass it a taxonomy file and it makes the train.tree
36         ~PhyloTree() {};
37         int addSeqToTree(string, string);
38         void assignHeirarchyIDs(int);
39         void printTreeNodes(string); //used by bayesian to save time
40         vector<int> getGenusNodes();
41         vector<int> getGenusTotals();   
42         void setUp(string);  //used to create file needed for summary file if you use () constructor and add seqs manually instead of passing taxonomyfile
43                 
44         TaxNode get(int i);                             
45         TaxNode get(string seqName);
46         string getName(int i);                  
47         int getGenusIndex(string seqName);      
48         string getFullTaxonomy(string);  //pass a sequence name return taxonomy
49     vector<string> getSeqs(string);      //returns names of sequences in given taxonomy
50         
51         int getMaxLevel()               {       return maxLevel;        }
52         int getNumSeqs()                {       return numSeqs;         }
53         int getNumNodes()               {       return tree.size();     }
54         
55         bool ErrorCheck(vector<string>);
56         
57 private:
58         string getNextTaxon(string&, string);
59         void print(ofstream&, vector<TaxNode>&); //used to create static reference taxonomy file
60         void fillOutTree(int, vector<TaxNode>&); //used to create static reference taxonomy file
61         void binUnclassified(string);
62         
63         vector<TaxNode> tree;
64         vector<int> genusIndex; //holds the indexes in tree where the genus level taxonomies are stored
65         vector<int> totals; //holds the numSeqs at each genus level taxonomy
66         map<string, int> name2Taxonomy;  //maps name to index in tree
67     map<string, int> name2GenusNodeIndex;
68         set<int> uniqueTaxonomies;  //map of unique taxonomies
69         map<int, int> leafNodes; //used to create static reference taxonomy file
70         //void print(int, ofstream&);
71         int numNodes;
72         int numSeqs;
73         int maxLevel;
74         bool calcTotals;
75         MothurOut* m;
76 };
77
78 /**************************************************************************************************/
79
80 #endif
81
82