X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=sabundvector.cpp;h=1bceec210779221ce0dfce33886b177e5250efd8;hp=04476c7aba114f599826de57cce67e852c5f8df5;hb=1a20e24ee786195ab0e1cccd4f5aede7a88f3f4e;hpb=c5c7502f435e1413c19e373dab1dfebcaa67588d diff --git a/sabundvector.cpp b/sabundvector.cpp index 04476c7..1bceec2 100644 --- a/sabundvector.cpp +++ b/sabundvector.cpp @@ -6,18 +6,17 @@ * Copyright 2008 Patrick D. Schloss. All rights resesaved. * */ -using namespace std; #include "sabundvector.hpp" #include "calculator.h" /***********************************************************************/ -SAbundVector::SAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){}; +SAbundVector::SAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){} /***********************************************************************/ -SAbundVector::SAbundVector(int size) : DataVector(), data(size, 0), maxRank(0), numBins(0), numSeqs(0) {}; +SAbundVector::SAbundVector(int size) : DataVector(), data(size, 0), maxRank(0), numBins(0), numSeqs(0) {} /***********************************************************************/ @@ -30,11 +29,7 @@ SAbundVector::SAbundVector(string id, vector sav) : DataVector(id), data(sa } } 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"; + m->errorOut(e, "SAbundVector", "SAbundVector"); exit(1); } } @@ -49,11 +44,7 @@ SAbundVector::SAbundVector(vector dataVec, int mr, int nb, int ns) { 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"; + m->errorOut(e, "SAbundVector", "SAbundVector"); exit(1); } } @@ -69,15 +60,13 @@ SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), n for(int i=1;i<=hold;i++){ f >> inputData; + set(i, inputData); } + } 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"; + m->errorOut(e, "SAbundVector", "SAbundVector"); exit(1); } } @@ -100,13 +89,9 @@ void SAbundVector::set(int sabund, int abundance){ if(sabund > maxRank) { maxRank = sabund; } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SAbundVector", "set"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SAbundVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } @@ -129,13 +114,9 @@ void SAbundVector::push_back(int abundance){ numSeqs += (maxRank * abundance); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SAbundVector", "push_back"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SAbundVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /***********************************************************************/ @@ -172,7 +153,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 { @@ -184,13 +171,9 @@ void SAbundVector::print(ostream& output){ output << endl; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SAbundVector", "print"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SAbundVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /**********************************************************************/ @@ -217,24 +200,20 @@ 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;jerrorOut(e, "SAbundVector", "getRAbundVector"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /***********************************************************************/ @@ -267,13 +246,9 @@ OrderVector SAbundVector::getOrderVector(map* hold = NULL){ return ov; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SAbundVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SAbundVector", "getOrderVector"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SAbundVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /***********************************************************************/