X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedrabundvector.cpp;h=6bf4916ea2ceb2a412a7833faa1386eb9d43d06f;hb=b7cce6e0a45013919e76a266533fcca4052cf157;hp=1711012d4a0e06945492252d0c9bdaca4d9bac90;hpb=37519fc35c0eb1523e84227517694c4015847c6d;p=mothur.git diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 1711012..6bf4916 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -7,9 +7,6 @@ * */ - -using namespace std; - #include "sharedrabundvector.h" #include "sabundvector.hpp" #include "ordervector.hpp" @@ -18,11 +15,12 @@ using namespace std; /***********************************************************************/ -SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {}; +SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {globaldata = GlobalData::getInstance();} /***********************************************************************/ SharedRAbundVector::SharedRAbundVector(int n) : DataVector(), maxRank(0), numBins(n), numSeqs(0) { + globaldata = GlobalData::getInstance(); individual newGuy; //initialize data for (int i=0; i< n; i++) { @@ -30,7 +28,7 @@ SharedRAbundVector::SharedRAbundVector(int n) : DataVector(), maxRank(0), numBin newGuy.abundance = 0; data.push_back(newGuy); } -}; +} /*********************************************************************** @@ -65,7 +63,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), if (globaldata->gGroupmap == NULL) { groupmap = new GroupMap(); } - int num, inputData, pos, count; + int num, inputData, count; count = 0; string holdLabel, nextLabel, groupN; individual newguy; @@ -78,7 +76,8 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), holdLabel = label; //add new vector to lookup - lookup.push_back(new SharedRAbundVector()); + SharedRAbundVector* temp = new SharedRAbundVector(); + lookup.push_back(temp); lookup[0]->setLabel(label); lookup[0]->setGroup(groupN); @@ -100,9 +99,6 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), } - //save position in file in case next line is a new label. - pos = f.tellg(); - if (f.eof() != true) { f >> nextLabel; } //read the rest of the groups info in @@ -117,7 +113,8 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), } //add new vector to lookup - lookup.push_back(new SharedRAbundVector()); + temp = new SharedRAbundVector(); + lookup.push_back(temp); lookup[count]->setLabel(label); lookup[count]->setGroup(groupN); @@ -127,16 +124,14 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), lookup[count]->push_back(inputData, i, groupN); //abundance, bin, group } - //save position in file in case next line is a new label. - pos = f.tellg(); - + if (f.eof() != true) { f >> nextLabel; } } //put file pointer back since you are now at a new distance label - f.seekg(pos, ios::beg); + for (int i = 0; i < nextLabel.length(); i++) { f.unget(); } - if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } + if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } } catch(exception& e) { @@ -151,12 +146,6 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), /***********************************************************************/ -SharedRAbundVector::~SharedRAbundVector() { - -} - -/***********************************************************************/ - void SharedRAbundVector::set(int binNumber, int newBinSize, string groupname){ try { int oldBinSize = data[binNumber].abundance; @@ -398,7 +387,9 @@ vector SharedRAbundVector::getSharedRAbundVectors(){ i--; } } - + + delete util; + return lookup; } catch(exception& e) {