X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedordervector.cpp;h=ca26362672e130364f66ed8bd005ae8fa9d68d4c;hb=55386dddad84cc1140d736cabaf4dd0ae16f2e01;hp=a009db16546d647b902dc31a6f00713485d03126;hpb=99bd02d78eaf21b01420c6f99e38efc7fa4e9e17;p=mothur.git diff --git a/sharedordervector.cpp b/sharedordervector.cpp index a009db1..ca26362 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -28,12 +28,11 @@ 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; + + groupmap = new GroupMap(); - if (globaldata->gGroupmap == NULL) { groupmap = new GroupMap(); } - - int num, inputData, pos, count; + int num, inputData, count; count = 0; numSeqs = 0; string holdLabel, nextLabel, groupN; individual newguy; @@ -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; - } + vector allGroups; + //save group in groupmap + allGroups.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 + allGroups.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; } @@ -86,18 +88,15 @@ 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; } + + groupmap->setNamesOfGroups(allGroups); + m->setAllGroups(allGroups); updateStats(); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function SharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "SharedOrderVector"); exit(1); } } @@ -167,20 +166,23 @@ void SharedOrderVector::print(ostream& output){ output << endl; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "print"); exit(1); } } +/***********************************************************************/ +void SharedOrderVector::clear(){ + numBins = 0; + maxRank = 0; + numSeqs = 0; + data.clear(); +} /***********************************************************************/ void SharedOrderVector::resize(int){ - cout << "resize() did nothing in class SharedOrderVector"; + m->mothurOut("resize() did nothing in class SharedOrderVector"); } /***********************************************************************/ @@ -223,13 +225,9 @@ RAbundVector SharedOrderVector::getRAbundVector(){ return rav; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "getRAbundVector"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /***********************************************************************/ @@ -247,11 +245,7 @@ OrderVector SharedOrderVector::getOrderVector(map* nameMap = NULL) { return ov; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "getOrderVector"); exit(1); } } @@ -281,14 +275,9 @@ SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) { return sharedRav; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); exit(1); } - } /***********************************************************************/ vector SharedOrderVector::getSharedRAbundVector() { @@ -297,20 +286,19 @@ vector SharedOrderVector::getSharedRAbundVector() { util = new SharedUtil(); vector lookup; - util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups); - util->getSharedVectors(globaldata->Groups, lookup, this); + vector Groups = m->getGroups(); + vector allGroups = m->getAllGroups(); + util->setGroups(Groups, allGroups); + util->getSharedVectors(Groups, lookup, this); + m->setGroups(Groups); + m->setAllGroups(allGroups); return lookup; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } /***********************************************************************/ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) { @@ -321,14 +309,9 @@ SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) { } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "getSharedSAbundVector"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } /***********************************************************************/ @@ -361,13 +344,9 @@ void SharedOrderVector::updateStats(){ } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "SharedOrderVector", "updateStats"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the SharedOrderVector class function updateStats. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } /***********************************************************************/