]> git.donarmstrong.com Git - mothur.git/blobdiff - sabundvector.cpp
changed defaults in allign.seqs command
[mothur.git] / sabundvector.cpp
index 4a926b26f17a7002217240156fdf9ae8e936b41f..04476c7aba114f599826de57cce67e852c5f8df5 100644 (file)
@@ -9,9 +9,7 @@
 using namespace std;
 
 #include "sabundvector.hpp"
-#include "datavector.hpp"
-#include "utilities.hpp"
-#include <exception>
+#include "calculator.h"
 
 /***********************************************************************/
 
@@ -25,7 +23,6 @@ SAbundVector::SAbundVector(int size) :        DataVector(), data(size, 0), maxRank(0),
 
 SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sav) {
        try {
-               
                for(int i=0;i<sav.size();i++){
                        if(data[i] != 0){       maxRank = i;    }
                        numSeqs += i*data[i];
@@ -44,6 +41,24 @@ SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sa
 
 /***********************************************************************/
 
+SAbundVector::SAbundVector(vector <int> dataVec, int mr, int nb, int ns) {
+       try {
+               data = dataVec;
+               maxRank = mr;
+               numBins = nb;
+               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";
+               exit(1);
+       }
+}
+/***********************************************************************/
+
 SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), numSeqs(0) {
        try {
                int hold;
@@ -67,6 +82,7 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n
        }
 }
 
+
 /***********************************************************************/
 
 void SAbundVector::set(int sabund, int abundance){
@@ -93,6 +109,7 @@ void SAbundVector::set(int sabund, int abundance){
        }       
 }
 
+
 /***********************************************************************/
 
 int SAbundVector::get(int index){
@@ -120,6 +137,18 @@ void SAbundVector::push_back(int abundance){
                exit(1);
        }               
 }
+/***********************************************************************/
+
+void SAbundVector::quicksort(){
+       sort(data.rbegin(), data.rend());
+}
+
+/***********************************************************************/
+
+int SAbundVector::sum(){
+       VecCalc vecCalc;
+       return vecCalc.sumElements(data);
+}
 
 /***********************************************************************/