From 9013e13ecfb2fda3c2664a76f76cc99b8c7fa74c Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 29 Jul 2010 13:09:06 +0000 Subject: [PATCH] 1.12.1 --- bayesian.cpp | 11 +++- chimeraslayercommand.cpp | 4 +- classifyseqscommand.cpp | 9 ++- engine.cpp | 126 +++++++++++++++++++++++++++++++++------ filterseqscommand.cpp | 2 +- getrelabundcommand.cpp | 1 - makefile | 2 +- mothur.cpp | 4 +- venn.cpp | 12 ++-- 9 files changed, 136 insertions(+), 35 deletions(-) diff --git a/bayesian.cpp b/bayesian.cpp index d0c0a16..e5ab89e 100644 --- a/bayesian.cpp +++ b/bayesian.cpp @@ -71,6 +71,8 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { for (int j = 0; j < wordGenusProb.size(); j++) { wordGenusProb[j].resize(genusNodes.size()); } + ofstream out; + ofstream out2; #ifdef USE_MPI int pid; @@ -79,12 +81,11 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { if (pid == 0) { #endif - ofstream out; + openOutputFile(probFileName, out); out << numKmers << endl; - ofstream out2; openOutputFile(probFileName2, out2); #ifdef USE_MPI @@ -94,7 +95,7 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { //for each word for (int i = 0; i < numKmers; i++) { - if (m->control_pressed) { break; } + if (m->control_pressed) { break; } #ifdef USE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are @@ -128,7 +129,9 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { wordGenusProb[i][k] = log((count[genusNodes[k]] + probabilityInTemplate) / (float) (genusTotals[k] + 1)); if (count[genusNodes[k]] != 0) { #ifdef USE_MPI + int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are + if (pid == 0) { #endif @@ -144,6 +147,7 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { #ifdef USE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are + if (pid == 0) { #endif @@ -157,6 +161,7 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { #ifdef USE_MPI MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are + if (pid == 0) { #endif diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 321883b..1dd3d42 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -150,7 +150,7 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { temp = validParameter.validFile(parameters, "minbs", false); if (temp == "not found") { temp = "90"; } convert(temp, minBS); - temp = validParameter.validFile(parameters, "minsnp", false); if (temp == "not found") { temp = "10"; } + temp = validParameter.validFile(parameters, "minsnp", false); if (temp == "not found") { temp = "100"; } convert(temp, minSNP); temp = validParameter.validFile(parameters, "parents", false); if (temp == "not found") { temp = "3"; } @@ -205,7 +205,7 @@ void ChimeraSlayerCommand::help(){ m->mothurOut("The minsim parameter allows you to specify a minimum similarity with the parent fragments, default=90. \n"); m->mothurOut("The mincov parameter allows you to specify minimum coverage by closest matches found in template. Default is 70, meaning 70%. \n"); m->mothurOut("The minbs parameter allows you to specify minimum bootstrap support for calling a sequence chimeric. Default is 90, meaning 90%. \n"); - m->mothurOut("The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) \n"); + m->mothurOut("The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 100) \n"); m->mothurOut("The search parameter allows you to specify search method for finding the closest parent. Choices are distance, blast, and kmer, default distance. \n"); m->mothurOut("The realign parameter allows you to realign the query to the potential parents. Choices are true or false, default false. \n"); m->mothurOut("The chimera.slayer command should be in the following format: \n"); diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 0635fde..a95f436 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -399,10 +399,15 @@ int ClassifySeqsCommand::execute(){ m->mothurOut("Classifying sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine(); + string RippedTaxName = getRootName(getSimpleName(taxonomyFileName)); + RippedTaxName = getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1)); + if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); } + RippedTaxName += "."; + if (outputDir == "") { outputDir += hasPath(fastaFileNames[s]); } - string newTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + getRootName(getSimpleName(taxonomyFileName)) + "taxonomy"; + string newTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy"; string tempTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "taxonomy.temp"; - string taxSummary = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + getRootName(getSimpleName(taxonomyFileName)) + "tax.summary"; + string taxSummary = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + RippedTaxName + "tax.summary"; outputNames.push_back(newTaxonomyFile); outputNames.push_back(taxSummary); diff --git a/engine.cpp b/engine.cpp index 7bcb4e4..7bacec5 100644 --- a/engine.cpp +++ b/engine.cpp @@ -51,17 +51,50 @@ bool InteractEngine::getInput(){ while(quitCommandCalled != 1){ - + #ifdef USE_MPI + int pid, processors; + MPI_Status status; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + MPI_Comm_size(MPI_COMM_WORLD, &processors); + + if (pid == 0) { + + #endif + mout->mothurOutEndLine(); input = getCommand(); mout->mothurOutEndLine(); - + if (mout->control_pressed) { input = "quit()"; } //allow user to omit the () on the quit command if (input == "quit") { input = "quit()"; } + + + #ifdef USE_MPI + //send commandName + for(int i = 1; i < processors; i++) { + int length = input.length(); + MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD); + MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD); + + } + }else { + int length; + MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status); + //recieve container + char* tempBuf = new char[length]; + MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status); + + input = tempBuf; + if (input.length() > length) { input = input.substr(0, length); } + delete tempBuf; + } + + #endif + CommandOptionParser parser(input); commandName = parser.getCommandString(); @@ -72,9 +105,9 @@ bool InteractEngine::getInput(){ #ifdef USE_MPI int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); - -//cout << pid << " is here " << commandName << endl; + if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) { + //cout << pid << " is in execute " << commandName << endl; #endif //executes valid command Command* command = cFactory->getCommand(commandName, options); @@ -100,9 +133,6 @@ bool InteractEngine::getInput(){ /***********************************************************************/ string Engine::getCommand() { try { - #ifdef USE_MPI - MPI_Barrier(MPI_COMM_WORLD); - #endif #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #ifdef USE_READLINE @@ -181,10 +211,45 @@ bool BatchEngine::getInput(){ int quitCommandCalled = 0; int count = 0; while(quitCommandCalled == 0){ - + + #ifdef USE_MPI + int pid, processors; + MPI_Status status; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + MPI_Comm_size(MPI_COMM_WORLD, &processors); + + if (pid == 0) { + + #endif + input = getNextCommand(inputBatchFile); count++; + #ifdef USE_MPI + //send commandName + for(int i = 1; i < processors; i++) { + int length = input.length(); + MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD); + MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD); + + } + }else { + int length; + MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status); + //recieve container + char* tempBuf = new char[length]; + MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status); + + input = tempBuf; + if (input.length() > length) { input = input.substr(0, length); } + delete tempBuf; + } + + + #endif + + + if (input[0] != '#') { mout->mothurOutEndLine(); @@ -239,11 +304,6 @@ bool BatchEngine::getInput(){ string BatchEngine::getNextCommand(ifstream& inputBatchFile) { try { - #ifdef USE_MPI - int err = MPI_Barrier(MPI_COMM_WORLD); -//cout << "barrier = " << err << '\t' << MPI_SUCCESS << endl; - #endif - string nextcommand = ""; if (inputBatchFile.eof()) { nextcommand = "quit()"; } @@ -294,7 +354,17 @@ bool ScriptEngine::getInput(){ int quitCommandCalled = 0; while(quitCommandCalled == 0){ - + + #ifdef USE_MPI + int pid, processors; + MPI_Status status; + MPI_Comm_rank(MPI_COMM_WORLD, &pid); + MPI_Comm_size(MPI_COMM_WORLD, &processors); + + if (pid == 0) { + + #endif + input = getNextCommand(listOfCommands); if (input == "") { input = "quit()"; } @@ -303,6 +373,30 @@ bool ScriptEngine::getInput(){ mout->mothurOut("mothur > " + input); mout->mothurOutEndLine(); + #ifdef USE_MPI + //send commandName + for(int i = 1; i < processors; i++) { + int length = input.length(); + MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD); + MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD); + + } + }else { + int length; + MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status); + //recieve container + char* tempBuf = new char[length]; + MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status); + + input = tempBuf; + if (input.length() > length) { input = input.substr(0, length); } + delete tempBuf; + } + + + #endif + + if (mout->control_pressed) { input = "quit()"; } //allow user to omit the () on the quit command @@ -354,10 +448,6 @@ bool ScriptEngine::getInput(){ string ScriptEngine::getNextCommand(string& commandString) { try { - #ifdef USE_MPI - MPI_Barrier(MPI_COMM_WORLD); - #endif - string nextcommand = ""; int count = 0; diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index d2c7c6b..7ab00a7 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -263,7 +263,7 @@ int FilterSeqsCommand::filterSequences() { MPI_Status status; MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are - + cout << pid << "is in create filter " << endl; MPI_File outMPI; MPI_File tempMPI; MPI_File inMPI; diff --git a/getrelabundcommand.cpp b/getrelabundcommand.cpp index 90d084f..037cd3e 100644 --- a/getrelabundcommand.cpp +++ b/getrelabundcommand.cpp @@ -244,7 +244,6 @@ int GetRelAbundCommand::getRelAbundance(vector& thisLookUp, //calc the total in this otu int totalOtu = 0; for (int l = 0; l < thisLookUp.size(); l++) { totalOtu += thisLookUp[l]->getAbundance(j); } - relabund = abund / (float) totalOtu; }else if (scale == "averagegroup") { relabund = abund / (float) (thisLookUp[i]->getNumSeqs() / (float) thisLookUp[i]->getNumBins()); diff --git a/makefile b/makefile index 55039af..d751bb6 100644 --- a/makefile +++ b/makefile @@ -39,7 +39,7 @@ endif # if you do not want to use the readline library, set this to no. # make sure you have the library installed -USEREADLINE ?= no +USEREADLINE ?= yes ifeq ($(strip $(USEREADLINE)),yes) CXXFLAGS += -DUSE_READLINE diff --git a/mothur.cpp b/mothur.cpp index a95c381..c413ced 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -98,9 +98,9 @@ int main(int argc, char *argv[]){ #endif //header - m->mothurOut("mothur v.1.12.0"); + m->mothurOut("mothur v.1.12.1"); m->mothurOutEndLine(); - m->mothurOut("Last updated: 7/23/2010"); + m->mothurOut("Last updated: 7/29/2010"); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOut("by"); diff --git a/venn.cpp b/venn.cpp index 7e24049..443c36c 100644 --- a/venn.cpp +++ b/venn.cpp @@ -34,7 +34,7 @@ vector Venn::getPic(SAbundVector* sabund, vector vCalcs) { vector outputNames; for(int i=0;iinputFileName) + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg"; outputNames.push_back(filenamesvg); openOutputFile(filenamesvg, outsvg); @@ -88,7 +88,7 @@ vector Venn::getPic(vector lookup, vectorinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg"; outputNames.push_back(filenamesvg); openOutputFile(filenamesvg, outsvg); @@ -140,7 +140,8 @@ vector Venn::getPic(vector lookup, vectorinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg"; + outputNames.push_back(filenamesvg); openOutputFile(filenamesvg, outsvg); @@ -214,7 +215,8 @@ vector Venn::getPic(vector lookup, vectorinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg"; + outputNames.push_back(filenamesvg); openOutputFile(filenamesvg, outsvg); @@ -475,7 +477,7 @@ vector Venn::getPic(vector lookup, vectorgetName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); m->mothurOutEndLine(); } else{ - string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg"; outputNames.push_back(filenamesvg); openOutputFile(filenamesvg, outsvg); -- 2.39.2