]> git.donarmstrong.com Git - mothur.git/blobdiff - nameassignment.cpp
fixed cluster.split with average method
[mothur.git] / nameassignment.cpp
index 0c30898dd4085f5000a68c005ccbeee1bcd3650c..641be4e626fb9c52b9035a979acd95dbe654e35a 100644 (file)
@@ -87,16 +87,35 @@ void NameAssignment::print(ostream& out){
 //**********************************************************************************************************************
 
 int NameAssignment::get(string key){
-       
-       return  (*this)[key];   
-
+       try {
+               map<string, int>::iterator itGet = (*this).find(key);
+               
+               //if you can't find it
+               if (itGet == (*this).end()) { return -1; }
+               
+               return  (*this)[key];   
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NameAssignment", "get");
+               exit(1);
+       }
 }
 //**********************************************************************************************************************
 
 string NameAssignment::get(int key){
+       try {
        
-       return  reverse[key];   
-
+               map<int, string>::iterator itGet = reverse.find(key);
+       
+               if (itGet == reverse.end()) { return "not found"; }
+       
+               return  reverse[key];   
+       
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NameAssignment", "get");
+               exit(1);
+       }
 }
 //**********************************************************************************************************************