]> git.donarmstrong.com Git - mothur.git/blobdiff - nameassignment.cpp
added distance search method to classify.seqs
[mothur.git] / nameassignment.cpp
index cf4e6774c32706d506d472963bda6f9ac86df7f1..d098a48460d3331e14529cb0c53884465f71a8cf 100644 (file)
@@ -28,24 +28,30 @@ void NameAssignment::readMap(){
 //                     data[firstCol] = secondCol;                     //store data in map
 
                        list.push_back(secondCol);              //adds data's value to list
+                       reverse[rowIndex] = firstCol;
                        (*this)[firstCol] = rowIndex++;
                        gobble(fileHandle);
                }
                fileHandle.close();
        
-//             map<string, string>::iterator it = data.begin();
-//             for(it;it!=data.end();it++){
-//                     cout << it->first << endl;
-//                     (*this)[it->first] = rowIndex;
-//                     rowIndex++;
-//             }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the NameAssignment class Function readMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "NameAssignment", "readMap");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the NameAssignment class function readMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+//**********************************************************************************************************************
+void NameAssignment::push_back(string name) {
+       try{
+       
+               int num = (*this).size();
+               (*this)[name] = num;
+               reverse[num] = name;
+               
+               list.push_back(name);
+       }
+       catch(exception& e) {
+               errorOut(e, "NameAssignment", "push_back");
                exit(1);
        }
 }
@@ -60,19 +66,16 @@ ListVector NameAssignment::getListVector(void){
 
 //**********************************************************************************************************************
 
-void NameAssignment::print(void){
+void NameAssignment::print(ostream& out){
        try {
-               map<string,int>::iterator it = (*this).begin();
-               for(it;it!=(*this).end();it++){
-                       cout << it->first << '\t' << it->second << endl;  //prints out keys and values of the map this.
+               map<string,int>::iterator it;
+cout << (*this).size() << endl;
+               for(it = (*this).begin(); it!=(*this).end(); it++){
+                       out << it->first << '\t' <<  it->second << endl;  //prints out keys and values of the map this.
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the NameAssignment class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the NameAssignment class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "NameAssignment", "print");
                exit(1);
        }
 }
@@ -84,6 +87,12 @@ int NameAssignment::get(string key){
        return  (*this)[key];   
 
 }
+//**********************************************************************************************************************
 
+string NameAssignment::get(int key){
+       
+       return  reverse[key];   
+
+}
 //**********************************************************************************************************************