X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedlistvector.cpp;h=4774180dd6032c0de1b87597360af6d14e7c2a2d;hb=753dc84cf289b1d5dc0ca5b0c043640927aa951a;hp=2bceace2565f404a08b85e5af59cf18e295bd41a;hpb=fd282e6b4be2560f5b1bd154a9e8d24b798eefaf;p=mothur.git diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp index 2bceace..4774180 100644 --- a/sharedlistvector.cpp +++ b/sharedlistvector.cpp @@ -7,43 +7,41 @@ * */ - -using namespace std; - -#include -#include #include "sabundvector.hpp" #include "rabundvector.hpp" #include "ordervector.hpp" -#include "datavector.hpp" -#include "utilities.hpp" #include "sharedlistvector.h" #include "sharedordervector.h" +#include "sharedutilities.h" + +/***********************************************************************/ +SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();} /***********************************************************************/ -SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){}; +SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();} /***********************************************************************/ SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) { try { globaldata = GlobalData::getInstance(); - + //set up groupmap for later. groupmap = new GroupMap(globaldata->getGroupFile()); groupmap->readMap(); int hold; + string inputData; f >> label >> hold; data.assign(hold, ""); - string inputData = ""; for(int i=0;i> inputData; set(i, inputData); } + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -232,7 +230,10 @@ SharedOrderVector* SharedListVector::getSharedOrderVector(){ groupName = groupmap->getGroup(names); order->push_back(i, binSize, groupName); } + random_shuffle(order->begin(), order->end()); + order->updateStats(); + return order; } catch(exception& e) { @@ -271,6 +272,7 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) { rav.setLabel(label); rav.setGroup(groupName); + return rav; } @@ -283,6 +285,35 @@ SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) { exit(1); } } +/***********************************************************************/ +vector SharedListVector::getSharedRAbundVector() { + try { + SharedUtil* util; + util = new SharedUtil(); + vector lookup; + + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups); + + delete util; + + for (int i = 0; i < globaldata->Groups.size(); i++) { + SharedRAbundVector* temp = new SharedRAbundVector(); + *temp = getSharedRAbundVector(globaldata->Groups[i]); + lookup.push_back(temp); + } + + return lookup; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} /***********************************************************************/ SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {