]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedordervector.cpp
modified chimera.slayer template=self
[mothur.git] / sharedordervector.cpp
index 218ed8709dd6ce4b624c233c4d60aa8c3cb4a27f..37cd28315a5c1928e965f7be8eef7ae0ef408692 100644 (file)
@@ -28,10 +28,9 @@ SharedOrderVector::SharedOrderVector(string id, vector<individual>  ov) :
 
 SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a shared file
        try {
-               globaldata = GlobalData::getInstance();
                maxRank = 0; numBins = 0; numSeqs = 0;
-               
-               if (globaldata->gGroupmap == NULL) {  groupmap = new GroupMap(); }
+                               
+               groupmap = new GroupMap(); 
                
                int num, inputData, count;
                count = 0;  numSeqs = 0;
@@ -42,11 +41,11 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                f >> label >> groupN >> num;
                holdLabel = label;
                
-               if (globaldata->gGroupmap == NULL) { 
-                       //save group in groupmap
-                       groupmap->namesOfGroups.push_back(groupN);
-                       groupmap->groupIndex[groupN] = 0;
-               }
+               
+               //save group in groupmap
+               groupmap->namesOfGroups.push_back(groupN);
+               groupmap->groupIndex[groupN] = 0;
+               
                
                for(int i=0;i<num;i++){
                        f >> inputData;
@@ -57,6 +56,8 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                        }
                }
                
+               m->gobble(f); 
+               
                if (f.eof() != true) { f >> nextLabel; }
                
                //read the rest of the groups info in
@@ -64,11 +65,11 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                        f >> groupN >> num;
                        count++;
                        
-                       if (globaldata->gGroupmap == NULL) { 
-                               //save group in groupmap
-                               groupmap->namesOfGroups.push_back(groupN);
-                               groupmap->groupIndex[groupN] = count;
-                       }
+                       
+                       //save group in groupmap
+                       groupmap->namesOfGroups.push_back(groupN);
+                       groupmap->groupIndex[groupN] = count;
+                       
                        
                        for(int i=0;i<num;i++){
                                f >> inputData;
@@ -79,6 +80,7 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                                }
                        }
                        
+                       m->gobble(f);
                                
                        if (f.eof() != true) { f >> nextLabel; }
 
@@ -87,17 +89,13 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a
                //put file pointer back since you are now at a new distance label
                for (int i = 0; i < nextLabel.length(); i++) { f.unget();  }
        
-               if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; }
+               m->namesOfGroups = groupmap->namesOfGroups;
                
                updateStats();
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "SharedOrderVector");
                exit(1);
        }
 }
@@ -167,20 +165,23 @@ void SharedOrderVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "print");
                exit(1);
        }
 }
 
+/***********************************************************************/
 
+void SharedOrderVector::clear(){
+       numBins = 0;
+       maxRank = 0;
+       numSeqs = 0;
+       data.clear();
+}
 /***********************************************************************/
 
 void SharedOrderVector::resize(int){
-       cout << "resize() did nothing in class SharedOrderVector";
+       m->mothurOut("resize() did nothing in class SharedOrderVector");
 }
 
 /***********************************************************************/
@@ -223,13 +224,9 @@ RAbundVector SharedOrderVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 /***********************************************************************/
 
@@ -247,11 +244,7 @@ OrderVector SharedOrderVector::getOrderVector(map<string,int>* nameMap = NULL) {
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "getOrderVector");
                exit(1);
        }
 }
@@ -281,14 +274,9 @@ SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) {
                return sharedRav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
                exit(1);
        }
-       
 }
 /***********************************************************************/
 vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
@@ -297,20 +285,15 @@ vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
                util = new SharedUtil();
                vector<SharedRAbundVector*> lookup;
                
-               util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
-               util->getSharedVectors(globaldata->Groups, lookup, this);
+               util->setGroups(m->Groups, m->namesOfGroups);
+               util->getSharedVectors(m->Groups, lookup, this);
                
                return lookup;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
                exit(1);
        }
-       
 }
 /***********************************************************************/
 SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
@@ -321,14 +304,9 @@ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
                                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "getSharedSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       
 }
 
 /***********************************************************************/
@@ -361,13 +339,9 @@ void SharedOrderVector::updateStats(){
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedOrderVector", "updateStats");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedOrderVector class function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/