]> git.donarmstrong.com Git - mothur.git/blobdiff - sabundvector.cpp
added shannonrange calc.
[mothur.git] / sabundvector.cpp
index c1997d5d91bc3cbd8fffb240909aa3dae791f646..0b3dde6fe9312b72d2f08a716b5b61ee01cca64d 100644 (file)
@@ -29,11 +29,7 @@ SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sa
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -48,11 +44,7 @@ SAbundVector::SAbundVector(vector <int> dataVec, int mr, int nb, int ns) {
                numSeqs = ns;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -62,7 +54,7 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n
        try {
                int hold;
                f >> label >> hold;
-       
+        
                data.assign(hold+1, 0);
                int inputData;
        
@@ -70,13 +62,10 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n
                        f >> inputData;
                        set(i, inputData);
                }
+
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function SAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -99,13 +88,9 @@ void SAbundVector::set(int sabund, int abundance){
                if(sabund > maxRank)    {       maxRank = sabund;               }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "set");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 
@@ -128,13 +113,9 @@ void SAbundVector::push_back(int abundance){
                numSeqs += (maxRank * abundance);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "push_back");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 
@@ -171,7 +152,13 @@ void SAbundVector::print(string prefix, ostream& output){
        }
        output << endl;
 }
-
+/***********************************************************************/
+void SAbundVector::clear(){
+       numBins = 0;
+       maxRank = 0;
+       numSeqs = 0;
+       data.clear();   
+}
 /***********************************************************************/
 void SAbundVector::print(ostream& output){
        try {
@@ -183,13 +170,9 @@ void SAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /**********************************************************************/
@@ -216,24 +199,20 @@ RAbundVector SAbundVector::getRAbundVector(){
        try {
                RAbundVector rav;
        
-               for(int i=1;i<=data.size();i++){                
+               for(int i=1;i < data.size();i++){
                        for(int j=0;j<data[i];j++){
                                rav.push_back(i);
                        }
                }
                sort(rav.rbegin(), rav.rend());
-       
+
                rav.setLabel(label);
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -266,13 +245,9 @@ OrderVector SAbundVector::getOrderVector(map<string,int>* hold = NULL){
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SAbundVector", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/