X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=matrixoutputcommand.cpp;h=a55edd04e1db2f2acd24f57862b4dffb51e0ab8e;hb=a98eb683e17d8e49583bf2d215ab7562a4cdca75;hp=078f411d669426daed4dcc1f09f65810644350ad;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index 078f411..a55edd0 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -52,7 +52,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option) { //if the user changes the output directory command factory will send this info to us in the output parameter outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; - outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it + outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it } //make sure the user has already run the read.otu command @@ -66,7 +66,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option) { label = validParameter.validFile(parameters, "label", false); if (label == "not found") { label = ""; } else { - if(label != "all") { splitAtDash(label, labels); allLines = 0; } + if(label != "all") { m->splitAtDash(label, labels); allLines = 0; } else { allLines = 1; } } @@ -82,7 +82,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option) { groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else { - splitAtDash(groups, Groups); + m->splitAtDash(groups, Groups); globaldata->Groups = Groups; } @@ -91,7 +91,7 @@ MatrixOutputCommand::MatrixOutputCommand(string option) { else { if (calc == "default") { calc = "jclass-thetayc"; } } - splitAtDash(calc, Estimators); + m->splitAtDash(calc, Estimators); if (abort == false) { @@ -193,10 +193,14 @@ int MatrixOutputCommand::execute(){ if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); return 0;} numGroups = lookup.size(); + + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } globaldata->Groups.clear(); return 0; } //as long as you are not at the end of the file or done wih the lines you want while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0; } + if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine(); process(lookup); @@ -205,7 +209,7 @@ int MatrixOutputCommand::execute(){ userLabels.erase(lookup[0]->getLabel()); } - if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { + if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { string saveLabel = lookup[0]->getLabel(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } @@ -228,6 +232,8 @@ int MatrixOutputCommand::execute(){ lookup = input->getSharedRAbundVectors(); } + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0; } + //output error messages about any remaining user labels set::iterator it; bool needToRun = false; @@ -241,6 +247,8 @@ int MatrixOutputCommand::execute(){ } } + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0; } + //run last label if you need to if (needToRun == true) { for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } } @@ -251,7 +259,8 @@ int MatrixOutputCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } } - + if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0; } + //reset groups parameter globaldata->Groups.clear(); @@ -301,7 +310,7 @@ void MatrixOutputCommand::printSims(ostream& out) { } } /***********************************************************/ -void MatrixOutputCommand::process(vector thisLookup){ +int MatrixOutputCommand::process(vector thisLookup){ try { EstOutput data; @@ -313,9 +322,9 @@ void MatrixOutputCommand::process(vector thisLookup){ //initialize simMatrix simMatrix.clear(); simMatrix.resize(numGroups); - for (int m = 0; m < simMatrix.size(); m++) { + for (int p = 0; p < simMatrix.size(); p++) { for (int j = 0; j < simMatrix.size(); j++) { - simMatrix[m].push_back(0.0); + simMatrix[p].push_back(0.0); } } @@ -324,6 +333,8 @@ void MatrixOutputCommand::process(vector thisLookup){ if (k != l) { //we dont need to similiarity of a groups to itself //get estimated similarity between 2 groups + if (m->control_pressed) { return 0; } + subset.clear(); //clear out old pair of sharedrabunds //add new pair of sharedrabunds subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]); @@ -336,8 +347,8 @@ void MatrixOutputCommand::process(vector thisLookup){ } } - exportFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist"; - openOutputFile(exportFileName, out); + exportFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist"; + m->openOutputFile(exportFileName, out); outputNames.push_back(exportFileName); printSims(out); @@ -345,7 +356,7 @@ void MatrixOutputCommand::process(vector thisLookup){ } - + return 0; } catch(exception& e) {