]> git.donarmstrong.com Git - mothur.git/blob - groupmap.h
changes while testing
[mothur.git] / groupmap.h
1 #ifndef GROUPMAP_H
2 #define GROUPMAP_H
3 /*
4  *  groupmap.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 12/1/08.
8  *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11
12 #include "mothur.h"
13 #include "mothurout.h"
14
15 /* This class is a representation of the groupfile.  It is used by all the shared commands to determine what group a 
16         certain sequence belongs to. */
17
18 class GroupMap {
19 public:
20         GroupMap() { m = MothurOut::getInstance(); }
21         GroupMap(string);
22         ~GroupMap();
23         int readMap();
24     int readMap(string);
25         int readDesignMap();
26     int readDesignMap(string);
27         int getNumGroups();
28         bool isValidGroup(string);  //return true if string is a valid group
29         string getGroup(string);
30         void setGroup(string, string);
31         vector<string> getNamesOfGroups() {
32                 sort(namesOfGroups.begin(), namesOfGroups.end());
33                 groupIndex.clear();
34                 for (int i = 0; i < namesOfGroups.size(); i++) { groupIndex[namesOfGroups[i]] = i; }
35                 return namesOfGroups;
36         }
37     vector<string> getNamesSeqs();
38         void setNamesOfGroups(vector<string> sn) { namesOfGroups = sn; }
39         int getNumSeqs()  {  return groupmap.size();  }
40         vector<string> getNamesSeqs(vector<string>); //get names of seqs belonging to a group or set of groups
41         int getNumSeqs(string); //return the number of seqs in a given group
42     int getCopy(GroupMap*);
43     
44     
45     map<string, int> groupIndex;  //groupname, vectorIndex in namesOfGroups. - used by collectdisplays and libshuff commands.
46     
47 private:
48         vector<string> namesOfGroups;
49         MothurOut* m;
50         ifstream fileHandle;
51         string groupFileName;
52     int index;
53         map<string, string>::iterator it;
54         void setNamesOfGroups(string); 
55         map<string, string> groupmap; //sequence name and groupname
56         map<string, int> seqsPerGroup;  //maps groupname to number of seqs in that group
57 };
58
59 #endif