]> git.donarmstrong.com Git - mothur.git/blob - phylotree.h
changes to chop.seqs
[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 getIndex(string seqName);   
48                         
49         string getFullTaxonomy(string);  //pass a sequence name return taxonomy
50         int getMaxLevel()                               {       return maxLevel;                                                }
51         int getNumSeqs()  {  return numSeqs;  }
52         bool ErrorCheck(vector<string>);
53         
54 private:
55         string getNextTaxon(string&);
56         void print(ofstream&, vector<TaxNode>&); //used to create static reference taxonomy file
57         void fillOutTree(int, vector<TaxNode>&); //used to create static reference taxonomy file
58         void binUnclassified(string);
59         
60         vector<TaxNode> tree;
61         vector<int> genusIndex; //holds the indexes in tree where the genus level taxonomies are stored
62         vector<int> totals; //holds the numSeqs at each genus level taxonomy
63         map<string, int> name2Taxonomy;  //maps name to index in tree
64         map<int, int> uniqueTaxonomies;  //map of unique taxonomies
65         map<int, int> leafNodes; //used to create static reference taxonomy file
66         //void print(int, ofstream&);
67         int numNodes;
68         int numSeqs;
69         int maxLevel;
70         bool calcTotals;
71         MothurOut* m;
72 };
73
74 /**************************************************************************************************/
75
76 #endif
77
78