]> 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 fd7f3acecf930dbb39c822748c34c7420da19826..6b0a048cabd5748107c070405efe8df7c09cdafa 100644 (file)
@@ -8,12 +8,12 @@
  */
 using namespace std;
  
-#include "datavector.hpp"
+
 #include "utilities.hpp"
-#include <exception>
 #include "rabundvector.hpp"
 #include "sabundvector.hpp"
 #include "ordervector.hpp"
+#include "calculator.h"
 
 
 /***********************************************************************/
@@ -53,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);
+       }
+}
+
+
 
 /***********************************************************************/
 
@@ -161,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();                           
 }