]> git.donarmstrong.com Git - mothur.git/blobdiff - sabundvector.cpp
added shannonrange calc.
[mothur.git] / sabundvector.cpp
index b70c642643cfd746e63c236e328feb8e37d74a44..0b3dde6fe9312b72d2f08a716b5b61ee01cca64d 100644 (file)
@@ -29,7 +29,7 @@ SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sa
                }
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "SAbundVector");
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -44,7 +44,7 @@ SAbundVector::SAbundVector(vector <int> dataVec, int mr, int nb, int ns) {
                numSeqs = ns;
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "SAbundVector");
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -54,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;
        
@@ -62,9 +62,10 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n
                        f >> inputData;
                        set(i, inputData);
                }
+
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "SAbundVector");
+               m->errorOut(e, "SAbundVector", "SAbundVector");
                exit(1);
        }
 }
@@ -87,7 +88,7 @@ void SAbundVector::set(int sabund, int abundance){
                if(sabund > maxRank)    {       maxRank = sabund;               }
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "set");
+               m->errorOut(e, "SAbundVector", "set");
                exit(1);
        }
 }
@@ -112,7 +113,7 @@ void SAbundVector::push_back(int abundance){
                numSeqs += (maxRank * abundance);
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "push_back");
+               m->errorOut(e, "SAbundVector", "push_back");
                exit(1);
        }
 }
@@ -151,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 {
@@ -163,7 +170,7 @@ void SAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "print");
+               m->errorOut(e, "SAbundVector", "print");
                exit(1);
        }
 }
@@ -192,18 +199,18 @@ 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) {
-               errorOut(e, "SAbundVector", "getRAbundVector");
+               m->errorOut(e, "SAbundVector", "getRAbundVector");
                exit(1);
        }
 }
@@ -238,7 +245,7 @@ OrderVector SAbundVector::getOrderVector(map<string,int>* hold = NULL){
                return ov;
        }
        catch(exception& e) {
-               errorOut(e, "SAbundVector", "getOrderVector");
+               m->errorOut(e, "SAbundVector", "getOrderVector");
                exit(1);
        }
 }