X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedrabundvector.cpp;h=9276b7bfdc0ae441a883f42ddd0aabcddf1f04bd;hb=3fd6dd6e4f19a458ac2966ee5458787e998a1bde;hp=d135091c3301ed428a8e8e0391a2120643a21520;hpb=e189982e0a9b7352ad57cc38ccee675f128be22e;p=mothur.git diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index d135091..9276b7b 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -73,8 +73,12 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } lookup.clear(); + if (globaldata->saveNextLabel == "") { f >> label; } + else { label = globaldata->saveNextLabel; } + //read in first row since you know there is at least 1 group. - f >> label >> groupN >> num; + f >> groupN >> num; + holdLabel = label; //add new vector to lookup @@ -98,13 +102,12 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), //numSeqs += inputData; //numBins++; if (inputData > maxRank) { maxRank = inputData; } - } - gobble(f); - - if (f.eof() != true) { f >> nextLabel; } + m->gobble(f); + if (!(f.eof())) { f >> nextLabel; } + //read the rest of the groups info in while ((nextLabel == holdLabel) && (f.eof() != true)) { f >> groupN >> num; @@ -112,6 +115,7 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), if (globaldata->gGroupmap == NULL) { //save group in groupmap + groupmap->namesOfGroups.push_back(groupN); groupmap->groupIndex[groupN] = count; } @@ -128,13 +132,12 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), lookup[count]->push_back(inputData, groupN); //abundance, bin, group } - gobble(f); + m->gobble(f); if (f.eof() != true) { f >> nextLabel; } } - - //put file pointer back since you are now at a new distance label - for (int i = 0; i < nextLabel.length(); i++) { f.unget(); } + + globaldata->saveNextLabel = nextLabel; if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } @@ -202,6 +205,16 @@ vector SharedRAbundVector::getData(){ } /***********************************************************************/ +void SharedRAbundVector::clear(){ + numBins = 0; + maxRank = 0; + numSeqs = 0; + data.clear(); + for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; } + lookup.clear(); +} +/***********************************************************************/ + void SharedRAbundVector::push_back(int binSize, string groupName){ try { individual newGuy; @@ -483,15 +496,15 @@ SharedOrderVector SharedRAbundVector::getSharedOrderVector() { OrderVector SharedRAbundVector::getOrderVector(map* nameMap = NULL) { try { OrderVector ov; - - for(int i=0;i