]> git.donarmstrong.com Git - mothur.git/blob - treemap.h
added subsample and consensus parameters to unifrac.weighted command
[mothur.git] / treemap.h
1 #ifndef TREEMAP_H
2 #define TREEMAP_H
3 /*
4  *  treemap.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 1/26/09.
8  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11
12 #include "mothur.h"
13 #include "groupmap.h"
14 #include "listvector.hpp"
15
16 /* This class is used by the read.tree command to build the tree container. */
17
18 struct GroupIndex {
19         string  groupname;
20         int             vectorIndex;
21 };
22
23 class GroupMap;
24 class ListVector;
25
26 class TreeMap {
27 public:
28         TreeMap() { m = MothurOut::getInstance(); }
29         TreeMap(string);
30         ~TreeMap();
31         int readMap();
32         int getNumGroups();
33         int getNumSeqs();
34         void setIndex(string, int);  //sequencename, index
35         int getIndex(string);           //returns vector index of sequence
36         bool isValidGroup(string);  //return true if string is a valid group
37         void removeSeq(string);  //removes a sequence, this is to accomadate trees that do not contain all the seqs in your groupfile
38         string getGroup(string);
39         void addSeq(string, string);
40         void addGroup(string s) { setNamesOfGroups(s); }
41         vector<string> getNamesOfGroups() {
42                 sort(namesOfGroups.begin(), namesOfGroups.end());
43                 return namesOfGroups;
44         }
45     
46     void print(ostream&);
47         void makeSim(vector<string>);  //takes groupmap info and fills treemap for use by tree.shared command.
48         void makeSim(ListVector*);  //takes listvector info and fills treemap for use by tree.shared command.   
49     vector<string> getNamesSeqs();
50         vector<string> getNamesSeqs(vector<string>); //get names of seqs belonging to a group or set of groups
51     int getCopy(TreeMap*);
52     
53     vector<string> namesOfSeqs;
54     map<string,int> seqsPerGroup;       //groupname, number of seqs in that group.
55         map<string, GroupIndex> treemap; //sequence name and <groupname, vector index>
56
57     
58 private:
59         vector<string> namesOfGroups;
60         ifstream fileHandle;
61         string groupFileName;
62         int numGroups;
63         map<string, GroupIndex>::iterator it;
64         map<string, int>::iterator it2;
65         void setNamesOfGroups(string); 
66         MothurOut* m;
67         
68         
69 };
70
71 #endif