]> git.donarmstrong.com Git - mothur.git/blobdiff - treemap.cpp
*** empty log message ***
[mothur.git] / treemap.cpp
index 9eb8330ad1917a26441b8c22527b50652dbd011a..5880b0c593fdd0dc96808e485921d96871e865d6 100644 (file)
@@ -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) {
@@ -138,3 +144,31 @@ void TreeMap::print(ostream& output){
 }
 
 /************************************************************/
+void TreeMap::makeSim(GroupMap* groupmap) {
+       try {
+               //set names of groups
+               namesOfGroups = groupmap->namesOfGroups;
+               
+               //set names of seqs to names of groups
+               namesOfSeqs = groupmap->namesOfGroups;
+               
+               // make map where key and value are both the group name since that what the tree.groups command wants
+               for (int i = 0; i < namesOfGroups.size(); i++) {
+                       treemap[namesOfGroups[i]].groupname = namesOfGroups[i];
+                       seqsPerGroup[namesOfGroups[i]] = 1;
+               }
+               
+               numGroups = namesOfGroups.size();
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the TreeMap class function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+/************************************************************/
+