]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedsabundvector.cpp
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / sharedsabundvector.cpp
index b2624840e568d5d90715db1d662bc0ee5d8e7567..efd14bcc249207ac4181fc552b8a918d57144083 100644 (file)
@@ -3,22 +3,17 @@
  *  Dotur
  *
  *  Created by Sarah Westcott on 12/10/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
+ *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
  *
  */
 
 #include "sharedsabundvector.h"
 #include "sabundvector.hpp"
-#include "datavector.hpp"
-#include "utilities.hpp"
-#include <exception>
-
-using namespace std;
 
 
 /***********************************************************************/
 
-SharedSAbundVector::SharedSAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){};
+SharedSAbundVector::SharedSAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){  }
 
 /***********************************************************************/
 
@@ -30,58 +25,6 @@ SharedSAbundVector::SharedSAbundVector(int size) :   DataVector(), maxRank(0), num
                        newGuy.abundance = 0;
                        data.push_back(newGuy);
                }
-       //      for(int i=0;i<data.size();i++){
-       //              if(data[i].abundance != 0){     maxRank = i;    }
-       //              numSeqs += i*data[i].abundance;
-       //              numBins += data[i].abundance;
-       //      }
-
-};
-
-/***********************************************************************
-
-SharedSAbundVector::SharedSAbundVector(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];
-                       numBins += data[i];
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function SharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function SharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/***********************************************************************
-
-SharedSAbundVector::SharedSAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               int hold;
-               f >> label >> hold;
-       
-               data.assign(hold+1, 0);
-               int inputData;
-       
-               for(int i=1;i<=hold;i++){
-                       f >> inputData;
-                       set(i, inputData);
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function SharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function SharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
 }
 
 /***********************************************************************/
@@ -102,13 +45,9 @@ void SharedSAbundVector::set(int bin, int abundance, string groupName){
                if(bin > maxRank)       {       maxRank = bin;          }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "set");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }
 
 /***********************************************************************/
@@ -140,13 +79,9 @@ void SharedSAbundVector::push_back(int abundance, int bin, string groupName){
                numSeqs += (maxRank * abundance);
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "push_back");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -172,13 +107,9 @@ void SharedSAbundVector::print(ostream& output){
                output << endl;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "print");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 string SharedSAbundVector::getGroup(){
@@ -212,7 +143,7 @@ RAbundVector SharedSAbundVector::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].abundance;j++){
                                rav.push_back(i);
                        }
@@ -223,13 +154,9 @@ RAbundVector SharedSAbundVector::getRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "getRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 /***********************************************************************/
 SAbundVector SharedSAbundVector::getSAbundVector(){
@@ -243,13 +170,9 @@ SAbundVector SharedSAbundVector::getSAbundVector(){
        
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "getSAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/
@@ -268,11 +191,9 @@ SharedRAbundVector SharedSAbundVector::getSharedRAbundVector(){
        try {
                SharedRAbundVector rav;
                
-               int binNumber = 0;
-               for(int i=1;i<=data.size();i++){                
+               for(int i=1;i<data.size();i++){         
                        for(int j=0;j<data[i].abundance;j++){
-                               rav.push_back(i, binNumber, data[i].group);
-                               binNumber++;
+                               rav.push_back(i, data[i].group);
                        }
                }
                sort(rav.rbegin(), rav.rend(), compareMembers);
@@ -283,13 +204,9 @@ SharedRAbundVector SharedSAbundVector::getSharedRAbundVector(){
                return rav;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSharedVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "getSharedRAbundVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSharedVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 
@@ -308,17 +225,24 @@ SharedOrderVector SharedSAbundVector::getSharedOrderVector() {
                rav = this->getSharedRAbundVector();
                ov = rav.getSharedOrderVector();
                
+               ov.updateStats();
+               
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "getSharedOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
+/***********************************************************************/
+
+void SharedSAbundVector::clear(){
+       numBins = 0;
+       maxRank = 0;
+       numSeqs = 0;
+       data.clear();
+}
+
 /***********************************************************************/
 OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
        try {
@@ -342,13 +266,9 @@ OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
                return ov;
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               m->errorOut(e, "SharedSAbundVector", "getOrderVector");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the SharedSAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }               
 }
 
 /***********************************************************************/