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