From 836150c0a3666899ad58426388f4999d6cf8829a Mon Sep 17 00:00:00 2001 From: westcott Date: Mon, 25 Apr 2011 18:00:39 +0000 Subject: [PATCH] minor bug in chimera maligner --- chimeraslayer.cpp | 10 ++--- chimeraslayercommand.cpp | 5 ++- maligner.cpp | 2 +- mothur.cpp | 17 ++++++--- sharedcommand.cpp | 82 ++++++++++++++++++++++------------------ 5 files changed, 66 insertions(+), 50 deletions(-) diff --git a/chimeraslayer.cpp b/chimeraslayer.cpp index c6613bf..73037c7 100644 --- a/chimeraslayer.cpp +++ b/chimeraslayer.cpp @@ -751,14 +751,14 @@ int ChimeraSlayer::getChimeras(Sequence* query) { if (m->control_pressed) { return 0; } vector Results = maligner.getOutput(); - - if (realign) { - ChimeraReAligner realigner(thisTemplate, match, misMatch); - realigner.reAlign(query, Results); - } if (chimeraFlag == "yes") { + if (realign) { + ChimeraReAligner realigner(thisTemplate, match, misMatch); + realigner.reAlign(query, Results); + } + //get sequence that were given from maligner results vector seqs; map removeDups; diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index cf082f8..9b49a4f 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -635,7 +635,7 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA); string candidateAligned = candidateSeq->getAligned(); - + if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file if (candidateSeq->getAligned().length() != templateSeqsLength) { @@ -698,15 +698,16 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f } count++; } - delete candidateSeq; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) unsigned long int pos = inFASTA.tellg(); + //cout << candidateSeq->getName() << '\t' << pos << endl; if ((pos == -1) || (pos >= filePos->end)) { break; } #else if (inFASTA.eof()) { break; } #endif + delete candidateSeq; //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } } diff --git a/maligner.cpp b/maligner.cpp index 4a00c1d..252b453 100644 --- a/maligner.cpp +++ b/maligner.cpp @@ -106,7 +106,7 @@ string Maligner::chimeraMaligner(int chimeraPenalty, DeCalculator* decalc) { // } if (trace.size() > 1) { chimera = "yes"; } - else { chimera = "no"; } + else { chimera = "no"; return chimera; } int traceStart = trace[0].col; int traceEnd = trace[trace.size()-1].oldCol; diff --git a/mothur.cpp b/mothur.cpp index 67ede87..b551302 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -78,13 +78,14 @@ int main(int argc, char *argv[]){ m->setVersion(mothurVersion); //will make the gui output "pretty" - bool guiMode = false; + bool outputHeader = true; if (argc>1) { string guiInput = argv[1]; - if (guiInput[0] == '+') { guiMode = true; } + if (guiInput[0] == '+') { outputHeader = false; } + if (guiInput[0] == '-') { outputHeader = false; } } - if (!guiMode) { + if (outputHeader) { //version #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) #if defined (__APPLE__) || (__MACH__) @@ -161,7 +162,7 @@ int main(int argc, char *argv[]){ //srand(54321); srand( (unsigned)time( NULL ) ); - Engine* mothur; + Engine* mothur = NULL; bool bail = 0; string input; @@ -177,6 +178,12 @@ int main(int argc, char *argv[]){ }else if (input[0] == '+') { mothur = new ScriptEngine(argv[0], argv[1]); m->gui = true; + }else if (input == "-version") { + m->mothurOut("Mothur version=" + mothurVersion + "\nRelease Date=" + releaseDate); m->mothurOutEndLine(); m->mothurOutEndLine(); m->closeLog(); + #ifdef USE_MPI + MPI_Finalize(); + #endif + return 0; }else{ m->mothurOutJustToLog("Batch Mode"); m->mothurOutEndLine(); m->mothurOutEndLine(); @@ -229,7 +236,7 @@ int main(int argc, char *argv[]){ } - delete mothur; + if (mothur != NULL) { delete mothur; } #ifdef USE_MPI MPI_Finalize(); diff --git a/sharedcommand.cpp b/sharedcommand.cpp index 2b4d56e..cb4b4e6 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -58,6 +58,7 @@ SharedCommand::SharedCommand(){ vector tempOutNames; outputTypes["rabund"] = tempOutNames; outputTypes["shared"] = tempOutNames; + outputTypes["group"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "SharedCommand", "SharedCommand"); @@ -136,7 +137,7 @@ SharedCommand::SharedCommand(string option) { else if (ordergroupfile == "not found") { ordergroupfile = ""; } groupfile = validParameter.validFile(parameters, "group", true); - if (groupfile == "not open") { abort = true; } + if (groupfile == "not open") { groupfile = ""; abort = true; } else if (groupfile == "not found") { groupfile = m->getGroupFile(); if (groupfile != "") { @@ -172,41 +173,6 @@ SharedCommand::SharedCommand(string option) { if(label != "all") { m->splitAtDash(label, labels); allLines = 0; } else { allLines = 1; } } - - //getting output filename - filename = listfile; - if (outputDir == "") { outputDir += m->hasPath(filename); } - - filename = outputDir + m->getRootName(m->getSimpleName(filename)); - filename = filename + "shared"; - outputTypes["shared"].push_back(filename); - - m->openOutputFile(filename, out); - pickedGroups = false; - - //if hte user has not specified any groups then use them all - if (Groups.size() == 0) { - Groups = groupMap->namesOfGroups; m->Groups = Groups; - } - - //fill filehandles with neccessary ofstreams - int i; - ofstream* temp; - for (i=0; igetRootName(m->getSimpleName(listfile)); - - //clears file before we start to write to it below - for (int i=0; ihasPath(filename); } + + filename = outputDir + m->getRootName(m->getSimpleName(filename)); + filename = filename + "shared"; + outputTypes["shared"].push_back(filename); + + m->openOutputFile(filename, out); + pickedGroups = false; + + //if hte user has not specified any groups then use them all + if (Groups.size() == 0) { + Groups = groupMap->namesOfGroups; m->Groups = Groups; + }else { pickedGroups = true; } + + //fill filehandles with neccessary ofstreams + int i; + ofstream* temp; + for (i=0; igetRootName(m->getSimpleName(listfile)); + + //clears file before we start to write to it below + for (int i=0; iGroups.size() != 0) { //make new group file + if (pickedGroups) { //make new group file string groups = ""; if (m->Groups.size() < 4) { for (int i = 0; i < m->Groups.size(); i++) { @@ -270,6 +271,8 @@ int SharedCommand::execute(){ }else { groups = "merge"; } string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + "groups"; + outputTypes["group"].push_back(newGroupFile); + outputNames.push_back(newGroupFile); ofstream outGroups; m->openOutputFile(newGroupFile, outGroups); @@ -420,6 +423,11 @@ int SharedCommand::execute(){ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } } + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } -- 2.39.2