X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedordervector.cpp;h=37cd28315a5c1928e965f7be8eef7ae0ef408692;hb=643cdf74ccd4fc2d565168716fb5645917dee834;hp=76eeafa4b519c02b25c8364e19d3d0397ffdcd96;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2;p=mothur.git diff --git a/sharedordervector.cpp b/sharedordervector.cpp index 76eeafa..37cd283 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -28,10 +28,9 @@ SharedOrderVector::SharedOrderVector(string id, vector ov) : SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a shared file try { - globaldata = GlobalData::getInstance(); maxRank = 0; numBins = 0; numSeqs = 0; - - if (globaldata->gGroupmap == NULL) { groupmap = new GroupMap(); } + + groupmap = new GroupMap(); int num, inputData, count; count = 0; numSeqs = 0; @@ -42,11 +41,11 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a f >> label >> groupN >> num; holdLabel = label; - if (globaldata->gGroupmap == NULL) { - //save group in groupmap - groupmap->namesOfGroups.push_back(groupN); - groupmap->groupIndex[groupN] = 0; - } + + //save group in groupmap + groupmap->namesOfGroups.push_back(groupN); + groupmap->groupIndex[groupN] = 0; + for(int i=0;i> inputData; @@ -57,6 +56,8 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a } } + m->gobble(f); + if (f.eof() != true) { f >> nextLabel; } //read the rest of the groups info in @@ -64,11 +65,11 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a f >> groupN >> num; count++; - if (globaldata->gGroupmap == NULL) { - //save group in groupmap - groupmap->namesOfGroups.push_back(groupN); - groupmap->groupIndex[groupN] = count; - } + + //save group in groupmap + groupmap->namesOfGroups.push_back(groupN); + groupmap->groupIndex[groupN] = count; + for(int i=0;i> inputData; @@ -79,6 +80,7 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a } } + m->gobble(f); if (f.eof() != true) { f >> nextLabel; } @@ -87,13 +89,13 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a //put file pointer back since you are now at a new distance label for (int i = 0; i < nextLabel.length(); i++) { f.unget(); } - if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } + m->namesOfGroups = groupmap->namesOfGroups; updateStats(); } catch(exception& e) { - errorOut(e, "SharedOrderVector", "SharedOrderVector"); + m->errorOut(e, "SharedOrderVector", "SharedOrderVector"); exit(1); } } @@ -163,16 +165,23 @@ void SharedOrderVector::print(ostream& output){ output << endl; } catch(exception& e) { - errorOut(e, "SharedOrderVector", "print"); + m->errorOut(e, "SharedOrderVector", "print"); exit(1); } } +/***********************************************************************/ +void SharedOrderVector::clear(){ + numBins = 0; + maxRank = 0; + numSeqs = 0; + data.clear(); +} /***********************************************************************/ void SharedOrderVector::resize(int){ - mothurOut("resize() did nothing in class SharedOrderVector"); + m->mothurOut("resize() did nothing in class SharedOrderVector"); } /***********************************************************************/ @@ -215,7 +224,7 @@ RAbundVector SharedOrderVector::getRAbundVector(){ return rav; } catch(exception& e) { - errorOut(e, "SharedOrderVector", "getRAbundVector"); + m->errorOut(e, "SharedOrderVector", "getRAbundVector"); exit(1); } } @@ -235,7 +244,7 @@ OrderVector SharedOrderVector::getOrderVector(map* nameMap = NULL) { return ov; } catch(exception& e) { - errorOut(e, "SharedOrderVector", "getOrderVector"); + m->errorOut(e, "SharedOrderVector", "getOrderVector"); exit(1); } } @@ -265,7 +274,7 @@ SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) { return sharedRav; } catch(exception& e) { - errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); + m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); exit(1); } } @@ -276,13 +285,13 @@ vector SharedOrderVector::getSharedRAbundVector() { util = new SharedUtil(); vector lookup; - util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups); - util->getSharedVectors(globaldata->Groups, lookup, this); + util->setGroups(m->Groups, m->namesOfGroups); + util->getSharedVectors(m->Groups, lookup, this); return lookup; } catch(exception& e) { - errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); + m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); exit(1); } } @@ -295,7 +304,7 @@ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) { } catch(exception& e) { - errorOut(e, "SharedOrderVector", "getSharedSAbundVector"); + m->errorOut(e, "SharedOrderVector", "getSharedSAbundVector"); exit(1); } } @@ -330,7 +339,7 @@ void SharedOrderVector::updateStats(){ } catch(exception& e) { - errorOut(e, "SharedOrderVector", "updateStats"); + m->errorOut(e, "SharedOrderVector", "updateStats"); exit(1); } }