5 * Created by Sarah Westcott on 12/1/08.
6 * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
12 /************************************************************/
14 GroupMap::GroupMap(string filename) {
15 groupFileName = filename;
16 openInputFile(filename, fileHandle);
20 /************************************************************/
21 GroupMap::~GroupMap(){}
23 /************************************************************/
24 void GroupMap::readMap() {
25 string seqName, seqGroup;
28 fileHandle >> seqName; //read from first column
29 fileHandle >> seqGroup; //read from second column
31 setNamesOfGroups(seqGroup);
33 groupmap[seqName] = seqGroup; //store data in map
39 /************************************************************/
40 int GroupMap::getNumGroups() { return namesOfGroups.size(); }
41 /************************************************************/
43 string GroupMap::getGroup(string sequenceName) {
45 it = groupmap.find(sequenceName);
46 if (it != groupmap.end()) { //sequence name was in group file
53 /************************************************************/
54 void GroupMap::setGroup(string sequenceName, string groupN) {
55 groupmap[sequenceName] = groupN;
57 /************************************************************/
58 void GroupMap::setNamesOfGroups(string seqGroup) {
61 for (i=0; i<namesOfGroups.size(); i++) {
62 if (namesOfGroups[i] != seqGroup) {
63 count++; //you have not found this group
65 break; //you already have it
68 if (count == namesOfGroups.size()) {
69 namesOfGroups.push_back(seqGroup); //new group
70 groupIndex[seqGroup] = index;
74 /************************************************************/
75 bool GroupMap::isValidGroup(string groupname) {
77 for (int i = 0; i < namesOfGroups.size(); i++) {
78 if (groupname == namesOfGroups[i]) { return true; }
84 errorOut(e, "GroupMap", "isValidGroup");