X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=sharedcommand.cpp;h=6ca1ed63585463d92ac8dc7aa65f921ca1070308;hp=439cdf13101b183aebd2cb6e112e1b92ace9ee74;hb=016a30dacbe75869aef5fdb58d2d1bf9eb8f9b33;hpb=301b61cb98aaa4641f8701f43cf830c0fa44fac1 diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 439cdf1..6ca1ed6 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -47,7 +47,7 @@ int SharedCommand::execute(){ input = globaldata->ginput; SharedList = globaldata->gSharedList; - SharedListVector* lastList = SharedList; + string lastLabel = SharedList->getLabel(); vector lookup; //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. @@ -69,18 +69,22 @@ int SharedCommand::execute(){ userLines.erase(count); } - if ((anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastList->getLabel()) != 1)) { - lookup = lastList->getSharedRAbundVector(); + if ((anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) { + delete SharedList; + SharedList = input->getSharedListVector(lastLabel); //get new list vector to process + + lookup = SharedList->getSharedRAbundVector(); printSharedData(lookup); //prints info to the .shared file for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } - processedLabels.insert(lastList->getLabel()); - userLabels.erase(lastList->getLabel()); + processedLabels.insert(SharedList->getLabel()); + userLabels.erase(SharedList->getLabel()); } - if (count != 1) { delete lastList; } - lastList = SharedList; - + + lastLabel = SharedList->getLabel(); + + delete SharedList; SharedList = input->getSharedListVector(); //get new list vector to process count++; @@ -91,7 +95,7 @@ int SharedCommand::execute(){ bool needToRun = false; for (it = userLabels.begin(); it != userLabels.end(); it++) { //cout << "Your file does not include the label "<< *it; - if (processedLabels.count(lastList->getLabel()) != 1) { + if (processedLabels.count(lastLabel) != 1) { //cout << ". I will use " << lastList->getLabel() << "." << endl; needToRun = true; }else { @@ -101,13 +105,16 @@ int SharedCommand::execute(){ //run last line if you need to if (needToRun == true) { - lookup = lastList->getSharedRAbundVector(); + delete SharedList; + SharedList = input->getSharedListVector(lastLabel); //get new list vector to process + + lookup = SharedList->getSharedRAbundVector(); printSharedData(lookup); //prints info to the .shared file for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } - + delete SharedList; } - delete lastList; globaldata->gSharedList = NULL; + globaldata->gSharedList = NULL; delete read; out.close();