From 348de0f8b17d84ede77081dcf67bd6ef43496677 Mon Sep 17 00:00:00 2001 From: westcott Date: Wed, 16 Mar 2011 17:14:04 +0000 Subject: [PATCH] added set.current and get.current commands and modified existing commands to update the current files with their output files. --- Mothur.xcodeproj/project.pbxproj | 16 +- aligncommand.cpp | 9 +- aligncommand.h | 2 - amovacommand.cpp | 8 - anosimcommand.cpp | 9 - binsequencecommand.cpp | 8 +- bootstrapsharedcommand.cpp | 7 + chimerabellerophoncommand.cpp | 9 +- chimeraccodecommand.cpp | 8 + chimerapintailcommand.cpp | 7 + chimeraslayercommand.cpp | 14 + chopseqscommand.cpp | 17 +- classifyseqscommand.cpp | 7 + clearcutcommand.cpp | 8 + clustercommand.cpp | 19 ++ clusterdoturcommand.cpp | 19 ++ clusterfragmentscommand.cpp | 12 + clustersplitcommand.cpp | 19 ++ command.hpp | 4 +- commandfactory.cpp | 10 + consensuscommand.cpp | 7 + currentfile.cpp | 47 ---- currentfile.h | 122 +++++---- deconvolutecommand.cpp | 12 +- degapseqscommand.cpp | 7 + deuniqueseqscommand.cpp | 7 + distancecommand.cpp | 13 + filterseqscommand.cpp | 6 + getcurrentcommand.cpp | 184 +++++++++++++ getcurrentcommand.h | 40 +++ getgroupscommand.cpp | 27 ++ getlineagecommand.cpp | 27 ++ getoturepcommand.cpp | 12 + getotuscommand.cpp | 12 + getrabundcommand.cpp | 7 + getrelabundcommand.cpp | 7 + getsabundcommand.cpp | 7 + getseqscommand.cpp | 33 +++ getsharedotucommand.cpp | 14 + hclustercommand.cpp | 21 +- indicatorcommand.cpp | 7 + listseqscommand.cpp | 14 +- makegroupcommand.cpp | 9 +- matrixoutputcommand.cpp | 7 + mergegroupscommand.cpp | 8 + mgclustercommand.cpp | 20 ++ mothurout.cpp | 57 ++++ mothurout.h | 73 ++++- normalizesharedcommand.cpp | 7 + optionparser.cpp | 74 ++++- pairwiseseqscommand.cpp | 13 + parsefastaqcommand.cpp | 18 +- parselistscommand.cpp | 7 + phylotypecommand.cpp | 19 ++ preclustercommand.cpp | 14 +- readotucommand.cpp | 14 + removegroupscommand.cpp | 27 ++ removelineagecommand.cpp | 27 ++ removeotuscommand.cpp | 12 + removerarecommand.cpp | 27 ++ removeseqscommand.cpp | 32 +++ reversecommand.cpp | 21 +- screenseqscommand.cpp | 17 ++ setcurrentcommand.cpp | 449 +++++++++++++++++++++++++++++++ setcurrentcommand.h | 46 ++++ sffinfocommand.cpp | 18 +- sharedcommand.cpp | 12 + splitabundcommand.cpp | 27 ++ splitgroupscommand.cpp | 11 + subsamplecommand.cpp | 39 ++- treegroupscommand.cpp | 9 +- trimflowscommand.cpp | 7 + trimseqscommand.cpp | 19 +- unifracunweightedcommand.cpp | 13 + unifracweightedcommand.cpp | 13 + 75 files changed, 1852 insertions(+), 159 deletions(-) delete mode 100644 currentfile.cpp create mode 100644 getcurrentcommand.cpp create mode 100644 getcurrentcommand.h create mode 100644 setcurrentcommand.cpp create mode 100644 setcurrentcommand.h diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 7d1df46..4bc5960 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ A75790591301749D00A30DAB /* homovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75790581301749D00A30DAB /* homovacommand.cpp */; }; A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */; }; A7A61F2D130062E000E05B6B /* amovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A61F2C130062E000E05B6B /* amovacommand.cpp */; }; - A7AACFBC132FE008003D6C4D /* currentfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7AACFBB132FE008003D6C4D /* currentfile.cpp */; }; A7E9B88112D37EC400DA6239 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B64F12D37EC300DA6239 /* ace.cpp */; }; A7E9B88212D37EC400DA6239 /* aligncommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B65112D37EC300DA6239 /* aligncommand.cpp */; }; A7E9B88312D37EC400DA6239 /* alignment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B65312D37EC300DA6239 /* alignment.cpp */; }; @@ -293,6 +292,8 @@ A7FA10021302E097003860FE /* mantelcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FA10011302E096003860FE /* mantelcommand.cpp */; }; A7FC480E12D788F20055BC5C /* linearalgebra.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FC480D12D788F20055BC5C /* linearalgebra.cpp */; }; A7FC486712D795D60055BC5C /* pcacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FC486612D795D60055BC5C /* pcacommand.cpp */; }; + A7FE7C401330EA1000F7B327 /* getcurrentcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FE7C3F1330EA1000F7B327 /* getcurrentcommand.cpp */; }; + A7FE7E6D13311EA400F7B327 /* setcurrentcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FE7E6C13311EA400F7B327 /* setcurrentcommand.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -331,7 +332,6 @@ A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amovacommand.h; sourceTree = ""; }; A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = amovacommand.cpp; sourceTree = ""; }; A7AACFBA132FE008003D6C4D /* currentfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = currentfile.h; sourceTree = ""; }; - A7AACFBB132FE008003D6C4D /* currentfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = currentfile.cpp; sourceTree = ""; }; A7E9B64F12D37EC300DA6239 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = ""; }; A7E9B65012D37EC300DA6239 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = ""; }; A7E9B65112D37EC300DA6239 /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aligncommand.cpp; sourceTree = ""; }; @@ -900,6 +900,10 @@ A7FC480D12D788F20055BC5C /* linearalgebra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = linearalgebra.cpp; sourceTree = ""; }; A7FC486512D795D60055BC5C /* pcacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcacommand.h; sourceTree = ""; }; A7FC486612D795D60055BC5C /* pcacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pcacommand.cpp; sourceTree = ""; }; + A7FE7C3E1330EA1000F7B327 /* getcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getcurrentcommand.h; sourceTree = ""; }; + A7FE7C3F1330EA1000F7B327 /* getcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcurrentcommand.cpp; sourceTree = ""; }; + A7FE7E6B13311EA400F7B327 /* setcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setcurrentcommand.h; sourceTree = ""; }; + A7FE7E6C13311EA400F7B327 /* setcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = setcurrentcommand.cpp; sourceTree = ""; }; C6A0FF2C0290799A04C91782 /* mothur.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = mothur.1; sourceTree = ""; }; /* End PBXFileReference section */ @@ -950,7 +954,6 @@ A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */, A7E9BA4212D3960D00DA6239 /* containers */, A7AACFBA132FE008003D6C4D /* currentfile.h */, - A7AACFBB132FE008003D6C4D /* currentfile.cpp */, A7E9B6C912D37EC400DA6239 /* display.h */, A7E9B6D112D37EC400DA6239 /* dlibshuff.cpp */, A7E9B6D212D37EC400DA6239 /* dlibshuff.h */, @@ -1099,6 +1102,8 @@ A7E9B6CC12D37EC400DA6239 /* distancecommand.h */, A7E9B6E312D37EC400DA6239 /* filterseqscommand.cpp */, A7E9B6E412D37EC400DA6239 /* filterseqscommand.h */, + A7FE7C3E1330EA1000F7B327 /* getcurrentcommand.h */, + A7FE7C3F1330EA1000F7B327 /* getcurrentcommand.cpp */, A7E9B6F212D37EC400DA6239 /* getgroupcommand.cpp */, A7E9B6F312D37EC400DA6239 /* getgroupcommand.h */, A7E9B6F412D37EC400DA6239 /* getgroupscommand.cpp */, @@ -1217,6 +1222,8 @@ A7E9B7D812D37EC400DA6239 /* seqerrorcommand.h */, A7E9B7D912D37EC400DA6239 /* seqsummarycommand.cpp */, A7E9B7DA12D37EC400DA6239 /* seqsummarycommand.h */, + A7FE7E6B13311EA400F7B327 /* setcurrentcommand.h */, + A7FE7E6C13311EA400F7B327 /* setcurrentcommand.cpp */, A7E9B7DF12D37EC400DA6239 /* setdircommand.cpp */, A7E9B7E012D37EC400DA6239 /* setdircommand.h */, A7E9B7E112D37EC400DA6239 /* setlogfilecommand.cpp */, @@ -1938,7 +1945,8 @@ A7FA10021302E097003860FE /* mantelcommand.cpp in Sources */, A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */, A71CB160130B04A2001E7287 /* anosimcommand.cpp in Sources */, - A7AACFBC132FE008003D6C4D /* currentfile.cpp in Sources */, + A7FE7C401330EA1000F7B327 /* getcurrentcommand.cpp in Sources */, + A7FE7E6D13311EA400F7B327 /* setcurrentcommand.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/aligncommand.cpp b/aligncommand.cpp index 77e99c0..a820542 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -79,7 +79,6 @@ AlignCommand::AlignCommand(){ AlignCommand::AlignCommand(string option) { try { abort = false; calledHelp = false; - currentFiles = CurrentFile::getInstance(); //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true;} @@ -139,9 +138,6 @@ AlignCommand::AlignCommand(string option) { candidateFileName = validParameter.validFile(parameters, "candidate", false); if (candidateFileName == "not found") { - //check currentFiles for a fasta file - if (currentFiles->getFastaFile() != "") { candidateFileName = currentFiles->getFastaFile(); m->mothurOut("Using " + candidateFileName + " as candidate file."); m->mothurOutEndLine(); - }else { m->mothurOut("candidate is a required parameter for the align.seqs command."); m->mothurOutEndLine(); abort = true; } }else { m->splitAtDash(candidateFileName, candidateFileNames); @@ -471,10 +467,9 @@ int AlignCommand::execute(){ string currentFasta = ""; itTypes = outputTypes.find("fasta"); if (itTypes != outputTypes.end()) { - if ((itTypes->second).size() != 0) { currentFasta = (itTypes->second)[0]; } + if ((itTypes->second).size() != 0) { currentFasta = (itTypes->second)[0]; m->setFastaFile(currentFasta); } } - currentFiles->setFastaFile(currentFasta); - cout << "current fasta = " << currentFiles->getFastaFile() << endl; + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/aligncommand.h b/aligncommand.h index d519e91..169b435 100644 --- a/aligncommand.h +++ b/aligncommand.h @@ -15,7 +15,6 @@ #include "database.hpp" #include "alignment.hpp" #include "alignmentdb.h" -#include "mothurfiles.h" class AlignCommand : public Command { @@ -60,7 +59,6 @@ private: vector outputNames; bool abort, flip, calledHelp; - CurrentFile* currentFiles; }; diff --git a/amovacommand.cpp b/amovacommand.cpp index 13c8b26..8ab0855 100644 --- a/amovacommand.cpp +++ b/amovacommand.cpp @@ -117,10 +117,6 @@ AmovaCommand::AmovaCommand(string option) { if (phylipFileName == "not open") { phylipFileName = ""; abort = true; } else if (phylipFileName == "not found") { phylipFileName = ""; - - //check currentFiles for a phylip file - //if (currentFiles->getPhylipFile() != "") { phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine(); - //}else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true; } } //check for required parameters @@ -128,10 +124,6 @@ AmovaCommand::AmovaCommand(string option) { if (designFileName == "not open") { abort = true; } else if (designFileName == "not found") { designFileName = ""; - - //check currentFiles for a design file - //if (currentFiles->getDesignFile() != "") { designFileName = currentFiles->getDesignFile(); m->mothurOut("Using " + designFileName + " as design file."); m->mothurOutEndLine(); - //}else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true; } } string temp = validParameter.validFile(parameters, "iters", false); diff --git a/anosimcommand.cpp b/anosimcommand.cpp index 443cf8a..79064a4 100644 --- a/anosimcommand.cpp +++ b/anosimcommand.cpp @@ -117,10 +117,6 @@ AnosimCommand::AnosimCommand(string option) { if (phylipFileName == "not open") { phylipFileName = ""; abort = true; } else if (phylipFileName == "not found") { phylipFileName = ""; - - //check currentFiles for a phylip file - //if (currentFiles->getPhylipFile() != "") { phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine(); - //}else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true; } } //check for required parameters @@ -128,11 +124,6 @@ AnosimCommand::AnosimCommand(string option) { if (designFileName == "not open") { abort = true; } else if (designFileName == "not found") { designFileName = ""; - - //check currentFiles for a design file - //if (currentFiles->getDesignFile() != "") { designFileName = currentFiles->getDesignFile(); m->mothurOut("Using " + designFileName + " as design file."); m->mothurOutEndLine(); - //}else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true; } - } string temp = validParameter.validFile(parameters, "iters", false); diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp index 81c24a3..8b137c8 100644 --- a/binsequencecommand.cpp +++ b/binsequencecommand.cpp @@ -387,7 +387,7 @@ int BinSeqCommand::process(ListVector* list) { if (sequence != "not found") { //if you don't have groups if (groupfile == "") { - name = name + "|" + toString(i+1); + name = name + "\t" + toString(i+1); out << ">" << name << endl; out << sequence << endl; }else {//if you do have groups @@ -396,7 +396,7 @@ int BinSeqCommand::process(ListVector* list) { m->mothurOut(name + " is missing from your group file. Please correct. "); m->mothurOutEndLine(); return 1; }else{ - name = name + "|" + group + "|" + toString(i+1); + name = name + "\t" + group + "\t" + toString(i+1); out << ">" << name << endl; out << sequence << endl; } @@ -413,7 +413,7 @@ int BinSeqCommand::process(ListVector* list) { if (sequence != "not found") { //if you don't have groups if (groupfile == "") { - binnames = binnames + "|" + toString(i+1); + binnames = binnames + "\t" + toString(i+1); out << ">" << binnames << endl; out << sequence << endl; }else {//if you do have groups @@ -422,7 +422,7 @@ int BinSeqCommand::process(ListVector* list) { m->mothurOut(binnames + " is missing from your group file. Please correct. "); m->mothurOutEndLine(); return 1; }else{ - binnames = binnames + "|" + group + "|" + toString(i+1); + binnames = binnames + "\t" + group + "\t" + toString(i+1); out << ">" << binnames << endl; out << sequence << endl; } diff --git a/bootstrapsharedcommand.cpp b/bootstrapsharedcommand.cpp index 66a4397..afc3cf1 100644 --- a/bootstrapsharedcommand.cpp +++ b/bootstrapsharedcommand.cpp @@ -340,6 +340,13 @@ int BootSharedCommand::execute(){ //reset groups parameter globaldata->Groups.clear(); + //set first tree file as new current treefile + string currentTree = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp index 22e4fe2..140a949 100644 --- a/chimerabellerophoncommand.cpp +++ b/chimerabellerophoncommand.cpp @@ -52,7 +52,6 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(){ vector tempOutNames; outputTypes["chimera"] = tempOutNames; outputTypes["accnos"] = tempOutNames; - outputTypes["fasta"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand"); @@ -87,7 +86,6 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option) { vector tempOutNames; outputTypes["chimera"] = tempOutNames; outputTypes["accnos"] = tempOutNames; - outputTypes["fasta"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); @@ -271,6 +269,13 @@ int ChimeraBellerophonCommand::execute(){ delete chimera; } + //set accnos file as new current accnosfile + string current = ""; + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index 8a4ccde..457eaf3 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -435,6 +435,14 @@ int ChimeraCcodeCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); } + + //set accnos file as new current accnosfile + string current = ""; + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index a8d2d65..038460f 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -517,6 +517,13 @@ int ChimeraPintailCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); } + //set accnos file as new current accnosfile + string current = ""; + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index a331908..e7b02b8 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -569,6 +569,20 @@ int ChimeraSlayerCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); } + //set accnos file as new current accnosfile + string current = ""; + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + + if (trim) { + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp index 1ebb1f4..a09ff65 100644 --- a/chopseqscommand.cpp +++ b/chopseqscommand.cpp @@ -133,7 +133,7 @@ ChopSeqsCommand::ChopSeqsCommand(string option) { void ChopSeqsCommand::help(){ try { - m->mothurOut("The chop.seqs command reads a fasta file and outputs a .chop.fasta containing the trimmed sequences.\n"); + m->mothurOut("The chop.seqs command reads a fasta file and outputs a .chop.fasta containing the trimmed sequences. Note: If a sequence is completely 'chopped', an accnos file will be created with the names of the sequences removed. \n"); m->mothurOut("The chop.seqs command parameters are fasta, numbases, countgaps and keep. fasta and numbases are required required.\n"); m->mothurOut("The chop.seqs command should be in the following format: chop.seqs(fasta=yourFasta, numbases=yourNum, keep=yourKeep).\n"); m->mothurOut("The numbases parameter allows you to specify the number of bases you want to keep.\n"); @@ -202,6 +202,21 @@ int ChopSeqsCommand::execute(){ m->mothurOutEndLine(); + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + if (wroteAccnos) { //set accnos file as new current accnosfile + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + } + + return 0; } diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 2dfe05a..6cfa332 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -682,6 +682,13 @@ int ClassifySeqsCommand::execute(){ m->mothurOutEndLine(); } + //set taxonomy file as new current taxonomyfile + string current = ""; + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } + delete classify; return 0; } diff --git a/clearcutcommand.cpp b/clearcutcommand.cpp index 767981d..7fd8c13 100644 --- a/clearcutcommand.cpp +++ b/clearcutcommand.cpp @@ -310,6 +310,14 @@ int ClearcutCommand::execute() { delete[] clearcutParameters; if (!stdoutWanted) { + + //set first tree file as new current treefile + string currentTree = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/clustercommand.cpp b/clustercommand.cpp index 5d9225b..391b20a 100644 --- a/clustercommand.cpp +++ b/clustercommand.cpp @@ -294,6 +294,25 @@ int ClusterCommand::execute(){ m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); } + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/clusterdoturcommand.cpp b/clusterdoturcommand.cpp index b2b31ed..5bcfe03 100644 --- a/clusterdoturcommand.cpp +++ b/clusterdoturcommand.cpp @@ -271,6 +271,25 @@ int ClusterDoturCommand::execute(){ // m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); //} + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/clusterfragmentscommand.cpp b/clusterfragmentscommand.cpp index a8277ff..be78e76 100644 --- a/clusterfragmentscommand.cpp +++ b/clusterfragmentscommand.cpp @@ -258,6 +258,18 @@ int ClusterFragmentsCommand::execute(){ m->mothurOut(newNamesFile); m->mothurOutEndLine(); outputNames.push_back(newFastaFile); outputNames.push_back(newNamesFile); outputTypes["fasta"].push_back(newFastaFile); outputTypes["name"].push_back(newNamesFile); m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } return 0; diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index cb3fc40..f9d3822 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -616,6 +616,25 @@ int ClusterSplitCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to merge."); m->mothurOutEndLine(); + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/command.hpp b/command.hpp index f65f6cc..93669ba 100644 --- a/command.hpp +++ b/command.hpp @@ -18,10 +18,11 @@ #include "validparameter.h" #include "mothurout.h" + class Command { public: - Command() { m = MothurOut::getInstance(); } + Command() { m = MothurOut::getInstance(); } virtual vector getValidParameters() = 0; virtual vector getRequiredParameters() = 0; //adding "or" as the last element indicates one of the previous is needed virtual vector getRequiredFiles() = 0; //adding "or" as the last element indicates one of the previous is needed @@ -31,7 +32,6 @@ class Command { virtual ~Command() { } protected: MothurOut* m; - bool calledHelp; map >::iterator itTypes; diff --git a/commandfactory.cpp b/commandfactory.cpp index a401177..e18e6ac 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -114,6 +114,8 @@ #include "mantelcommand.h" #include "makefastqcommand.h" #include "anosimcommand.h" +#include "getcurrentcommand.h" +#include "setcurrentcommand.h" /*******************************************************/ @@ -231,6 +233,8 @@ CommandFactory::CommandFactory(){ commands["anosim"] = "anosim"; commands["make.fastq"] = "make.fastq"; commands["merge.groups"] = "merge.groups"; + commands["get.current"] = "get.current"; + commands["set.current"] = "set.current"; commands["pairwise.seqs"] = "MPIEnabled"; commands["pipeline.pds"] = "MPIEnabled"; commands["classify.seqs"] = "MPIEnabled"; @@ -396,6 +400,8 @@ Command* CommandFactory::getCommand(string commandName, string optionString){ else if(commandName == "homova") { command = new HomovaCommand(optionString); } else if(commandName == "mantel") { command = new MantelCommand(optionString); } else if(commandName == "make.fastq") { command = new MakeFastQCommand(optionString); } + else if(commandName == "get.current") { command = new GetCurrentCommand(optionString); } + else if(commandName == "set.current") { command = new SetCurrentCommand(optionString); } else if(commandName == "anosim") { command = new AnosimCommand(optionString); } else { command = new NoCommand(optionString); } @@ -529,6 +535,8 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str else if(commandName == "mantel") { pipecommand = new MantelCommand(optionString); } else if(commandName == "anosim") { pipecommand = new AnosimCommand(optionString); } else if(commandName == "make.fastq") { pipecommand = new MakeFastQCommand(optionString); } + else if(commandName == "get.current") { pipecommand = new GetCurrentCommand(optionString); } + else if(commandName == "set.current") { pipecommand = new SetCurrentCommand(optionString); } else { pipecommand = new NoCommand(optionString); } return pipecommand; @@ -649,6 +657,8 @@ Command* CommandFactory::getCommand(string commandName){ else if(commandName == "mantel") { shellcommand = new MantelCommand(); } else if(commandName == "anosim") { shellcommand = new AnosimCommand(); } else if(commandName == "make.fastq") { shellcommand = new MakeFastQCommand(); } + else if(commandName == "get.current") { shellcommand = new GetCurrentCommand(); } + else if(commandName == "set.current") { shellcommand = new SetCurrentCommand(); } else { shellcommand = new NoCommand(); } return shellcommand; diff --git a/consensuscommand.cpp b/consensuscommand.cpp index 9880b8d..d64dc93 100644 --- a/consensuscommand.cpp +++ b/consensuscommand.cpp @@ -211,6 +211,13 @@ int ConcensusCommand::execute(){ delete consensusTree; + //set first tree file as new current treefile + string currentTree = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); } + } + return 0; } catch(exception& e) { diff --git a/currentfile.cpp b/currentfile.cpp deleted file mode 100644 index cf4800a..0000000 --- a/currentfile.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * currentfile.cpp - * Mothur - * - * Created by westcott on 3/15/11. - * Copyright 2011 Schloss Lab. All rights reserved. - * - */ - -#include "currentfile.h" - -/******************************************************/ -CurrentFile* CurrentFile::getInstance() { - if(_uniqueInstance == 0) { - _uniqueInstance = new CurrentFile(); - } - return _uniqueInstance; -} -/*********************************************************************************************/ -CurrentFile::CurrentFile() { - m = MothurOut::getInstance(); - - phylipfile = ""; - columnfile = ""; - listfile = ""; - rabundfile = ""; - sabundfile = ""; - namefile = ""; - groupfile = ""; - designfile = ""; - orderfile = ""; - treefile = ""; - sharedfile = ""; - ordergroupfile = ""; - relabundfile = ""; - fastafile = ""; - qualfile = ""; - sfffile = ""; - oligosfile = ""; -} -/*********************************************************************************************/ -CurrentFile::~CurrentFile() { - _uniqueInstance = 0; -} -/*********************************************************************************************/ - - diff --git a/currentfile.h b/currentfile.h index b763971..8f2ea48 100644 --- a/currentfile.h +++ b/currentfile.h @@ -17,60 +17,78 @@ class CurrentFile { -public: - - static CurrentFile* getInstance(); - - string getPhylipFile() { return phylipfile; } - string getColumnFile() { return columnfile; } - string getListFile() { return listfile; } - string getRabundFile() { return rabundfile; } - string getSabundFile() { return sabundfile; } - string getNameFile() { return namefile; } - string getGroupFile() { return groupfile; } - string getOrderFile() { return orderfile; } - string getOrderGroupFile() { return ordergroupfile; } - string getTreeFile() { return treefile; } - string getSharedFile() { return sharedfile; } - string getRelAbundFile() { return relabundfile; } - string getDesignFile() { return designfile; } - string getFastaFile() { return fastafile; } - string getSFFFile() { return sfffile; } - string getQualFile() { return qualfile; } - string getOligosFile() { return oligosfile; } - - - void setListFile(string f) { listfile = m->getFullPathName(f); } - void setTreeFile(string f) { treefile = m->getFullPathName(f); } - void setGroupFile(string f) { groupfile = m->getFullPathName(f); } - void setPhylipFile(string f) { phylipfile = m->getFullPathName(f); } - void setColumnFile(string f) { columnfile = m->getFullPathName(f); } - void setNameFile(string f) { namefile = m->getFullPathName(f); } - void setRabundFile(string f) { rabundfile = m->getFullPathName(f); } - void setSabundFile(string f) { sabundfile = m->getFullPathName(f); } - void setSharedFile(string f) { sharedfile = m->getFullPathName(f); } - void setRelAbundFile(string f) { relabundfile = m->getFullPathName(f); } - void setOrderFile(string f) { orderfile = m->getFullPathName(f); } - void setOrderGroupFile(string f) { ordergroupfile = m->getFullPathName(f); } - void setDesignFile(string f) { designfile = m->getFullPathName(f); } - void setFastaFile(string f) { fastafile = m->getFullPathName(f); } - void setSFFFile(string f) { sfffile = m->getFullPathName(f); } - void setQualFile(string f) { qualfile = m->getFullPathName(f); } - void setOligosFile(string f) { oligosfile = m->getFullPathName(f); } - -private: - - static CurrentFile* _uniqueInstance; - CurrentFile( const CurrentFile& ); // Disable copy constructor - void operator=( const CurrentFile& ); // Disable assignment operator - CurrentFile(); - ~CurrentFile(); - - MothurOut* m; - string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile; - string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; + public: + static CurrentFile* getInstance() { + if(instance == 0) { instance = new CurrentFile(); } + return instance; + } + + string getPhylipFile() { return phylipfile; } + string getColumnFile() { return columnfile; } + string getListFile() { return listfile; } + string getRabundFile() { return rabundfile; } + string getSabundFile() { return sabundfile; } + string getNameFile() { return namefile; } + string getGroupFile() { return groupfile; } + string getOrderFile() { return orderfile; } + string getOrderGroupFile() { return ordergroupfile; } + string getTreeFile() { return treefile; } + string getSharedFile() { return sharedfile; } + string getRelAbundFile() { return relabundfile; } + string getDesignFile() { return designfile; } + string getFastaFile() { return fastafile; } + string getSFFFile() { return sfffile; } + string getQualFile() { return qualfile; } + string getOligosFile() { return oligosfile; } + + + void setListFile(string f) { listfile = m->getFullPathName(f); } + void setTreeFile(string f) { treefile = m->getFullPathName(f); } + void setGroupFile(string f) { groupfile = m->getFullPathName(f); } + void setPhylipFile(string f) { phylipfile = m->getFullPathName(f); } + void setColumnFile(string f) { columnfile = m->getFullPathName(f); } + void setNameFile(string f) { namefile = m->getFullPathName(f); } + void setRabundFile(string f) { rabundfile = m->getFullPathName(f); } + void setSabundFile(string f) { sabundfile = m->getFullPathName(f); } + void setSharedFile(string f) { sharedfile = m->getFullPathName(f); } + void setRelAbundFile(string f) { relabundfile = m->getFullPathName(f); } + void setOrderFile(string f) { orderfile = m->getFullPathName(f); } + void setOrderGroupFile(string f) { ordergroupfile = m->getFullPathName(f); } + void setDesignFile(string f) { designfile = m->getFullPathName(f); } + void setFastaFile(string f) { fastafile = m->getFullPathName(f); } + void setSFFFile(string f) { sfffile = m->getFullPathName(f); } + void setQualFile(string f) { qualfile = m->getFullPathName(f); } + void setOligosFile(string f) { oligosfile = m->getFullPathName(f); } + private: + MothurOut* m; + string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile; + string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; + + static CurrentFile* instance; + CurrentFile( const CurrentFile& ); // Disable copy constructor + void operator=( const CurrentFile& ); // Disable assignment operator + CurrentFile() { + phylipfile = ""; + columnfile = ""; + listfile = ""; + rabundfile = ""; + sabundfile = ""; + namefile = ""; + groupfile = ""; + designfile = ""; + orderfile = ""; + treefile = ""; + sharedfile = ""; + ordergroupfile = ""; + relabundfile = ""; + fastafile = ""; + qualfile = ""; + sfffile = ""; + oligosfile = ""; + } + ~CurrentFile() { instance = 0; } }; /***********************************************/ diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 6c04c12..62daa61 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -177,7 +177,17 @@ int DeconvoluteCommand::execute() { outputNames.push_back(outFastaFile); outputNames.push_back(outNameFile); outputTypes["fasta"].push_back(outFastaFile); outputTypes["name"].push_back(outNameFile); m->mothurOutEndLine(); - + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } return 0; } diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp index 5df6188..7fd2803 100644 --- a/degapseqscommand.cpp +++ b/degapseqscommand.cpp @@ -219,6 +219,13 @@ int DegapSeqsCommand::execute(){ if (m->control_pressed) { outputTypes.clear(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; } } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/deuniqueseqscommand.cpp b/deuniqueseqscommand.cpp index 214359e..1d87204 100644 --- a/deuniqueseqscommand.cpp +++ b/deuniqueseqscommand.cpp @@ -215,6 +215,13 @@ int DeUniqueSeqsCommand::execute() { outputNames.push_back(outFastaFile); outputTypes["fasta"].push_back(outFastaFile); m->mothurOutEndLine(); + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + return 0; } catch(exception& e) { diff --git a/distancecommand.cpp b/distancecommand.cpp index 3d66722..5ffe0da 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -501,6 +501,19 @@ int DistanceCommand::execute(){ delete distCalculator; + //set phylip file as new current phylipfile + string current = ""; + itTypes = outputTypes.find("phylip"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); } + } + + //set column file as new current columnfile + itTypes = outputTypes.find("column"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); m->mothurOut(outputFile); m->mothurOutEndLine(); diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index 6fd4e04..cb0b131 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -302,6 +302,12 @@ int FilterSeqsCommand::execute() { m->mothurOut("Length of the original alignment: " + toString(alignmentLength)); m->mothurOutEndLine(); m->mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); m->mothurOutEndLine(); + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/getcurrentcommand.cpp b/getcurrentcommand.cpp new file mode 100644 index 0000000..bd7539a --- /dev/null +++ b/getcurrentcommand.cpp @@ -0,0 +1,184 @@ +/* + * getcurrentcommand.cpp + * Mothur + * + * Created by westcott on 3/16/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + +#include "getcurrentcommand.h" + + +//********************************************************************************************************************** +vector GetCurrentCommand::getValidParameters(){ + try { + string Array[] = {"outputdir","inputdir","clear"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +GetCurrentCommand::GetCurrentCommand(){ + try { + abort = true; calledHelp = true; + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetCurrentCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetCurrentCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "getRequiredFiles"); + exit(1); + } +} +//********************************************************************************************************************** +GetCurrentCommand::GetCurrentCommand(string option) { + try { + abort = false; calledHelp = false; + + //allow user to run help + if(option == "help") { help(); abort = true; calledHelp = true; } + + else { + //valid paramters for this command + string Array[] = {"outputdir","inputdir","clear"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + + OptionParser parser(option); + map parameters = parser.getParameters(); + + ValidParameters validParameter; + //check to make sure all parameters are valid for command + for (map::iterator it = parameters.begin(); it != parameters.end(); it++) { + if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } + } + + clearTypes = validParameter.validFile(parameters, "clear", false); + if (clearTypes == "not found") { clearTypes = ""; } + else { m->splitAtDash(clearTypes, types); } + } + + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand"); + exit(1); + } +} +//********************************************************************************************************************** + +void GetCurrentCommand::help(){ + try { + m->mothurOut("The get.current command outputs the current files saved by mothur.\n"); + m->mothurOut("The get.current command has one parameter: clear.\n"); + m->mothurOut("The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n"); + m->mothurOut("The get.current command should be in the following format: \n"); + m->mothurOut("get.current() or get.current(clear=fasta-name-accnos)\n"); + + } + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "help"); + exit(1); + } +} + +//********************************************************************************************************************** +GetCurrentCommand::~GetCurrentCommand(){} +//********************************************************************************************************************** + +int GetCurrentCommand::execute(){ + try { + + if (abort == true) { if (calledHelp) { return 0; } return 2; } + + //user wants to clear a type + if (types.size() != 0) { + for (int i = 0; i < types.size(); i++) { + + if (m->control_pressed) { break; } + + //look for file types + if (types[i] == "fasta") { + m->setFastaFile(""); + }else if (types[i] == "qfile") { + m->setQualFile(""); + }else if (types[i] == "phylip") { + m->setPhylipFile(""); + }else if (types[i] == "column") { + m->setColumnFile(""); + }else if (types[i] == "list") { + m->setListFile(""); + }else if (types[i] == "rabund") { + m->setRabundFile(""); + }else if (types[i] == "sabund") { + m->setSabundFile(""); + }else if (types[i] == "name") { + m->setNameFile(""); + }else if (types[i] == "group") { + m->setGroupFile(""); + }else if (types[i] == "order") { + m->setOrderFile(""); + }else if (types[i] == "ordergroup") { + m->setOrderGroupFile(""); + }else if (types[i] == "tree") { + m->setTreeFile(""); + }else if (types[i] == "shared") { + m->setSharedFile(""); + }else if (types[i] == "relabund") { + m->setRelAbundFile(""); + }else if (types[i] == "design") { + m->setDesignFile(""); + }else if (types[i] == "sff") { + m->setSFFFile(""); + }else if (types[i] == "oligos") { + m->setOligosFile(""); + }else if (types[i] == "accnos") { + m->setAccnosFile(""); + }else if (types[i] == "taxonomy") { + m->setTaxonomyFile(""); + }else if (types[i] == "all") { + m->clearCurrentFiles(); + }else { + m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine(); + } + } + } + + m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine(); + m->printCurrentFiles(); + + return 0; + } + + catch(exception& e) { + m->errorOut(e, "GetCurrentCommand", "execute"); + exit(1); + } +} + +//********************************************************************************************************************** + + + diff --git a/getcurrentcommand.h b/getcurrentcommand.h new file mode 100644 index 0000000..c36b6a5 --- /dev/null +++ b/getcurrentcommand.h @@ -0,0 +1,40 @@ +#ifndef GETCURRENTCOMMAND_H +#define GETCURRENTCOMMAND_H + +/* + * getcurrentcommand.h + * Mothur + * + * Created by westcott on 3/16/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + +#include "command.hpp" + +class GetCurrentCommand : public Command { + + public: + GetCurrentCommand(string); + GetCurrentCommand(); + ~GetCurrentCommand(); + vector getRequiredParameters(); + vector getValidParameters(); + vector getRequiredFiles(); + map > getOutputFiles() { return outputTypes; } + int execute(); + void help(); + + private: + + vector outputNames; + map > outputTypes; + bool abort; + + string clearTypes; + vector types; + +}; + +#endif + diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp index 2d7ac54..ac76d73 100644 --- a/getgroupscommand.cpp +++ b/getgroupscommand.cpp @@ -258,6 +258,33 @@ int GetGroupsCommand::execute(){ m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } } return 0; diff --git a/getlineagecommand.cpp b/getlineagecommand.cpp index eee0cca..5a30e1e 100644 --- a/getlineagecommand.cpp +++ b/getlineagecommand.cpp @@ -257,6 +257,33 @@ int GetLineageCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } } return 0; diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp index 84d3871..78c39f7 100644 --- a/getoturepcommand.cpp +++ b/getoturepcommand.cpp @@ -543,6 +543,18 @@ int GetOTURepCommand::execute(){ if (m->control_pressed) { return 0; } + //set fasta file as new current fastafile - use first one?? + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/getotuscommand.cpp b/getotuscommand.cpp index f10142b..15d2bcb 100644 --- a/getotuscommand.cpp +++ b/getotuscommand.cpp @@ -207,6 +207,18 @@ int GetOtusCommand::execute(){ m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } } return 0; diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index 0b2d4ee..3b03f36 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -262,6 +262,13 @@ int GetRAbundCommand::execute(){ globaldata->gListVector = NULL; + //set rabund file as new current rabundfile + string current = ""; + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + return 0; } diff --git a/getrelabundcommand.cpp b/getrelabundcommand.cpp index 5e48203..e79ccc9 100644 --- a/getrelabundcommand.cpp +++ b/getrelabundcommand.cpp @@ -263,6 +263,13 @@ int GetRelAbundCommand::execute(){ m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["relabund"].push_back(outputFileName); m->mothurOutEndLine(); + //set relabund file as new current relabundfile + string current = ""; + itTypes = outputTypes.find("relabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRelAbundFile(current); } + } + return 0; } catch(exception& e) { diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index 2ae807c..0533af3 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -248,6 +248,13 @@ int GetSAbundCommand::execute(){ m->mothurOut(filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["sabund"].push_back(filename); m->mothurOutEndLine(); + //set sabund file as new current sabundfile + string current = ""; + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + return 0; } diff --git a/getseqscommand.cpp b/getseqscommand.cpp index 902cc07..68d0d2b 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -282,6 +282,39 @@ int GetSeqsCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } + } return 0; diff --git a/getsharedotucommand.cpp b/getsharedotucommand.cpp index 7746ef9..4fe711e 100644 --- a/getsharedotucommand.cpp +++ b/getsharedotucommand.cpp @@ -334,6 +334,20 @@ int GetSharedOTUCommand::execute(){ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete groupMap; return 0; } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + if (output == "accnos") { + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/hclustercommand.cpp b/hclustercommand.cpp index 94082df..128dee3 100644 --- a/hclustercommand.cpp +++ b/hclustercommand.cpp @@ -395,7 +395,26 @@ int HClusterCommand::execute(){ for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } - + + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index 239a4bc..654ec06 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -325,6 +325,13 @@ int IndicatorCommand::execute(){ delete outputTree; delete globaldata->gTreemap; return 0; } + //set tree file as new current treefile + string current = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/listseqscommand.cpp b/listseqscommand.cpp index 4060857..a8a9d2b 100644 --- a/listseqscommand.cpp +++ b/listseqscommand.cpp @@ -226,6 +226,7 @@ int ListSeqsCommand::execute(){ ofstream out; m->openOutputFile(outputFileName, out); + outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName); //output to .accnos file for (int i = 0; i < names.size(); i++) { @@ -237,12 +238,21 @@ int ListSeqsCommand::execute(){ out.close(); if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; } - + + m->setAccnosFile(outputFileName); + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); - m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName); + m->mothurOut(outputFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); + //set accnos file as new current accnosfile + string current = ""; + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + return 0; } diff --git a/makegroupcommand.cpp b/makegroupcommand.cpp index 1c04fec..8adfe09 100644 --- a/makegroupcommand.cpp +++ b/makegroupcommand.cpp @@ -229,7 +229,14 @@ int MakeGroupCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("Output File Name: " + filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["group"].push_back(filename); m->mothurOutEndLine(); - + + //set group file as new current groupfile + string current = ""; + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + return 0; } catch(exception& e) { diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index baf449e..ef2c236 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -402,6 +402,13 @@ int MatrixOutputCommand::execute(){ //reset groups parameter globaldata->Groups.clear(); + //set phylip file as new current phylipfile + string current = ""; + itTypes = outputTypes.find("phylip"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/mergegroupscommand.cpp b/mergegroupscommand.cpp index c54cd1c..60b9c85 100644 --- a/mergegroupscommand.cpp +++ b/mergegroupscommand.cpp @@ -273,6 +273,14 @@ int MergeGroupsCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0;} + + //set shared file as new current sharedfile + string current = ""; + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp index 4809964..23f359e 100644 --- a/mgclustercommand.cpp +++ b/mgclustercommand.cpp @@ -507,6 +507,26 @@ int MGClusterCommand::execute(){ m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + + m->mothurOut("It took " + toString(time(NULL) - start) + " seconds to cluster."); m->mothurOutEndLine(); return 0; diff --git a/mothurout.cpp b/mothurout.cpp index 96e7bb8..0c25f2a 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -18,6 +18,63 @@ MothurOut* MothurOut::getInstance() { return _uniqueInstance; } /*********************************************************************************************/ +void MothurOut::printCurrentFiles() { + try { + if (accnosfile != "") { mothurOut("accnos=" + accnosfile); mothurOutEndLine(); } + if (columnfile != "") { mothurOut("column=" + columnfile); mothurOutEndLine(); } + if (designfile != "") { mothurOut("design=" + designfile); mothurOutEndLine(); } + if (fastafile != "") { mothurOut("fasta=" + fastafile); mothurOutEndLine(); } + if (groupfile != "") { mothurOut("group=" + groupfile); mothurOutEndLine(); } + if (listfile != "") { mothurOut("list=" + listfile); mothurOutEndLine(); } + if (namefile != "") { mothurOut("name=" + namefile); mothurOutEndLine(); } + if (oligosfile != "") { mothurOut("oligos=" + oligosfile); mothurOutEndLine(); } + if (orderfile != "") { mothurOut("order=" + orderfile); mothurOutEndLine(); } + if (ordergroupfile != "") { mothurOut("ordergroup=" + ordergroupfile); mothurOutEndLine(); } + if (phylipfile != "") { mothurOut("phylip=" + phylipfile); mothurOutEndLine(); } + if (qualfile != "") { mothurOut("qfile=" + qualfile); mothurOutEndLine(); } + if (rabundfile != "") { mothurOut("rabund=" + rabundfile); mothurOutEndLine(); } + if (relabundfile != "") { mothurOut("relabund=" + relabundfile); mothurOutEndLine(); } + if (sabundfile != "") { mothurOut("sabund=" + sabundfile); mothurOutEndLine(); } + if (sfffile != "") { mothurOut("sff=" + sfffile); mothurOutEndLine(); } + if (sharedfile != "") { mothurOut("shared=" + sharedfile); mothurOutEndLine(); } + if (taxonomyfile != "") { mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine(); } + if (treefile != "") { mothurOut("tree=" + treefile); mothurOutEndLine(); } + + } + catch(exception& e) { + errorOut(e, "MothurOut", "printCurrentFiles"); + exit(1); + } +} +/*********************************************************************************************/ +void MothurOut::clearCurrentFiles() { + try { + phylipfile = ""; + columnfile = ""; + listfile = ""; + rabundfile = ""; + sabundfile = ""; + namefile = ""; + groupfile = ""; + designfile = ""; + orderfile = ""; + treefile = ""; + sharedfile = ""; + ordergroupfile = ""; + relabundfile = ""; + fastafile = ""; + qualfile = ""; + sfffile = ""; + oligosfile = ""; + accnosfile = ""; + taxonomyfile = ""; + } + catch(exception& e) { + errorOut(e, "MothurOut", "clearCurrentFiles"); + exit(1); + } +} +/*********************************************************************************************/ void MothurOut::setFileName(string filename) { try { logFileName = filename; diff --git a/mothurout.h b/mothurout.h index 750973f..3580532 100644 --- a/mothurout.h +++ b/mothurout.h @@ -91,17 +91,86 @@ class MothurOut { int control_pressed; bool executing; + //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles. + string getPhylipFile() { return phylipfile; } + string getColumnFile() { return columnfile; } + string getListFile() { return listfile; } + string getRabundFile() { return rabundfile; } + string getSabundFile() { return sabundfile; } + string getNameFile() { return namefile; } + string getGroupFile() { return groupfile; } + string getOrderFile() { return orderfile; } + string getOrderGroupFile() { return ordergroupfile; } + string getTreeFile() { return treefile; } + string getSharedFile() { return sharedfile; } + string getRelAbundFile() { return relabundfile; } + string getDesignFile() { return designfile; } + string getFastaFile() { return fastafile; } + string getSFFFile() { return sfffile; } + string getQualFile() { return qualfile; } + string getOligosFile() { return oligosfile; } + string getAccnosFile() { return accnosfile; } + string getTaxonomyFile() { return taxonomyfile; } + + void setListFile(string f) { listfile = getFullPathName(f); } + void setTreeFile(string f) { treefile = getFullPathName(f); } + void setGroupFile(string f) { groupfile = getFullPathName(f); } + void setPhylipFile(string f) { phylipfile = getFullPathName(f); } + void setColumnFile(string f) { columnfile = getFullPathName(f); } + void setNameFile(string f) { namefile = getFullPathName(f); } + void setRabundFile(string f) { rabundfile = getFullPathName(f); } + void setSabundFile(string f) { sabundfile = getFullPathName(f); } + void setSharedFile(string f) { sharedfile = getFullPathName(f); } + void setRelAbundFile(string f) { relabundfile = getFullPathName(f); } + void setOrderFile(string f) { orderfile = getFullPathName(f); } + void setOrderGroupFile(string f) { ordergroupfile = getFullPathName(f); } + void setDesignFile(string f) { designfile = getFullPathName(f); } + void setFastaFile(string f) { fastafile = getFullPathName(f); } + void setSFFFile(string f) { sfffile = getFullPathName(f); } + void setQualFile(string f) { qualfile = getFullPathName(f); } + void setOligosFile(string f) { oligosfile = getFullPathName(f); } + void setAccnosFile(string f) { accnosfile = getFullPathName(f); } + void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); } + + void printCurrentFiles(); + void clearCurrentFiles(); + private: static MothurOut* _uniqueInstance; MothurOut( const MothurOut& ); // Disable copy constructor void operator=( const MothurOut& ); // Disable assignment operator - MothurOut() { control_pressed = false; defaultPath=""; }; + MothurOut() { + control_pressed = false; defaultPath=""; + phylipfile = ""; + columnfile = ""; + listfile = ""; + rabundfile = ""; + sabundfile = ""; + namefile = ""; + groupfile = ""; + designfile = ""; + orderfile = ""; + treefile = ""; + sharedfile = ""; + ordergroupfile = ""; + relabundfile = ""; + fastafile = ""; + qualfile = ""; + sfffile = ""; + oligosfile = ""; + accnosfile = ""; + taxonomyfile = ""; + }; ~MothurOut(); string logFileName; string defaultPath, outputDir; string releaseDate, version; - + + string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile; + string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; + + ofstream out; int mem_usage(double&, double&); diff --git a/normalizesharedcommand.cpp b/normalizesharedcommand.cpp index d9405a5..37cfb5d 100644 --- a/normalizesharedcommand.cpp +++ b/normalizesharedcommand.cpp @@ -381,6 +381,13 @@ int NormalizeSharedCommand::execute(){ m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName); m->mothurOutEndLine(); + //set shared file as new current sharedfile + string current = ""; + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } + return 0; } catch(exception& e) { diff --git a/optionparser.cpp b/optionparser.cpp index 08032b3..0506da6 100644 --- a/optionparser.cpp +++ b/optionparser.cpp @@ -30,13 +30,83 @@ OptionParser::OptionParser(string option) { } } catch(exception& e) { - m->errorOut(e, "OptionParser", "parse"); + m->errorOut(e, "OptionParser", "OptionParser"); exit(1); } } /***********************************************************************/ -map OptionParser::getParameters() { return parameters; } +map OptionParser::getParameters() { + try { + + //loop through parameters and look for "current" so you can return the appropriate file + //doing it here to avoid code duplication in each of the commands + + map::iterator it; + for (it = parameters.begin(); it != parameters.end();) { + + if (it->second == "current") { + + //look for file types + if ((it->first == "fasta") || (it->first == "candidate")) { + it->second = m->getFastaFile(); + }else if (it->first == "qfile") { + it->second = m->getQualFile(); + }else if (it->first == "phylip") { + it->second = m->getPhylipFile(); + }else if (it->first == "column") { + it->second = m->getColumnFile(); + }else if (it->first == "list") { + it->second = m->getListFile(); + }else if (it->first == "rabund") { + it->second = m->getRabundFile(); + }else if (it->first == "sabund") { + it->second = m->getSabundFile(); + }else if (it->first == "name") { + it->second = m->getNameFile(); + }else if (it->first == "group") { + it->second = m->getGroupFile(); + }else if (it->first == "order") { + it->second = m->getOrderFile(); + }else if (it->first == "ordergroup") { + it->second = m->getOrderGroupFile(); + }else if (it->first == "tree") { + it->second = m->getTreeFile(); + }else if (it->first == "shared") { + it->second = m->getSharedFile(); + }else if (it->first == "relabund") { + it->second = m->getRelAbundFile(); + }else if (it->first == "design") { + it->second = m->getDesignFile(); + }else if (it->first == "sff") { + it->second = m->getSFFFile(); + }else if (it->first == "oligos") { + it->second = m->getOligosFile(); + }else if (it->first == "accnos") { + it->second = m->getAccnosFile(); + }else if (it->first == "taxonomy") { + it->second = m->getTaxonomyFile(); + }else { + m->mothurOut("[ERROR]: mothur does not save a current file for " + it->first); m->mothurOutEndLine(); + } + + if (it->second == "") { //no file was saved for that type, warn and remove from parameters + m->mothurOut("[WARNING]: no file was saved for " + it->first + " parameter."); m->mothurOutEndLine(); + parameters.erase(it++); + }else { + m->mothurOut("Using " + it->second + " as input file for the " + it->first + " parameter."); m->mothurOutEndLine(); + it++; + } + }else{ it++; } + } + + return parameters; + } + catch(exception& e) { + m->errorOut(e, "OptionParser", "getParameters"); + exit(1); + } +} /***********************************************************************/ diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index 0a4edea..e3f8852 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -494,6 +494,19 @@ int PairwiseSeqsCommand::execute(){ delete distCalculator; + //set phylip file as new current phylipfile + string current = ""; + itTypes = outputTypes.find("phylip"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); } + } + + //set column file as new current columnfile + itTypes = outputTypes.find("column"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 7f4fbba..87ec2d2 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -28,7 +28,7 @@ ParseFastaQCommand::ParseFastaQCommand(){ abort = true; calledHelp = true; vector tempOutNames; outputTypes["fasta"] = tempOutNames; - outputTypes["qual"] = tempOutNames; + outputTypes["qfile"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "ParseFastaQCommand", "ParseFastaQCommand"); @@ -84,7 +84,7 @@ ParseFastaQCommand::ParseFastaQCommand(string option){ //initialize outputTypes vector tempOutNames; outputTypes["fasta"] = tempOutNames; - outputTypes["qual"] = tempOutNames; + outputTypes["qfile"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); @@ -146,7 +146,7 @@ int ParseFastaQCommand::execute(){ string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "qual"; ofstream outFasta, outQual; m->openOutputFile(fastaFile, outFasta); outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile); - m->openOutputFile(qualFile, outQual); outputNames.push_back(qualFile); outputTypes["qual"].push_back(qualFile); + m->openOutputFile(qualFile, outQual); outputNames.push_back(qualFile); outputTypes["qfile"].push_back(qualFile); ifstream in; m->openInputFile(fastaQFile, in); @@ -194,6 +194,18 @@ int ParseFastaQCommand::execute(){ if (m->control_pressed) { outputTypes.clear(); remove(fastaFile.c_str()); remove(qualFile.c_str()); return 0; } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/parselistscommand.cpp b/parselistscommand.cpp index fdacc3a..2d26ef3 100644 --- a/parselistscommand.cpp +++ b/parselistscommand.cpp @@ -295,6 +295,13 @@ int ParseListCommand::execute(){ return 0; } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/phylotypecommand.cpp b/phylotypecommand.cpp index 4b524dd..c3aee47 100644 --- a/phylotypecommand.cpp +++ b/phylotypecommand.cpp @@ -305,6 +305,25 @@ int PhylotypeCommand::execute(){ return 0; } + //set list file as new current listfile + string current = ""; + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + //set rabund file as new current rabundfile + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + //set sabund file as new current sabundfile + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/preclustercommand.cpp b/preclustercommand.cpp index 14409f5..0fb9370 100644 --- a/preclustercommand.cpp +++ b/preclustercommand.cpp @@ -245,7 +245,19 @@ int PreClusterCommand::execute(){ m->mothurOut(newFastaFile); m->mothurOutEndLine(); outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile); m->mothurOut(newNamesFile); m->mothurOutEndLine(); outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile); m->mothurOutEndLine(); - + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + return 0; } diff --git a/readotucommand.cpp b/readotucommand.cpp index 6757556..3d0b94d 100644 --- a/readotucommand.cpp +++ b/readotucommand.cpp @@ -310,8 +310,22 @@ int ReadOtuCommand::execute(){ outputTypes = shared->getOutputFiles(); + //set rabund file as new current rabundfile + string current = ""; + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } + delete shared; } + + return 0; } catch(exception& e) { diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 4462b52..34a072b 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -258,6 +258,33 @@ int RemoveGroupsCommand::execute(){ m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } } return 0; diff --git a/removelineagecommand.cpp b/removelineagecommand.cpp index 6e43b10..893b210 100644 --- a/removelineagecommand.cpp +++ b/removelineagecommand.cpp @@ -256,6 +256,33 @@ int RemoveLineageCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } } return 0; diff --git a/removeotuscommand.cpp b/removeotuscommand.cpp index 347bb08..f1ef4ac 100644 --- a/removeotuscommand.cpp +++ b/removeotuscommand.cpp @@ -207,6 +207,18 @@ int RemoveOtusCommand::execute(){ m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } } return 0; diff --git a/removerarecommand.cpp b/removerarecommand.cpp index 0c656a0..bcb9af6 100644 --- a/removerarecommand.cpp +++ b/removerarecommand.cpp @@ -243,6 +243,33 @@ int RemoveRareCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set rabund file as new current rabundfile + string current = ""; + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } } return 0; diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index 81c42f6..1990e9c 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -273,6 +273,38 @@ int RemoveSeqsCommand::execute(){ m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("taxonomy"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } } return 0; diff --git a/reversecommand.cpp b/reversecommand.cpp index 5eceb30..fffe8a2 100644 --- a/reversecommand.cpp +++ b/reversecommand.cpp @@ -181,7 +181,7 @@ int ReverseSeqsCommand::execute(){ } inFASTA.close(); outFASTA.close(); - outputNames.push_back(fastaReverseFileName); + outputNames.push_back(fastaReverseFileName); outputTypes["fasta"].push_back(fastaReverseFileName); } string qualReverseFileName; @@ -204,9 +204,24 @@ int ReverseSeqsCommand::execute(){ } inQual.close(); outQual.close(); - outputNames.push_back(qualReverseFileName); + outputNames.push_back(qualReverseFileName); outputTypes["qfile"].push_back(qualReverseFileName); } + if (m->control_pressed) { remove(qualReverseFileName.c_str()); remove(fastaReverseFileName.c_str()); return 0; } + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } + + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); for(int i=0;imothurOutEndLine(); } + + return 0; } catch(exception& e) { diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index e6d29c1..8c334cb 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -484,6 +484,23 @@ int ScreenSeqsCommand::execute(){ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); m->mothurOutEndLine(); + + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } m->mothurOut("It took " + toString(time(NULL) - start) + " secs to screen " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); diff --git a/setcurrentcommand.cpp b/setcurrentcommand.cpp new file mode 100644 index 0000000..a4f5c5c --- /dev/null +++ b/setcurrentcommand.cpp @@ -0,0 +1,449 @@ +/* + * setcurrentcommand.cpp + * Mothur + * + * Created by westcott on 3/16/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + +#include "setcurrentcommand.h" + +//********************************************************************************************************************** +vector SetCurrentCommand::getValidParameters(){ + try { + string Array[] = {"outputdir","inputdir","clear", "phylip", "column", "list","rabund","sabund","name","group", + "design","order","tree","shared","ordergroup","relabund","fasta","qfile","sff","oligos","accnos","taxonomy"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +SetCurrentCommand::SetCurrentCommand(){ + try { + abort = true; calledHelp = true; + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "SetCurrentCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector SetCurrentCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector SetCurrentCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "getRequiredFiles"); + exit(1); + } +} +//********************************************************************************************************************** +SetCurrentCommand::SetCurrentCommand(string option) { + try { + abort = false; calledHelp = false; + + //allow user to run help + if(option == "help") { help(); abort = true; calledHelp = true; } + + else { + //valid paramters for this command + string Array[] = {"outputdir","inputdir","clear", "phylip", "column", "list","rabund","sabund","name","group", + "design","order","tree","shared","ordergroup","relabund","fasta","qfile","sff","oligos","accnos","taxonomy"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + + OptionParser parser(option); + map parameters = parser.getParameters(); + + ValidParameters validParameter; + map::iterator it; + //check to make sure all parameters are valid for command + for (it = parameters.begin(); it != parameters.end(); it++) { + if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } + } + + + //if the user changes the input directory command factory will send this info to us in the output parameter + string inputDir = validParameter.validFile(parameters, "inputdir", false); + if (inputDir == "not found"){ inputDir = ""; } + else { + string path; + it = parameters.find("phylip"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["phylip"] = inputDir + it->second; } + } + + it = parameters.find("column"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["column"] = inputDir + it->second; } + } + + it = parameters.find("fasta"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["fasta"] = inputDir + it->second; } + } + + it = parameters.find("list"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["list"] = inputDir + it->second; } + } + + it = parameters.find("rabund"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["rabund"] = inputDir + it->second; } + } + + it = parameters.find("sabund"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["sabund"] = inputDir + it->second; } + } + + it = parameters.find("name"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["name"] = inputDir + it->second; } + } + + it = parameters.find("group"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["group"] = inputDir + it->second; } + } + + it = parameters.find("design"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["design"] = inputDir + it->second; } + } + + it = parameters.find("order"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["order"] = inputDir + it->second; } + } + + it = parameters.find("tree"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["tree"] = inputDir + it->second; } + } + + it = parameters.find("shared"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["shared"] = inputDir + it->second; } + } + + it = parameters.find("ordergroup"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["ordergroup"] = inputDir + it->second; } + } + + it = parameters.find("relabund"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["relabund"] = inputDir + it->second; } + } + + it = parameters.find("fasta"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["fasta"] = inputDir + it->second; } + } + + it = parameters.find("qfile"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["qfile"] = inputDir + it->second; } + } + + it = parameters.find("sff"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["sff"] = inputDir + it->second; } + } + + it = parameters.find("oligos"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["oligos"] = inputDir + it->second; } + } + + it = parameters.find("accnos"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["accnos"] = inputDir + it->second; } + } + + it = parameters.find("taxonomy"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["taxonomy"] = inputDir + it->second; } + } + } + + //check for parameters + phylipfile = validParameter.validFile(parameters, "phylip", true); + if (phylipfile == "not open") { m->mothurOut("Ignoring: " + parameters["phylip"]); m->mothurOutEndLine(); phylipfile = ""; } + else if (phylipfile == "not found") { phylipfile = ""; } + if (phylipfile != "") { m->setPhylipFile(phylipfile); } + + columnfile = validParameter.validFile(parameters, "column", true); + if (columnfile == "not open") { m->mothurOut("Ignoring: " + parameters["column"]); m->mothurOutEndLine(); columnfile = ""; } + else if (columnfile == "not found") { columnfile = ""; } + if (columnfile != "") { m->setColumnFile(columnfile); } + + listfile = validParameter.validFile(parameters, "list", true); + if (listfile == "not open") { m->mothurOut("Ignoring: " + parameters["list"]); m->mothurOutEndLine(); listfile = ""; } + else if (listfile == "not found") { listfile = ""; } + if (listfile != "") { m->setListFile(listfile); } + + rabundfile = validParameter.validFile(parameters, "rabund", true); + if (rabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["rabund"]); m->mothurOutEndLine(); rabundfile = ""; } + else if (rabundfile == "not found") { rabundfile = ""; } + if (rabundfile != "") { m->setRabundFile(rabundfile); } + + sabundfile = validParameter.validFile(parameters, "sabund", true); + if (sabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["sabund"]); m->mothurOutEndLine(); sabundfile = ""; } + else if (sabundfile == "not found") { sabundfile = ""; } + if (sabundfile != "") { m->setSabundFile(sabundfile); } + + namefile = validParameter.validFile(parameters, "name", true); + if (namefile == "not open") { m->mothurOut("Ignoring: " + parameters["name"]); m->mothurOutEndLine(); namefile = ""; } + else if (namefile == "not found") { namefile = ""; } + if (namefile != "") { m->setNameFile(namefile); } + + groupfile = validParameter.validFile(parameters, "group", true); + if (groupfile == "not open") { m->mothurOut("Ignoring: " + parameters["group"]); m->mothurOutEndLine(); groupfile = ""; } + else if (groupfile == "not found") { groupfile = ""; } + if (groupfile != "") { m->setGroupFile(groupfile); } + + designfile = validParameter.validFile(parameters, "design", true); + if (designfile == "not open") { m->mothurOut("Ignoring: " + parameters["design"]); m->mothurOutEndLine(); designfile = ""; } + else if (designfile == "not found") { designfile = ""; } + if (designfile != "") { m->setDesignFile(designfile); } + + orderfile = validParameter.validFile(parameters, "order", true); + if (orderfile == "not open") { m->mothurOut("Ignoring: " + parameters["order"]); m->mothurOutEndLine(); orderfile = ""; } + else if (orderfile == "not found") { orderfile = ""; } + if (orderfile != "") { m->setOrderFile(orderfile); } + + treefile = validParameter.validFile(parameters, "tree", true); + if (treefile == "not open") { m->mothurOut("Ignoring: " + parameters["tree"]); m->mothurOutEndLine(); treefile = ""; } + else if (treefile == "not found") { treefile = ""; } + if (treefile != "") { m->setTreeFile(treefile); } + + sharedfile = validParameter.validFile(parameters, "shared", true); + if (sharedfile == "not open") { m->mothurOut("Ignoring: " + parameters["shared"]); m->mothurOutEndLine(); sharedfile = ""; } + else if (sharedfile == "not found") { sharedfile = ""; } + if (sharedfile != "") { m->setSharedFile(sharedfile); } + + ordergroupfile = validParameter.validFile(parameters, "ordergroup", true); + if (ordergroupfile == "not open") { m->mothurOut("Ignoring: " + parameters["ordergroup"]); m->mothurOutEndLine(); ordergroupfile = ""; } + else if (ordergroupfile == "not found") { ordergroupfile = ""; } + if (ordergroupfile != "") { m->setOrderGroupFile(ordergroupfile); } + + relabundfile = validParameter.validFile(parameters, "relabund", true); + if (relabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["relabund"]); m->mothurOutEndLine(); relabundfile = ""; } + else if (relabundfile == "not found") { relabundfile = ""; } + if (relabundfile != "") { m->setRelAbundFile(relabundfile); } + + fastafile = validParameter.validFile(parameters, "fasta", true); + if (fastafile == "not open") { m->mothurOut("Ignoring: " + parameters["fasta"]); m->mothurOutEndLine(); fastafile = ""; } + else if (fastafile == "not found") { fastafile = ""; } + if (fastafile != "") { m->setFastaFile(fastafile); } + + qualfile = validParameter.validFile(parameters, "qfile", true); + if (qualfile == "not open") { m->mothurOut("Ignoring: " + parameters["qfile"]); m->mothurOutEndLine(); qualfile = ""; } + else if (qualfile == "not found") { qualfile = ""; } + if (qualfile != "") { m->setQualFile(qualfile); } + + sfffile = validParameter.validFile(parameters, "sff", true); + if (sfffile == "not open") { m->mothurOut("Ignoring: " + parameters["sff"]); m->mothurOutEndLine(); sfffile = ""; } + else if (sfffile == "not found") { sfffile = ""; } + if (sfffile != "") { m->setSFFFile(sfffile); } + + oligosfile = validParameter.validFile(parameters, "oligos", true); + if (oligosfile == "not open") { m->mothurOut("Ignoring: " + parameters["oligos"]); m->mothurOutEndLine(); oligosfile = ""; } + else if (oligosfile == "not found") { oligosfile = ""; } + if (oligosfile != "") { m->setOligosFile(oligosfile); } + + accnosfile = validParameter.validFile(parameters, "accnos", true); + if (accnosfile == "not open") { m->mothurOut("Ignoring: " + parameters["accnos"]); m->mothurOutEndLine(); accnosfile = ""; } + else if (accnosfile == "not found") { accnosfile = ""; } + if (accnosfile != "") { m->setAccnosFile(accnosfile); } + + taxonomyfile = validParameter.validFile(parameters, "taxonomy", true); + if (taxonomyfile == "not open") { m->mothurOut("Ignoring: " + parameters["taxonomy"]); m->mothurOutEndLine(); taxonomyfile = ""; } + else if (taxonomyfile == "not found") { taxonomyfile = ""; } + if (taxonomyfile != "") { m->setTaxonomyFile(taxonomyfile); } + + clearTypes = validParameter.validFile(parameters, "clear", false); + if (clearTypes == "not found") { clearTypes = ""; } + else { m->splitAtDash(clearTypes, types); } + } + + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "SetCurrentCommand"); + exit(1); + } +} +//********************************************************************************************************************** + +void SetCurrentCommand::help(){ + try { + m->mothurOut("The set.current command allows you to set the current files saved by mothur.\n"); + m->mothurOut("The set.current command parameters are: clear, phylip, column, list, rabund, sabund, name, group, design, order, tree, shared, ordergroup, relabund, fasta, qfile, sff, oligos, accnos, taxonomy.\n"); + m->mothurOut("The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n"); + m->mothurOut("The set.current command should be in the following format: \n"); + m->mothurOut("set.current(fasta=yourFastaFile) or set.current(fasta=amazon.fasta, clear=name-accnos)\n"); + + } + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "help"); + exit(1); + } +} + +//********************************************************************************************************************** +SetCurrentCommand::~SetCurrentCommand(){} +//********************************************************************************************************************** + +int SetCurrentCommand::execute(){ + try { + + if (abort == true) { if (calledHelp) { return 0; } return 2; } + + //user wants to clear a type + if (types.size() != 0) { + for (int i = 0; i < types.size(); i++) { + + if (m->control_pressed) { break; } + + //look for file types + if (types[i] == "fasta") { + m->setFastaFile(""); + }else if (types[i] == "qfile") { + m->setQualFile(""); + }else if (types[i] == "phylip") { + m->setPhylipFile(""); + }else if (types[i] == "column") { + m->setColumnFile(""); + }else if (types[i] == "list") { + m->setListFile(""); + }else if (types[i] == "rabund") { + m->setRabundFile(""); + }else if (types[i] == "sabund") { + m->setSabundFile(""); + }else if (types[i] == "name") { + m->setNameFile(""); + }else if (types[i] == "group") { + m->setGroupFile(""); + }else if (types[i] == "order") { + m->setOrderFile(""); + }else if (types[i] == "ordergroup") { + m->setOrderGroupFile(""); + }else if (types[i] == "tree") { + m->setTreeFile(""); + }else if (types[i] == "shared") { + m->setSharedFile(""); + }else if (types[i] == "relabund") { + m->setRelAbundFile(""); + }else if (types[i] == "design") { + m->setDesignFile(""); + }else if (types[i] == "sff") { + m->setSFFFile(""); + }else if (types[i] == "oligos") { + m->setOligosFile(""); + }else if (types[i] == "accnos") { + m->setAccnosFile(""); + }else if (types[i] == "taxonomy") { + m->setTaxonomyFile(""); + }else if (types[i] == "all") { + m->clearCurrentFiles(); + }else { + m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine(); + } + } + } + + m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine(); + m->printCurrentFiles(); + + return 0; + } + + catch(exception& e) { + m->errorOut(e, "SetCurrentCommand", "execute"); + exit(1); + } +} + +//********************************************************************************************************************** + + + diff --git a/setcurrentcommand.h b/setcurrentcommand.h new file mode 100644 index 0000000..98033b7 --- /dev/null +++ b/setcurrentcommand.h @@ -0,0 +1,46 @@ +#ifndef SETCURRENTCOMMAND_H +#define SETCURRENTCOMMAND_H + +/* + * setcurrentcommand.h + * Mothur + * + * Created by westcott on 3/16/11. + * Copyright 2011 Schloss Lab. All rights reserved. + * + */ + + +#include "command.hpp" + +class SetCurrentCommand : public Command { + +public: + SetCurrentCommand(string); + SetCurrentCommand(); + ~SetCurrentCommand(); + vector getRequiredParameters(); + vector getValidParameters(); + vector getRequiredFiles(); + map > getOutputFiles() { return outputTypes; } + int execute(); + void help(); + +private: + + vector outputNames; + map > outputTypes; + bool abort; + + string clearTypes; + vector types; + + string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile; + string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; + + +}; + +#endif + + diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index 4a9271c..973e14f 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -30,7 +30,7 @@ SffInfoCommand::SffInfoCommand(){ outputTypes["fasta"] = tempOutNames; outputTypes["flow"] = tempOutNames; outputTypes["sfftxt"] = tempOutNames; - outputTypes["qual"] = tempOutNames; + outputTypes["qfile"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "SffInfoCommand", "SffInfoCommand"); @@ -89,7 +89,7 @@ SffInfoCommand::SffInfoCommand(string option) { outputTypes["fasta"] = tempOutNames; outputTypes["flow"] = tempOutNames; outputTypes["sfftxt"] = tempOutNames; - outputTypes["qual"] = tempOutNames; + outputTypes["qfile"] = tempOutNames; //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 = ""; } @@ -300,6 +300,18 @@ int SffInfoCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } + //report output filenames m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -336,7 +348,7 @@ int SffInfoCommand::extractSffInfo(string input, string accnos){ if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint); outputNames.push_back(sfftxtFileName); outputTypes["sfftxt"].push_back(sfftxtFileName); } if (fasta) { m->openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); } - if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName); } + if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName); } if (flow) { m->openOutputFile(outFlowFileName, outFlow); outputNames.push_back(outFlowFileName); outFlow.setf(ios::fixed, ios::floatfield); outFlow.setf(ios::showpoint); outputTypes["flow"].push_back(outFlowFileName); } ifstream in; diff --git a/sharedcommand.cpp b/sharedcommand.cpp index ec6b1d3..731f981 100644 --- a/sharedcommand.cpp +++ b/sharedcommand.cpp @@ -321,6 +321,18 @@ int SharedCommand::execute(){ return 1; } + //set rabund file as new current rabundfile + string current = ""; + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp index d0f925e..bdfbeae 100644 --- a/splitabundcommand.cpp +++ b/splitabundcommand.cpp @@ -332,6 +332,33 @@ int SplitAbundCommand::execute(){ if (fastafile != "") { parseFasta(tag); } } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("accnos"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/splitgroupscommand.cpp b/splitgroupscommand.cpp index d389d89..16d90a4 100644 --- a/splitgroupscommand.cpp +++ b/splitgroupscommand.cpp @@ -184,6 +184,17 @@ int SplitGroupCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 223c9f5..d24bcc5 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -295,7 +295,44 @@ int SubSampleCommand::execute(){ if (fastafile != "") { getSubSampleFasta(); } if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); return 0; } } - + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("name"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } + } + + itTypes = outputTypes.find("group"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } + } + + itTypes = outputTypes.find("list"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } + } + + itTypes = outputTypes.find("shared"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } + } + + itTypes = outputTypes.find("rabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); } + } + + itTypes = outputTypes.find("sabund"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); } + } + + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index a31c151..07999f6 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -476,7 +476,14 @@ int TreeGroupCommand::execute(){ } //reset groups parameter - globaldata->Groups.clear(); + globaldata->Groups.clear(); + + //set tree file as new current treefile + string current = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); } + } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index 6592651..bf80ee8 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -330,6 +330,13 @@ int TrimFlowsCommand::execute(){ outputTypes["flow.files"].push_back(flowFilesFileName); outputNames.push_back(flowFileName); + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 49aca82..0e0ed58 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -405,7 +405,7 @@ int TrimSeqsCommand::execute(){ //output group counts m->mothurOutEndLine(); - int total = 0; + //int total = 0; // for (int i = 0; i < barcodeNameVector.size(); i++) { // if ((barcodeNameVector[i] != "") && (groupCounts[i] != 0)) { total += groupCounts[i]; m->mothurOut("Group " + barcodeNameVector[i] + " contains " + toString(groupCounts[i]) + " sequences."); m->mothurOutEndLine(); } // } @@ -413,6 +413,23 @@ int TrimSeqsCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + //set fasta file as new current fastafile + string current = ""; + itTypes = outputTypes.find("fasta"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } + } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(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(); } diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 2e90626..5c0d583 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -307,6 +307,19 @@ int UnifracUnweightedCommand::execute() { m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.unweighted."); m->mothurOutEndLine(); + //set phylip file as new current phylipfile + string current = ""; + itTypes = outputTypes.find("phylip"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); } + } + + //set column file as new current columnfile + itTypes = outputTypes.find("column"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); } + } + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 0ccdf2f..d521200 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -318,6 +318,19 @@ int UnifracWeightedCommand::execute() { m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.weighted."); m->mothurOutEndLine(); + //set phylip file as new current phylipfile + string current = ""; + itTypes = outputTypes.find("phylip"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); } + } + + //set column file as new current columnfile + itTypes = outputTypes.find("column"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(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