]> git.donarmstrong.com Git - mothur.git/blobdiff - rabundvector.cpp
added the Calculators Thomas made in the fall. Added parameter and command error...
[mothur.git] / rabundvector.cpp
index d6b7d1225691e9287c94679317fa2ece34caf158..6b0a048cabd5748107c070405efe8df7c09cdafa 100644 (file)
@@ -13,6 +13,7 @@ using namespace std;
 #include "rabundvector.hpp"
 #include "sabundvector.hpp"
 #include "ordervector.hpp"
+#include "calculator.h"
 
 
 /***********************************************************************/
@@ -52,6 +53,26 @@ RAbundVector::RAbundVector(string id, vector<int> rav) : DataVector(id), data(ra
        }
 }
 
+/***********************************************************************/
+
+RAbundVector::RAbundVector(vector<int> rav, int mr, int nb, int ns) {
+       try {
+               numBins = nb;
+               maxRank = mr;
+               numSeqs = ns;
+               data = rav;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the RAbundVector class Function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the RAbundVector class function RAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+
 
 /***********************************************************************/
 
@@ -160,6 +181,33 @@ int RAbundVector::size(){
 
 /***********************************************************************/
 
+void RAbundVector::quicksort(){
+       sort(data.rbegin(), data.rend());
+}
+
+/***********************************************************************/
+
+int RAbundVector::sum(){
+       VecCalc vecCalc;
+       return vecCalc.sumElements(data);
+}
+
+/***********************************************************************/
+
+int RAbundVector::sum(int index){
+       VecCalc vecCalc;
+       return vecCalc.sumElements(data, index);
+}
+
+/***********************************************************************/
+
+int RAbundVector::numNZ(){
+       VecCalc vecCalc;
+       return vecCalc.numNZ(data);
+}
+
+/***********************************************************************/
+
 vector<int>::reverse_iterator RAbundVector::rbegin(){
        return data.rbegin();                           
 }