X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=summarysharedcommand.cpp;h=7116e46e0f9e96045fc3c60a717ae41819949118;hb=2bb9267aa4b4ecdf8488b06605cc9f3f36fa4332;hp=13a77ed31b19ae8b87006ea36ba5a53839365ebe;hpb=1d898dc6edaf9e9f287fab53bf1f21fb29757a17;p=mothur.git diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 13a77ed..7116e46 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -56,7 +56,7 @@ vector SummarySharedCommand::setParameters(){ CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared); CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pdistance); - CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-skulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc); + CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc); CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall); CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); @@ -119,6 +119,7 @@ SummarySharedCommand::SummarySharedCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { vector myArray = setParameters(); @@ -160,7 +161,7 @@ SummarySharedCommand::SummarySharedCommand(string option) { sharedfile = m->getSharedFile(); if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; } - } + }else { m->setSharedFile(sharedfile); } //if the user changes the output directory command factory will send this info to us in the output parameter @@ -183,12 +184,17 @@ SummarySharedCommand::SummarySharedCommand(string option) { if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; } } m->splitAtDash(calc, Estimators); + if (m->inUsersGroups("citation", Estimators)) { + ValidCalculators validCalc; validCalc.printCitations(Estimators); + //remove citation from list of calcs + for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") { Estimators.erase(Estimators.begin()+i); break; } } + } groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else { m->splitAtDash(groups, Groups); - m->Groups = Groups; + m->setGroups(Groups); } string temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; } @@ -199,7 +205,7 @@ SummarySharedCommand::SummarySharedCommand(string option) { temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); - convert(temp, processors); + m->mothurConvert(temp, processors); if (abort == false) { @@ -358,23 +364,23 @@ int SummarySharedCommand::execute(){ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } //close files and clean up - remove(outputFileName.c_str()); - if (mult == true) { remove(outAllFileName.c_str()); } + m->mothurRemove(outputFileName); + if (mult == true) { m->mothurRemove(outAllFileName); } return 0; //if you only have 2 groups you don't need a .sharedmultiple file }else if ((lookup.size() == 2) && (mult == true)) { mult = false; - remove(outAllFileName.c_str()); + m->mothurRemove(outAllFileName); outputNames.pop_back(); } if (m->control_pressed) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i=0;iGroups.clear(); + m->clearGroups(); return 0; } /******************************************************/ @@ -382,7 +388,7 @@ int SummarySharedCommand::execute(){ /******************************************************/ //comparison breakup to be used by different processes later - numGroups = m->Groups.size(); + numGroups = m->getNumGroups(); lines.resize(processors); for (int i = 0; i < processors; i++) { lines[i].start = int (sqrt(float(i)/float(processors)) * numGroups); @@ -397,12 +403,12 @@ int SummarySharedCommand::execute(){ //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) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i=0;iGroups.clear(); + m->clearGroups(); return 0; } @@ -440,11 +446,11 @@ int SummarySharedCommand::execute(){ } if (m->control_pressed) { - if (mult) { remove(outAllFileName.c_str()); } - remove(outputFileName.c_str()); + if (mult) { m->mothurRemove(outAllFileName); } + m->mothurRemove(outputFileName); delete input; for(int i=0;iGroups.clear(); + m->clearGroups(); return 0; } @@ -473,14 +479,14 @@ int SummarySharedCommand::execute(){ //reset groups parameter - m->Groups.clear(); + m->clearGroups(); for(int i=0;icontrol_pressed) { - remove(outAllFileName.c_str()); - remove(outputFileName.c_str()); + m->mothurRemove(outAllFileName); + m->mothurRemove(outputFileName); return 0; } @@ -509,10 +515,10 @@ int SummarySharedCommand::process(vector thisLookup, string if(processors == 1){ driver(thisLookup, 0, numGroups, sumFileName+".temp", sumAllFileName+".temp", calcDists); m->appendFiles((sumFileName + ".temp"), sumFileName); - remove((sumFileName + ".temp").c_str()); + m->mothurRemove((sumFileName + ".temp")); if (mult) { m->appendFiles((sumAllFileName + ".temp"), sumAllFileName); - remove((sumAllFileName + ".temp").c_str()); + m->mothurRemove((sumAllFileName + ".temp")); } }else{ int process = 1; @@ -555,7 +561,7 @@ int SummarySharedCommand::process(vector thisLookup, string //parent do your part driver(thisLookup, lines[0].start, lines[0].end, sumFileName + toString(getpid()) + ".temp", sumAllFileName + toString(getpid()) + ".temp", calcDists); m->appendFiles((sumFileName + toString(getpid()) + ".temp"), sumFileName); - remove((sumFileName + toString(getpid()) + ".temp").c_str()); + m->mothurRemove((sumFileName + toString(getpid()) + ".temp")); if (mult) { m->appendFiles((sumAllFileName + toString(getpid()) + ".temp"), sumAllFileName); } //force parent to wait until all the processes are done @@ -566,15 +572,15 @@ int SummarySharedCommand::process(vector thisLookup, string for (int i = 0; i < processIDS.size(); i++) { m->appendFiles((sumFileName + toString(processIDS[i]) + ".temp"), sumFileName); - remove((sumFileName + toString(processIDS[i]) + ".temp").c_str()); - if (mult) { remove((sumAllFileName + toString(processIDS[i]) + ".temp").c_str()); } + m->mothurRemove((sumFileName + toString(processIDS[i]) + ".temp")); + if (mult) { m->mothurRemove((sumAllFileName + toString(processIDS[i]) + ".temp")); } if (createPhylip) { string tempdistFileName = m->getRootName(m->getSimpleName(sumFileName)) + toString(processIDS[i]) + ".dist"; ifstream intemp; m->openInputFile(tempdistFileName, intemp); - for (int i = 0; i < calcDists.size(); i++) { + for (int k = 0; k < calcDists.size(); k++) { int size = 0; intemp >> size; m->gobble(intemp); @@ -586,11 +592,11 @@ int SummarySharedCommand::process(vector thisLookup, string intemp >> seq1 >> seq2 >> dist; m->gobble(intemp); seqDist tempDist(seq1, seq2, dist); - calcDists[i].push_back(tempDist); + calcDists[k].push_back(tempDist); } } intemp.close(); - remove(tempdistFileName.c_str()); + m->mothurRemove(tempdistFileName); } } @@ -598,10 +604,10 @@ int SummarySharedCommand::process(vector thisLookup, string #else driver(thisLookup, 0, numGroups, (sumFileName + ".temp"), (sumAllFileName + ".temp"), calcDists); m->appendFiles((sumFileName + ".temp"), sumFileName); - remove((sumFileName + ".temp").c_str()); + m->mothurRemove((sumFileName + ".temp")); if (mult) { m->appendFiles((sumAllFileName + ".temp"), sumAllFileName); - remove((sumAllFileName + ".temp").c_str()); + m->mothurRemove((sumAllFileName + ".temp")); } #endif @@ -727,7 +733,7 @@ int SummarySharedCommand::driver(vector thisLookup, int sta outputFileHandle << '\t'; sumCalculators[i]->print(outputFileHandle); - seqDist temp(l, k, (1.0 - tempdata[0])); + seqDist temp(l, k, tempdata[0]); calcDists[i].push_back(temp); } outputFileHandle << endl;