]> git.donarmstrong.com Git - mothur.git/blobdiff - treemap.cpp
fixed bug in read.tree updates help and validparameters strings, added ability for...
[mothur.git] / treemap.cpp
index bee0d11ed21323ee9dff1bc38c860a3042231150..fee309c5877138039c2ecdff8f54428a8060bc24 100644 (file)
@@ -47,7 +47,7 @@ void TreeMap::readMap() {
 
 int TreeMap::getNumGroups() {
                        
-       return seqsPerGroup.size();     
+       return namesOfGroups.size();    
                
 }
 /************************************************************/
@@ -72,7 +72,13 @@ string TreeMap::getGroup(string sequenceName) {
 }
 /************************************************************/
 void TreeMap::setIndex(string seq, int index) {
-       treemap[seq].vectorIndex = index;
+       it = treemap.find(seq);
+       if (it != treemap.end()) { //sequence name was in group file
+               treemap[seq].vectorIndex = index;       
+       }else {
+               treemap[seq].vectorIndex = index;
+               treemap[seq].groupname = "not found";
+       }
 }
 /************************************************************/
 int TreeMap::getIndex(string seq) {
@@ -100,7 +106,24 @@ void TreeMap::setNamesOfGroups(string seqGroup) {
                                namesOfGroups.push_back(seqGroup); //new group
                        }
 }
-
+/************************************************************/
+bool TreeMap::isValidGroup(string groupname) {
+       try {
+               for (int i = 0; i < namesOfGroups.size(); i++) {
+                       if (groupname == namesOfGroups[i]) { return true; }
+               }
+               
+               return false;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the TreeMap class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
 /***********************************************************************/
 
 void TreeMap::print(ostream& output){