]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug in phylo.diversity rooting. added filename patterns and create filename...
authorSarah Westcott <mothur.westcott@gmail.com>
Thu, 13 Dec 2012 21:33:31 +0000 (16:33 -0500)
committerSarah Westcott <mothur.westcott@gmail.com>
Thu, 13 Dec 2012 21:33:31 +0000 (16:33 -0500)
259 files changed:
aligncommand.cpp
aligncommand.h
amovacommand.cpp
amovacommand.h
anosimcommand.cpp
anosimcommand.h
binsequencecommand.cpp
binsequencecommand.h
catchallcommand.cpp
catchallcommand.h
chimerabellerophoncommand.cpp
chimerabellerophoncommand.h
chimeraccodecommand.cpp
chimeraccodecommand.h
chimeracheckcommand.cpp
chimeracheckcommand.h
chimeraperseuscommand.cpp
chimeraperseuscommand.h
chimerapintailcommand.cpp
chimerapintailcommand.h
chimeraslayercommand.cpp
chimeraslayercommand.h
chimerauchimecommand.cpp
chimerauchimecommand.h
chopseqscommand.cpp
chopseqscommand.h
classifyotucommand.cpp
classifyotucommand.h
classifyseqscommand.cpp
classifyseqscommand.h
classifysharedcommand.cpp
classifysharedcommand.h
classifytreecommand.cpp
classifytreecommand.h
clearcutcommand.cpp
clearcutcommand.h
clearmemorycommand.cpp
clearmemorycommand.h
clustercommand.cpp
clustercommand.h
clusterdoturcommand.cpp
clusterdoturcommand.h
clusterfragmentscommand.cpp
clusterfragmentscommand.h
clustersplitcommand.cpp
clustersplitcommand.h
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
collectsharedcommand.h
command.hpp
commandparameter.h
consensusseqscommand.cpp
consensusseqscommand.h
cooccurrencecommand.cpp
cooccurrencecommand.h
corraxescommand.cpp
corraxescommand.h
countgroupscommand.cpp
countgroupscommand.h
countseqscommand.cpp
countseqscommand.h
createdatabasecommand.cpp
createdatabasecommand.h
deconvolutecommand.cpp
deconvolutecommand.h
degapseqscommand.cpp
degapseqscommand.h
deuniqueseqscommand.cpp
deuniqueseqscommand.h
deuniquetreecommand.cpp
deuniquetreecommand.h
distancecommand.cpp
distancecommand.h
filterseqscommand.cpp
filterseqscommand.h
getcommandinfocommand.cpp
getcommandinfocommand.h
getcoremicrobiomecommand.cpp
getcoremicrobiomecommand.h
getcurrentcommand.cpp
getcurrentcommand.h
getgroupcommand.cpp
getgroupcommand.h
getgroupscommand.cpp
getgroupscommand.h
getlabelcommand.cpp
getlabelcommand.h
getlineagecommand.cpp
getlineagecommand.h
getlistcountcommand.cpp
getlistcountcommand.h
getotulabelscommand.cpp
getotulabelscommand.h
getoturepcommand.cpp
getoturepcommand.h
getotuscommand.cpp
getotuscommand.h
getrabundcommand.cpp
getrabundcommand.h
getrelabundcommand.cpp
getrelabundcommand.h
getsabundcommand.cpp
getsabundcommand.h
getseqscommand.cpp
getseqscommand.h
getsharedotucommand.cpp
getsharedotucommand.h
hclustercommand.cpp
hclustercommand.h
heatmapcommand.cpp
heatmapcommand.h
heatmapsimcommand.cpp
heatmapsimcommand.h
helpcommand.h
homovacommand.cpp
homovacommand.h
indicatorcommand.cpp
indicatorcommand.h
libshuffcommand.cpp
libshuffcommand.h
listotulabelscommand.cpp
listotulabelscommand.h
listseqscommand.cpp
listseqscommand.h
loadlogfilecommand.cpp
loadlogfilecommand.h
makebiomcommand.cpp
makebiomcommand.h
makecontigscommand.cpp
makecontigscommand.h
makefastqcommand.cpp
makefastqcommand.h
makegroupcommand.cpp
makegroupcommand.h
mantelcommand.cpp
mantelcommand.h
matrixoutputcommand.cpp
matrixoutputcommand.h
mergefilecommand.cpp
mergefilecommand.h
mergegroupscommand.cpp
mergegroupscommand.h
metastatscommand.cpp
metastatscommand.h
mgclustercommand.cpp
mgclustercommand.h
newcommandtemplate.cpp
newcommandtemplate.h
nmdscommand.cpp
nmdscommand.h
nocommands.h
normalizesharedcommand.cpp
normalizesharedcommand.h
otuassociationcommand.cpp
otuassociationcommand.h
otuhierarchycommand.cpp
otuhierarchycommand.h
pairwiseseqscommand.cpp
pairwiseseqscommand.h
parsefastaqcommand.cpp
parsefastaqcommand.h
parselistscommand.cpp
parselistscommand.h
parsimonycommand.cpp
parsimonycommand.h
pcacommand.cpp
pcacommand.h
pcoacommand.cpp
pcoacommand.h
pcrseqscommand.h
phylodiversitycommand.cpp
phylodiversitycommand.h
phylotypecommand.cpp
phylotypecommand.h
pipelinepdscommand.cpp
pipelinepdscommand.h
prcseqscommand.cpp
preclustercommand.cpp
preclustercommand.h
quitcommand.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h
readtree.cpp
removegroupscommand.cpp
removegroupscommand.h
removelineagecommand.cpp
removelineagecommand.h
removeotulabelscommand.cpp
removeotulabelscommand.h
removeotuscommand.cpp
removeotuscommand.h
removerarecommand.cpp
removerarecommand.h
removeseqscommand.cpp
removeseqscommand.h
reversecommand.cpp
reversecommand.h
screenseqscommand.cpp
screenseqscommand.h
secondarystructurecommand.cpp
secondarystructurecommand.h
sensspeccommand.cpp
sensspeccommand.h
seqerrorcommand.cpp
seqerrorcommand.h
seqsummarycommand.cpp
seqsummarycommand.h
setcurrentcommand.cpp
setcurrentcommand.h
setdircommand.cpp
setdircommand.h
setlogfilecommand.cpp
setlogfilecommand.h
sffinfocommand.cpp
sffinfocommand.h
sffmultiplecommand.cpp
sffmultiplecommand.h
sharedcommand.cpp
sharedcommand.h
shhhercommand.cpp
shhhercommand.h
shhhseqscommand.cpp
shhhseqscommand.h
sortseqscommand.cpp
sortseqscommand.h
splitabundcommand.cpp
splitabundcommand.h
splitgroupscommand.cpp
splitgroupscommand.h
splitmatrix.cpp
subsample.cpp
subsamplecommand.cpp
subsamplecommand.h
summarycommand.cpp
summarycommand.h
summaryqualcommand.cpp
summaryqualcommand.h
summarysharedcommand.cpp
summarysharedcommand.h
summarytaxcommand.cpp
summarytaxcommand.h
systemcommand.cpp
systemcommand.h
tree.cpp
treegroupscommand.cpp
treegroupscommand.h
trimflowscommand.cpp
trimflowscommand.h
trimseqscommand.cpp
trimseqscommand.h
unifracunweightedcommand.cpp
unifracunweightedcommand.h
unifracweightedcommand.cpp
unifracweightedcommand.h
venncommand.cpp
venncommand.h

index efc8ce489e79ac5e1d17084f5e952b39590894ba..9d4a609963316d31bcf0740649b88f4b798747ba 100644 (file)
 //**********************************************************************************************************************
 vector<string> AlignCommand::setParameters(){  
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pcandidate("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pcandidate);
-               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix", "kmer", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pksize("ksize", "Number", "", "8", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "",false,false); parameters.push_back(palign);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               CommandParameter pthreshold("threshold", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pcandidate("fasta", "InputTypes", "", "", "none", "none", "none","fasta-alignreport-accnos",false,true,true); parameters.push_back(pcandidate);
+               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix", "kmer", "", "", "","",false,false,true); parameters.push_back(psearch);
+               CommandParameter pksize("ksize", "Number", "", "8", "", "", "","",false,false); parameters.push_back(pksize);
+               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pmatch);
+               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "","",false,false,true); parameters.push_back(palign);
+               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pmismatch);
+               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "","",false,false); parameters.push_back(pgapopen);
+               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pgapextend);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pflip);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
+               CommandParameter pthreshold("threshold", "Number", "", "0.50", "", "", "","",false,false); parameters.push_back(pthreshold);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -76,28 +76,22 @@ string AlignCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string AlignCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string tag = "";
-               map<string, vector<string> >::iterator it;
+string AlignCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  tag = "align"; }
-            else if (type == "alignreport") {  tag = "align.report"; }
-            else if (type == "accnos") {  tag = "flip.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return tag;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "getOutputFileName");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],align"; } //makes file like: amazon.align
+        else if (type == "alignreport") {  pattern = "[filename],align.report"; }
+        else if (type == "accnos") {  pattern = "[filename],flip.accnos"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "AlignCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 AlignCommand::AlignCommand(){  
        try {
@@ -328,9 +322,11 @@ int AlignCommand::execute(){
                        m->mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); m->mothurOutEndLine();
                        
                        if (outputDir == "") {  outputDir += m->hasPath(candidateFileNames[s]); }
-                       string alignFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + getOutputFileNameTag("fasta");  
-                       string reportFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + getOutputFileNameTag("alignreport");
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + getOutputFileNameTag("accnos");
+            map<string, string> variables; variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s]));
+                       string alignFileName = getOutputFileName("fasta", variables);  
+                       string reportFileName = getOutputFileName("alignreport", variables);
+                       string accnosFileName = getOutputFileName("accnos", variables);
+            
                        bool hasAccnos = true;
                        
                        int numFastaSeqs = 0;
index 5432d00564b2151fabaf09e9d16258dff0d298ae..cfded3819156764fc86e49e9cb1977af9bb2ef48 100644 (file)
@@ -34,8 +34,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "align.seqs";                  }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "DeSantis TZ, Jr., Hugenholtz P, Keller K, Brodie EL, Larsen N, Piceno YM, Phan R, Andersen GL (2006). NAST: a multiple sequence alignment server for comparative analysis of 16S rRNA genes. Nucleic Acids Res 34: W394-9.\nSchloss PD (2009). A high-throughput DNA sequence aligner for microbial ecology studies. PLoS ONE 4: e8230.\nSchloss PD (2010). The effects of alignment quality, distance calculation method, sequence filtering, and region on the analysis of 16S rRNA gene-based studies. PLoS Comput Biol 6: e1000844.\nhttp://www.mothur.org/wiki/Align.seqs http://www.mothur.org/wiki/Align.seqs"; }
        string getDescription()         { return "align sequences"; }
        
index f36027f9acb625ab9c02e906a90d5716aa66aa58..a78aafcbd92a344420c29598f6cac4456404a890 100644 (file)
 //**********************************************************************************************************************
 vector<string> AmovaCommand::setParameters(){  
        try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-        CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","amova",false,true,true); parameters.push_back(pdesign);
+        CommandParameter psets("sets", "String", "", "", "", "", "","",false,false); parameters.push_back(psets);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","amova",false,true,true); parameters.push_back(pphylip);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "","",false,false); parameters.push_back(palpha);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,24 +54,19 @@ string AmovaCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string AmovaCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string tag = "";
-               map<string, vector<string> >::iterator it;
+string AmovaCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "amova") {  tag = "amova"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file.\n");  }
-        }
-        return tag;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "amova") {  pattern = "[filename],amova"; } //makes file like: amazon.align
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "AmovaCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 AmovaCommand::AmovaCommand(){  
@@ -241,7 +236,9 @@ int AmovaCommand::execute(){
                
                //create a new filename
                ofstream AMOVAFile;
-               string AMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("amova");                            
+        map<string, string> variables; variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipFileName));
+               string AMOVAFileName = getOutputFileName("amova", variables);   
+        
                m->openOutputFile(AMOVAFileName, AMOVAFile);
                outputNames.push_back(AMOVAFileName); outputTypes["amova"].push_back(AMOVAFileName);
                
index 17dbae650912c5f4c21e0c8924dce3a676cc4fda..98d19ddfc249d550c5d6d5b7c33cf036642393a0 100644 (file)
@@ -23,9 +23,10 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "amova";                                       }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
-       string getCitation() { return "Anderson MJ (2001). A new method for non-parametric multivariate analysis of variance. Austral Ecol 26: 32-46.\nhttp://www.mothur.org/wiki/Amova"; }
+    string getOutputPattern(string);   
+    string getCitation() { return "Anderson MJ (2001). A new method for non-parametric multivariate analysis of variance. Austral Ecol 26: 32-46.\nhttp://www.mothur.org/wiki/Amova"; }
        string getDescription()         { return "analysis of molecular variance"; }
        
        int execute();
index bd4e6b0683886bd0012e6b222a12592c8e594107..2a688f59b72c4ba9779ea921149254b3e554b788 100644 (file)
 //**********************************************************************************************************************
 vector<string> AnosimCommand::setParameters(){ 
        try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","anosim",false,true,true); parameters.push_back(pdesign);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","anosim",false,true,true); parameters.push_back(pphylip);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "","",false,false); parameters.push_back(palpha);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -50,24 +50,19 @@ string AnosimCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string AnosimCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string AnosimCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "anosim") {  outputFileName =  "anosim"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "anosim") {  pattern = "[filename],anosim"; } //makes file like: amazon.align
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "AnosimCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 AnosimCommand::AnosimCommand(){        
@@ -207,7 +202,9 @@ int AnosimCommand::execute(){
                
                //create a new filename
                ofstream ANOSIMFile;
-               string ANOSIMFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("anosim");                          
+        map<string, string> variables; variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipFileName));
+               string ANOSIMFileName = getOutputFileName("anosim", variables); 
+        
                m->openOutputFile(ANOSIMFileName, ANOSIMFile);
                outputNames.push_back(ANOSIMFileName); outputTypes["anosim"].push_back(ANOSIMFileName);
                m->mothurOut("\ncomparison\tR-value\tP-value\n");
index ff1b683fac8a45e4146789f7c09a0503c0c39392..6e5aba0e65980914e6c25e6e0e55fadc4b0136b9 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "anosim";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Clarke, K. R. (1993). Non-parametric multivariate analysis of changes in community structure. _Australian Journal of Ecology_ 18, 117-143.\nhttp://www.mothur.org/wiki/Anosim"; }
        string getDescription()         { return "analysis of similarity"; }
        
index ad71d1065fb32904b365a7cd2be46a28718a7d98..7798a4d74f749eed04d4554c796776a58697b98b 100644 (file)
 //**********************************************************************************************************************
 vector<string> BinSeqCommand::setParameters(){ 
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(plist);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -51,24 +51,19 @@ string BinSeqCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string BinSeqCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string BinSeqCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "fasta"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],[distance],fasta"; } //makes file like: amazon.0.03.fasta
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "BinSeqCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 BinSeqCommand::BinSeqCommand(){        
@@ -333,6 +328,13 @@ int BinSeqCommand::execute(){
                if (groupfile != "") {  delete groupMap;   } 
                
                if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);                }  return 0; }  
+        
+        //set align file as new current fastafile
+               string currentFasta = "";
+               itTypes = outputTypes.find("fasta");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { currentFasta = (itTypes->second)[0]; m->setFastaFile(currentFasta); }
+               }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -385,7 +387,11 @@ void BinSeqCommand::readNamesFile() {
 //return 1 if error, 0 otherwise
 int BinSeqCommand::process(ListVector* list) {
        try {
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + "." + getOutputFileNameTag("fasta");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[distance]"] = list->getLabel();
+        string outputFileName = getOutputFileName("fasta", variables);
+        
         m->openOutputFile(outputFileName, out);
         outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
         
index 5bdd401f9411e4abb21aa6a12284bfa98f4b5bda..c93041f348505d7482e9a18d2658d29919eae309 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "bin.seqs";                    }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Bin.seqs"; }
        string getDescription()         { return "maps sequences to otus"; }
        
index 1cfd4154686cd4884e275f4c3ea8c8ca3d5624d3..584f798d30d51155b439064bbf2fafb1b693ad64 100644 (file)
 //**********************************************************************************************************************
 vector<string> CatchAllCommand::setParameters(){       
        try {
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
                //can choose shared or sabund not both, so put them in the same chooseOnlyOneGroup
-               CommandParameter pshared("shared", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none",false,false); parameters.push_back(pshared);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none","analysis-bestanalysis-models-bubble-summary",false,false,true); parameters.push_back(pshared);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none","analysis-bestanalysis-models-bubble-summary",false,false,true); parameters.push_back(psabund);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -49,25 +49,24 @@ string CatchAllCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CatchAllCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CatchAllCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "csv") {  outputFileName =  "csv"; }
-            else if (type == "summary") {  outputFileName =  "catchall.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "analysis") {  pattern = "[filename],_Analysis.csv"; } 
+        else if (type == "bestanalysis") {  pattern = "[filename],_BestModelsAnalysis.csv"; }
+        else if (type == "models") {  pattern = "[filename],_BestModelsAnalysis.csv"; }
+        else if (type == "bubble") {  pattern = "[filename],_BubblePlot.csv"; }
+        else if (type == "summary") {  pattern =  "[filename],catchall.summary"; }
+        else if (type == "sabund") {  pattern =  "[filename],[distance],csv"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CatchAllCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 CatchAllCommand::CatchAllCommand(){    
@@ -76,7 +75,10 @@ CatchAllCommand::CatchAllCommand(){
                setParameters();
                //initialize outputTypes
                vector<string> tempOutNames;
-               outputTypes["csv"] = tempOutNames;
+               outputTypes["analysis"] = tempOutNames;
+               outputTypes["bestanalysis"] = tempOutNames;
+        outputTypes["models"] = tempOutNames;
+               outputTypes["bubble"] = tempOutNames;
                outputTypes["summary"] = tempOutNames;
        }
        catch(exception& e) {
@@ -111,8 +113,12 @@ CatchAllCommand::CatchAllCommand(string option)  {
                        
                        //initialize outputTypes
                        vector<string> tempOutNames;
-                       outputTypes["csv"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
+                       outputTypes["analysis"] = tempOutNames;
+            outputTypes["bestanalysis"] = tempOutNames;
+            outputTypes["models"] = tempOutNames;
+            outputTypes["bubble"] = tempOutNames;
+            outputTypes["summary"] = 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);              
@@ -257,7 +263,9 @@ int CatchAllCommand::execute() {
                        set<string> processedLabels;
                        set<string> userLabels = labels;
                        
-                       string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + getOutputFileNameTag("summary");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
+                       string summaryfilename = getOutputFileName("summary", variables);
                        summaryfilename = m->getFullPathName(summaryfilename);
                        
             if (m->debug) { m->mothurOut("[DEBUG]: Input File = " + inputFileNames[p] + ".\n[DEBUG]: inputdata address = " + toString(&input) + ".\n[DEBUG]: sabund address = " + toString(&sabund) + ".\n"); } 
@@ -285,10 +293,18 @@ int CatchAllCommand::execute() {
                                                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                                #else
-                                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
-                                                       //wrap entire string in ""
-                                                       catchAllCommand = "\"" + catchAllCommand + "\"";
+                            //removes extra '\\' catchall doesnt like that
+                            vector<string> tempNames;
+                            string tempFilename = filename;
+                            m->splitAtDash(tempFilename, tempNames);
+                            tempFilename = tempNames[0];
+                            tempNames.clear();
+                            string tempOutputPath = outputPath;
+                            m->splitAtDash(tempOutputPath, tempNames);
+                            tempOutputPath = tempNames[0];
+                            if (tempOutputPath.length() > 0) { tempOutputPath = tempOutputPath.substr(0, tempOutputPath.length()-1); }
+                            catchAllCommand += catchAllCommandExe + "\"" + tempFilename + "\" \""  + tempOutputPath + "\" 1";
+                            catchAllCommand = "\"" + catchAllCommand + "\"";
                                                #endif
                         
                         if (m->debug) {  m->mothurOut("[DEBUG]: catchall command = " + catchAllCommand + ". About to call system.\n"); }
@@ -304,10 +320,11 @@ int CatchAllCommand::execute() {
                                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
                                        
-                                               outputNames.push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv"));
-                                               outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv"));
-                                               outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv"));
-                                               outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv"));
+                        variables["[filename]"] = filename;
+                                               outputNames.push_back(getOutputFileName("analysis", variables)); outputTypes["analysis"].push_back(getOutputFileName("analysis", variables));
+                                               outputNames.push_back(getOutputFileName("bestanalysis", variables)); outputTypes["bestanalysis"].push_back(getOutputFileName("bestanalysis", variables));
+                        outputNames.push_back(getOutputFileName("models", variables)); outputTypes["models"].push_back(getOutputFileName("models", variables));
+                        outputNames.push_back(getOutputFileName("bubble", variables)); outputTypes["bubble"].push_back(getOutputFileName("bubble", variables));
                         
                         if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); }
                     
@@ -339,8 +356,17 @@ int CatchAllCommand::execute() {
                                                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                                #else
-                                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
+                            //removes extra '\\' catchall doesnt like that
+                            vector<string> tempNames;
+                            string tempFilename = filename;
+                            m->splitAtDash(tempFilename, tempNames);
+                            tempFilename = tempNames[0];
+                            tempNames.clear();
+                            string tempOutputPath = outputPath;
+                            m->splitAtDash(tempOutputPath, tempNames);
+                            tempOutputPath = tempNames[0];
+                                                       if (tempOutputPath.length() > 0) { tempOutputPath = tempOutputPath.substr(0, tempOutputPath.length()-1); }
+                                                       catchAllCommand += catchAllCommandExe + "\"" + tempFilename + "\" \""  + tempOutputPath + "\" 1";
                                                        catchAllCommand = "\"" + catchAllCommand + "\"";
                                                #endif
                         
@@ -357,10 +383,11 @@ int CatchAllCommand::execute() {
                                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
                                        
-                        outputNames.push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv"));
-                        outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv"));
-                        outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv"));
-                        outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv"));
+                        variables["[filename]"] = filename;
+                        outputNames.push_back(getOutputFileName("analysis", variables)); outputTypes["analysis"].push_back(getOutputFileName("analysis", variables));
+                        outputNames.push_back(getOutputFileName("bestanalysis", variables)); outputTypes["bestanalysis"].push_back(getOutputFileName("bestanalysis", variables));
+                        outputNames.push_back(getOutputFileName("models", variables)); outputTypes["models"].push_back(getOutputFileName("models", variables));
+                        outputNames.push_back(getOutputFileName("bubble", variables)); outputTypes["bubble"].push_back(getOutputFileName("bubble", variables));
                         
                     
                         if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); }
@@ -414,9 +441,18 @@ int CatchAllCommand::execute() {
                                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                #else
-                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
-                                       catchAllCommand = "\"" + catchAllCommand + "\"";
+                    //removes extra '\\' catchall doesnt like that
+                    vector<string> tempNames;
+                    string tempFilename = filename;
+                    m->splitAtDash(tempFilename, tempNames);
+                    tempFilename = tempNames[0];
+                    tempNames.clear();
+                    string tempOutputPath = outputPath;
+                    m->splitAtDash(tempOutputPath, tempNames);
+                    tempOutputPath = tempNames[0];
+                    if (tempOutputPath.length() > 0) { tempOutputPath = tempOutputPath.substr(0, tempOutputPath.length()-1); }
+                    catchAllCommand += catchAllCommandExe + "\"" + tempFilename + "\" \""  + tempOutputPath + "\" 1";
+                    catchAllCommand = "\"" + catchAllCommand + "\"";
                                #endif
                 
                 if (m->debug) {  m->mothurOut("[DEBUG]: catchall command = " + catchAllCommand + ". About to call system.\n"); }
@@ -431,10 +467,12 @@ int CatchAllCommand::execute() {
                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
                                
-                               outputNames.push_back(filename + "_Analysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_Analysis." + getOutputFileNameTag("csv"));
-                outputNames.push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis." + getOutputFileNameTag("csv"));
-                outputNames.push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BestModelsFits." + getOutputFileNameTag("csv"));
-                outputNames.push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv")); outputTypes["csv"].push_back(filename + "_BubblePlot." + getOutputFileNameTag("csv"));                         if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); }
+                               variables["[filename]"] = filename;
+                outputNames.push_back(getOutputFileName("analysis", variables)); outputTypes["analysis"].push_back(getOutputFileName("analysis", variables));
+                outputNames.push_back(getOutputFileName("bestanalysis", variables)); outputTypes["bestanalysis"].push_back(getOutputFileName("bestanalysis", variables));
+                outputNames.push_back(getOutputFileName("models", variables)); outputTypes["models"].push_back(getOutputFileName("models", variables));
+                outputNames.push_back(getOutputFileName("bubble", variables)); outputTypes["bubble"].push_back(getOutputFileName("bubble", variables));
+                if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); }
                 
                                createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
                 
@@ -478,7 +516,10 @@ int CatchAllCommand::execute() {
 //**********************************************************************************************************************
 string CatchAllCommand::process(SAbundVector* sabund, string file1) {
        try {
-               string filename = outputDir + m->getRootName(m->getSimpleName(file1)) + sabund->getLabel() + ".csv";
+        map<string, string> variables;
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(file1));
+        variables["[distance]"] = sabund->getLabel();
+        string filename = getOutputFileName("sabund", variables);
                filename = m->getFullPathName(filename);
        
                ofstream out;
@@ -511,7 +552,9 @@ string CatchAllCommand::combineSummmary(vector<string>& outputNames) {
        try {
                
                ofstream out;
-               string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
+        map<string, string> variables;
+        variables["[filename]"] = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        string combineFileName = getOutputFileName("summary", variables);
                
                //open combined file
                m->openOutputFile(combineFileName, out);
index 44ed3ef162b0a82465c1662f2f19e73d43468f86..32be8b63d2ce751391ae5ebbc6154be221b77c9d 100644 (file)
@@ -31,8 +31,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "catchall";                    }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Bunge J, Woodard L, Bohning D, Foster JA, Connolly S, Allen HK (2012). Estimating population diversity with CatchAll. Bioinformatics  28:1045.\nhttp://www.northeastern.edu/catchall/index.html\nhttp://www.mothur.org/wiki/Catchall"; }
        string getDescription()         { return "estimate number of species"; }
        
index 82400112bc8770ca2ded637853028d86e6aede99..bb119e41c8e5b40dd681793c43c10f4c6f7e6c61 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraBellerophonCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none","none","none",false,true); parameters.push_back(pfasta);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pcorrection("correction", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcorrection);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pincrement("increment", "Number", "", "25", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none","none","none","chimera-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfilter);
+               CommandParameter pcorrection("correction", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pcorrection);
+               CommandParameter pwindow("window", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pwindow);
+               CommandParameter pincrement("increment", "Number", "", "25", "", "", "","",false,false); parameters.push_back(pincrement);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -57,25 +57,20 @@ string ChimeraBellerophonCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraBellerophonCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraBellerophonCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "bellerophon.chimeras"; }
-            else if (type == "accnos") {  outputFileName =  "bellerophon.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],bellerophon.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],bellerophon.accnos"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraBellerophonCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraBellerophonCommand::ChimeraBellerophonCommand(){        
@@ -242,9 +237,11 @@ int ChimeraBellerophonCommand::execute(){
                        
                        chimera = new Bellerophon(fastaFileNames[i], filter, correction, window, increment, processors, outputDir);     
                        
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[i]);  }//if user entered a file with a path then preserve it               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) +  getOutputFileNameTag("chimera");
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) +  getOutputFileNameTag("accnos");
+                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[i]);  }//if user entered a file with a path then preserve it       
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i]));
+                       string outputFileName = getOutputFileName("chimera", variables);
+                       string accnosFileName = getOutputFileName("accnos", variables);
                        
                        chimera->getChimeras();
                        
index 015f2b78a6d412deda2dc639b4c7a2b3b055ec17..23e555d6914482d9a2c819b079715d1a178d0f53 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.bellerophon"; }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Huber T, Faulkner G, Hugenholtz P (2004). Bellerophon: a program to detect chimeric sequences in multiple sequence alignments. Bioinformatics 20: 2317-9. \nhttp://www.mothur.org/wiki/Chimera.bellerophon"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index 942635ea183cedee17550fd85df3c3daa68d9979..7adf82814ee5447edef7e203bbb046ad61c51b07 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraCcodeCommand::setParameters(){   
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pnumwanted("numwanted", "Number", "", "20", "", "", "",false,false); parameters.push_back(pnumwanted);
-               CommandParameter pmask("mask", "String", "", "", "", "", "",false,false); parameters.push_back(pmask);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-mapinfo-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfilter);
+               CommandParameter pwindow("window", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pwindow);
+               CommandParameter pnumwanted("numwanted", "Number", "", "20", "", "", "","",false,false); parameters.push_back(pnumwanted);
+               CommandParameter pmask("mask", "String", "", "", "", "", "","",false,false); parameters.push_back(pmask);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -64,26 +64,21 @@ string ChimeraCcodeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraCcodeCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraCcodeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "ccode.chimeras"; }
-            else if (type == "mapinfo") {  outputFileName =  "mapinfo"; }
-            else if (type == "accnos") {  outputFileName =  "ccode.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],[tag],ccode.chimeras-[filename],ccode.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],[tag],ccode.accnos-[filename],ccode.accnos"; } 
+        else if (type == "mapinfo") {  pattern =  "[filename],mapinfo"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraCcodeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraCcodeCommand::ChimeraCcodeCommand(){    
@@ -94,6 +89,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(){
                outputTypes["chimera"] = tempOutNames;
                outputTypes["mapinfo"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
+        
        }
        catch(exception& e) {
                m->errorOut(e, "ChimeraCcodeCommand", "ChimeraCcodeCommand");
@@ -128,6 +124,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
                        outputTypes["chimera"] = tempOutNames;
                        outputTypes["mapinfo"] = tempOutNames;
                        outputTypes["accnos"] = 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);              
@@ -305,18 +302,13 @@ int ChimeraCcodeCommand::execute(){
                        
                        if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it
                        string outputFileName, accnosFileName;
-                       if (maskfile != "") {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + getOutputFileNameTag("chimera");
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + getOutputFileNameTag("accnos");
-                       }else {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + getOutputFileNameTag("chimera");
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + getOutputFileNameTag("accnos");
-
-                       }
-
-                       string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("mapinfo");
-
-                       
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+            string mapInfo = getOutputFileName("mapinfo", variables);
+                       if (maskfile != "") { variables["[tag]"] = maskfile; }
+            outputFileName = getOutputFileName("chimera", variables);
+            accnosFileName = getOutputFileName("accnos", variables);
+                                               
                        if (m->control_pressed) { delete chimera;  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } outputTypes.clear(); return 0;        }
                        
                #ifdef USE_MPI
index 408e2feb05f541cd46945c231df7b70f8dea276e..52bf07d01f6a411b870e119f82ef97f7b6f45cbd 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.ccode";               }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Gonzalez JM, Zimmermann J, Saiz-Jimenez C (2005). Evaluating putative chimeric sequences from PCR-amplified products. Bioinformatics 21: 333-7. \nhttp://www.mothur.org/wiki/Chimera.ccode"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index 6a4732cf72cd4222e539beb93c6b0b45226d2a08..6caa606dc10ee387cd2eb829d264a7d17f0ee670 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraCheckCommand::setParameters(){   
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter psvg("svg", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psvg);
-               CommandParameter pincrement("increment", "Number", "", "10", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pksize("ksize", "Number", "", "7", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(pname);
+               CommandParameter psvg("svg", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psvg);
+               CommandParameter pincrement("increment", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pincrement);
+               CommandParameter pksize("ksize", "Number", "", "7", "", "", "","",false,false); parameters.push_back(pksize);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,24 +65,19 @@ string ChimeraCheckCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraCheckCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraCheckCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "chimeracheck.chimeras"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],chimeracheck.chimeras"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraCheckCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraCheckCommand::ChimeraCheckCommand(){    
@@ -362,7 +357,9 @@ int ChimeraCheckCommand::execute(){
                        if (m->control_pressed) { delete chimera;       return 0;       }
                        
                        if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[i]);  }//if user entered a file with a path then preserve it
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + getOutputFileNameTag("chimera");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i]));
+                       string outputFileName = getOutputFileName("chimera", variables);
                        outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
                        
                #ifdef USE_MPI
index 61129cd618264c62322ccfe8a0a2107140170358..8981a14ff5e6e7813ab54123fe3fa1c8b68a0bc4 100644 (file)
@@ -27,8 +27,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.check";               }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "CHIMERA_CHECK version 2.7 written by Niels Larsen (http://wdcm.nig.ac.jp/RDP/docs/chimera_doc.html) \nhttp://www.mothur.org/wiki/Chimera.check"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index 7ae5d69141979736bcb2b6fcfb25e1ba4682086d..e1ad14ecccda1e5208d03809db7539a12f4a2904 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraPerseusCommand::setParameters(){ 
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "NameCount", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "NameCount", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter palpha("alpha", "Number", "", "-5.54", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pbeta("beta", "Number", "", "0.33", "", "", "",false,false); parameters.push_back(pbeta);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "NameCount", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "NameCount", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter pcutoff("cutoff", "Number", "", "0.5", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter palpha("alpha", "Number", "", "-5.54", "", "", "","",false,false); parameters.push_back(palpha);
+               CommandParameter pbeta("beta", "Number", "", "0.33", "", "", "","",false,false); parameters.push_back(pbeta);
                        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -62,25 +62,20 @@ string ChimeraPerseusCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraPerseusCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraPerseusCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "perseus.chimeras"; }
-            else if (type == "accnos") {  outputFileName =  "perseus.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],perseus.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],perseus.accnos"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraPerseusCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraPerseusCommand::ChimeraPerseusCommand(){        
@@ -486,9 +481,11 @@ int ChimeraPerseusCommand::execute(){
                        m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
                        
                        int start = time(NULL); 
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
+                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it       
+                       map<string, string> variables;
+                       variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+                       string outputFileName = getOutputFileName("chimera", variables);
+                       string accnosFileName = getOutputFileName("accnos", variables);
 
                        //string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
                        
@@ -695,6 +692,7 @@ vector<seqData> ChimeraPerseusCommand::loadSequences(string group){
                 it = counts.find(thisGroupsSeqs[i].getName());
                 if (it == counts.end()) { error = true; m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your count file, please correct."); m->mothurOutEndLine(); }
                 else {
+                    thisGroupsSeqs[i].setAligned(removeNs(thisGroupsSeqs[i].getUnaligned()));
                     sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), it->second));
                     if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
                 }
@@ -712,6 +710,7 @@ vector<seqData> ChimeraPerseusCommand::loadSequences(string group){
                 if (it == nameMap.end()) { error = true; m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct."); m->mothurOutEndLine(); }
                 else {
                     int num = m->getNumNames(it->second);
+                    thisGroupsSeqs[i].setAligned(removeNs(thisGroupsSeqs[i].getUnaligned()));
                     sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), num));
                     if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
                 }
@@ -753,6 +752,7 @@ vector<seqData> ChimeraPerseusCommand::readFiles(string inputFile, string name){
                        it = nameMap.find(temp.getName());
                        if (it == nameMap.end()) { error = true; m->mothurOut("[ERROR]: " + temp.getName() + " is in your fasta file and not in your namefile, please correct."); m->mothurOutEndLine(); }
                        else {
+                temp.setAligned(removeNs(temp.getUnaligned()));
                                sequences.push_back(seqData(temp.getName(), temp.getUnaligned(), it->second));
                 if (temp.getUnaligned().length() > alignLength) { alignLength = temp.getUnaligned().length(); }
                        }
@@ -772,6 +772,20 @@ vector<seqData> ChimeraPerseusCommand::readFiles(string inputFile, string name){
        }
 }
 //**********************************************************************************************************************
+string ChimeraPerseusCommand::removeNs(string seq){
+       try {
+        string newSeq = "";
+        for (int i = 0; i < seq.length(); i++) {
+            if (seq[i] != 'N') {  newSeq += seq[i]; }
+        }
+        return newSeq;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraPerseusCommand", "removeNs");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 vector<seqData> ChimeraPerseusCommand::readFiles(string inputFile, CountTable* ct){
        try {           
                //read fasta file and create sequenceData structure - checking for file mismatches
@@ -786,6 +800,7 @@ vector<seqData> ChimeraPerseusCommand::readFiles(string inputFile, CountTable* c
                        int count = ct->getNumSeqs(temp.getName());
                        if (m->control_pressed) { break; }
                        else {
+                temp.setAligned(removeNs(temp.getUnaligned()));
                                sequences.push_back(seqData(temp.getName(), temp.getUnaligned(), count));
                 if (temp.getUnaligned().length() > alignLength) { alignLength = temp.getUnaligned().length(); }
                        }
index e2855d019ff984d9ac026a2554860c5b3aa33f42..fdece95e5c90b528c7fcc3d476a53f28d4ea7b3b 100644 (file)
@@ -30,8 +30,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.perseus";             }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Quince C, Lanzen A, Davenport RJ, Turnbaugh PJ (2011).  Removing noise from pyrosequenced amplicons.  BMC Bioinformatics  12:38.\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection.  Bioinformatics 27:2194.\nhttp://www.mothur.org/wiki/Chimera.perseus\n"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
@@ -65,6 +66,7 @@ private:
        int deconvoluteResults(map<string, string>&, string, string);
        int driverGroups(string, string, int, int, vector<string>);
        int createProcessesGroups(string, string, vector<string>, string, string, string);
+    string removeNs(string);
 };
 
 /**************************************************************************************************/
@@ -136,11 +138,11 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
                int totalSeqs = 0;
                int numChimeras = 0;
                
-               for (int i = pDataArray->start; i < pDataArray->end; i++) {
+               for (int u = pDataArray->start; u < pDataArray->end; u++) {
                        
                        int start = time(NULL);  if (pDataArray->m->control_pressed) {  if (pDataArray->hasCount) { delete cparser; } { delete parser; } pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
                        
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group " + pDataArray->groups[i] + "...");  pDataArray->m->mothurOutEndLine();                                      
+                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group " + pDataArray->groups[u] + "...");  pDataArray->m->mothurOutEndLine();                                      
                        
                        //vector<seqData> sequences = loadSequences(parser, groups[i]); - same function below
                        ////////////////////////////////////////////////////////////////////////////////////////
@@ -148,8 +150,8 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
             int alignLength = 0;
             vector<seqData> sequences;
             if (pDataArray->hasCount) {
-                vector<Sequence> thisGroupsSeqs = cparser->getSeqs(pDataArray->groups[i]);
-                map<string, int> counts = cparser->getCountTable(pDataArray->groups[i]);
+                vector<Sequence> thisGroupsSeqs = cparser->getSeqs(pDataArray->groups[u]);
+                map<string, int> counts = cparser->getCountTable(pDataArray->groups[u]);
                 map<string, int>::iterator it;
                 
                 for (int i = 0; i < thisGroupsSeqs.size(); i++) {
@@ -159,13 +161,18 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
                     it = counts.find(thisGroupsSeqs[i].getName());
                     if (it == counts.end()) { error = true; pDataArray->m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your count file, please correct."); pDataArray->m->mothurOutEndLine(); }
                     else {
+                        string newSeq = "";
+                        string tempSeq = thisGroupsSeqs[i].getUnaligned();
+                        for (int j = 0; j < tempSeq.length(); j++) { if (tempSeq[j] != 'N') {  newSeq += tempSeq[j]; } }
+                        thisGroupsSeqs[i].setAligned(newSeq);
+                        
                         sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), it->second));
                         if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
                     }
                 }
             }else{
-                vector<Sequence> thisGroupsSeqs = parser->getSeqs(pDataArray->groups[i]);
-                map<string, string> nameMap = parser->getNameMap(pDataArray->groups[i]);
+                vector<Sequence> thisGroupsSeqs = parser->getSeqs(pDataArray->groups[u]);
+                map<string, string> nameMap = parser->getNameMap(pDataArray->groups[u]);
                 map<string, string>::iterator it;
                 
                 for (int i = 0; i < thisGroupsSeqs.size(); i++) {
@@ -176,6 +183,11 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
                     if (it == nameMap.end()) { error = true; pDataArray->m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
                     else {
                         int num = pDataArray->m->getNumNames(it->second);
+                        string newSeq = "";
+                        string tempSeq = thisGroupsSeqs[i].getUnaligned();
+                        for (int j = 0; j < tempSeq.length(); j++) { if (tempSeq[j] != 'N') {  newSeq += tempSeq[j]; } }
+                        thisGroupsSeqs[i].setAligned(newSeq);
+
                         sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), num));
                         if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
                     }
@@ -194,8 +206,8 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
                        
                        //int numSeqs = driver((outputFName + groups[i]), sequences, (accnos+groups[i]), numChimeras); - same function below
                        ////////////////////////////////////////////////////////////////////////////////////////
-                       string chimeraFileName = pDataArray->outputFName+pDataArray->groups[i];
-                       string accnosFileName = pDataArray->accnos+pDataArray->groups[i];
+                       string chimeraFileName = pDataArray->outputFName+pDataArray->groups[u];
+                       string accnosFileName = pDataArray->accnos+pDataArray->groups[u];
                        
                        vector<vector<double> > correctModel(4);        //could be an option in the future to input own model matrix
                        for(int j=0;j<4;j++){   correctModel[j].resize(4);      }
@@ -339,7 +351,7 @@ static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){
                        //append files
                        pDataArray->m->appendFiles(chimeraFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(chimeraFileName);
                        pDataArray->m->appendFiles(accnosFileName, pDataArray->accnos); pDataArray->m->mothurRemove(accnosFileName);
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->groups[i] + ".");        pDataArray->m->mothurOutEndLine();                                      
+                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->groups[u] + ".");        pDataArray->m->mothurOutEndLine();                                      
                        
                        if (pDataArray->m->control_pressed) { if (pDataArray->hasCount) { delete cparser; } { delete parser; } pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
                }       
index c5c678e78a344eed06ea0308c0df6178e7f22a51..d2b73998da9e0319880a8baf5948ed15a6132ae6 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraPintailCommand::setParameters(){ 
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pconservation("conservation", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pconservation);
-               CommandParameter pquantile("quantile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pquantile);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pincrement("increment", "Number", "", "25", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pmask("mask", "String", "", "", "", "", "",false,false); parameters.push_back(pmask);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pconservation("conservation", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pconservation);
+               CommandParameter pquantile("quantile", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pquantile);
+               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfilter);
+               CommandParameter pwindow("window", "Number", "", "0", "", "", "","","",false,false); parameters.push_back(pwindow);
+               CommandParameter pincrement("increment", "Number", "", "25", "", "", "","",false,false); parameters.push_back(pincrement);
+               CommandParameter pmask("mask", "String", "", "", "", "", "","",false,false); parameters.push_back(pmask);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -69,25 +69,20 @@ string ChimeraPintailCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraPintailCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraPintailCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "pintail.chimeras"; }
-            else if (type == "accnos") {  outputFileName =  "pintail.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],[tag],pintail.chimeras-[filename],pintail.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],[tag],pintail.accnos-[filename],pintail.accnos"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraPintailCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraPintailCommand::ChimeraPintailCommand(){        
@@ -97,6 +92,7 @@ ChimeraPintailCommand::ChimeraPintailCommand(){
                vector<string> tempOutNames;
                outputTypes["chimera"] = tempOutNames;
                outputTypes["accnos"] = tempOutNames;
+        
        }
        catch(exception& e) {
                m->errorOut(e, "ChimeraPintailCommand", "ChimeraPintailCommand");
@@ -130,6 +126,7 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                        vector<string> tempOutNames;
                        outputTypes["chimera"] = tempOutNames;
                        outputTypes["accnos"] = tempOutNames;
+        
                
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        inputDir = validParameter.validFile(parameters, "inputdir", false);             
@@ -417,13 +414,12 @@ int ChimeraPintailCommand::execute(){
                        
                        if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it
                        string outputFileName, accnosFileName;
-                       if (maskfile != "") {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + getOutputFileNameTag("chimera");
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + getOutputFileNameTag("accnos");
-                       }else {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
-                       }
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+                       if (maskfile != "") { variables["[tag]"] = m->getSimpleName(m->getRootName(maskfile)); }
+            outputFileName = getOutputFileName("chimera", variables);
+            accnosFileName = getOutputFileName("accnos", variables);
+                       
                        
                        if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0;    }
                        
index 1f30b7d32ef8e826fa0479ff10dcd529982c2b00..fa195e7253e870f2a38b8e72ca90a1a6875e4652 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.pintail";             }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Ashelford KE, Chuzhanova NA, Fry JC, Jones AJ, Weightman AJ (2005). At least 1 in 20 16S rRNA sequence records currently held in public repositories is estimated to contain substantial anomalies. Appl Environ Microbiol 71: 7724-36. \nAshelford KE, Chuzhanova NA, Fry JC, Jones AJ, Weightman AJ (2006). New screening software shows that most recent large 16S rRNA gene clone libraries contain chimeras. Appl Environ Microbiol 72: 5734-41. \nhttp://www.mothur.org/wiki/Chimera.pintail"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index bd9bdbf2f3dcb4d5ed3ce3a7ced35dfe7a4a1ba5..a29fc82727eb0d68d8d8a071d2e969dfab8d2103 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraSlayerCommand::setParameters(){  
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pwindow("window", "Number", "", "50", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pksize("ksize", "Number", "", "7", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmatch("match", "Number", "", "5.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-4.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pminsim("minsim", "Number", "", "90", "", "", "",false,false); parameters.push_back(pminsim);
-               CommandParameter pmincov("mincov", "Number", "", "70", "", "", "",false,false); parameters.push_back(pmincov);
-               CommandParameter pminsnp("minsnp", "Number", "", "10", "", "", "",false,false); parameters.push_back(pminsnp);
-               CommandParameter pminbs("minbs", "Number", "", "90", "", "", "",false,false); parameters.push_back(pminbs);
-               CommandParameter psearch("search", "Multiple", "kmer-blast", "blast", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prealign("realign", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(prealign);
-               CommandParameter ptrim("trim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptrim);
-               CommandParameter psplit("split", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psplit);
-               CommandParameter pnumwanted("numwanted", "Number", "", "15", "", "", "",false,false); parameters.push_back(pnumwanted);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pdivergence("divergence", "Number", "", "1.007", "", "", "",false,false); parameters.push_back(pdivergence);
-               CommandParameter pparents("parents", "Number", "", "3", "", "", "",false,false); parameters.push_back(pparents);
-               CommandParameter pincrement("increment", "Number", "", "5", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pblastlocation("blastlocation", "String", "", "", "", "", "",false,false); parameters.push_back(pblastlocation);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+         CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pwindow("window", "Number", "", "50", "", "", "","",false,false); parameters.push_back(pwindow);
+               CommandParameter pksize("ksize", "Number", "", "7", "", "", "","",false,false); parameters.push_back(pksize);
+               CommandParameter pmatch("match", "Number", "", "5.0", "", "", "","",false,false); parameters.push_back(pmatch);
+               CommandParameter pmismatch("mismatch", "Number", "", "-4.0", "", "", "","",false,false); parameters.push_back(pmismatch);
+               CommandParameter pminsim("minsim", "Number", "", "90", "", "", "","",false,false); parameters.push_back(pminsim);
+               CommandParameter pmincov("mincov", "Number", "", "70", "", "", "","",false,false); parameters.push_back(pmincov);
+               CommandParameter pminsnp("minsnp", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pminsnp);
+               CommandParameter pminbs("minbs", "Number", "", "90", "", "", "","",false,false); parameters.push_back(pminbs);
+               CommandParameter psearch("search", "Multiple", "kmer-blast", "blast", "", "", "","",false,false); parameters.push_back(psearch);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter prealign("realign", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(prealign);
+               CommandParameter ptrim("trim", "Boolean", "", "F", "", "", "","fasta",false,false); parameters.push_back(ptrim);
+               CommandParameter psplit("split", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psplit);
+               CommandParameter pnumwanted("numwanted", "Number", "", "15", "", "", "","",false,false); parameters.push_back(pnumwanted);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pdivergence("divergence", "Number", "", "1.007", "", "", "","",false,false); parameters.push_back(pdivergence);
+               CommandParameter pparents("parents", "Number", "", "3", "", "", "","",false,false); parameters.push_back(pparents);
+               CommandParameter pincrement("increment", "Number", "", "5", "", "", "","",false,false); parameters.push_back(pincrement);
+               CommandParameter pblastlocation("blastlocation", "String", "", "", "", "", "","",false,false); parameters.push_back(pblastlocation);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -101,26 +101,21 @@ string ChimeraSlayerCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraSlayerCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraSlayerCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "slayer.chimeras"; }
-            else if (type == "accnos") {  outputFileName =  "slayer.accnos"; }
-            else if (type == "fasta") {  outputFileName =  "slayer.fasta"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],slayer.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],slayer.accnos"; } 
+        else if (type == "fasta") {  pattern = "[filename],slayer.fasta"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraSlayerCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraSlayerCommand::ChimeraSlayerCommand(){  
@@ -666,10 +661,12 @@ int ChimeraSlayerCommand::execute(){
                        m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
                
                        int start = time(NULL); 
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
-                       string trimFastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("fasta");             
+                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it       
+                       map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+                       string outputFileName = getOutputFileName("chimera", variables);
+                       string accnosFileName = getOutputFileName("accnos", variables);
+                       string trimFastaFileName = getOutputFileName("fasta", variables);
                        
                        //clears files
                        ofstream out, out1, out2;
index 4d53c5c048dafe1f969437a384ea93a160a83c04..6149ef5b7ded364733fa4480dc9386d2e7e92fb2 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.slayer";              }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Haas BJ, Gevers D, Earl A, Feldgarden M, Ward DV, Giannokous G, Ciulla D, Tabbaa D, Highlander SK, Sodergren E, Methe B, Desantis TZ, Petrosino JF, Knight R, Birren BW (2011). Chimeric 16S rRNA sequence formation and detection in Sanger and 454-pyrosequenced PCR amplicons. Genome Res  21:494.\nhttp://www.mothur.org/wiki/Chimera.slayer"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index 6f7ba106ead04e9ccd3b7b290dce4c3a55dabd20..04e1f1ddf244057e462d51c39c2913900d6424c3 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChimeraUchimeCommand::setParameters(){  
        try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pabskew("abskew", "Number", "", "1.9", "", "", "",false,false); parameters.push_back(pabskew);
-               CommandParameter pchimealns("chimealns", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pchimealns);
-               CommandParameter pminh("minh", "Number", "", "0.3", "", "", "",false,false); parameters.push_back(pminh);
-               CommandParameter pmindiv("mindiv", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pmindiv);
-               CommandParameter pxn("xn", "Number", "", "8.0", "", "", "",false,false); parameters.push_back(pxn);
-               CommandParameter pdn("dn", "Number", "", "1.4", "", "", "",false,false); parameters.push_back(pdn);
-               CommandParameter pxa("xa", "Number", "", "1", "", "", "",false,false); parameters.push_back(pxa);
-               CommandParameter pchunks("chunks", "Number", "", "4", "", "", "",false,false); parameters.push_back(pchunks);
-               CommandParameter pminchunk("minchunk", "Number", "", "64", "", "", "",false,false); parameters.push_back(pminchunk);
-               CommandParameter pidsmoothwindow("idsmoothwindow", "Number", "", "32", "", "", "",false,false); parameters.push_back(pidsmoothwindow);
-        CommandParameter pdups("dereplicate", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pdups);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","chimera-accnos",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter pabskew("abskew", "Number", "", "1.9", "", "", "","",false,false); parameters.push_back(pabskew);
+               CommandParameter pchimealns("chimealns", "Boolean", "", "F", "", "", "","alns",false,false); parameters.push_back(pchimealns);
+               CommandParameter pminh("minh", "Number", "", "0.3", "", "", "","",false,false); parameters.push_back(pminh);
+               CommandParameter pmindiv("mindiv", "Number", "", "0.5", "", "", "","",false,false); parameters.push_back(pmindiv);
+               CommandParameter pxn("xn", "Number", "", "8.0", "", "", "","",false,false); parameters.push_back(pxn);
+               CommandParameter pdn("dn", "Number", "", "1.4", "", "", "","",false,false); parameters.push_back(pdn);
+               CommandParameter pxa("xa", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pxa);
+               CommandParameter pchunks("chunks", "Number", "", "4", "", "", "","",false,false); parameters.push_back(pchunks);
+               CommandParameter pminchunk("minchunk", "Number", "", "64", "", "", "","",false,false); parameters.push_back(pminchunk);
+               CommandParameter pidsmoothwindow("idsmoothwindow", "Number", "", "32", "", "", "","",false,false); parameters.push_back(pidsmoothwindow);
+        CommandParameter pdups("dereplicate", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pdups);
 
                //CommandParameter pminsmoothid("minsmoothid", "Number", "", "0.95", "", "", "",false,false); parameters.push_back(pminsmoothid);
-               CommandParameter pmaxp("maxp", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmaxp);
-               CommandParameter pskipgaps("skipgaps", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pskipgaps);
-               CommandParameter pskipgaps2("skipgaps2", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pskipgaps2);
-               CommandParameter pminlen("minlen", "Number", "", "10", "", "", "",false,false); parameters.push_back(pminlen);
-               CommandParameter pmaxlen("maxlen", "Number", "", "10000", "", "", "",false,false); parameters.push_back(pmaxlen);
-               CommandParameter pucl("ucl", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pucl);
-               CommandParameter pqueryfract("queryfract", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pqueryfract);
+               CommandParameter pmaxp("maxp", "Number", "", "2", "", "", "","",false,false); parameters.push_back(pmaxp);
+               CommandParameter pskipgaps("skipgaps", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pskipgaps);
+               CommandParameter pskipgaps2("skipgaps2", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pskipgaps2);
+               CommandParameter pminlen("minlen", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pminlen);
+               CommandParameter pmaxlen("maxlen", "Number", "", "10000", "", "", "","",false,false); parameters.push_back(pmaxlen);
+               CommandParameter pucl("ucl", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pucl);
+               CommandParameter pqueryfract("queryfract", "Number", "", "0.5", "", "", "","",false,false); parameters.push_back(pqueryfract);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -103,26 +103,21 @@ string ChimeraUchimeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChimeraUchimeCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChimeraUchimeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "chimera") {  outputFileName =  "uchime.chimeras"; }
-            else if (type == "accnos") {  outputFileName =  "uchime.accnos"; }
-            else if (type == "alns") {  outputFileName =  "uchime.alns"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "chimera") {  pattern = "[filename],uchime.chimeras"; } 
+        else if (type == "accnos") {  pattern = "[filename],uchime.accnos"; } 
+        else if (type == "alns") {  pattern = "[filename],uchime.alns"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChimeraUchimeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChimeraUchimeCommand::ChimeraUchimeCommand(){  
@@ -642,9 +637,11 @@ int ChimeraUchimeCommand::execute(){
                        int start = time(NULL); 
                        string nameFile = "";
                        if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
-                       string alnsFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + getOutputFileNameTag("alns");
+                       map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+                       string outputFileName = getOutputFileName("chimera", variables);
+                       string accnosFileName = getOutputFileName("accnos", variables);
+                       string alnsFileName = getOutputFileName("alns", variables);
                        string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
                                
                        //you provided a groupfile
index f0c30d08a03f1834de06c550668e6b3b1f64c1b1..735c97d1269848b94ac5a01926f93e08d1ccd5ef 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.uchime";              }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "uchime by Robert C. Edgar\nhttp://drive5.com/uchime\nThis code was donated to the public domain.\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection.  Bioinformatics 27:2194.\nhttp://www.mothur.org/wiki/Chimera.uchime\n"; }
        string getDescription()         { return "detect chimeric sequences"; }
        
index 1761efcbfffe273d52fa67480f390aec38b08b0a..0cce69f23efa4869ae5b4b8955c6192d25a69f52 100644 (file)
 //**********************************************************************************************************************
 vector<string> ChopSeqsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-        CommandParameter pnumbases("numbases", "Number", "", "0", "", "", "",false,true); parameters.push_back(pnumbases);
-               CommandParameter pcountgaps("countgaps", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcountgaps);
-               CommandParameter pshort("short", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pshort);
-               CommandParameter pkeep("keep", "Multiple", "front-back", "front", "", "", "",false,false); parameters.push_back(pkeep);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+        CommandParameter pnumbases("numbases", "Number", "", "0", "", "", "","",false,true,true); parameters.push_back(pnumbases);
+               CommandParameter pcountgaps("countgaps", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pcountgaps);
+               CommandParameter pshort("short", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pshort);
+               CommandParameter pkeep("keep", "Multiple", "front-back", "front", "", "", "","",false,false); parameters.push_back(pkeep);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,25 +54,20 @@ string ChopSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ChopSeqsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ChopSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "chop.fasta"; }
-            else if (type == "accnos") {  outputFileName =  "chop.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],chop.fasta"; } 
+        else if (type == "accnos") {  pattern = "[filename],chop.accnos"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ChopSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ChopSeqsCommand::ChopSeqsCommand(){    
@@ -173,9 +168,10 @@ int ChopSeqsCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
-               string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
-        
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+        string outputFileName = getOutputFileName("fasta", variables);
+        string outputFileNameAccnos = getOutputFileName("accnos", variables);        
         
         vector<unsigned long long> positions; 
         vector<linePair> lines;
index fa3f559056161945021e10f9b1892db742a6116e..cd2b2fe9640eb7e359cdc068d98552611f5b2d13 100644 (file)
@@ -25,8 +25,9 @@ class ChopSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "chop.seqs";           }
                string getCommandCategory()             { return "Sequence Processing"; }
-               string getOutputFileNameTag(string, string);
+               
         string getHelpString();        
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Chops.seqs"; }
                string getDescription()         { return "trim sequence length"; }
        
index 0ada1c8f77da53a27f02658184fa8fc6a0713e4b..47b18410e6e2d61d2e58ec1b2ab170fbce34285f 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClassifyOtuCommand::setParameters(){    
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(preftaxonomy);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppersample);
-        CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pbasis("basis", "Multiple", "otu-sequence", "otu", "", "", "",false,false); parameters.push_back(pbasis);
-               CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pprobs);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none","constaxonomy",false,true,true); parameters.push_back(ptaxonomy);
+               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(preftaxonomy);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+        CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ppersample);
+        CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pbasis("basis", "Multiple", "otu-sequence", "otu", "", "", "","",false,false); parameters.push_back(pbasis);
+               CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "","",false,true); parameters.push_back(pcutoff);
+               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pprobs);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -67,25 +67,20 @@ string ClassifyOtuCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClassifyOtuCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClassifyOtuCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "constaxonomy") {  outputFileName =  "cons.taxonomy"; }
-            else if (type == "taxsummary") {  outputFileName =  "cons.tax.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "constaxonomy") {  pattern = "[filename],[distance],cons.taxonomy"; } 
+        else if (type == "taxsummary") {  pattern = "[filename],[distance],cons.tax.summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClassifyOtuCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClassifyOtuCommand::ClassifyOtuCommand(){      
@@ -532,12 +527,15 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
                                
                ofstream out;
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." +getOutputFileNameTag("constaxonomy");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[distance]"] = processList->getLabel();
+               string outputFile = getOutputFileName("constaxonomy", variables);
                m->openOutputFile(outputFile, out);
                outputNames.push_back(outputFile); outputTypes["constaxonomy"].push_back(outputFile);
                
                ofstream outSum;
-               string outputSumFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." +getOutputFileNameTag("taxsummary");
+               string outputSumFile = getOutputFileName("taxsummary", variables);
                m->openOutputFile(outputSumFile, outSum);
                outputNames.push_back(outputSumFile); outputTypes["taxsummary"].push_back(outputSumFile);
                
@@ -560,14 +558,15 @@ int ClassifyOtuCommand::process(ListVector* processList) {
             for (int i = 0; i < groups.size(); i++) {
                 groupIndex[groups[i]] = i;
                 ofstream* temp = new ofstream();
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + groups[i] + "." +getOutputFileNameTag("constaxonomy");
+                variables["[distance]"] = processList->getLabel() + "." + groups[i];
+                string outputFile = getOutputFileName("constaxonomy", variables);
                 m->openOutputFile(outputFile, *temp);
                 (*temp) << "OTU\tSize\tTaxonomy" << endl;
                 outs.push_back(temp);
                 outputNames.push_back(outputFile); outputTypes["constaxonomy"].push_back(outputFile);
                 
                 ofstream* tempSum = new ofstream();
-                string outputSumFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + groups[i] + "." +getOutputFileNameTag("taxsummary");
+                string outputSumFile = getOutputFileName("taxsummary", variables);
                 m->openOutputFile(outputSumFile, *tempSum);
                 outSums.push_back(tempSum);
                 outputNames.push_back(outputSumFile); outputTypes["taxsummary"].push_back(outputSumFile);
index c08a29b8c71552be73d7bd1d3e28c3b0a1ee2159..c0a822070fa9a8b0b570f05e1ede727e19ead48b 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.otu";                }
        string getCommandCategory()             { return "Phylotype Analysis";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol 77:3219.\nhttp://www.mothur.org/wiki/Classify.otu"; }
        string getDescription()         { return "find the concensus taxonomy for each OTU"; }
        
index 0012cd246e5f9e708c7fcbdc52c22f2176200578..89668d9e7bd122577d9be167f590a96a6aedbf22 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClassifySeqsCommand::setParameters(){   
        try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptaxonomy);
+               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(ptemplate);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","taxonomy",false,true,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
 
-               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix-distance-align", "kmer", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pksize("ksize", "Number", "", "8", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmethod("method", "Multiple", "wang-knn-zap", "wang", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               //CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pprobs);
-               CommandParameter piters("iters", "Number", "", "100", "", "", "",false,true); parameters.push_back(piters);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-        CommandParameter pshortcuts("shortcuts", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshortcuts);
-               CommandParameter pnumwanted("numwanted", "Number", "", "10", "", "", "",false,true); parameters.push_back(pnumwanted);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix-distance-align", "kmer", "", "", "","",false,false); parameters.push_back(psearch);
+               CommandParameter pksize("ksize", "Number", "", "8", "", "", "","",false,false); parameters.push_back(pksize);
+               CommandParameter pmethod("method", "Multiple", "wang-knn-zap", "wang", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pmatch);
+               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pmismatch);
+               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "","",false,false); parameters.push_back(pgapopen);
+               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pgapextend);
+               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "","",false,true); parameters.push_back(pcutoff);
+               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pprobs);
+               CommandParameter piters("iters", "Number", "", "100", "", "", "","",false,true); parameters.push_back(piters);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
+        CommandParameter pshortcuts("shortcuts", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshortcuts);
+               CommandParameter pnumwanted("numwanted", "Number", "", "10", "", "", "","",false,true); parameters.push_back(pnumwanted);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -89,27 +88,22 @@ string ClassifySeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClassifySeqsCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClassifySeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "taxonomy") {  outputFileName =  "taxonomy"; }
-            else if (type == "accnos") {  outputFileName =  "flip.accnos"; }
-            else if (type == "taxsummary") {  outputFileName =  "tax.summary"; }
-            else if (type == "matchdist") {  outputFileName =  "match.dist"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "taxonomy") {  pattern = "[filename],[tag],[tag2],taxonomy"; } 
+        else if (type == "taxsummary") {  pattern = "[filename],[tag],[tag2],tax.summary"; } 
+        else if (type == "accnos") {  pattern =  "[filename],[tag],[tag2],flip.accnos"; }
+        else if (type == "matchdist") {  pattern =  "[filename],[tag],[tag2],match.dist"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClassifySeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClassifySeqsCommand::ClassifySeqsCommand(){    
@@ -181,23 +175,7 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["taxonomy"] = 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("count");
-                               //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["count"] = inputDir + it->second;            }
-                               }
-                       }
+            }
 
                        fastaFileName = validParameter.validFile(parameters, "fasta", false);
                        if (fastaFileName == "not found") {                             
@@ -436,49 +414,68 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                
                                //go through files and make sure they are good, if not, then disregard them
                                for (int i = 0; i < groupfileNames.size(); i++) {
-                                       if (inputDir != "") {
-                                               string path = m->hasPath(groupfileNames[i]);
-                                               //if the user has not given a path then, add inputdir. else leave path alone.
-                                               if (path == "") {       groupfileNames[i] = inputDir + groupfileNames[i];               }
-                                       }
-                                       int ableToOpen;
                                        
-                                       ifstream in;
-                                       ableToOpen = m->openInputFile(groupfileNames[i], in, "noerror");
-                               
-                                       //if you can't open it, try default location
-                                       if (ableToOpen == 1) {
-                                               if (m->getDefaultPath() != "") { //default path is set
-                                                       string tryPath = m->getDefaultPath() + m->getSimpleName(groupfileNames[i]);
-                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       groupfileNames[i] = tryPath;
+                                       bool ignore = false;
+                                       if (groupfileNames[i] == "current") { 
+                                               groupfileNames[i] = m->getGroupFile(); 
+                                               if (groupfileNames[i] != "") {  m->mothurOut("Using " + groupfileNames[i] + " as input file for the group parameter where you had given current."); m->mothurOutEndLine(); }
+                                               else {  
+                                                       m->mothurOut("You have no current group file, ignoring current."); m->mothurOutEndLine(); ignore=true; 
+                                                       //erase from file list
+                                                       groupfileNames.erase(groupfileNames.begin()+i);
+                                                       i--;
                                                }
                                        }
                                        
-                                       if (ableToOpen == 1) {
-                                               if (m->getOutputDir() != "") { //default path is set
-                                                       string tryPath = m->getOutputDir() + m->getSimpleName(groupfileNames[i]);
-                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       groupfileNames[i] = tryPath;
+                                       if (!ignore) {
+                                               
+                                               if (inputDir != "") {
+                                                       string path = m->hasPath(groupfileNames[i]);
+                            cout << path << '\t' << inputDir << endl;
+                                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                                       if (path == "") {       groupfileNames[i] = inputDir + groupfileNames[i];               }
+                                               }
+                                               
+                                               int ableToOpen;
+                                               
+                                               ifstream in;
+                                               ableToOpen = m->openInputFile(groupfileNames[i], in, "noerror");
+                        
+                                               //if you can't open it, try default location
+                                               if (ableToOpen == 1) {
+                                                       if (m->getDefaultPath() != "") { //default path is set
+                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(groupfileNames[i]);
+                                                               m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                               ifstream in2;
+                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                               in2.close();
+                                                               groupfileNames[i] = tryPath;
+                                                       }
+                                               }
+                                               
+                                               if (ableToOpen == 1) {
+                                                       if (m->getOutputDir() != "") { //default path is set
+                                                               string tryPath = m->getOutputDir() + m->getSimpleName(groupfileNames[i]);
+                                                               m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                               ifstream in2;
+                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
+                                                               in2.close();
+                                                               groupfileNames[i] = tryPath;
+                                                       }
+                                               }
+                                               
+                                               in.close();
+                                               
+                                               if (ableToOpen == 1) { 
+                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
+                                                       //erase from file list
+                                                       groupfileNames.erase(groupfileNames.begin()+i);
+                                                       i--;
+                                               }else {
+                                                       m->setGroupFile(groupfileNames[i]);
                                                }
                                        }
                                        
-                                       in.close();
-                                       
-                                       if (ableToOpen == 1) { 
-                                               m->mothurOut("Unable to open " + groupfileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); groupfileNames[i] = "";
-                                               //erase from file list
-                                               groupfileNames.erase(groupfileNames.begin()+i);
-                                               i--;
-                                       }else {
-                                               m->setGroupFile(groupfileNames[i]);
-                                       }
                                }
                        }
 
@@ -644,16 +641,20 @@ int ClassifySeqsCommand::execute(){
                 else if (foundDot && (baseTName[i] == '.')) {  break; }
                 else if (!foundDot && (baseTName[i] == '.')) {  foundDot = true; }
             }
-            if (RippedTaxName != "") { RippedTaxName +=  "."; }   
+            //if (RippedTaxName != "") { RippedTaxName +=  "."; }   
           
                        if (outputDir == "") { outputDir += m->hasPath(fastaFileNames[s]); }
-                       string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + outputMethodTag + getOutputFileNameTag("taxonomy");
-                       string newaccnosFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + outputMethodTag +getOutputFileNameTag("accnos");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+            variables["[tag]"] = RippedTaxName;
+            variables["[tag2]"] = outputMethodTag;
+                       string newTaxonomyFile = getOutputFileName("taxonomy", variables);
+                       string newaccnosFile = getOutputFileName("accnos", variables);
                        string tempTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
-                       string taxSummary = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + outputMethodTag + getOutputFileNameTag("taxsummary");
+                       string taxSummary = getOutputFileName("taxsummary", variables);
                        
                        if ((method == "knn") && (search == "distance")) { 
-                               string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("matchdist");
+                               string DistName = getOutputFileName("matchdist", variables);
                                classify->setDistName(DistName);  outputNames.push_back(DistName); outputTypes["matchdist"].push_back(DistName);
                        }
                        
index 87d4f51cf78230f6ab301e1d72462a461b9f9da9..a3328d8dcea09eebe63c641e04e1b816fc92fee1 100644 (file)
@@ -43,8 +43,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.seqs";               }
        string getCommandCategory()             { return "Phylotype Analysis";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Wang Q, Garrity GM, Tiedje JM, Cole JR (2007). Naive Bayesian classifier for rapid assignment of rRNA sequences into the new bacterial taxonomy. Appl Environ Microbiol 73: 5261-7. [ for Bayesian classifier ] \nAltschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ (1997). Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Res 25: 3389-402. [ for BLAST ] \nDeSantis TZ, Hugenholtz P, Larsen N, Rojas M, Brodie EL, Keller K, Huber T, Dalevi D, Hu P, Andersen GL (2006). Greengenes, a chimera-checked 16S rRNA gene database and workbench compatible with ARB. Appl Environ Microbiol 72: 5069-72. [ for kmer ] \nhttp://www.mothur.org/wiki/Classify.seqs"; }
        string getDescription()         { return "classify sequences"; }
        
index f964937b4ded24bc8f9eb001f1a8557f2ffcfd77..2dc963babfc0ebea56cb0505e647667d1e964170 100755 (executable)
 vector<string> ClassifySharedCommand::setParameters(){ 
        try {
                //CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);        
-        CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);            
-        CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);    
-        CommandParameter potupersplit("otupersplit", "Multiple", "log2-squareroot", "log2", "", "", "",false,false); parameters.push_back(potupersplit);
-        CommandParameter psplitcriteria("splitcriteria", "Multiple", "gainratio-infogain", "gainratio", "", "", "",false,false); parameters.push_back(psplitcriteria);
-               CommandParameter pnumtrees("numtrees", "Number", "", "100", "", "", "",false,false); parameters.push_back(pnumtrees);
+        CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pshared);             
+        CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pdesign);    
+        CommandParameter potupersplit("otupersplit", "Multiple", "log2-squareroot", "log2", "", "", "","",false,false); parameters.push_back(potupersplit);
+        CommandParameter psplitcriteria("splitcriteria", "Multiple", "gainratio-infogain", "gainratio", "", "", "","",false,false); parameters.push_back(psplitcriteria);
+               CommandParameter pnumtrees("numtrees", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pnumtrees);
 
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,24 +53,19 @@ string ClassifySharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClassifySharedCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string tag = "";
-               map<string, vector<string> >::iterator it;
+string ClassifySharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary") {  tag = "summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return tag;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySharedCommand", "getOutputFileName");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],[distance],summary"; } //makes file like: amazon.0.03.fasta
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClassifySharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 
@@ -348,7 +343,10 @@ void ClassifySharedCommand::processSharedAndDesignData(vector<SharedRAbundVector
         randomForest.populateDecisionTrees();
         randomForest.calcForrestErrorRate();
         
-        string filename = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[distance]"] = lookup[0]->getLabel();
+        string filename = getOutputFileName("summary", variables);
         outputNames.push_back(filename); outputTypes["summary"].push_back(filename);
         
         randomForest.calcForrestVariableImportance(filename);
index 93c62867d48069e7374bf955cfe695c1762227be..fe0637494db78aa96ecbac56c2f82b08ba2f9c6d 100755 (executable)
@@ -21,8 +21,9 @@ public:
   vector<string> setParameters();
   string getCommandName()                      { return "classify.shared";     }
    string getCommandCategory()         { return "OTU-Based Approaches";                }
-  string getOutputFileNameTag(string, string);
-  string getHelpString();
+  
+  string getHelpString();      
+    string getOutputPattern(string);
   string getCitation() { return "http://www.mothur.org/wiki/Classify.shared\n"; }
   string getDescription()              { return "description"; }
   int execute();
index 69da8e0d74e58d54d7ae59c78c7ad7f91e9f4b29..f1f1ffdda61422ab11d9c04bb507411e2ee9da59 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClassifyTreeCommand::setParameters(){   
        try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "", "", "none",false,true); parameters.push_back(ptree);
-        CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "", "", "none",false,true); parameters.push_back(ptaxonomy);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "", "", "none","tree-summary",false,true,true); parameters.push_back(ptree);
+        CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "", "", "none","",false,true,true); parameters.push_back(ptaxonomy);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+        CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "","",false,true); parameters.push_back(pcutoff);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,25 +52,20 @@ string ClassifyTreeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClassifyTreeCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClassifyTreeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "tree") {  outputFileName =  "taxonomy.tre"; }
-            else if (type == "summary") {  outputFileName =  "taxonomy.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],taxonomy.summary"; } //makes file like: amazon.0.03.fasta
+        else if (type == "tree") {  pattern = "[filename],taxonomy.tre"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClassifyTreeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClassifyTreeCommand::ClassifyTreeCommand(){    
@@ -286,7 +281,9 @@ int ClassifyTreeCommand::getClassifications(Tree*& T){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(treefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(treefile));
+               string outputFileName = getOutputFileName("summary", variables);
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -300,7 +297,8 @@ int ClassifyTreeCommand::getClassifications(Tree*& T){
                
                string treeOutputDir = outputDir;
                if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
+        variables["[filename]"] = treeOutputDir + m->getRootName(m->getSimpleName(treefile));
+               string outputTreeFileName = getOutputFileName("tree", variables);
                
                //create a map from tree node index to names of descendants, save time later
                map<int, map<string, set<string> > > nodeToDescendants; //node# -> (groupName -> groupMembers)
index dd972b61b457378462392f771d759585bef53188..ef180babdf12e2a3640ea6157d64b91fe4cc9268 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.tree";                               }
        string getCommandCategory()             { return "Phylotype Analysis";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Classify.tree"; }
        string getDescription()         { return "Find the consensus taxonomy for the descendant of each tree node"; }
     
index 55fbe0a1dceb9a2d2c16e2f6936646d3e851ee19..1b0a532cace0792297ce3162a03c7a382b66b282 100644 (file)
@@ -19,26 +19,26 @@ extern "C" {
 //**********************************************************************************************************************
 vector<string> ClearcutCommand::setParameters(){       
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pverbose("verbose", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pverbose);
-               CommandParameter pquiet("quiet", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pquiet);
-               CommandParameter pversion("version", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pversion);
-               CommandParameter pseed("seed", "String", "", "", "*", "", "",false,false); parameters.push_back(pseed);
-               CommandParameter pnorandom("norandom", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pnorandom);
-               CommandParameter pshuffle("shuffle", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pshuffle);
-               CommandParameter pneighbor("neighbor", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pneighbor);
-               CommandParameter pexpblen("expblen", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpblen);
-               CommandParameter pexpdist("expdist", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpdist);
-               CommandParameter pDNA("DNA", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pDNA);
-               CommandParameter pprotein("protein", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pprotein);
-               CommandParameter pjukes("jukes", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pjukes);
-               CommandParameter pkimura("kimura", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkimura);
-               CommandParameter pstdout("stdout", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pstdout);
-               CommandParameter pntrees("ntrees", "Number", "", "1", "", "", "",false,false); parameters.push_back(pntrees);
-               CommandParameter pmatrixout("matrixout", "String", "", "", "", "", "",false,false); parameters.push_back(pmatrixout);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none","tree",false,false,true); parameters.push_back(pphylip);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none","tree",false,false,true); parameters.push_back(pfasta);
+               CommandParameter pverbose("verbose", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pverbose);
+               CommandParameter pquiet("quiet", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pquiet);
+               CommandParameter pversion("version", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pversion);
+               CommandParameter pseed("seed", "String", "", "", "*", "", "","",false,false); parameters.push_back(pseed);
+               CommandParameter pnorandom("norandom", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pnorandom);
+               CommandParameter pshuffle("shuffle", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pshuffle);
+               CommandParameter pneighbor("neighbor", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pneighbor);
+               CommandParameter pexpblen("expblen", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pexpblen);
+               CommandParameter pexpdist("expdist", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pexpdist);
+               CommandParameter pDNA("DNA", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pDNA);
+               CommandParameter pprotein("protein", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pprotein);
+               CommandParameter pjukes("jukes", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pjukes);
+               CommandParameter pkimura("kimura", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkimura);
+               CommandParameter pstdout("stdout", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pstdout);
+               CommandParameter pntrees("ntrees", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pntrees);
+               CommandParameter pmatrixout("matrixout", "String", "", "", "", "", "","",false,false); parameters.push_back(pmatrixout);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -87,25 +87,20 @@ string ClearcutCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClearcutCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClearcutCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "tree") {  outputFileName =  "tre"; }
-            else if (type == "matrixout") {  outputFileName =  ""; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "matrixout") {  pattern = "[filename],"; } 
+        else if (type == "tree") {  pattern = "[filename],tre"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClearcutCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClearcutCommand::ClearcutCommand(){    
@@ -264,7 +259,9 @@ int ClearcutCommand::execute() {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //prepare filename
-               string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + getOutputFileNameTag("tree");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFile));
+               string outputName = getOutputFileName("tree", variables);
                outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
                
                vector<char*> cPara;
index 8f3773eef5cafc5b4a18c56da51df9bdb9606be6..817c4a3290804405bd47582d9b3ec5349c182b43 100644 (file)
@@ -30,8 +30,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "clearcut";                    }
        string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Sheneman L, Evans J, Foster JA (2006). Clearcut: a fast implementation of relaxed neighbor joining. Bioinformatics 22: 2823-4. \nhttp://www.mothur.org/wiki/Clearcut"; }
        string getDescription()         { return "create a tree from a fasta or phylip file"; }
        
index e1f39723c6b6b9d56c961fa16345c6194f9c8a7c..abdc5558ae1aa26ab7c2d21454f8ff0696802ad1 100644 (file)
@@ -22,25 +22,6 @@ vector<string> ClearMemoryCommand::setParameters(){
        }
 }
 //**********************************************************************************************************************
-string ClearMemoryCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
-        
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; 
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearMemoryCommand", "getOutputFileNameTag");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 string ClearMemoryCommand::getHelpString(){    
        try {
                string helpString = "";
index 1208315a54c880e39c1bfd4a3316fe3a47cab33d..765f41d5ecfbc3770863f3283c72dea48ec1bb1b 100644 (file)
@@ -21,8 +21,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "clear.memory";                        }
        string getCommandCategory()             { return "General";     }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string) { return ""; }     
        string getCitation() { return "http://www.mothur.org/wiki/Clear.memory"; }
        string getDescription()         { return "remove saved references from memory"; }
        
index b46e1fb14f9aaf9c34a94216ffd5692c4f043148..93e29fd6e4daad8f09c6d373ba3b57e00ea55b52 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClusterCommand::setParameters(){        
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pcount);
-        CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);             
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","list",false,false,true); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName","rabund-sabund",false,false,true); parameters.push_back(pname);
+               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pcount);
+        CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName","list",false,false,true); parameters.push_back(pcolumn);         
+               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false,true); parameters.push_back(pmethod);
+               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
+               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
+               CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -56,26 +56,21 @@ string ClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClusterCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClusterCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClusterCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClusterCommand::ClusterCommand(){      
@@ -339,11 +334,13 @@ int ClusterCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(distfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
                
-        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
-        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
-        string listFileName = fileroot+ tag + ".";
-        if (countfile != "") { listFileName += "unique_"; }
-        listFileName += getOutputFileNameTag("list");
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+        if (countfile != "") { variables["[tag2]"] = "unique_list"; }
+        variables["[clustertag]"] = tag;
+        string sabundFileName = getOutputFileName("sabund", variables);
+        string rabundFileName = getOutputFileName("rabund", variables);
+        string listFileName = getOutputFileName("list", variables);
         
         if (countfile == "") {
             m->openOutputFile(sabundFileName,  sabundFile);
index a5b792ea7c8a3e35345606765aaa3ede84916a86..96b7c08861f216862de0c1e600d07fed463eb56a 100644 (file)
@@ -35,8 +35,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster";             }
        string getCommandCategory()             { return "Clustering";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol 77:3219.\nSchloss PD, Handelsman J (2005). Introducing DOTUR, a computer program for defining operational taxonomic units and estimating species richness. Appl Environ Microbiol 71: 1501-6.\nhttp://www.mothur.org/wiki/Cluster"; }
        string getDescription()         { return "cluster your sequences into OTUs using a distance matrix"; }
        
index 2515b5c15129434f4d45c19f798c76c7645ad369..4463896cefd13f6bafcc625846fd94213b610ba7 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClusterDoturCommand::setParameters(){   
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","list",false,true,true); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","rabund-sabund",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+               CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -50,26 +50,21 @@ string ClusterDoturCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClusterDoturCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClusterDoturCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClusterDoturCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClusterDoturCommand::ClusterDoturCommand(){    
@@ -247,11 +242,13 @@ int ClusterDoturCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(phylipfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(phylipfile));
                        
-        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
-        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
-        string listFileName = fileroot+ tag + ".";
-        if (countfile != "") { listFileName += "unique_"; }
-        listFileName += getOutputFileNameTag("list");
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+        if (countfile != "") { variables["[tag2]"] = "unique_list"; }
+        variables["[clustertag]"] = tag;
+        string sabundFileName = getOutputFileName("sabund", variables);
+        string rabundFileName = getOutputFileName("rabund", variables);
+        string listFileName = getOutputFileName("list", variables);
         
         if (countfile == "") {
             m->openOutputFile(sabundFileName,  sabundFile);
index dd61a35bdcf3e45a72a590ec9b430584cc30376d..ccfe03bb74c42d43921f8a8224c210bc7a3a7ab0 100644 (file)
@@ -27,8 +27,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.classic";             }
        string getCommandCategory()             { return "Clustering";                  }
-    string getOutputFileNameTag(string, string);
-       string getHelpString();         
+    
+       string getHelpString(); 
+    string getOutputPattern(string);           
        string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol 77:3219.\nSchloss PD, Handelsman J (2005). Introducing DOTUR, a computer program for defining operational taxonomic units and estimating species richness. Appl Environ Microbiol 71: 1501-6.\nhttp://www.mothur.org/wiki/Cluster.classic\n";}
        string getDescription()         { return "cluster your sequences into OTUs using DOTUR’s method"; }
        
index f785c506db502c32c52209badf1af3258b97f1c9..ef199ccdf0a11efba99eaf0299ff50413b70b89f 100644 (file)
@@ -28,13 +28,13 @@ inline bool comparePriority(seqRNode first, seqRNode second) {
 //**********************************************************************************************************************
 vector<string> ClusterFragmentsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pdiffs);
-               CommandParameter ppercent("percent", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppercent);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pdiffs);
+               CommandParameter ppercent("percent", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ppercent);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -68,28 +68,22 @@ string ClusterFragmentsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClusterFragmentsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClusterFragmentsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "fragclust.fasta"; }
-            else if (type == "name") {  outputFileName =  "fragclust.names"; }
-            else if (type == "count") {  outputFileName =  "fragclust.count_table"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],fragclust.fasta"; } 
+        else if (type == "name") {  pattern = "[filename],fragclust.names"; } 
+        else if (type == "count") {  pattern = "[filename],fragclust.count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClusterFragmentsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ClusterFragmentsCommand::ClusterFragmentsCommand(){    
        try {
@@ -275,10 +269,11 @@ int ClusterFragmentsCommand::execute(){
        
                
                string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               
-               string newFastaFile = fileroot + getOutputFileNameTag("fasta");
-               string newNamesFile = fileroot + getOutputFileNameTag("name");
-        if (countfile != "") { newNamesFile = fileroot + getOutputFileNameTag("count"); }
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+               string newFastaFile = getOutputFileName("fasta", variables);
+               string newNamesFile = getOutputFileName("name", variables);
+        if (countfile != "") { newNamesFile = getOutputFileName("count", variables); }
                
                if (m->control_pressed) { return 0; }
                
index e3d861a8a1477c0edf71ae7208c86560ceb56860..ee25fb30da91c4ab338b0b173bcf05a6f1689c81 100644 (file)
@@ -38,8 +38,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.fragments";           }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Cluster.fragments"; }
        string getDescription()         { return "creates a namesfile with sequences that are a fragment of a larger sequence"; }
        
index 277e4a248374e596f61fa2f976c1b25696495a9d..ac5e75536fa44ff36341795b3cbecf7226061c6f 100644 (file)
 //**********************************************************************************************************************
 vector<string> ClusterSplitCommand::setParameters(){   
        try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FastaTaxName",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "FastaTaxName",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName-FastaTaxName",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "",false,false); parameters.push_back(pcount);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter ptaxlevel("taxlevel", "Number", "", "3", "", "", "",false,false); parameters.push_back(ptaxlevel);
-               CommandParameter psplitmethod("splitmethod", "Multiple", "classify-fasta-distance", "distance", "", "", "",false,false); parameters.push_back(psplitmethod);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-        CommandParameter pcluster("cluster", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcluster);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.25", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-        CommandParameter pclassic("classic", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pclassic);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FastaTaxName","",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "none","list",false,false,true); parameters.push_back(pphylip);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "FastaTaxName","list",false,false,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName-FastaTaxName","rabund-sabund",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "ColumnName","list",false,false,true); parameters.push_back(pcolumn);
+               CommandParameter ptaxlevel("taxlevel", "Number", "", "3", "", "", "","",false,false,true); parameters.push_back(ptaxlevel);
+               CommandParameter psplitmethod("splitmethod", "Multiple", "classify-fasta-distance", "distance", "", "", "","",false,false,true); parameters.push_back(psplitmethod);
+               CommandParameter plarge("large", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
+        CommandParameter pcluster("cluster", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pcluster);
+               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pcutoff("cutoff", "Number", "", "0.25", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+        CommandParameter pclassic("classic", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pclassic);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -81,27 +81,22 @@ string ClusterSplitCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ClusterSplitCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ClusterSplitCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else if (type == "column") {  outputFileName =  "dist"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
+        else if (type == "column") {  pattern = "[filename],dist"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ClusterSplitCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ClusterSplitCommand::ClusterSplitCommand(){    
@@ -821,11 +816,13 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> us
                if (outputDir == "") { outputDir += m->hasPath(distfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
                
-        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
-        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
-        string listFileName = fileroot+ tag + ".";
-        if (countfile != "") { listFileName += "unique_"; }
-        listFileName += getOutputFileNameTag("list");
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+        if (countfile != "") { variables["[tag2]"] = "unique_list"; }
+        variables["[clustertag]"] = tag;
+        string sabundFileName = getOutputFileName("sabund", variables);
+        string rabundFileName = getOutputFileName("rabund", variables);
+        string listFileName = getOutputFileName("list", variables);
         
         if (countfile == "") {
             m->openOutputFile(sabundFileName,  outSabund);
@@ -1440,7 +1437,9 @@ int ClusterSplitCommand::createMergedDistanceFile(vector< map<string, string> >
                
                string thisOutputDir = outputDir;
                if (outputDir == "") { thisOutputDir = m->hasPath(fastafile); }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("column");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+               string outputFileName = getOutputFileName("column", variables);
                m->mothurRemove(outputFileName);
                
                
index d88a934f3ef94649eb94f05c256822597dc96f73..e1f17b1bd0b8c4088d5deb3c06691fb3ccf26999 100644 (file)
@@ -35,8 +35,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.split";               }
        string getCommandCategory()             { return "Clustering";                  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol 77:3219. \nhttp://www.mothur.org/wiki/Cluster.split"; }
        string getDescription()         { return "splits your sequences by distance or taxonomy then clusters into OTUs"; }
        
index 73de2a42ffb7fecfa6b5591f076bf7f893271b53..de92e494ac7565953716e1ab413ffc13ee829913 100644 (file)
 //**********************************************************************************************************************
 vector<string> CollectCommand::setParameters(){        
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(psabund);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(pshared);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
+               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pabund("abund", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pabund);
+               CommandParameter psize("size", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psize);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -81,48 +81,43 @@ string CollectCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CollectCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CollectCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "sobs")             {  outputFileName =  "sobs";            }
-            else if (type == "chao")        {  outputFileName =  "chao";            }
-            else if (type == "nseqs")       {  outputFileName =  "nseqs";           }
-            else if (type == "coverage")    {  outputFileName =  "coverage";        }
-            else if (type == "ace")         {  outputFileName =  "ace";             }
-            else if (type == "jack")        {  outputFileName =  "jack";            }
-            else if (type == "shannon")     {  outputFileName =  "shannon";         }
-            else if (type == "shannoneven") {  outputFileName =  "shannoneven";     }
-            else if (type == "npshannon")   {  outputFileName =  "npshannon";       }
-            else if (type == "heip")        {  outputFileName =  "heip";            }
-            else if (type == "smithwilson") {  outputFileName =  "smithwilson";     }
-            else if (type == "simpson")     {  outputFileName =  "simpson";         }
-            else if (type == "simpsoneven") {  outputFileName =  "simpsoneven";     }
-            else if (type == "invsimpson")  {  outputFileName =  "invsimpson";      }
-            else if (type == "bootstrap")   {  outputFileName =  "bootstrap";       }
-            else if (type == "geometric")   {  outputFileName =  "geometric";       }
-            else if (type == "qstat")       {  outputFileName =  "qstat";           }
-            else if (type == "logseries")   {  outputFileName =  "logseries";       }
-            else if (type == "bergerparker") {  outputFileName =  "bergerparker";   }
-            else if (type == "bstick")      {  outputFileName =  "bstick";          }
-            else if (type == "goodscoverage") {  outputFileName =  "goodscoverage"; }
-            else if (type == "efron")       {  outputFileName =  "efron";           }
-            else if (type == "boneh")       {  outputFileName =  "boneh";           }
-            else if (type == "solow")       {  outputFileName =  "solow";           }
-            else if (type == "shen")        {  outputFileName =  "shen";            }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "sobs")             {  pattern =  "[filename],sobs";            }
+        else if (type == "chao")        {  pattern =  "[filename],chao";            }
+        else if (type == "nseqs")       {  pattern =  "[filename],nseqs";           }
+        else if (type == "coverage")    {  pattern =  "[filename],coverage";        }
+        else if (type == "ace")         {  pattern =  "[filename],ace";             }
+        else if (type == "jack")        {  pattern =  "[filename],jack";            }
+        else if (type == "shannon")     {  pattern =  "[filename],shannon";         }
+        else if (type == "shannoneven") {  pattern =  "[filename],shannoneven";     }
+        else if (type == "npshannon")   {  pattern =  "[filename],npshannon";       }
+        else if (type == "heip")        {  pattern =  "[filename],heip";            }
+        else if (type == "smithwilson") {  pattern =  "[filename],smithwilson";     }
+        else if (type == "simpson")     {  pattern =  "[filename],simpson";         }
+        else if (type == "simpsoneven") {  pattern =  "[filename],simpsoneven";     }
+        else if (type == "invsimpson")  {  pattern =  "[filename],invsimpson";      }
+        else if (type == "bootstrap")   {  pattern =  "[filename],bootstrap";       }
+        else if (type == "geometric")   {  pattern =  "[filename],geometric";       }
+        else if (type == "qstat")       {  pattern =  "[filename],qstat";           }
+        else if (type == "logseries")   {  pattern =  "[filename],logseries";       }
+        else if (type == "bergerparker") {  pattern =  "[filename],bergerparker";   }
+        else if (type == "bstick")      {  pattern =  "[filename],bstick";          }
+        else if (type == "goodscoverage") {  pattern =  "[filename],goodscoverage"; }
+        else if (type == "efron")       {  pattern =  "[filename],efron";           }
+        else if (type == "boneh")       {  pattern =  "[filename],boneh";           }
+        else if (type == "solow")       {  pattern =  "[filename],solow";           }
+        else if (type == "shen")        {  pattern =  "[filename],shen";            }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CollectCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 CollectCommand::CollectCommand(){      
@@ -355,6 +350,8 @@ int CollectCommand::execute(){
                        
                        if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); }
                        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
+            map<string, string> variables; 
+            variables["[filename]"] = fileNameRoot;
                        //globaldata->inputFileName = inputFileNames[p];
                
                        if (inputFileNames.size() > 1) {
@@ -366,80 +363,80 @@ int CollectCommand::execute(){
                        for (int i=0; i<Estimators.size(); i++) {
                                if (validCalculator.isValidCalculator("single", Estimators[i]) == true) { 
                                        if (Estimators[i] == "sobs") { 
-                                               cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("sobs"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("sobs")); outputTypes["sobs"].push_back(fileNameRoot+getOutputFileNameTag("sobs"));
+                                               cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(getOutputFileName("sobs", variables))));
+                                               outputNames.push_back(getOutputFileName("sobs", variables)); outputTypes["sobs"].push_back(getOutputFileName("sobs", variables));
                                        }else if (Estimators[i] == "chao") { 
-                                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("chao"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("chao")); outputTypes["chao"].push_back(fileNameRoot+getOutputFileNameTag("chao"));
+                                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(getOutputFileName("chao", variables))));
+                                               outputNames.push_back(getOutputFileName("chao", variables)); outputTypes["chao"].push_back(getOutputFileName("chao", variables));
                                        }else if (Estimators[i] == "nseqs") { 
-                                               cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("nseqs"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("nseqs")); outputTypes["nseqs"].push_back(fileNameRoot+getOutputFileNameTag("nseqs"));
+                                               cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(getOutputFileName("nseqs", variables))));
+                                               outputNames.push_back(getOutputFileName("nseqs", variables)); outputTypes["nseqs"].push_back(getOutputFileName("nseqs", variables));
                                        }else if (Estimators[i] == "coverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("coverage"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("coverage")); outputTypes["coverage"].push_back(fileNameRoot+getOutputFileNameTag("coverage"));
+                                               cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(getOutputFileName("coverage", variables))));
+                                               outputNames.push_back(getOutputFileName("coverage", variables)); outputTypes["coverage"].push_back(getOutputFileName("coverage", variables));
                                        }else if (Estimators[i] == "ace") { 
-                                               cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("ace"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("ace")); outputTypes["ace"].push_back(fileNameRoot+getOutputFileNameTag("ace"));
+                                               cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(getOutputFileName("ace", variables))));
+                                               outputNames.push_back(getOutputFileName("ace", variables)); outputTypes["ace"].push_back(getOutputFileName("ace", variables));
                                        }else if (Estimators[i] == "jack") { 
-                                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("jack"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("jack")); outputTypes["jack"].push_back(fileNameRoot+getOutputFileNameTag("jack"));
+                                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(getOutputFileName("jack", variables))));
+                                               outputNames.push_back(getOutputFileName("jack", variables)); outputTypes["jack"].push_back(getOutputFileName("jack", variables));
                                        }else if (Estimators[i] == "shannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("shannon"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("shannon")); outputTypes["shannon"].push_back(fileNameRoot+getOutputFileNameTag("shannon"));
+                                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(getOutputFileName("shannon", variables))));
+                                               outputNames.push_back(getOutputFileName("shannon", variables)); outputTypes["shannon"].push_back(getOutputFileName("shannon", variables));
                                        }else if (Estimators[i] == "shannoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new ShannonEven(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("shannoneven"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("shannoneven")); outputTypes["shannoneven"].push_back(fileNameRoot+getOutputFileNameTag("shannoneven"));
+                                               cDisplays.push_back(new CollectDisplay(new ShannonEven(), new OneColumnFile(getOutputFileName("shannoneven", variables))));
+                                               outputNames.push_back(getOutputFileName("shannoneven", variables)); outputTypes["shannoneven"].push_back(getOutputFileName("shannoneven", variables));
                                        }else if (Estimators[i] == "npshannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("npshannon"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("npshannon")); outputTypes["npshannon"].push_back(fileNameRoot+getOutputFileNameTag("npshannon"));
+                                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(getOutputFileName("npshannon", variables))));
+                                               outputNames.push_back(getOutputFileName("npshannon", variables)); outputTypes["npshannon"].push_back(getOutputFileName("npshannon", variables));
                                        }else if (Estimators[i] == "heip") { 
-                                               cDisplays.push_back(new CollectDisplay(new Heip(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("heip"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("heip")); outputTypes["heip"].push_back(fileNameRoot+getOutputFileNameTag("heip"));
+                                               cDisplays.push_back(new CollectDisplay(new Heip(), new OneColumnFile(getOutputFileName("heip", variables))));
+                                               outputNames.push_back(getOutputFileName("heip", variables)); outputTypes["heip"].push_back(getOutputFileName("heip", variables));
                                        }else if (Estimators[i] == "smithwilson") { 
-                                               cDisplays.push_back(new CollectDisplay(new SmithWilson(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("smithwilson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("smithwilson")); outputTypes["smithwilson"].push_back(fileNameRoot+getOutputFileNameTag("smithwilson"));
+                                               cDisplays.push_back(new CollectDisplay(new SmithWilson(), new OneColumnFile(getOutputFileName("smithwilson", variables))));
+                                               outputNames.push_back(getOutputFileName("smithwilson", variables)); outputTypes["smithwilson"].push_back(getOutputFileName("smithwilson", variables));
                                        }else if (Estimators[i] == "simpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("simpson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("simpson")); outputTypes["simpson"].push_back(fileNameRoot+getOutputFileNameTag("simpson"));
+                                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(getOutputFileName("simpson", variables))));
+                                               outputNames.push_back(getOutputFileName("simpson", variables)); outputTypes["simpson"].push_back(getOutputFileName("simpson", variables));
                                        }else if (Estimators[i] == "simpsoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new SimpsonEven(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("simpsoneven"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("simpsoneven")); outputTypes["simpsoneven"].push_back(fileNameRoot+getOutputFileNameTag("simpsoneven"));
+                                               cDisplays.push_back(new CollectDisplay(new SimpsonEven(), new OneColumnFile(getOutputFileName("simpsoneven", variables))));
+                                               outputNames.push_back(getOutputFileName("simpsoneven", variables)); outputTypes["simpsoneven"].push_back(getOutputFileName("simpsoneven", variables));
                                        }else if (Estimators[i] == "invsimpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("invsimpson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("invsimpson")); outputTypes["invsimpson"].push_back(fileNameRoot+getOutputFileNameTag("invsimpson"));
+                                               cDisplays.push_back(new CollectDisplay(new InvSimpson(), new ThreeColumnFile(getOutputFileName("invsimpson", variables))));
+                                               outputNames.push_back(getOutputFileName("invsimpson", variables)); outputTypes["invsimpson"].push_back(getOutputFileName("invsimpson", variables));
                                        }else if (Estimators[i] == "bootstrap") { 
-                                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("bootstrap"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("bootstrap")); outputTypes["bootstrap"].push_back(fileNameRoot+getOutputFileNameTag("bootstrap"));
+                                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(getOutputFileName("bootstrap", variables))));
+                                               outputNames.push_back(getOutputFileName("bootstrap", variables)); outputTypes["bootstrap"].push_back(getOutputFileName("bootstrap", variables));
                                        }else if (Estimators[i] == "geometric") { 
-                                               cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("geometric"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("geometric")); outputTypes["geometric"].push_back(fileNameRoot+getOutputFileNameTag("geometric"));
+                                               cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(getOutputFileName("geometric", variables))));
+                                               outputNames.push_back(getOutputFileName("geometric", variables)); outputTypes["geometric"].push_back(getOutputFileName("geometric", variables));
                                        }else if (Estimators[i] == "qstat") { 
-                                               cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("qstat"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("qstat")); outputTypes["qstat"].push_back(fileNameRoot+getOutputFileNameTag("qstat"));
+                                               cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(getOutputFileName("qstat", variables))));
+                                               outputNames.push_back(getOutputFileName("qstat", variables)); outputTypes["qstat"].push_back(getOutputFileName("qstat", variables));
                                        }else if (Estimators[i] == "logseries") { 
-                                               cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("logseries"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("logseries")); outputTypes["logseries"].push_back(fileNameRoot+getOutputFileNameTag("logseries"));
+                                               cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(getOutputFileName("logseries", variables))));
+                                               outputNames.push_back(getOutputFileName("logseries", variables)); outputTypes["logseries"].push_back(getOutputFileName("logseries", variables));
                                        }else if (Estimators[i] == "bergerparker") { 
-                                               cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("bergerparker"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("bergerparker")); outputTypes["bergerparker"].push_back(fileNameRoot+getOutputFileNameTag("bergerparker"));
+                                               cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(getOutputFileName("bergerparker", variables))));
+                                               outputNames.push_back(getOutputFileName("bergerparker", variables)); outputTypes["bergerparker"].push_back(getOutputFileName("bergerparker", variables));
                                        }else if (Estimators[i] == "bstick") { 
-                                               cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("bstick"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("bstick")); outputTypes["bstick"].push_back(fileNameRoot+getOutputFileNameTag("bstick"));
+                                               cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(getOutputFileName("bstick", variables))));
+                                               outputNames.push_back(getOutputFileName("bstick", variables)); outputTypes["bstick"].push_back(getOutputFileName("bstick", variables));
                                        }else if (Estimators[i] == "goodscoverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+getOutputFileNameTag("goodscoverage"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("goodscoverage")); outputTypes["goodscoverage"].push_back(fileNameRoot+getOutputFileNameTag("goodscoverage"));
+                                               cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(getOutputFileName("goodscoverage", variables))));
+                                               outputNames.push_back(getOutputFileName("goodscoverage", variables)); outputTypes["goodscoverage"].push_back(getOutputFileName("goodscoverage", variables));
                                        }else if (Estimators[i] == "efron") {
-                                               cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+getOutputFileNameTag("efron"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("efron")); outputTypes["efron"].push_back(fileNameRoot+getOutputFileNameTag("efron"));
+                                               cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(getOutputFileName("efron", variables))));
+                                               outputNames.push_back(getOutputFileName("efron", variables)); outputTypes["efron"].push_back(getOutputFileName("efron", variables));
                                        }else if (Estimators[i] == "boneh") {
-                                               cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+getOutputFileNameTag("boneh"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("boneh")); outputTypes["boneh"].push_back(fileNameRoot+getOutputFileNameTag("boneh"));
+                                               cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(getOutputFileName("boneh", variables))));
+                                               outputNames.push_back(getOutputFileName("boneh", variables)); outputTypes["boneh"].push_back(getOutputFileName("boneh", variables));
                                        }else if (Estimators[i] == "solow") {
-                                               cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+getOutputFileNameTag("solow"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("solow")); outputTypes["solow"].push_back(fileNameRoot+getOutputFileNameTag("solow"));
+                                               cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(getOutputFileName("solow", variables))));
+                                               outputNames.push_back(getOutputFileName("solow", variables)); outputTypes["solow"].push_back(getOutputFileName("solow", variables));
                                        }else if (Estimators[i] == "shen") {
-                                               cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(fileNameRoot+getOutputFileNameTag("shen"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("shen")); outputTypes["shen"].push_back(fileNameRoot+getOutputFileNameTag("shen"));
+                                               cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(getOutputFileName("shen", variables))));
+                                               outputNames.push_back(getOutputFileName("shen", variables)); outputTypes["shen"].push_back(getOutputFileName("shen", variables));
                                        }
                                }
                        }
index 1d8734fa5d713ad4535e067af55d3c56d699573c..ee1b914ee1594b4997a7706be60606e686fda305 100644 (file)
@@ -38,8 +38,9 @@ public:
        string getCommandName()                 { return "collect.single";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
        string getCitation() { return "Schloss PD, Handelsman J (2006). Introducing SONS, A tool that compares the membership of microbial communities. Appl Environ Microbiol 72: 6773-9. \nhttp://www.mothur.org/wiki/Collect.single"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getDescription()         { return "generates collector's curves using calculators, that describe the richness, diversity, and other features of individual samples"; }
        
        int execute(); 
index baebeb16298b28c3cd6372fe06a2de547e7bfbdc..dd1ec270334e09f1d316ce060c2ab8c185e0d313 100644 (file)
 //**********************************************************************************************************************
 vector<string> CollectSharedCommand::setParameters(){  
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pshared);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
+               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -98,63 +98,59 @@ string CollectSharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CollectSharedCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CollectSharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "sharedchao")               {  outputFileName =  "shared.chao";     }
-            else if (type == "sharedsobs")          {  outputFileName =  "shared.sobs";     }
-            else if (type == "sharedace")           {  outputFileName =  "shared.ace";      }
-            else if (type == "jabund")              {  outputFileName =  "jabund";          }
-            else if (type == "sorabund")            {  outputFileName =  "sorabund";        }
-            else if (type == "jclass")              {  outputFileName =  "jclass";          }
-            else if (type == "sorclass")            {  outputFileName =  "sorclass";        }
-            else if (type == "jest")                {  outputFileName =  "jest";            }
-            else if (type == "sorest")              {  outputFileName =  "sorest";          }
-            else if (type == "thetayc")             {  outputFileName =  "thetayc";         }
-            else if (type == "thetan")              {  outputFileName =  "thetan";          }
-            else if (type == "kstest")              {  outputFileName =  "kstest";          }
-            else if (type == "whittaker")           {  outputFileName =  "whittaker";       }
-            else if (type == "sharednseqs")         {  outputFileName =  "shared.nseqs";    }
-            else if (type == "ochiai")              {  outputFileName =  "ochiai";          }
-            else if (type == "anderberg")           {  outputFileName =  "anderberg";       }
-            else if (type == "kulczynski")          {  outputFileName =  "kulczynski";      }
-            else if (type == "kulczynskicody")      {  outputFileName =  "kulczynskicody";  }
-            else if (type == "lennon")              {  outputFileName =  "lennon";          }
-            else if (type == "morisitahorn")        {  outputFileName =  "morisitahorn";    }
-            else if (type == "braycurtis")          {  outputFileName =  "braycurtis";      }
-            else if (type == "odum")                {  outputFileName =  "odum";            }
-            else if (type == "canberra")            {  outputFileName =  "canberra";        }
-            else if (type == "structeuclidean")     {  outputFileName =  "structeuclidean"; }
-            else if (type == "structchord")         {  outputFileName =  "structchord";     }
-            else if (type == "hellinger")           {  outputFileName =  "hellinger";       }
-            else if (type == "manhattan")           {  outputFileName =  "manhattan";       }
-            else if (type == "structpearson")       {  outputFileName =  "structpearson";   }
-            else if (type == "soergel")             {  outputFileName =  "soergel";         }
-            else if (type == "spearman")            {  outputFileName =  "spearman";        }
-            else if (type == "structkulczynski")    {  outputFileName =  "structkulczynski";}
-            else if (type == "structchi2")          {  outputFileName =  "structchi2";      }
-            else if (type == "speciesprofile")      {  outputFileName =  "speciesprofile";  }
-            else if (type == "hamming")             {  outputFileName =  "hamming";         }
-            else if (type == "gower")               {  outputFileName =  "gower";           }
-            else if (type == "memchi2")             {  outputFileName =  "memchi2";         }
-            else if (type == "memchord")            {  outputFileName =  "memchord";        }
-            else if (type == "memeuclidean")        {  outputFileName =  "memeuclidean";    }
-            else if (type == "mempearson")          {  outputFileName =  "mempearson";      }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "sharedchao")               {  pattern =  "[filename],shared.chao";     }
+        else if (type == "sharedsobs")          {  pattern =  "[filename],shared.sobs";     }
+        else if (type == "sharedace")           {  pattern =  "[filename],shared.ace";      }
+        else if (type == "jabund")              {  pattern =  "[filename],jabund";          }
+        else if (type == "sorabund")            {  pattern =  "[filename],sorabund";        }
+        else if (type == "jclass")              {  pattern =  "[filename],jclass";          }
+        else if (type == "sorclass")            {  pattern =  "[filename],sorclass";        }
+        else if (type == "jest")                {  pattern =  "[filename],jest";            }
+        else if (type == "sorest")              {  pattern =  "[filename],sorest";          }
+        else if (type == "thetayc")             {  pattern =  "[filename],thetayc";         }
+        else if (type == "thetan")              {  pattern =  "[filename],thetan";          }
+        else if (type == "kstest")              {  pattern =  "[filename],kstest";          }
+        else if (type == "whittaker")           {  pattern =  "[filename],whittaker";       }
+        else if (type == "sharednseqs")         {  pattern =  "[filename],shared.nseqs";    }
+        else if (type == "ochiai")              {  pattern =  "[filename],ochiai";          }
+        else if (type == "anderberg")           {  pattern =  "[filename],anderberg";       }
+        else if (type == "kulczynski")          {  pattern =  "[filename],kulczynski";      }
+        else if (type == "kulczynskicody")      {  pattern =  "[filename],kulczynskicody";  }
+        else if (type == "lennon")              {  pattern =  "[filename],lennon";          }
+        else if (type == "morisitahorn")        {  pattern =  "[filename],morisitahorn";    }
+        else if (type == "braycurtis")          {  pattern =  "[filename],braycurtis";      }
+        else if (type == "odum")                {  pattern =  "[filename],odum";            }
+        else if (type == "canberra")            {  pattern =  "[filename],canberra";        }
+        else if (type == "structeuclidean")     {  pattern =  "[filename],structeuclidean"; }
+        else if (type == "structchord")         {  pattern =  "[filename],structchord";     }
+        else if (type == "hellinger")           {  pattern =  "[filename],hellinger";       }
+        else if (type == "manhattan")           {  pattern =  "[filename],manhattan";       }
+        else if (type == "structpearson")       {  pattern =  "[filename],structpearson";   }
+        else if (type == "soergel")             {  pattern =  "[filename],soergel";         }
+        else if (type == "spearman")            {  pattern =  "[filename],spearman";        }
+        else if (type == "structkulczynski")    {  pattern =  "[filename],structkulczynski";}
+        else if (type == "structchi2")          {  pattern =  "[filename],structchi2";      }
+        else if (type == "speciesprofile")      {  pattern =  "[filename],speciesprofile";  }
+        else if (type == "hamming")             {  pattern =  "[filename],hamming";         }
+        else if (type == "gower")               {  pattern =  "[filename],gower";           }
+        else if (type == "memchi2")             {  pattern =  "[filename],memchi2";         }
+        else if (type == "memchord")            {  pattern =  "[filename],memchord";        }
+        else if (type == "memeuclidean")        {  pattern =  "[filename],memeuclidean";    }
+        else if (type == "mempearson")          {  pattern =  "[filename],mempearson";      }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CollectSharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 CollectSharedCommand::CollectSharedCommand(){  
        try {
@@ -340,128 +336,130 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        if (abort == false) {
                                
                                string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(sharedfile));
-                               
+                               map<string, string> variables; 
+                variables["[filename]"] = fileNameRoot;
+                
                                ValidCalculators validCalculator;
                                
                                for (int i=0; i<Estimators.size(); i++) {
                                        if (validCalculator.isValidCalculator("shared", Estimators[i]) == true) { 
                                                if (Estimators[i] == "sharedchao") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sharedchao"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharedchao")); outputTypes["sharedchao"].push_back(fileNameRoot+getOutputFileNameTag("sharedchao"));
+                                                       cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(getOutputFileName("sharedchao", variables))));
+                                                       outputNames.push_back(getOutputFileName("sharedchao", variables)); outputTypes["sharedchao"].push_back(getOutputFileName("sharedchao", variables));
                                                }else if (Estimators[i] == "sharedsobs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sharedsobs"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharedsobs")); outputTypes["sharedsobs"].push_back(fileNameRoot+getOutputFileNameTag("sharedsobs"));
+                                                       cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(getOutputFileName("sharedsobs", variables))));
+                                                       outputNames.push_back(getOutputFileName("sharedsobs", variables)); outputTypes["sharedsobs"].push_back(getOutputFileName("sharedsobs", variables));
                                                }else if (Estimators[i] == "sharedace") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sharedace"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharedace")); outputTypes["sharedace"].push_back(fileNameRoot+getOutputFileNameTag("sharedace"));
+                                                       cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(getOutputFileName("sharedace", variables))));
+                                                       outputNames.push_back(getOutputFileName("sharedace", variables)); outputTypes["sharedace"].push_back(getOutputFileName("sharedace", variables));
                                                }else if (Estimators[i] == "jabund") {  
-                                                       cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("jabund"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("jabund")); outputTypes["jabund"].push_back(fileNameRoot+getOutputFileNameTag("jabund"));
+                                                       cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(getOutputFileName("jabund", variables))));
+                                                       outputNames.push_back(getOutputFileName("jabund", variables)); outputTypes["jabund"].push_back(getOutputFileName("jabund", variables));
                                                }else if (Estimators[i] == "sorabund") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sorabund"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sorabund")); outputTypes["sorabund"].push_back(fileNameRoot+getOutputFileNameTag("sorabund"));
+                                                       cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(getOutputFileName("sorabund", variables))));
+                                                       outputNames.push_back(getOutputFileName("sorabund", variables)); outputTypes["sorabund"].push_back(getOutputFileName("sorabund", variables));
                                                }else if (Estimators[i] == "jclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("jclass"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("jclass")); outputTypes["jclass"].push_back(fileNameRoot+getOutputFileNameTag("jclass"));
+                                                       cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(getOutputFileName("jclass", variables))));
+                                                       outputNames.push_back(getOutputFileName("jclass", variables)); outputTypes["jclass"].push_back(getOutputFileName("jclass", variables));
                                                }else if (Estimators[i] == "sorclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sorclass"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sorclass")); outputTypes["sorclass"].push_back(fileNameRoot+getOutputFileNameTag("sorclass"));
+                                                       cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(getOutputFileName("sorclass", variables))));
+                                                       outputNames.push_back(getOutputFileName("sorclass", variables)); outputTypes["sorclass"].push_back(getOutputFileName("sorclass", variables));
                                                }else if (Estimators[i] == "jest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("jest"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("jest")); outputTypes["jest"].push_back(fileNameRoot+getOutputFileNameTag("jest"));
+                                                       cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(getOutputFileName("jest", variables))));
+                                                       outputNames.push_back(getOutputFileName("jest", variables)); outputTypes["jest"].push_back(getOutputFileName("jest", variables));
                                                }else if (Estimators[i] == "sorest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sorest"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sorest")); outputTypes["sorest"].push_back(fileNameRoot+getOutputFileNameTag("sorest"));
+                                                       cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(getOutputFileName("sorest", variables))));
+                                                       outputNames.push_back(getOutputFileName("sorest", variables)); outputTypes["sorest"].push_back(getOutputFileName("sorest", variables));
                                                }else if (Estimators[i] == "thetayc") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("thetayc"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("thetayc")); outputTypes["thetayc"].push_back(fileNameRoot+getOutputFileNameTag("thetayc"));
+                                                       cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(getOutputFileName("thetayc", variables))));
+                                                       outputNames.push_back(getOutputFileName("thetayc", variables)); outputTypes["thetayc"].push_back(getOutputFileName("thetayc", variables));
                                                }else if (Estimators[i] == "thetan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("thetan"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("thetan")); outputTypes["thetan"].push_back(fileNameRoot+getOutputFileNameTag("thetan"));
+                                                       cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(getOutputFileName("thetan", variables))));
+                                                       outputNames.push_back(getOutputFileName("thetan", variables)); outputTypes["thetan"].push_back(getOutputFileName("thetan", variables));
                                                }else if (Estimators[i] == "kstest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("kstest"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("kstest")); outputTypes["kstest"].push_back(fileNameRoot+getOutputFileNameTag("kstest"));
+                                                       cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(getOutputFileName("kstest", variables))));
+                                                       outputNames.push_back(getOutputFileName("kstest", variables)); outputTypes["kstest"].push_back(getOutputFileName("kstest", variables));
                                                }else if (Estimators[i] == "whittaker") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("whittaker"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("whittaker")); outputTypes["whittaker"].push_back(fileNameRoot+getOutputFileNameTag("whittaker"));
+                                                       cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(getOutputFileName("whittaker", variables))));
+                                                       outputNames.push_back(getOutputFileName("whittaker", variables)); outputTypes["whittaker"].push_back(getOutputFileName("whittaker", variables));
                                                }else if (Estimators[i] == "sharednseqs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("sharednseqs"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharednseqs")); outputTypes["shared.nseqs"].push_back(fileNameRoot+getOutputFileNameTag("sharednseqs"));
+                                                       cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(getOutputFileName("sharednseqs", variables))));
+                                                       outputNames.push_back(getOutputFileName("sharednseqs", variables)); outputTypes["shared.nseqs"].push_back(getOutputFileName("sharednseqs", variables));
                                                }else if (Estimators[i] == "ochiai") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("ochiai"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("ochiai")); outputTypes["ochiai"].push_back(fileNameRoot+getOutputFileNameTag("ochiai"));
+                                                       cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(getOutputFileName("ochiai", variables))));
+                                                       outputNames.push_back(getOutputFileName("ochiai", variables)); outputTypes["ochiai"].push_back(getOutputFileName("ochiai", variables));
                                                }else if (Estimators[i] == "anderberg") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("anderberg"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("anderberg")); outputTypes["anderberg"].push_back(fileNameRoot+getOutputFileNameTag("anderberg"));
+                                                       cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(getOutputFileName("anderberg", variables))));
+                                                       outputNames.push_back(getOutputFileName("anderberg", variables)); outputTypes["anderberg"].push_back(getOutputFileName("anderberg", variables));
                                                }else if (Estimators[i] == "kulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("kulczynski"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("kulczynski")); outputTypes["kulczynski"].push_back(fileNameRoot+getOutputFileNameTag("kulczynski"));
+                                                       cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(getOutputFileName("kulczynski", variables))));
+                                                       outputNames.push_back(getOutputFileName("kulczynski", variables)); outputTypes["kulczynski"].push_back(getOutputFileName("kulczynski", variables));
                                                }else if (Estimators[i] == "kulczynskicody") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("kulczynskicody"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("kulczynskicody")); outputTypes["kulczynskicody"].push_back(fileNameRoot+getOutputFileNameTag("kulczynskicody"));
+                                                       cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(getOutputFileName("kulczynskicody", variables))));
+                                                       outputNames.push_back(getOutputFileName("kulczynskicody", variables)); outputTypes["kulczynskicody"].push_back(getOutputFileName("kulczynskicody", variables));
                                                }else if (Estimators[i] == "lennon") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("lennon"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("lennon")); outputTypes["lennon"].push_back(fileNameRoot+getOutputFileNameTag("lennon"));
+                                                       cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(getOutputFileName("lennon", variables))));
+                                                       outputNames.push_back(getOutputFileName("lennon", variables)); outputTypes["lennon"].push_back(getOutputFileName("lennon", variables));
                                                }else if (Estimators[i] == "morisitahorn") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("morisitahorn"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("morisitahorn")); outputTypes["morisitahorn"].push_back(fileNameRoot+getOutputFileNameTag("morisitahorn"));
+                                                       cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(getOutputFileName("morisitahorn", variables))));
+                                                       outputNames.push_back(getOutputFileName("morisitahorn", variables)); outputTypes["morisitahorn"].push_back(getOutputFileName("morisitahorn", variables));
                                                }else if (Estimators[i] == "braycurtis") { 
-                                                       cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("braycurtis"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("braycurtis")); outputTypes["braycurtis"].push_back(fileNameRoot+getOutputFileNameTag("braycurtis"));
+                                                       cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(getOutputFileName("braycurtis", variables))));
+                                                       outputNames.push_back(getOutputFileName("braycurtis", variables)); outputTypes["braycurtis"].push_back(getOutputFileName("braycurtis", variables));
                                                }else if (Estimators[i] == "odum") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("odum"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("odum")); outputTypes["odum"].push_back(fileNameRoot+getOutputFileNameTag("odum"));
+                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(getOutputFileName("odum", variables))));
+                                                       outputNames.push_back(getOutputFileName("odum", variables)); outputTypes["odum"].push_back(getOutputFileName("odum", variables));
                                                }else if (Estimators[i] == "canberra") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("canberra"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("canberra")); outputTypes["canberra"].push_back(fileNameRoot+getOutputFileNameTag("canberra"));
+                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(getOutputFileName("canberra", variables))));
+                                                       outputNames.push_back(getOutputFileName("canberra", variables)); outputTypes["canberra"].push_back(getOutputFileName("canberra", variables));
                                                }else if (Estimators[i] == "structeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructEuclidean(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("structeuclidean"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("structeuclidean")); outputTypes["structeuclidean"].push_back(fileNameRoot+getOutputFileNameTag("structeuclidean"));
+                                                       cDisplays.push_back(new CollectDisplay(new StructEuclidean(), new SharedOneColumnFile(getOutputFileName("structeuclidean", variables))));
+                                                       outputNames.push_back(getOutputFileName("structeuclidean", variables)); outputTypes["structeuclidean"].push_back(getOutputFileName("structeuclidean", variables));
                                                }else if (Estimators[i] == "structchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChord(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("structchord"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("structchord")); outputTypes["structchord"].push_back(fileNameRoot+getOutputFileNameTag("structchord"));
+                                                       cDisplays.push_back(new CollectDisplay(new StructChord(), new SharedOneColumnFile(getOutputFileName("structchord", variables))));
+                                                       outputNames.push_back(getOutputFileName("structchord", variables)); outputTypes["structchord"].push_back(getOutputFileName("structchord", variables));
                                                }else if (Estimators[i] == "hellinger") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("hellinger"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("hellinger")); outputTypes["hellinger"].push_back(fileNameRoot+getOutputFileNameTag("hellinger"));
+                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(getOutputFileName("hellinger", variables))));
+                                                       outputNames.push_back(getOutputFileName("hellinger", variables)); outputTypes["hellinger"].push_back(getOutputFileName("hellinger", variables));
                                                }else if (Estimators[i] == "manhattan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("manhattan"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("manhattan")); outputTypes["manhattan"].push_back(fileNameRoot+getOutputFileNameTag("manhattan"));
+                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(getOutputFileName("manhattan", variables))));
+                                                       outputNames.push_back(getOutputFileName("manhattan", variables)); outputTypes["manhattan"].push_back(getOutputFileName("manhattan", variables));
                                                }else if (Estimators[i] == "structpearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructPearson(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("structpearson"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("structpearson")); outputTypes["structpearson"].push_back(fileNameRoot+getOutputFileNameTag("structpearson"));
+                                                       cDisplays.push_back(new CollectDisplay(new StructPearson(), new SharedOneColumnFile(getOutputFileName("structpearson", variables))));
+                                                       outputNames.push_back(getOutputFileName("structpearson", variables)); outputTypes["structpearson"].push_back(getOutputFileName("structpearson", variables));
                                                }else if (Estimators[i] == "soergel") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("soergel"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("soergel")); outputTypes["soergel"].push_back(fileNameRoot+getOutputFileNameTag("soergel"));
+                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(getOutputFileName("soergel", variables))));
+                                                       outputNames.push_back(getOutputFileName("soergel", variables)); outputTypes["soergel"].push_back(getOutputFileName("soergel", variables));
                                                }else if (Estimators[i] == "spearman") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("spearman"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("spearman")); outputTypes["spearman"].push_back(fileNameRoot+getOutputFileNameTag("spearman"));
+                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(getOutputFileName("spearman", variables))));
+                                                       outputNames.push_back(getOutputFileName("spearman", variables)); outputTypes["spearman"].push_back(getOutputFileName("spearman", variables));
                                                }else if (Estimators[i] == "structkulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructKulczynski(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("structkulczynski"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("structkulczynski")); outputTypes["structkulczynski"].push_back(fileNameRoot+getOutputFileNameTag("structkulczynski"));
+                                                       cDisplays.push_back(new CollectDisplay(new StructKulczynski(), new SharedOneColumnFile(getOutputFileName("structkulczynski", variables))));
+                                                       outputNames.push_back(getOutputFileName("structkulczynski", variables)); outputTypes["structkulczynski"].push_back(getOutputFileName("structkulczynski", variables));
                                                }else if (Estimators[i] == "speciesprofile") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("speciesprofile"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("speciesprofile")); outputTypes["speciesprofile"].push_back(fileNameRoot+getOutputFileNameTag("speciesprofile"));
+                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(getOutputFileName("speciesprofile", variables))));
+                                                       outputNames.push_back(getOutputFileName("speciesprofile", variables)); outputTypes["speciesprofile"].push_back(getOutputFileName("speciesprofile", variables));
                                                }else if (Estimators[i] == "hamming") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("hamming"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("hamming")); outputTypes["hamming"].push_back(fileNameRoot+getOutputFileNameTag("hamming"));
+                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(getOutputFileName("hamming", variables))));
+                                                       outputNames.push_back(getOutputFileName("hamming", variables)); outputTypes["hamming"].push_back(getOutputFileName("hamming", variables));
                                                }else if (Estimators[i] == "structchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChi2(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("structchi2"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("structchi2")); outputTypes["structchi2"].push_back(fileNameRoot+getOutputFileNameTag("structchi2"));
+                                                       cDisplays.push_back(new CollectDisplay(new StructChi2(), new SharedOneColumnFile(getOutputFileName("structchi2", variables))));
+                                                       outputNames.push_back(getOutputFileName("structchi2", variables)); outputTypes["structchi2"].push_back(getOutputFileName("structchi2", variables));
                                                }else if (Estimators[i] == "gower") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Gower(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("gower"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("gower")); outputTypes["gower"].push_back(fileNameRoot+getOutputFileNameTag("gower"));
+                                                       cDisplays.push_back(new CollectDisplay(new Gower(), new SharedOneColumnFile(getOutputFileName("gower", variables))));
+                                                       outputNames.push_back(getOutputFileName("gower", variables)); outputTypes["gower"].push_back(getOutputFileName("gower", variables));
                                                }else if (Estimators[i] == "memchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChi2(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("memchi2"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("memchi2")); outputTypes["memchi2"].push_back(fileNameRoot+getOutputFileNameTag("memchi2"));
+                                                       cDisplays.push_back(new CollectDisplay(new MemChi2(), new SharedOneColumnFile(getOutputFileName("memchi2", variables))));
+                                                       outputNames.push_back(getOutputFileName("memchi2", variables)); outputTypes["memchi2"].push_back(getOutputFileName("memchi2", variables));
                                                }else if (Estimators[i] == "memchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChord(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("memchord"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("memchord")); outputTypes["memchord"].push_back(fileNameRoot+getOutputFileNameTag("memchord"));
+                                                       cDisplays.push_back(new CollectDisplay(new MemChord(), new SharedOneColumnFile(getOutputFileName("memchord", variables))));
+                                                       outputNames.push_back(getOutputFileName("memchord", variables)); outputTypes["memchord"].push_back(getOutputFileName("memchord", variables));
                                                }else if (Estimators[i] == "memeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemEuclidean(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("memeuclidean"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("memeuclidean")); outputTypes["memeuclidean"].push_back(fileNameRoot+getOutputFileNameTag("memeuclidean"));
+                                                       cDisplays.push_back(new CollectDisplay(new MemEuclidean(), new SharedOneColumnFile(getOutputFileName("memeuclidean", variables))));
+                                                       outputNames.push_back(getOutputFileName("memeuclidean", variables)); outputTypes["memeuclidean"].push_back(getOutputFileName("memeuclidean", variables));
                                                }else if (Estimators[i] == "mempearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemPearson(), new SharedOneColumnFile(fileNameRoot+getOutputFileNameTag("mempearson"))));
-                                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("mempearson")); outputTypes["mempearson"].push_back(fileNameRoot+getOutputFileNameTag("mempearson"));
+                                                       cDisplays.push_back(new CollectDisplay(new MemPearson(), new SharedOneColumnFile(getOutputFileName("mempearson", variables))));
+                                                       outputNames.push_back(getOutputFileName("mempearson", variables)); outputTypes["mempearson"].push_back(getOutputFileName("mempearson", variables));
                                                }
                                                
                                        }
index d0908de54afb261e4e8184efd6910c3238848d2b..868cd473b29cb97ba5ee38f847aab8343e06c3ac 100644 (file)
@@ -29,8 +29,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "collect.shared";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Handelsman J (2006). Introducing SONS, A tool that compares the membership of microbial communities. Appl Environ Microbiol 72: 6773-9. \nhttp://www.mothur.org/wiki/Collect.shared"; }
        string getDescription()         { return "generates collector's curves for calculators, which describe the similarity between communities or their shared richness"; }
 
index f5e09042234f1c39ac8010f859e6f69708871dc3..2ba35ab14308ded53d6868586d8695799cbb25a0 100644 (file)
@@ -33,7 +33,69 @@ class Command {
                virtual string getDescription() = 0;
                
                virtual map<string, vector<string> > getOutputFiles() { return outputTypes; }
-        virtual string getOutputFileNameTag(string, string) = 0;  //we may not know the complete filename, because some commands use info from the file to create the output file name (ie label). but we do the ending tag which should be enough to find the output file name from a list. Allows for optional passing of the inputFileName for the commands that require its extension.
+        string getOutputFileName(string type, map<string, string> variableParts) {  //uses the pattern to create an output filename for a given type and input file name.  
+               try {
+                    string filename = "";
+                    map<string, vector<string> >::iterator it;
+                    
+                    //is this a type this command creates
+                    it = outputTypes.find(type);
+                    if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
+                    else {
+                        
+                        string patternTemp = getOutputPattern(type);
+                        vector<string> patterns;
+                        m->splitAtDash(patternTemp, patterns);
+                        
+                        //find pattern to use based on number of variables passed in
+                        string pattern = "";
+                        bool foundPattern = false;
+                        for (int i = 0; i < patterns.size(); i++) {
+                            int numVariables = 0;
+                            for (int j = 0; j < patterns[i].length(); j++) { if (patterns[i][j] == '[') { numVariables++; } }
+                            
+                            if (numVariables == variableParts.size()) { pattern = patterns[i]; foundPattern = true; break; }
+                        }
+                        
+                        if (!foundPattern) {  m->mothurOut("[ERROR]: Not enough variable pieces for " + type + ".\n"); m->control_pressed = true; }
+                        
+                        if (pattern != "") {
+                            int numVariables = 0;
+                            for (int i = 0; i < pattern.length(); i++) { if (pattern[i] == '[') { numVariables++; } }
+                            
+                            vector<string> pieces;
+                            m->splitAtComma(pattern, pieces);
+                            
+                        
+                            for (int i = 0; i < pieces.size(); i++) {
+                                if (pieces[i][0] == '[') {
+                                    map<string, string>::iterator it = variableParts.find(pieces[i]);
+                                    if (it == variableParts.end()) {
+                                        m->mothurOut("[ERROR]: Did not provide variable for " + pieces[i] + ".\n"); m->control_pressed = true;
+                                    }else {
+                                        if (it->second != "") {
+                                            if (it->first != "[filename]") { filename += it->second + "."; }
+                                            else { filename += it->second; }
+                                        }
+                                    }
+                                }else {
+                                    filename += pieces[i] + ".";
+                                }
+                            }
+                            if (filename.length() > 0) { //rip off last "."
+                                filename = filename.substr(0, filename.length()-1);
+                            }
+                        }
+                    }
+                    return filename;
+                }
+                catch(exception& e) {
+                    m->errorOut(e, "command", "getOutputFileName");
+                    exit(1);
+                }
+        }
+        
+        virtual string getOutputPattern(string) = 0; //pass in type, returns something like: [filename],align or [filename],[distance],subsample.shared  strings in [] means its a variable.  This is used by the gui to predict output file names.  use variable keywords: [filename], [distance], [group], [extension], [tag]
                virtual vector<string> setParameters() = 0; //to fill parameters
                virtual vector<CommandParameter> getParameters() { return parameters; }
        
index 9dda0a17b77cc77027326f148735731d3848009c..3c622c65913fede9a386a58c02475bda3ce6dd54 100644 (file)
 class CommandParameter {
        
        public:
-               CommandParameter() { name = ""; type = ""; options = ""; optionsDefault = ""; chooseOnlyOneGroup = ""; chooseAtLeastOneGroup = ""; linkedGroup = ""; multipleSelectionAllowed = false; required = false; }
-               CommandParameter(string n, string t, string o, string d, string only, string atLeast, string linked, bool m, bool r) : name(n), type(t), options(o), optionsDefault(d), 
-                               chooseOnlyOneGroup(only), chooseAtLeastOneGroup(atLeast), linkedGroup(linked), multipleSelectionAllowed(m), required(r) {}
+    CommandParameter() { name = ""; type = ""; options = ""; optionsDefault = ""; chooseOnlyOneGroup = ""; chooseAtLeastOneGroup = ""; linkedGroup = ""; multipleSelectionAllowed = false; required = false; important = false; outputTypes = ""; }
+               CommandParameter(string n, string t, string o, string d, string only, string atLeast, string linked, string opt, bool m, bool r, bool i) : name(n), type(t), options(o), optionsDefault(d), 
+                               chooseOnlyOneGroup(only), chooseAtLeastOneGroup(atLeast), linkedGroup(linked), outputTypes(opt),multipleSelectionAllowed(m), required(r), important(i) {}
+        CommandParameter(string n, string t, string o, string d, string only, string atLeast, string linked, string opt, bool m, bool r) : name(n), type(t), options(o), optionsDefault(d), 
+    chooseOnlyOneGroup(only), chooseAtLeastOneGroup(atLeast), linkedGroup(linked), outputTypes(opt), multipleSelectionAllowed(m), required(r)  { important = false; }
                ~CommandParameter() {}
        
                string name;            //something like fasta, processors, method
@@ -37,11 +39,14 @@ class CommandParameter {
                string chooseAtLeastOneGroup; //for file inputs: if a command has several options for input files and you want to make sure one is choosen then put them in a group
                                                                        //for instance in the read.dist command you must provide a phylip or column file so set chooseAtLeastOneGroup for both parameters to something like "DistanceFileGroup"
                string linkedGroup; //for file inputs: if a command has a file option were if you provide one you must provide another you can put them in a group
-                                                                               //for instance in the read.dist command if you provide a column file you must provide a name file so set linkedGroup for both parameters to something like "ColumnNameGroup"
+                                                                               //for instance in the cluster command if you provide a column file you must provide a name file so set linkedGroup for both parameters to something like "ColumnNameGroup"
 
                bool multipleSelectionAllowed; //for "Multiple" type to say whether you can select multiple options, for instance for calc parameter set to true, but for method set to false
                bool required; //is this parameter required
-       
+    
+        bool important; //is this parameter important.  The gui will put "important" parameters first in the option panel.
+        
+        string outputTypes; //types on files created by the command if this parameter is given.  ie. get.seqs command fasta parameter makes a fasta file. can be multiple values split by dashes.
                
        private:
 };
index 4134a52a3ce1e680a8a440672d48be192be5f04c..f0fc6bff9da6d6d8b0ed8b368ad2422f25cd732a 100644 (file)
 //**********************************************************************************************************************
 vector<string> ConsensusSeqsCommand::setParameters(){  
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "100", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","fasta-name",false,false,true); parameters.push_back(plist);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcutoff("cutoff", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -55,29 +55,23 @@ string ConsensusSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ConsensusSeqsCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ConsensusSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "cons.fasta"; }
-            else if (type == "name") {  outputFileName =  "cons.names"; }
-            else if (type == "count") {  outputFileName =  "cons.count_table"; }
-            else if (type == "summary") {  outputFileName =  "cons.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],cons.fasta-[filename],[tag],cons.fasta"; } 
+        else if (type == "name") {  pattern = "[filename],cons.names-[filename],[tag],cons.names"; } 
+        else if (type == "count") {  pattern = "[filename],cons.count_table-[filename],[tag],cons.count_table"; }
+        else if (type == "summary") {  pattern = "[filename],cons.summary-[filename],[tag],cons.summary"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ConsensusSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ConsensusSeqsCommand::ConsensusSeqsCommand(){  
        try {
@@ -238,7 +232,9 @@ int ConsensusSeqsCommand::execute(){
                if (listfile == "") {
                        
                        ofstream outSummary;
-                       string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+                       string outputSummaryFile = getOutputFileName("summary", variables);
                        m->openOutputFile(outputSummaryFile, outSummary);
                        outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
                        outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
@@ -246,7 +242,7 @@ int ConsensusSeqsCommand::execute(){
                        outSummary << "PositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
                        
                        ofstream outFasta;
-                       string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
+                       string outputFastaFile = getOutputFileName("fasta", variables);
                        m->openOutputFile(outputFastaFile, outFasta);
                        outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
         
@@ -415,18 +411,21 @@ int ConsensusSeqsCommand::processList(ListVector*& list){
        try{
                
                ofstream outSummary;
-               string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[tag]"] = list->getLabel();
+               string outputSummaryFile = getOutputFileName("summary", variables);
                m->openOutputFile(outputSummaryFile, outSummary);
                outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
                outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
                
                ofstream outName;
-               string outputNameFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("name");
+               string outputNameFile = getOutputFileName("name",variables);
                m->openOutputFile(outputNameFile, outName);
                outputNames.push_back(outputNameFile); outputTypes["name"].push_back(outputNameFile);
                
                ofstream outFasta;
-               string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("fasta");
+               string outputFastaFile = getOutputFileName("fasta",variables);
                m->openOutputFile(outputFastaFile, outFasta);
                outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
                
index e0c97150bfb0bc3e5baafcea911c4ba1c6c60dcb..a69ddbf9197f6ca0264d467ff4c7428c79f56f02 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "consensus.seqs";              }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Consensus.seqs"; }
        string getDescription()         { return "create a consensus sequence for each OTU or for a fasta file"; }
 
index ef8c9eddce64e93092df8ed1031b37684f09fe38..78be06f28bd4e6d9b476f9bc92a1fcbb4c9d8365 100644 (file)
 //**********************************************************************************************************************
 vector<string> CooccurrenceCommand::setParameters() {  
        try { 
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);             
-               CommandParameter pmetric("metric", "Multiple", "cscore-checker-combo-vratio", "cscore", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter pmatrix("matrixmodel", "Multiple", "sim1-sim2-sim3-sim4-sim5-sim6-sim7-sim8-sim9", "sim2", "", "", "",false,false); parameters.push_back(pmatrix);
-        CommandParameter pruns("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pruns);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pshared);              
+               CommandParameter pmetric("metric", "Multiple", "cscore-checker-combo-vratio", "cscore", "", "", "","",false,false); parameters.push_back(pmetric);
+               CommandParameter pmatrix("matrixmodel", "Multiple", "sim1-sim2-sim3-sim4-sim5-sim6-sim7-sim8-sim9", "sim2", "", "", "","",false,false); parameters.push_back(pmatrix);
+        CommandParameter pruns("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(pruns);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+        CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -51,24 +51,19 @@ string CooccurrenceCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CooccurrenceCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CooccurrenceCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary") {  outputFileName =  "cooccurence.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],cooccurence.summary"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CooccurrenceCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 CooccurrenceCommand::CooccurrenceCommand(){    
@@ -196,7 +191,9 @@ int CooccurrenceCommand::execute(){
                set<string> userLabels = labels;
 
         ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+               string outputFileName = getOutputFileName("summary", variables);
         m->openOutputFile(outputFileName, out);
         outputNames.push_back(outputFileName);  outputTypes["summary"].push_back(outputFileName);
         out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
index 08209190f3f51b0e334706530afed253684eb75e..758a9fff0c155261c1efbe60e7a0992d9b215681 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "Cooccurrence";                        }
        string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Ulrich W & Gotelli NJ (2010).  Null model analysis of species associations using abundance data.  Ecology  91:3384.\nhttp://www.mothur.org/wiki/Cooccurrence"; }
        string getDescription()         { return "calculates four metrics and tests their significance to assess whether presence-absence patterns are different than what one would expect by chance."; }
        
index c4454a5181c719302011e6e98410408826183735..853c174ac63012c2ebf8d21800c4886138f8ab16 100644 (file)
 //**********************************************************************************************************************
 vector<string> CorrAxesCommand::setParameters(){       
        try {
-               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paxes);
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pmetadata);
-               CommandParameter pnumaxes("numaxes", "Number", "", "3", "", "", "",false,false); parameters.push_back(pnumaxes);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none","corraxes",false,true,true); parameters.push_back(paxes);
+               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false,true); parameters.push_back(pshared);
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false,true); parameters.push_back(prelabund);
+               CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","",false,false); parameters.push_back(pmetadata);
+               CommandParameter pnumaxes("numaxes", "Number", "", "3", "", "", "","",false,false); parameters.push_back(pnumaxes);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -56,25 +56,21 @@ string CorrAxesCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CorrAxesCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CorrAxesCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "corraxes") {  outputFileName =  "corr.axes"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "corraxes") {  pattern = "[filename],[tag],corr.axes"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CorrAxesCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 CorrAxesCommand::CorrAxesCommand(){    
        try {
@@ -285,8 +281,10 @@ int CorrAxesCommand::execute(){
                /*************************************************************************************/
                // calc the r values                                                                                                                            //
                /************************************************************************************/
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + "." + getOutputFileNameTag("corraxes");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[tag]"] = method;
+               string outputFileName = getOutputFileName("corraxes", variables);
                outputNames.push_back(outputFileName); outputTypes["corraxes"].push_back(outputFileName);       
                ofstream out;
                m->openOutputFile(outputFileName, out);
index 067228f88ae5c55406021880ea21f4dde2018ce0..a91a24019c46b1b8d7346fd87e5a45ea957242a9 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "corr.axes";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Corr.axes"; }
        string getDescription()         { return "calculate the correlation coefficient for each column in a shared/relabund file to the axes displayed in a pcoa file"; }
        
index 716dc90693969140d3af32403d3818c04224d7f9..215c2e5a24c925e449ecbb297f267c463f283d39 100644 (file)
 //**********************************************************************************************************************
 vector<string> CountGroupsCommand::setParameters(){    
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter pcount("count", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none",false,false); parameters.push_back(pcount);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none","",false,false,true); parameters.push_back(pshared);
+               CommandParameter pgroup("group", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none","",false,false,true); parameters.push_back(pgroup);
+        CommandParameter pcount("count", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index d27a7f8f94ce1577421061e862696de4a4856a2a..1ab83c86ea98cb5a9bdd5c43e31558cbe4971307 100644 (file)
@@ -23,8 +23,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "count.groups";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
+    string getOutputPattern(string){ return ""; }      
        string getCitation() { return "http://www.mothur.org/wiki/Count.groups"; }
        string getDescription()         { return "counts the number of sequences in each group"; }
        
index e4aa253b8d150db93a0b57f97f11d2df678b3d2a..3bafbcd71752b48e675e0d85fcf037cc896056dc 100644 (file)
 //**********************************************************************************************************************
 vector<string> CountSeqsCommand::setParameters(){      
        try {
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","count",false,true,true); parameters.push_back(pname);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(pgroup);
+        CommandParameter plarge("large", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -50,24 +50,19 @@ string CountSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CountSeqsCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CountSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "counttable") {  outputFileName =  "count_table"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "count") {  pattern = "[filename],count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CountSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 CountSeqsCommand::CountSeqsCommand(){  
@@ -75,7 +70,7 @@ CountSeqsCommand::CountSeqsCommand(){
                abort = true; calledHelp = true; 
                setParameters();
                vector<string> tempOutNames;
-               outputTypes["counttable"] = tempOutNames;
+               outputTypes["count"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "CountSeqsCommand", "CountSeqsCommand");
@@ -107,7 +102,7 @@ CountSeqsCommand::CountSeqsCommand(string option)  {
                        
                        //initialize outputTypes
                        vector<string> tempOutNames;
-                       outputTypes["counttable"] = tempOutNames;
+                       outputTypes["count"] = tempOutNames;
                        
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -171,7 +166,9 @@ int CountSeqsCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("counttable");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(namefile));
+               string outputFileName = getOutputFileName("count", variables);
                
         int total = 0;
         if (!large) { total = processSmall(outputFileName); }
@@ -180,7 +177,7 @@ int CountSeqsCommand::execute(){
                if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; }
                
         //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("counttable");
+               itTypes = outputTypes.find("count");
                if (itTypes != outputTypes.end()) {
                        if ((itTypes->second).size() != 0) { string current = (itTypes->second)[0]; m->setCountTableFile(current); }
                }
@@ -205,8 +202,8 @@ int CountSeqsCommand::execute(){
 int CountSeqsCommand::processSmall(string outputFileName){
        try {
         ofstream out;
-        m->openOutputFile(outputFileName, out); outputTypes["counttable"].push_back(outputFileName);
-        outputNames.push_back(outputFileName); outputTypes["counttable"].push_back(outputFileName);
+        m->openOutputFile(outputFileName, out); outputTypes["count"].push_back(outputFileName);
+        outputNames.push_back(outputFileName); outputTypes["count"].push_back(outputFileName);
                out << "Representative_Sequence\ttotal\t";
         
         GroupMap* groupMap;
@@ -299,7 +296,7 @@ int CountSeqsCommand::processLarge(string outputFileName){
         for (set<string>::iterator it = namesOfGroups.begin(); it != namesOfGroups.end(); it++) { initial[(*it)] = 0;  }
         ofstream out;
         m->openOutputFile(outputFileName, out); 
-        outputNames.push_back(outputFileName); outputTypes["counttable"].push_back(outputFileName);
+        outputNames.push_back(outputFileName); outputTypes["count"].push_back(outputFileName);
                out << "Representative_Sequence\ttotal\t";
         if (groupfile == "") { out << endl; }
         
index 555d6a74fa36fa034b6d0aafeb5f07bd0c4e7bbc..b4170a8867897b96e13f7483f6053b960f7629b4 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "count.seqs";                          }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Count.seqs"; }
        string getDescription()         { return "counts the number of sequences represented by each unique sequence in a namesfile"; }
 
index 4331c29249338ec1a9d9e57b0328dcd65945bdf6..51211395356228a5e3b9b3f554a399da3a558c30 100644 (file)
 //**********************************************************************************************************************
 vector<string> CreateDatabaseCommand::setParameters(){ 
        try {
-               CommandParameter pfasta("repfasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("repname", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pcontaxonomy);
-               CommandParameter plist("list", "InputTypes", "", "", "ListShared", "ListShared", "none",false,false); parameters.push_back(plist);
-        CommandParameter pshared("shared", "InputTypes", "", "", "ListShared", "ListShared", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("repfasta", "InputTypes", "", "", "none", "none", "none","database",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("repname", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pname);
+               CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pcontaxonomy);
+               CommandParameter plist("list", "InputTypes", "", "", "ListShared", "ListShared", "none","",false,false,true); parameters.push_back(plist);
+        CommandParameter pshared("shared", "InputTypes", "", "", "ListShared", "ListShared", "none","",false,false,true); parameters.push_back(pshared);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pgroup);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -55,26 +55,20 @@ string CreateDatabaseCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string CreateDatabaseCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string CreateDatabaseCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "database") {  outputFileName =  "database"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "database") {  pattern = "[filename],database"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "CreateDatabaseCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 CreateDatabaseCommand::CreateDatabaseCommand(){        
        try {
@@ -281,9 +275,10 @@ int CreateDatabaseCommand::execute(){
         if (m->control_pressed) { return 0; }
         
         
-        string outputFileName = "";
-        if (listfile != "") { outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("database"); }
-        else { outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("database"); }
+        map<string, string> variables; 
+        if (listfile != "") {  variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile)); }
+        else { variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile)); }
+        string outputFileName = getOutputFileName("database", variables); 
         outputNames.push_back(outputFileName); outputTypes["database"].push_back(outputFileName);
         
         ofstream out;
index 741feba082958ae8e4f2ec73f7a188255208b069..ca47b7a3e1ce1e3b8dafcdffe7280e1d0510418c 100644 (file)
@@ -22,8 +22,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "create.database";             }
        string getCommandCategory()             { return "OTU-Based Approaches"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Create.database"; }
        string getDescription()         { return "creates database file that includes, abundances across groups, representative sequences, and taxonomy for each OTU"; }
     
index 90a40ce8e86dbe6a6e3cba8cb9d070de374805cc..f33a1400721093ee642c90d35c70fed703fdb6a5 100644 (file)
 //**********************************************************************************************************************
 vector<string> DeconvoluteCommand::setParameters(){    
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","count",false,false,true); parameters.push_back(pcount);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,27 +46,23 @@ string DeconvoluteCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string DeconvoluteCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string DeconvoluteCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "unique" + m->getExtension(inputName); }
-            else if (type == "name") {  outputFileName =  "names"; }
-            else if (type == "count") {  outputFileName =  "count_table"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],unique,[extension]"; } 
+        else if (type == "name") {  pattern = "[filename],names-[filename],[tag],names"; } 
+        else if (type == "count") {  pattern = "[filename],count_table-[filename],[tag],count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "DeconvoluteCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 DeconvoluteCommand::DeconvoluteCommand(){      
        try {
@@ -192,20 +188,27 @@ int DeconvoluteCommand::execute() {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
 
                //prepare filenames and open files
-               string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("name");
-        string outCountFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("count");
-               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("fasta", inFastaName);
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inFastaName));
+        string outNameFile = getOutputFileName("name", variables);
+        string outCountFile = getOutputFileName("count", variables);
+        variables["[extension]"] = m->getExtension(inFastaName);
+               string outFastaFile = getOutputFileName("fasta", variables);
                
                map<string, string> nameMap;
                map<string, string>::iterator itNames;
                if (oldNameMapFName != "")  {  
             m->readNames(oldNameMapFName, nameMap); 
-            if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("name");   }
+            if (oldNameMapFName == outNameFile){ 
+                variables["[tag]"] = "unique";
+                outNameFile = getOutputFileName("name", variables);   }
         }
         CountTable ct;
         if (countfile != "")  {  
             ct.readTable(countfile);
-            if (countfile == outCountFile){ outCountFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("count");   }
+            if (countfile == outCountFile){ 
+                variables["[tag]"] = "unique";
+                outCountFile = getOutputFileName("count", variables);   }
         }
                
                if (m->control_pressed) { return 0; }
index 673ffc9e4d2e689cd32c6b16867089fe43f216d1..e514bdae70f7e0b51854b40baacf44d2b0174c8a 100644 (file)
@@ -27,8 +27,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "unique.seqs";         }
        string getCommandCategory()             { return "Sequence Processing";         }
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Unique.seqs"; }
        string getDescription()         { return "creates a fasta containing the unique sequences as well as a namesfile with the names each sequence represents"; }
 
index 095eef30e6691a6eeaca8bd77fdda26bb4febb31..8687194778d2da8360b3367c3c5ec2bb00108431 100644 (file)
@@ -13,9 +13,9 @@
 //**********************************************************************************************************************
 vector<string> DegapSeqsCommand::setParameters(){      
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,24 +46,19 @@ string DegapSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string DegapSeqsCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string DegapSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "ng.fasta"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],ng.fasta"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "DegapSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 DegapSeqsCommand::DegapSeqsCommand(){  
@@ -213,7 +208,9 @@ int DegapSeqsCommand::execute(){
                        ofstream outFASTA;
                        string tempOutputDir = outputDir;
                        if (outputDir == "") { tempOutputDir = m->hasPath(fastaFileNames[s]); }
-                       string degapFile = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("fasta");
+            map<string, string> variables; 
+            variables["[filename]"] = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
+                       string degapFile = getOutputFileName("fasta", variables);
                        m->openOutputFile(degapFile, outFASTA);
                        
                        while(!inFASTA.eof()){
index c6adac214e0339807ac9fee9845ef404dee311cb..3b03c9b0ca1d8a61704dd3c13885d12d8204100a 100644 (file)
@@ -22,8 +22,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "degap.seqs";          }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Degap.seqs"; }
        string getDescription()         { return "removes gap characters from sequences"; }
 
index 918079cfe45aa2fbe6f14b155a6edd494e555c1d..f72a7c9c7e1264265d4d28e1072e087cf501c288 100644 (file)
 //**********************************************************************************************************************
 vector<string> DeUniqueSeqsCommand::setParameters(){   
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pname);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -45,24 +45,19 @@ string DeUniqueSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string DeUniqueSeqsCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string DeUniqueSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "redundant.fasta"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],redundant.fasta"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "DeUniqueSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 DeUniqueSeqsCommand::DeUniqueSeqsCommand(){    
@@ -167,11 +162,11 @@ int DeUniqueSeqsCommand::execute() {
                ofstream out;
                string outFastaFile = m->getRootName(m->getSimpleName(fastaFile));
                int pos = outFastaFile.find("unique");
-               if (pos != string::npos) {
-                       outFastaFile = outputDir + outFastaFile.substr(0, pos) + getOutputFileNameTag("fasta");
-               }else{
-                       outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + getOutputFileNameTag("fasta");
-               }
+               if (pos != string::npos) { outFastaFile = outputDir + outFastaFile.substr(0, pos); }
+        else { outFastaFile = outputDir + outFastaFile; }
+        map<string, string> variables; 
+        variables["[filename]"] = outFastaFile;
+        outFastaFile = getOutputFileName("fasta", variables);
                m->openOutputFile(outFastaFile, out);
                
                readNamesFile();
index 5310b83b3002c8b3d52b32bdb56bf8cc772eddd2..a6d467a16a96c56ca3f1282d7c7fbbdfbdf02ca7 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "deunique.seqs";               }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Deunique.seqs"; }
        string getDescription()         { return "reverse of the unique.seqs command, and creates a fasta file from a fasta and name file"; }
 
index d334f8f4ef107d12a57eaa4aff4d71b84808edb9..703e75f21be03d4cba59d994f68932301d84a946 100644 (file)
 //**********************************************************************************************************************
 vector<string> DeuniqueTreeCommand::setParameters(){   
        try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","tree",false,true,true); parameters.push_back(ptree);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pname);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -43,24 +43,19 @@ string DeuniqueTreeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string DeuniqueTreeCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string DeuniqueTreeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "tree") {  outputFileName =  "deunique.tre"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "tree") {  pattern = "[filename],deunique.tre"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "DeuniqueTreeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 DeuniqueTreeCommand::DeuniqueTreeCommand(){    
@@ -166,7 +161,9 @@ int DeuniqueTreeCommand::execute() {
         delete reader;         
                
                //print new Tree
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+               string outputFile = getOutputFileName("tree", variables);
                outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                ofstream out;
                m->openOutputFile(outputFile, out);
index afb25a4a2b777c49f57f16884e36f871568ab1ac..849b3d7fef9bfbaa9cb97aaf4e2d38cf1f0bf5c4 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "deunique.tree";               }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Deunique.tree"; }
        string getDescription()         { return "add the redundant sequence names back into a tree of unique sequences"; }
        
index 2a4398baf2773c491d91a2ff8be7fb35ebc12986..73a38bfe023025be8b5533e20f72d28539a09cde 100644 (file)
 //**********************************************************************************************************************
 vector<string> DistanceCommand::setParameters(){       
        try {
-               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "OldFastaColumn",false,false); parameters.push_back(pcolumn);
-               CommandParameter poldfasta("oldfasta", "InputTypes", "", "", "none", "none", "OldFastaColumn",false,false); parameters.push_back(poldfasta);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poutput("output", "Multiple", "column-lt-square-phylip", "column", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcountends);
-               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcompress);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "OldFastaColumn","column",false,false); parameters.push_back(pcolumn);
+               CommandParameter poldfasta("oldfasta", "InputTypes", "", "", "none", "none", "OldFastaColumn","",false,false); parameters.push_back(poldfasta);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","phylip-column",false,true, true); parameters.push_back(pfasta);
+               CommandParameter poutput("output", "Multiple", "column-lt-square-phylip", "column", "", "", "","phylip-column",false,false, true); parameters.push_back(poutput);
+               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "","",false,false); parameters.push_back(pcalc);
+               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pcountends);
+               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pcompress);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false, true); parameters.push_back(pprocessors);
+               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "","",false,false, true); parameters.push_back(pcutoff);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -59,25 +59,20 @@ string DistanceCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string DistanceCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string DistanceCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "phylip") {  outputFileName =  "dist"; }
-            else if (type == "column") {  outputFileName =  "dist"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "phylip") {  pattern = "[filename],[outputtag],dist"; } 
+        else if (type == "column") { pattern = "[filename],dist"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "DistanceCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 DistanceCommand::DistanceCommand(){    
@@ -249,14 +244,17 @@ int DistanceCommand::execute(){
                if (!alignDB.sameLength()) {  m->mothurOut("[ERROR]: your sequences are not the same length, aborting."); m->mothurOutEndLine(); return 0; }
                
                string outputFile;
-                               
+        
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
                if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip." + getOutputFileNameTag("phylip");
+            variables["[outputtag]"] = "phylip";
+                       outputFile = getOutputFileName("phylip", variables);
                        m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile);
                        
                        //output numSeqs to phylip formatted dist file
                }else if (output == "column") { //user wants column format
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("column");
+                       outputFile = getOutputFileName("column", variables);
                        outputTypes["column"].push_back(outputFile);
                        
                        //so we don't accidentally overwrite
@@ -267,7 +265,8 @@ int DistanceCommand::execute(){
                        
                        m->mothurRemove(outputFile);
                }else { //assume square
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square." + getOutputFileNameTag("phylip");
+                       variables["[outputtag]"] = "square";
+                       outputFile = getOutputFileName("phylip", variables);
                        m->mothurRemove(outputFile);
                        outputTypes["phylip"].push_back(outputFile);
                }
index 9dea351250b7c7550a1071ca3189051345245d01..ddce0449d5498d48914f95d9ff64900b12837ccf 100644 (file)
@@ -178,8 +178,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "dist.seqs";                   }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD (2010). The effects of alignment quality, distance calculation method, sequence filtering, and region on the analysis of 16S rRNA gene-based studies. PLoS Comput Biol 6: e1000844. \nhttp://www.mothur.org/wiki/Dist.seqs"; }
        string getDescription()         { return "calculate the pairwaise distances between aligned sequences"; }
 
index 7a8fbc8cdfe6236601dbc0b369f6ef415a5c7c48..f6ca47988809f623b940f2ae04703d276ad90fa8 100644 (file)
 //**********************************************************************************************************************
 vector<string> FilterSeqsCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter phard("hard", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(phard);
-               CommandParameter ptrump("trump", "String", "", "*", "", "", "",false,false); parameters.push_back(ptrump);
-               CommandParameter psoft("soft", "Number", "", "0", "", "", "",false,false); parameters.push_back(psoft);
-               CommandParameter pvertical("vertical", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pvertical);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-filter",false,true, true); parameters.push_back(pfasta);
+               CommandParameter phard("hard", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(phard);
+               CommandParameter ptrump("trump", "String", "", "*", "", "", "","",false,false, true); parameters.push_back(ptrump);
+               CommandParameter psoft("soft", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psoft);
+               CommandParameter pvertical("vertical", "Boolean", "", "T", "", "", "","",false,false, true); parameters.push_back(pvertical);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false, true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -57,25 +57,20 @@ string FilterSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string FilterSeqsCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string FilterSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "filter.fasta"; }
-            else if (type == "filter") {  outputFileName =  "filter"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],filter.fasta"; } 
+        else if (type == "filter") {  pattern =  "[filename],filter"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "FilterSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 FilterSeqsCommand::FilterSeqsCommand(){        
@@ -298,9 +293,10 @@ int FilterSeqsCommand::execute() {
                ofstream outFilter;
                
                //prevent giantic file name
-               string filterFile;
-               if (fastafileNames.size() > 3) { filterFile = outputDir + "merge." + getOutputFileNameTag("filter"); }
-               else {  filterFile = outputDir + filterFileName + "." + getOutputFileNameTag("filter");  }
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + filterFileName + ".";
+               if (fastafileNames.size() > 3) { variables["[filename]"] = outputDir + "merge."; }
+               string filterFile = getOutputFileName("filter", variables);  
                
                m->openOutputFile(filterFile, outFilter);
                outFilter << filter << endl;
@@ -363,7 +359,9 @@ int FilterSeqsCommand::filterSequences() {
                        
                                for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                                
-                               string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + getOutputFileNameTag("fasta");
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s]));
+                               string filteredFasta = getOutputFileName("fasta", variables);
 #ifdef USE_MPI 
                                int pid, numSeqsPerProcessor, num; 
                                int tag = 2001;
index b2322379d6eb0467c2e64ba5e98c28e6d604181c..fc6bcb2efab1b3885af316a160faa59446600f30 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();\r
        string getCommandName()                 { return "filter.seqs";                 }\r
        string getCommandCategory()             { return "Sequence Processing"; }\r
-       string getOutputFileNameTag(string, string);\r
+       \r
        string getHelpString(); \r
+    string getOutputPattern(string);   \r
        string getCitation() { return "http://www.mothur.org/wiki/Filter.seqs"; }\r
        string getDescription()         { return "removes columns from alignments based on a criteria defined by the user"; }\r
        \r
index 03c6b17a8a9be441c52070f2af24705eb8f3a168..b61236dbac71421d0e63a2dbd5c89071182652e2 100644 (file)
@@ -12,9 +12,9 @@
 //**********************************************************************************************************************
 vector<string> GetCommandInfoCommand::setParameters(){ 
        try {
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter poutput("output", "String", "", "", "", "", "","",false,false); parameters.push_back(poutput);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -127,13 +127,17 @@ int GetCommandInfoCommand::execute(){
                                map<string, vector<string> > thisOutputTypes = thisCommand->getOutputFiles();
                                map<string, vector<string> >::iterator itTypes;
                                
-                               if (thisOutputTypes.size() == 0) { out << "outputTypes=none" << endl; }
+                               if (thisOutputTypes.size() == 0) { out << "outputTypesNames=0" << endl; }
                                else {
-                                       string types = "";
-                                       for (itTypes = thisOutputTypes.begin(); itTypes != thisOutputTypes.end(); itTypes++) {  types += itTypes->first + "-";  }
+                                       //string types = "";
+                                       //for (itTypes = thisOutputTypes.begin(); itTypes != thisOutputTypes.end(); itTypes++) {        types += itTypes->first + "-";  }
                                        //rip off last -
-                                       types = types.substr(0, types.length()-1);
-                                       out << "outputTypes=" << types << endl;
+                                       //types = types.substr(0, types.length()-1);
+                                       out << "outputTypesNames=" << thisOutputTypes.size() << endl;
+                    
+                    for (itTypes = thisOutputTypes.begin(); itTypes != thisOutputTypes.end(); itTypes++) {
+                        out << itTypes->first << "=" << thisCommand->getOutputPattern(itTypes->first) << endl;
+                    }
                                }
                                
                                vector<string> booleans; vector<string> numbers; vector<string> multiples; vector<string> Strings;
@@ -212,34 +216,54 @@ int GetCommandInfoCommand::getInfo(vector<CommandParameter> para, vector<string>
                for (int i = 0; i < para.size(); i++) {
                        if ((para[i].name == "inputdir") || (para[i].name == "outputdir")) {} //ignore
                        else {
+                string important = "|F";
+                if (para[i].important || para[i].required) { important = "|T"; }
+                
+                string outputType = "|none";
+                if (para[i].outputTypes != "") { outputType = "|" + para[i].outputTypes; }
+                
                                if (para[i].type == "Boolean") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
+                                       string temp = para[i].name + "=" + para[i].optionsDefault + important + outputType;
                                        booleans.push_back(temp);
                                }else if (para[i].type == "Multiple") {
                                        string multAllowed = "F";
                                        if (para[i].multipleSelectionAllowed) { multAllowed = "T"; }
-                                       string temp = para[i].name + "=" + para[i].options + "|" + para[i].optionsDefault + "|" + multAllowed;
+                                       string temp = para[i].name + "=" + para[i].options + "|" + para[i].optionsDefault + "|" + multAllowed + important + outputType;
                                        multiples.push_back(temp);
                                }else if (para[i].type == "Number") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
+                                       string temp = para[i].name + "=" + para[i].optionsDefault + important + outputType;
                                        numbers.push_back(temp);
                                }else if (para[i].type == "String") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
+                                       string temp = para[i].name + "=" + para[i].optionsDefault + important + outputType;
                                        strings.push_back(temp);
                                }else if (para[i].type == "InputTypes") {
                                        string required = "F";
                                        if (para[i].required) { required = "T"; }
-                                       string temp = required + "|" + para[i].chooseOnlyOneGroup + "|" + para[i].chooseAtLeastOneGroup + "|" + para[i].linkedGroup;
+                                       string temp = required + important + "|" + para[i].chooseOnlyOneGroup + "|" + para[i].chooseAtLeastOneGroup + "|" + para[i].linkedGroup + outputType;
                                        inputTypes[para[i].name] = temp;
                                        
                                        //add choose only one groups
-                                       groups[para[i].chooseOnlyOneGroup].insert(para[i].name);
-                                       
+                    vector<string> tempGroups;
+                    m->splitAtDash(para[i].chooseOnlyOneGroup, tempGroups);
+                    for (int l = 0; l < tempGroups.size(); l++) {
+                        groups[tempGroups[l]].insert(para[i].name);
+                    }
+                                       tempGroups.clear();
+                    
                                        //add at least one group names
-                                       groups[para[i].chooseAtLeastOneGroup].insert(para[i].name);
+                    m->splitAtDash(para[i].chooseAtLeastOneGroup, tempGroups);
+                    for (int l = 0; l < tempGroups.size(); l++) {
+                        groups[tempGroups[l]].insert(para[i].name);
+                    }
+                                       tempGroups.clear();
+                                       
                                        
                                        //add at linked group names
-                                       groups[para[i].linkedGroup].insert(para[i].name);
+                    m->splitAtDash(para[i].linkedGroup, tempGroups);
+                    for (int l = 0; l < tempGroups.size(); l++) {
+                        groups[tempGroups[l]].insert(para[i].name);
+                    }
+                                       tempGroups.clear();
                                                  
                                }else { m->mothurOut("[ERROR]: " + para[i].type + " is an unknown parameter type, please correct."); m->mothurOutEndLine(); }
                        }
index b72c2368a911996fcdc71d67748533766f9fe637..46ff78b5e41ec4b9792657f80885425726531351 100644 (file)
@@ -27,8 +27,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.commandinfo";             }
        string getCommandCategory()             { return "Hidden";                              }
-       string getOutputFileNameTag(string, string) {  return "";  }
        string getHelpString(); 
+    string getOutputPattern(string) {  return "";  }   
        string getCitation() { return "no citation"; }
        string getDescription()         { return "get.commandinfo"; }
        
index 3cc77be4ab73ad4f8d17635aa5b2ace242b22ec8..5fbb78131ed3ceda425516bdcd2766f3c1eb196f 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetCoreMicroBiomeCommand::setParameters(){      
        try {
-        CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(prelabund);
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter poutput("output", "Multiple", "fraction-count", "fraction", "", "", "",false,false); parameters.push_back(poutput);
-        CommandParameter pabund("abundance", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter psamples("samples", "Number", "", "-1", "", "", "",false,false); parameters.push_back(psamples);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none","coremicrobiom",false,false, true); parameters.push_back(pshared);
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none","coremicrobiom",false,false, true); parameters.push_back(prelabund);
+        CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter poutput("output", "Multiple", "fraction-count", "fraction", "", "", "","",false,false); parameters.push_back(poutput);
+        CommandParameter pabund("abundance", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pabund);
+               CommandParameter psamples("samples", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(psamples);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,26 +52,20 @@ string GetCoreMicroBiomeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetCoreMicroBiomeCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetCoreMicroBiomeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "coremicrobiome") {  outputFileName =  "core.microbiome"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCoreMicroBiomeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "coremicrobiome") {  pattern = "[filename],[tag],core.microbiome"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetCoreMicroBiomeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 GetCoreMicroBiomeCommand::GetCoreMicroBiomeCommand(){  
        try {
@@ -307,8 +301,10 @@ int GetCoreMicroBiomeCommand::execute(){
 
 int GetCoreMicroBiomeCommand::createTable(vector<SharedRAbundFloatVector*>& lookup){
        try {
-        
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("coremicrobiome");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[tag]"] = lookup[0]->getLabel();
+        string outputFileName = getOutputFileName("coremicrobiome", variables);
         outputNames.push_back(outputFileName);  outputTypes["coremicrobiome"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
index 469214c2916e3e00c466c4f0c1183809382aa3b5..80def83dc27d947df1d5f13a16315a38f279b514 100644 (file)
@@ -26,8 +26,9 @@ public:
     string getCommandName()                    { return "get.coremicrobiome";                  }
     string getCommandCategory()                { return "OTU-Based Approaches";                } 
     //commmand category choices: Sequence Processing, OTU-Based Approaches, Hypothesis Testing, Phylotype Analysis, General, Clustering and Hidden
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/Get.coremicrobiome"; }
     string getDescription()            { return "determines the fraction of OTUs that are found in varying numbers of samples for different minimum relative abundances"; }
     
index 86046b64375ebd151c27e5909c0efdc9d0149bbf..f73b5600d741d09395eaece04816d6d1859b4ead 100644 (file)
@@ -12,9 +12,9 @@
 //**********************************************************************************************************************
 vector<string> GetCurrentCommand::setParameters(){     
        try {
-               CommandParameter pclear("clear", "String", "", "", "", "", "",false,false); parameters.push_back(pclear);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pclear("clear", "String", "", "", "", "", "","",false,false); parameters.push_back(pclear);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index f10e6d4e556878d6cb55e30cd7b4ce1138a896da..2d8dbb1a432168f26a2371ccd996762d53670be5 100644 (file)
@@ -22,8 +22,8 @@ class GetCurrentCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.current"; }
                string getCommandCategory()             { return "General";             }
-        string getOutputFileNameTag(string, string) { return ""; }
         string getHelpString();        
+        string getOutputPattern(string)        { return ""; }
                string getCitation() { return "http://www.mothur.org/wiki/Get.current"; }
                string getDescription()         { return "get current files saved by mothur"; }
 
index b92924c7a7f9608329e08968401ac7d1af91712e..529ed934d5b194d1a1d82869c44053ca4f7bbaf2 100644 (file)
@@ -13,9 +13,9 @@
 //**********************************************************************************************************************
 vector<string> GetgroupCommand::setParameters(){       
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "current", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "current", "none", "none", "none","",false,true, true); parameters.push_back(pshared);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 7924d7b55a708886c0875bf26f173ffa13cc9da1..fb438dfd91caf9a8213e780db8c7b626768873d3 100644 (file)
@@ -21,8 +21,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.group";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string) { return "";  }
        string getHelpString(); 
+    string getOutputPattern(string)    { return "";  }
        string getCitation() { return "http://www.mothur.org/wiki/Get.group"; }
        string getDescription()         { return "outputs group names"; }
 
index 69f4403ca0039dab9d3c4f5aa626a566fa0805d9..e4f7450b4291e1ca281ebe806dd476fac86019b9 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetGroupsCommand::setParameters(){      
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(pfasta);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "sharedGroup", "FNGLT",false,false); parameters.push_back(pgroup);         
-        CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pdesign);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT","fasta",false,false, true); parameters.push_back(pfasta);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none","shared",false,false, true); parameters.push_back(pshared);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false, true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false, true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "sharedGroup", "FNGLT","group",false,false, true); parameters.push_back(pgroup);           
+        CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT","design",false,false, true); parameters.push_back(pdesign);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT","list",false,false, true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT","taxonomy",false,false, true); parameters.push_back(ptaxonomy);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -59,33 +59,27 @@ string GetGroupsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetGroupsCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetGroupsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "shared")      {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "design")      {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "shared")      {   pattern = "[filename],[tag],pick,[extension]";    }
+        else if (type == "design")      {   pattern = "[filename],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetGroupsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 GetGroupsCommand::GetGroupsCommand(){  
        try {
@@ -467,7 +461,10 @@ int GetGroupsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -530,12 +527,17 @@ int GetGroupsCommand::readShared(){
                
                InputData input(sharedfile, "sharedfile");
                vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
                
                bool wroteSomething = false;
                
                while(lookup[0] != NULL) {
                        
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("shared", sharedfile);
+            variables["[tag]"] = lookup[0]->getLabel();
+            string outputFileName = getOutputFileName("shared", variables);
+                       
                        ofstream out;
                        m->openOutputFile(outputFileName, out);
                        outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -580,7 +582,10 @@ int GetGroupsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -673,7 +678,10 @@ int GetGroupsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -754,7 +762,10 @@ int GetGroupsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -801,7 +812,10 @@ int GetGroupsCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -877,7 +891,10 @@ int GetGroupsCommand::readDesign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + getOutputFileNameTag("design", designfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(designfile));
+        variables["[extension]"] = m->getExtension(designfile);
+               string outputFileName = getOutputFileName("design", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -927,7 +944,11 @@ int GetGroupsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
+               
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index 6bb608833a418f2c0854c2b8bf0ac9c16a66f790..f67c36584a58a14556032ce2374bda17925c6aaa 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.groups";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.groups"; }
        string getDescription()         { return "gets sequences from a list, fasta, name, group, shared, design or taxonomy file from a given group or set of groups"; }
 
index 8535db3203c6da354ce55e1a4f095f07b6d4e487..03bf7ad991829e2afc693db3d15560d66e597a91 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetlabelCommand::setParameters(){       
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false, true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false, true); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false, true); parameters.push_back(psabund);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 7a4d9b5885214696ac38a289f95f8ae20af0c239..26ec6550b4f6b7fb622b60c1b711fc24c0c4ac40 100644 (file)
@@ -24,8 +24,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.label";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
+    string getOutputPattern(string) { return ""; }     
        string getCitation() { return "http://www.mothur.org/wiki/Get.label"; }
        string getDescription()         { return "outputs labels"; }
 
index 99359bd882e1e2b668cd6bef2b2ec7cfc32fc0bf..438aa3808441e60b9fb4fa22d4e9313a58956b2a 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetLineageCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptaxon("taxon", "String", "", "", "", "", "",false,true); parameters.push_back(ptaxon);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false, true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false, true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false, true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false, true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false, true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none","taxonomy",false,true, true); parameters.push_back(ptaxonomy);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none","alignreport",false,false); parameters.push_back(palignreport);
+               CommandParameter ptaxon("taxon", "String", "", "", "", "", "","",false,true, true); parameters.push_back(ptaxon);
+               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pdups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -60,30 +60,25 @@ string GetLineageCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetLineageCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetLineageCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";                    }  
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "alignreport") {   outputFileName =  "pick.align.report";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetLineageCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetLineageCommand::GetLineageCommand(){        
@@ -362,7 +357,10 @@ int GetLineageCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -409,7 +407,10 @@ int GetLineageCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -463,7 +464,10 @@ int GetLineageCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -535,7 +539,10 @@ int GetLineageCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -621,7 +628,10 @@ int GetLineageCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -668,7 +678,10 @@ int GetLineageCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -867,7 +880,11 @@ int GetLineageCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(alignfile));
+        variables["[extension]"] = m->getExtension(alignfile);
+               string outputFileName = getOutputFileName("alignreport", variables);
+               
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index 99bc0fa347313bb023e8bd1b41a5c3e2be5c93ed..68f974f21461933b8feed0657bc07f86c17b4e20 100644 (file)
@@ -23,8 +23,9 @@ class GetLineageCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.lineage";                         }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Get.lineage"; }
                string getDescription()         { return "gets sequences from a list, fasta, name, group, alignreport or taxonomy file from a given taxonomy or set of taxonomies"; }
 
index b7c4f1790b152371a6e302f3d56ae79fc60badf1..a4d7b83397f83bf6ae3dd21627566252035b328f 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetListCountCommand::setParameters(){   
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter parasort("sort", "Multiple", "name-otu", "otu", "", "", "",false,false); parameters.push_back(parasort);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","otu",false,true, true); parameters.push_back(plist);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter parasort("sort", "Multiple", "name-otu", "otu", "", "", "","",false,false); parameters.push_back(parasort);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -49,24 +49,19 @@ string GetListCountCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetListCountCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetListCountCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "otu") {  outputFileName =  "otu"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "otu") {  pattern = "[filename],[tag],otu"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetListCountCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetListCountCommand::GetListCountCommand(){    
@@ -254,7 +249,11 @@ void GetListCountCommand::process(ListVector* list) {
        try {
                string binnames;
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + "." +getOutputFileNameTag("otu");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[tag]"] = list->getLabel();
+               string outputFileName = getOutputFileName("otu", variables);
+               
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
                
index 629e9b98991fa839ccca7a704d582150f47f7d5f..c2645562f1111c4a03be95c4e27c143745311ed5 100644 (file)
@@ -28,8 +28,9 @@ public:
        string getCitation() { return "http://www.mothur.org/wiki/Get.otulist"; }
        string getDescription()         { return "lists each OTU number and the sequence contained in that OTU"; }
 
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        
        int execute(); 
        void help() { m->mothurOut(getHelpString()); }  
index 7dc0b414f40e3db4b3daa0469589ba30dc5fe781..0f042c0bcb9a4de9d8cebd4f1bd017d1c65c37fb 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetOtuLabelsCommand::setParameters(){   
        try {
-        CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-        CommandParameter pconstaxonomy("constaxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pconstaxonomy);
-               CommandParameter potucorr("otucorr", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(potucorr);
-        CommandParameter pcorraxes("corraxes", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pcorraxes);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,true, true); parameters.push_back(paccnos);
+        CommandParameter pconstaxonomy("constaxonomy", "InputTypes", "", "", "none", "FNGLT", "none","constaxonomy",false,false, true); parameters.push_back(pconstaxonomy);
+               CommandParameter potucorr("otucorr", "InputTypes", "", "", "none", "FNGLT", "none","otucorr",false,false, true); parameters.push_back(potucorr);
+        CommandParameter pcorraxes("corraxes", "InputTypes", "", "", "none", "FNGLT", "none","corraxes",false,false, true); parameters.push_back(pcorraxes);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,27 +46,23 @@ string GetOtuLabelsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetOtuLabelsCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetOtuLabelsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "constaxonomy") {  outputFileName =  "pick.taxonomy"; }
-            else if (type == "otucorr") {  outputFileName =  "pick.corr"; }
-            else if (type == "corraxes") {  outputFileName =  "pick.axes"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtuLabelsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "constaxonomy")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "otucorr")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "corraxes")        {   pattern = "[filename],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetOtuLabelsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 GetOtuLabelsCommand::GetOtuLabelsCommand(){    
        try {
@@ -226,7 +222,11 @@ int GetOtuLabelsCommand::readClassifyOtu(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(constaxonomyfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + getOutputFileNameTag("constaxonomy");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile));
+        variables["[extension]"] = m->getExtension(constaxonomyfile);
+               string outputFileName = getOutputFileName("constaxonomy", variables);
+               
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -277,7 +277,11 @@ int GetOtuLabelsCommand::readOtuAssociation(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(otucorrfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + getOutputFileNameTag("otucorr");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile));
+        variables["[extension]"] = m->getExtension(otucorrfile);
+               string outputFileName = getOutputFileName("otucorr", variables);
+
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -328,7 +332,11 @@ int GetOtuLabelsCommand::readCorrAxes(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(corraxesfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + getOutputFileNameTag("corraxes");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile));
+        variables["[extension]"] = m->getExtension(corraxesfile);
+               string outputFileName = getOutputFileName("corraxes", variables);
+
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index 8cfe8b96617516b00bf4809963a361695c457a5c..8ce0300fee9a0df9ec9feb56753951cf4b8216b5 100644 (file)
@@ -23,8 +23,9 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "get.otulabels";          }
     string getCommandCategory()                { return "OTU-Based Approaches";        } 
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/Get.otulabels"; }
     string getDescription()            { return "Can be used with output from classify.otu, otu.association, or corr.axes to select specific otus."; }
     
index 1d26b47b39c3ee998fb018bad12fb4e904b1e333..b8de5a62f6a8678c8b6f3e7f5de39b4da13aa817 100644 (file)
@@ -39,22 +39,22 @@ inline bool compareGroup(repStruct left, repStruct right){
 //**********************************************************************************************************************
 vector<string> GetOTURepCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "ColumnName",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pweighted("weighted", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pweighted);
-               CommandParameter psorted("sorted", "Multiple", "none-name-bin-size-group", "none", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","name",false,true, true); parameters.push_back(plist);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,false, true); parameters.push_back(pfasta);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","",false,false, true); parameters.push_back(pphylip);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName","",false,false, true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "ColumnName","count",false,false, true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false, true); parameters.push_back(pgroup);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName","",false,false, true); parameters.push_back(pcolumn);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pweighted("weighted", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pweighted);
+               CommandParameter psorted("sorted", "Multiple", "none-name-bin-size-group", "none", "", "", "","",false,false); parameters.push_back(psorted);
+               CommandParameter plarge("large", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -96,26 +96,21 @@ string GetOTURepCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetOTURepCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetOTURepCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "rep.fasta";   }
-            else if (type == "name")        {   outputFileName =  "rep.names";   }
-            else if (type == "count")        {   outputFileName =  "rep.count_table";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],[tag],rep.fasta-[filename],[tag],[group],rep.fasta"; } 
+        else if (type == "name") {  pattern = "[filename],[tag],rep.names-[filename],[tag],[group],rep.names"; } 
+        else if (type == "count") {  pattern = "[filename],[tag],rep.count_table-[filename],[tag],[group],rep.count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetOTURepCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetOTURepCommand::GetOTURepCommand(){  
@@ -861,13 +856,16 @@ int GetOTURepCommand::process(ListVector* processList) {
                string outputNamesFile;
                map<string, ofstream*> filehandles;
                
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        
                if (Groups.size() == 0) { //you don't want to use groups
-                       outputNamesFile  = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".";
+            variables["[tag]"] = processList->getLabel();
             if (countfile == "") { 
-                outputNamesFile += getOutputFileNameTag("name");
+                outputNamesFile = getOutputFileName("name", variables);
                 outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile); 
             }else {
-                outputNamesFile += getOutputFileNameTag("count");
+                outputNamesFile = getOutputFileName("count", variables);
                 outputNames.push_back(outputNamesFile); outputTypes["count"].push_back(outputNamesFile); 
             }
                        outputNameFiles[outputNamesFile] = processList->getLabel();
@@ -877,13 +875,15 @@ int GetOTURepCommand::process(ListVector* processList) {
                        ofstream* temp;
                        for (int i=0; i<Groups.size(); i++) {
                                temp = new ofstream;
+                variables["[tag]"] = processList->getLabel();
+                variables["[group]"] = Groups[i];
                                filehandles[Groups[i]] = temp;
                                outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".";
                 if (countfile == "") { 
-                    outputNamesFile += getOutputFileNameTag("name");
+                    outputNamesFile = getOutputFileName("name", variables);
                     outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile); 
                 }else {
-                    outputNamesFile += getOutputFileNameTag("count");
+                    outputNamesFile = getOutputFileName("count", variables);
                     outputNames.push_back(outputNamesFile); outputTypes["count"].push_back(outputNamesFile); 
                 }
                                
@@ -978,7 +978,10 @@ int GetOTURepCommand::processFastaNames(string filename, string label) {
 
                //create output file
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("fasta");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[tag]"] = label;
+               string outputFileName = getOutputFileName("fasta",variables);
                m->openOutputFile(outputFileName, out);
                vector<repStruct> reps;
                outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
index 390632975afc85aac5b714c7194c81e74d58e16e..a1bf3f0229a98231e9a627e4fc98f9d23ad897ea 100644 (file)
@@ -43,8 +43,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.oturep";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.oturep"; }
        string getDescription()         { return "gets a representative sequence for each OTU"; }
 
index 8d20e63b65b9a99b6476608fe4a108ce233718f0..335ebc4506ca99ac3a0e3dc9a2d068b0f1c41cd7 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetOtusCommand::setParameters(){        
        try {
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","group",false,true, true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","list",false,true, true); parameters.push_back(plist);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,25 +54,20 @@ string GetOtusCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetOtusCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetOtusCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "group")            {   outputFileName = "pick" + m->getExtension(inputName);  }
-            else if (type == "list")        {   outputFileName = "pick" + m->getExtension(inputName);  }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "group")       {   pattern = "[filename],[tag],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],[tag],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetOtusCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetOtusCommand::GetOtusCommand(){      
@@ -251,14 +246,20 @@ int GetOtusCommand::readListGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("list", listfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[tag]"] = label;
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
                string GroupOutputDir = outputDir;
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + label + "." + getOutputFileNameTag("group", groupfile);
+        variables["[filename]"] = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputGroupFileName = getOutputFileName("group", variables);
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
index 4eff4b69569625561788804e16cf09379c4e97fb..c71ab062b431c9ca7945c8e0b8679980058939c8 100644 (file)
@@ -27,8 +27,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.otus";                            }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.otus"; }
        string getDescription()         { return "outputs a new list file containing the otus containing sequences from the groups specified"; }
 
index 35342933c5f898a97b2c925baa09520defd47179..d5f5a8b8b8450deef538f564d59885b57647c430 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetRAbundCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);            
-               CommandParameter psorted("sorted", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","rabund",false,false, true); parameters.push_back(plist);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","rabund",false,false, true); parameters.push_back(psabund);             
+               CommandParameter psorted("sorted", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(psorted);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,25 +48,21 @@ string GetRAbundCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetRAbundCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetRAbundCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "rabund")            {   outputFileName = "rabund";  }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "rabund")      {   pattern = "[filename],rabund";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetRAbundCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 GetRAbundCommand::GetRAbundCommand(){  
        try {
@@ -192,7 +188,9 @@ int GetRAbundCommand::execute(){
        
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("rabund");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+               filename = getOutputFileName("rabund", variables);
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);
index 7e9363080e7bf7b794b3797c37df9527d8f84764..dcf8c686dbd2bf75847ef500bf7fea0fbd087cb5 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.rabund";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.rabund"; }
        string getDescription()         { return "creates a rabund file"; }
 
index 7c623fbfd8ced3cd88bff70b3579e893d6e6cfa0..f36f1ba23a6af6c9110dc0aac103054ceefedaff 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetRelAbundCommand::setParameters(){    
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pscale("scale", "Multiple", "totalgroup-totalotu-averagegroup-averageotu", "totalgroup", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","relabund",false,true, true); parameters.push_back(pshared);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pscale("scale", "Multiple", "totalgroup-totalotu-averagegroup-averageotu", "totalgroup", "", "", "","",false,false); parameters.push_back(pscale);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -49,24 +49,19 @@ string GetRelAbundCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetRelAbundCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetRelAbundCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "relabund")         {   outputFileName = "relabund" ;  }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "relabund")      {   pattern = "[filename],relabund";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetRelAbundCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetRelAbundCommand::GetRelAbundCommand(){      
@@ -174,7 +169,9 @@ int GetRelAbundCommand::execute(){
        
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("relabund");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+               string outputFileName = getOutputFileName("relabund", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
index c5b50e602ef133913061f56b11cc9cadae874d34..dcb4cf71e43a919bc6fce2588b8d7e8e7c2864dd 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.relabund";                        }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.relabund"; }
        string getDescription()         { return "calculates the relative abundance of each OTU in a sample"; }
 
index 50692495b9c87f83cfde870168c5214a41b9a7ac..237506e666641ab80e263db5573aec13756e3429 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetSAbundCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);            
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","sabund",false,false, true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","sabund",false,false, true); parameters.push_back(prabund);             
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,24 +46,19 @@ string GetSAbundCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetSAbundCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetSAbundCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "sabund")            {   outputFileName = "sabund";  }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "sabund")      {   pattern = "[filename],sabund";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetRAbundCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetSAbundCommand::GetSAbundCommand(){  
@@ -185,7 +180,9 @@ int GetSAbundCommand::execute(){
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("sabund");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+               filename = getOutputFileName("sabund", variables);
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);
index 4c967b5e9f3455c3a7ceea5fd3dac67a99f9695b..685f039f302577505598c84f86637ec0bb06561c 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.sabund";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Get.sabund"; }
        string getDescription()         { return "creates a sabund file"; }
 
index 6b16111fdcda83099c0e36396543d40ee345c865..779ea912ebebbe58ec22e65723899c4ea566b85f 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetSeqsCommand::setParameters(){        
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter paccnos2("accnos2", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos2);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none","taxonomy",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none","alignreport",false,false); parameters.push_back(palignreport);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none","qfile",false,false); parameters.push_back(pqfile);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(paccnos);
+               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pdups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter paccnos2("accnos2", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos2);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -79,32 +79,27 @@ GetSeqsCommand::GetSeqsCommand(){
        }
 }
 //**********************************************************************************************************************
-string GetSeqsCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "qfile")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "accnosreport"){   outputFileName =  "accnos.report";                       }
-            else if (type == "alignreport") {   outputFileName =  "pick.align.report";                   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "qfile")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "accnosreport")      {   pattern = "[filename],pick.accnos.report";    }
+        else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetSeqsCommand::GetSeqsCommand(string option)  {
@@ -409,7 +404,10 @@ int GetSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -465,7 +463,10 @@ int GetSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(qualfile));
+        variables["[extension]"] = m->getExtension(qualfile);
+               string outputFileName = getOutputFileName("qfile", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -537,7 +538,10 @@ int GetSeqsCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -595,7 +599,10 @@ int GetSeqsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -671,7 +678,10 @@ int GetSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -771,7 +781,10 @@ int GetSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -827,7 +840,10 @@ int GetSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -881,7 +897,9 @@ int GetSeqsCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(alignfile));
+               string outputFileName = getOutputFileName("alignreport", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -1047,7 +1065,10 @@ int GetSeqsCommand::compareAccnos(){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(accnosfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(accnosfile)) + getOutputFileNameTag("accnosreport");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(accnosfile));
+               string outputFileName = getOutputFileName("accnosreport", variables);
+               
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index 60e471eebf7865d5924406ef7c720c3bdcdf4648..42070e53a57cf05c6d5674e022c602636fa374bf 100644 (file)
@@ -23,8 +23,9 @@ class GetSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.seqs";                            }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Get.seqs"; }
                string getDescription()         { return "gets sequences from a list, fasta, name, group, alignreport, quality or taxonomy file"; }
 
index 1b69a25d4af7e638dbf48a64baec2390f37dcfec..5ae8da588ba4a6d36b6658527d8cd12e208c50c4 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetSharedOTUCommand::setParameters(){   
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(plist);
-               CommandParameter poutput("output", "Multiple", "accnos-default", "default", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter punique("unique", "String", "", "", "", "", "",false,false); parameters.push_back(punique);
-               CommandParameter pshared("shared", "String", "", "", "", "", "",false,false); parameters.push_back(pshared);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false); parameters.push_back(pfasta);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none","sharedseq",false,true,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","sharedseq",false,true,true); parameters.push_back(plist);
+               CommandParameter poutput("output", "Multiple", "accnos-default", "default", "", "", "","",false,false); parameters.push_back(poutput);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter punique("unique", "String", "", "", "", "", "","",false,false,true); parameters.push_back(punique);
+               CommandParameter pshared("shared", "String", "", "", "", "", "","",false,false,true); parameters.push_back(pshared);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -59,28 +59,22 @@ string GetSharedOTUCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetSharedOTUCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetSharedOTUCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+
+        if (type == "fasta")            {   pattern =  "[filename],[distance],[group],shared.fasta";   }
+        else if (type == "accnos")      {   pattern =  "[filename],[distance],[group],accnos";         }
+        else if (type == "sharedseqs")  {   pattern =  "[filename],[distance],[group],shared.seqs";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "shared.fasta";   }
-            else if (type == "accnos")      {   outputFileName =  "accnos";         }
-            else if (type == "sharedseqs")  {   outputFileName =  "shared.seqs";    }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetSharedOTUCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 GetSharedOTUCommand::GetSharedOTUCommand(){    
        try {
@@ -394,11 +388,13 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                string outputFileNames;
                
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               if (output != "accnos") {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("sharedseqs");
-               }else {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("accnos");
-               }
+        map<string, string> variables;
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[distance]"] = shared->getLabel();
+        variables["[group]"] = userGroups;
+               if (output != "accnos") { outputFileNames = getOutputFileName("sharedseqs", variables); }
+               else { outputFileNames = getOutputFileName("accnos", variables); }
+        
                m->openOutputFile(outputFileNames, outNames);
                
                bool wroteSomething = false;
@@ -491,7 +487,8 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                //if fasta file provided output new fasta file
                if ((fastafile != "") && wroteSomething) {
                        if (outputDir == "") { outputDir += m->hasPath(fastafile); }
-                       string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("fasta");
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+                       string outputFileFasta = getOutputFileName("fasta", variables);
                        ofstream outFasta;
                        m->openOutputFile(outputFileFasta, outFasta);
                        outputNames.push_back(outputFileFasta); outputTypes["fasta"].push_back(outputFileFasta);
index e2026d71442b4a1c461ca1028c7dcd6fc4071986..583c2e001a00607cd97771e8fdfa42cbd8866c9f 100644 (file)
@@ -28,8 +28,9 @@ class GetSharedOTUCommand : public Command {
                string getCommandName()                 { return "get.sharedseqs";                      }
                string getCommandCategory()             { return "OTU-Based Approaches";        }
                string getRequiredCommand()             { return "none";                                        }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Get.sharedseqs"; }
                string getDescription()         { return "identifies sequences that are either unique or shared by specific groups"; }
 
index cf35cd9d6fa4c2a8fe1349b63399eb60007a4217..b991ccd6289b9afd44628c12bf451eb86529fa44 100644 (file)
 //**********************************************************************************************************************
 vector<string> HClusterCommand::setParameters(){       
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter psorted("sorted", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);          
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","list-rabund-sabund",false,false,true); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName","",false,false,true); parameters.push_back(pname);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName","list-rabund-sabund",false,false,true); parameters.push_back(pcolumn);
+               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+               CommandParameter psorted("sorted", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psorted);
+               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
+               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);               
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,27 +52,23 @@ string HClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string HClusterCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string HClusterCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[clustertag],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "HClusterCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 HClusterCommand::HClusterCommand(){    
        try {
@@ -240,10 +236,14 @@ HClusterCommand::HClusterCommand(string option)  {
                                else if (method == "nearest")   { tag = "nn";  }
                                else if (method == "weighted")  { tag = "wn";  }
                                else                                                    { tag = "an";  }
+                
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[clustertag]"] = tag;
                        
-                               string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
-                string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
-                string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+                               string sabundFileName = getOutputFileName("sabund",variables);
+                string rabundFileName = getOutputFileName("rabund",variables);
+                string listFileName = getOutputFileName("list", variables);
                 
                 m->openOutputFile(sabundFileName,      sabundFile);
                 m->openOutputFile(rabundFileName,      rabundFile);
index 6bf559ae6937f130679a5b601e939d7b79193acc..d1074070420fc89347a65b8fa8c0448c953c8881 100644 (file)
@@ -38,8 +38,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "hcluster";    }
        string getCommandCategory()             { return "Clustering";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Sun Y, Cai Y, Liu L, Yu F, Farrell ML, Mckendree W, Farmerie W (2009). ESPRIT: estimating species richness using large collections of 16S rRNA pyrosequences. Nucleic Acids Res 37: e76. \nhttp://www.mothur.org/wiki/Hcluster"; }
        string getDescription()         { return "cluster your sequences into OTUs using a distance matrix"; }
 
index 441eaf8a4dc4e77beb36c7e39c102f9aa13f0d53..e07ae220eba02c86117feaa656e2b07015a4b94b 100644 (file)
 //**********************************************************************************************************************
 vector<string> HeatMapCommand::setParameters(){        
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pscale("scale", "Multiple", "log10-log2-linear", "log10", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter psorted("sorted", "Multiple", "none-shared-topotu-topgroup", "shared", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter pnumotu("numotu", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnumotu);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false,true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false); parameters.push_back(psabund);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false,true); parameters.push_back(pshared); 
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false); parameters.push_back(prelabund);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pscale("scale", "Multiple", "log10-log2-linear", "log10", "", "", "","",false,false); parameters.push_back(pscale);
+               CommandParameter psorted("sorted", "Multiple", "none-shared-topotu-topgroup", "shared", "", "", "","",false,false); parameters.push_back(psorted);
+               CommandParameter pnumotu("numotu", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pnumotu);
+               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "","",false,false); parameters.push_back(pfontsize);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -62,25 +62,19 @@ string HeatMapCommand::getHelpString(){
 }
 
 //**********************************************************************************************************************
-
-string HeatMapCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string HeatMapCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "svg")            {   outputFileName =  "svg";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "svg") {  pattern = "[filename],svg"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "HeatMapCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
index 58eaa36b31b67bc1d453958f58336f559397b726..fc5165ed65b9aa63e56de900acafcede5cc4d43c 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "heatmap.bin";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Heatmap.bin"; }
        string getDescription()         { return "generate a heatmap where the color represents the relative abundanceof an OTU"; }
 
index 8a4a12bc70f2d707fb923e74036043f12c1dcd3f..98739b68291fd42d83d1190a46313886126f02bf 100644 (file)
 //**********************************************************************************************************************
 vector<string> HeatMapSimCommand::setParameters(){     
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pshared);        
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName",false,false); parameters.push_back(pcolumn);          
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none","svg",false,false,true); parameters.push_back(pshared);     
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none","svg",false,false); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","",false,false); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false); parameters.push_back(pcount);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName","svg",false,false); parameters.push_back(pcolumn);            
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "","",true,false); parameters.push_back(pcalc);
+               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "","",false,false); parameters.push_back(pfontsize);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -73,27 +73,20 @@ string HeatMapSimCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-
-string HeatMapSimCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string HeatMapSimCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "svg")            {   outputFileName =  "svg";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "svg") {  pattern = "[filename],svg"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "HeatMapCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 HeatMapSimCommand::HeatMapSimCommand(){        
        try {
index 2c3a470761d719af0bff13bc4d194e5164bd42e0..f421fdc5bf2c3ff8aed22a197afc3309a86b4e34 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "heatmap.sim";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Heatmap.sim"; }
        string getDescription()         { return "generate a heatmap indicating the pairwise distance between multiple samples using a variety of calculators"; }
 
index 31dbd2b9014ab27a150663a6eff56c63f2f98f8f..aedb7b5a626570f39f16d420ca7bd82a0034f740 100644 (file)
@@ -25,7 +25,7 @@ public:
        string getCommandName()                 { return "help";                }
        string getCommandCategory()             { return "Hidden";              }
        string getHelpString() { return "For more information about a specific command type 'commandName(help)' i.e. 'cluster(help)'"; }        
-    string getOutputFileNameTag(string, string) { return "";  }
+     string getOutputPattern(string) { return "";                }
        string getCitation() { return "no citation"; }
        string getDescription()         { return "help"; }
 
index 6496cea746a1cf6895005564798a4c5cb909f88d..49b8b64a0ebea8d5c6dae20118a19e0b814806b1 100644 (file)
 //**********************************************************************************************************************
 vector<string> HomovaCommand::setParameters(){ 
        try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-        CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","homova",false,true,true); parameters.push_back(pdesign);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","homova",false,true,true); parameters.push_back(pphylip);
+        CommandParameter psets("sets", "String", "", "", "", "", "","",false,false); parameters.push_back(psets);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "","",false,false); parameters.push_back(palpha);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,24 +53,19 @@ string HomovaCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string HomovaCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string HomovaCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "homova")            {   outputFileName =  "homova";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "homova") {  pattern = "[filename],homova"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "HomovaCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 HomovaCommand::HomovaCommand(){        
@@ -242,7 +237,9 @@ int HomovaCommand::execute(){
                
                //create a new filename
                ofstream HOMOVAFile;
-               string HOMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("homova");                          
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipFileName));
+               string HOMOVAFileName = getOutputFileName("homova", variables);                         
                m->openOutputFile(HOMOVAFileName, HOMOVAFile);
                outputNames.push_back(HOMOVAFileName); outputTypes["homova"].push_back(HOMOVAFileName);
                
index 9398627105ad53f7644c47a0db4b0e969f77862f..22741e979ec9b0847ca660f5ab41eab49fe715d5 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "homova";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Stewart CN, Excoffier L (1996). Assessing population genetic structure and variability with RAPD data: Application to Vaccinium macrocarpon (American Cranberry). J Evol Biol 9: 153-71. \nhttp://www.mothur.org/wiki/Homova"; }
        string getDescription()         { return "homova"; }
 
index 3c461d7188ea5096de8031200913a1a43bc1101c..b92c58b54852b35c80ad039720c847b8d35d02bb 100644 (file)
 //**********************************************************************************************************************
 vector<string> IndicatorCommand::setParameters(){      
        try {
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pdesign("design", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none",false,false); parameters.push_back(pdesign);
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(pshared);  
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter ptree("tree", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none",false,false); parameters.push_back(ptree);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pdesign("design", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none","summary",false,false,true); parameters.push_back(pdesign);
+               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none","summary",false,false,true); parameters.push_back(pshared);   
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none","summary",false,false); parameters.push_back(prelabund);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter ptree("tree", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none","tree-summary",false,false,true); parameters.push_back(ptree);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pprocessors);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -58,25 +58,20 @@ string IndicatorCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string IndicatorCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string IndicatorCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "tree")       {   outputFileName =  "indicator.tre";   }
-            else if (type == "summary")    {   outputFileName =  "indicator.summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "tree") {  pattern = "[filename],indicator.tre"; } 
+        else if (type == "summary") {  pattern = "[filename],indicator.summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "IndicatorCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 IndicatorCommand::IndicatorCommand(){  
@@ -410,7 +405,9 @@ int IndicatorCommand::GetIndicatorSpecies(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName));
+               string outputFileName = getOutputFileName("summary", variables);
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -526,7 +523,9 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName));
+               string outputFileName = getOutputFileName("summary",variables);
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -546,7 +545,8 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                
                string treeOutputDir = outputDir;
                if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
+        variables["[filename]"] = treeOutputDir + m->getRootName(m->getSimpleName(treefile));
+               string outputTreeFileName = getOutputFileName("tree", variables);
                
                
                //create a map from tree node index to names of descendants, save time later to know which sharedRabund you need
index b058af33b05b2a7a29f3f1e4aede4e22c37cbf7d..1f46081dd464c32e599cf1d173d1eba60df3db46 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "indicator";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Dufrene M, Legendre P (1997). Species assemblages and indicator species: The need for a flexible asymmetrical approach. Ecol Monogr 67: 345-66.\n McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Indicator"; }
        string getDescription()         { return "calculate the indicator value for each OTU"; }
 
index 7f8cd9b721fe50e82f4fdf2553e51a6d53b86a22..46f1a53a475767d379059ca431f0d01e8596afa8 100644 (file)
 //**********************************************************************************************************************
 vector<string> LibShuffCommand::setParameters(){       
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "10000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pstep("step", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pstep);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pform("form", "Multiple", "discrete-integral", "integral", "", "", "",false,false); parameters.push_back(pform);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","coverage-libshuffsummary",false,true,true); parameters.push_back(pphylip);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter piters("iters", "Number", "", "10000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pstep("step", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(pstep);
+               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pform("form", "Multiple", "discrete-integral", "integral", "", "", "","",false,false); parameters.push_back(pform);
+               CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,25 +65,20 @@ string LibShuffCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string LibShuffCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string LibShuffCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "coverage")             {   outputFileName =  "libshuff.coverage";       }
-            else if (type == "libshuffsummary")      {   outputFileName =  "libshuff.summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "coverage") {  pattern = "[filename],libshuff.coverage"; } 
+        else if (type == "libshuffsummary") {  pattern = "[filename],libshuff.summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "LibShuffCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 LibShuffCommand::LibShuffCommand(){    
@@ -362,7 +357,9 @@ int LibShuffCommand::printCoverageFile() {
        try {
 
                ofstream outCov;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("coverage");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipfile));
+               summaryFile = getOutputFileName("coverage", variables);
                m->openOutputFile(summaryFile, outCov);
                outputNames.push_back(summaryFile); outputTypes["coverage"].push_back(summaryFile);
                outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
@@ -458,7 +455,9 @@ int LibShuffCommand::printSummaryFile() {
        try {
 
                ofstream outSum;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("libshuffsummary");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipfile));
+               summaryFile = getOutputFileName("libshuffsummary",variables);
                m->openOutputFile(summaryFile, outSum);
                outputNames.push_back(summaryFile); outputTypes["libshuffsummary"].push_back(summaryFile);
 
index 81ae17ab644287e75a2de30f88427a67937b549d..9148576b9135826ffe33b084d833525af182bb5a 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "libshuff";                            }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Singleton DR, Furlong MA, Rathbun SL, Whitman WB (2001). Quantitative comparisons of 16S rRNA gene sequence libraries from environmental samples. Appl Environ Microbiol 67: 4374-6. \nSchloss PD, Larget BR, Handelsman J (2004). Integration of microbial ecology and statistics: a test to compare gene libraries. Appl Environ Microbiol 70: 5485-92. \nhttp://www.mothur.org/wiki/Libshuff"; }
        string getDescription()         { return "a generic test that describes whether two or more communities have the same structure using the Cramer-von Mises test statistic"; }
 
index 4a12197b9f21534173c92f6d99c389a3aabb907f..e50196bec8bdb8e22004561df9537648d529514d 100644 (file)
 //**********************************************************************************************************************
 vector<string> ListOtuLabelsCommand::setParameters(){  
        try {
-        CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(prelabund);
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
+        CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none","otulabels",false,false,true); parameters.push_back(pshared);
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none","otulabels",false,false); parameters.push_back(prelabund);
+        CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
         //every command must have inputdir and outputdir.  This allows mothur users to redirect input and output files.
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -47,26 +47,20 @@ string ListOtuLabelsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ListOtuLabelsCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ListOtuLabelsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "otulabels")             {   outputFileName =  "otulabels";       }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListOtuLabelsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "otulabels") {  pattern = "[filename],[distance],otulabels"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ListOtuLabelsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ListOtuLabelsCommand::ListOtuLabelsCommand(){  
        try {
@@ -365,7 +359,10 @@ int ListOtuLabelsCommand::execute(){
 int ListOtuLabelsCommand::createList(vector<SharedRAbundVector*>& lookup){
        try {
         
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[distance]"] = lookup[0]->getLabel();
+        string outputFileName = getOutputFileName("otulabels",variables);
         outputNames.push_back(outputFileName);  outputTypes["otulabels"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -386,8 +383,10 @@ int ListOtuLabelsCommand::createList(vector<SharedRAbundVector*>& lookup){
 
 int ListOtuLabelsCommand::createList(vector<SharedRAbundFloatVector*>& lookup){
        try {
-        
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[distance]"] = lookup[0]->getLabel();
+        string outputFileName = getOutputFileName("otulabels",variables);
         outputNames.push_back(outputFileName);  outputTypes["accnos"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
index 1b10331925c1c91d32e42b06bedcb3f225e32c5a..b1150a8f828ad5f8bdb26931732b9288d017672e 100644 (file)
@@ -25,8 +25,9 @@ public:
     string getCommandName()                    { return "list.otulabels";          }
     string getCommandCategory()                { return "OTU-Based Approaches";        } 
     //commmand category choices: Sequence Processing, OTU-Based Approaches, Hypothesis Testing, Phylotype Analysis, General, Clustering and Hidden
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/List.otulabels"; }
     string getDescription()            { return "lists otu labels from shared or relabund file. Can be used by get.otulabels with output from classify.otu, otu.association, or corr.axes to select specific otus."; }
     
index 4bc33a3d24989a53aa063497dcbf238f432642e8..8a1effeb7deaf02f6931633f1abfc41f355a9957 100644 (file)
 //**********************************************************************************************************************
 vector<string> ListSeqsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false); parameters.push_back(palignreport);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,24 +52,19 @@ string ListSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ListSeqsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ListSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "accnos")             {   outputFileName =  "accnos";       }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "accnos") {  pattern = "[filename],accnos"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ListSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ListSeqsCommand::ListSeqsCommand(){    
@@ -249,7 +244,9 @@ int ListSeqsCommand::execute(){
                
                if (outputDir == "") {  outputDir += m->hasPath(inputFileName);  }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("accnos");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+               string outputFileName = getOutputFileName("accnos", variables);
 
                ofstream out;
                m->openOutputFile(outputFileName, out);
index 8e4cce3c932100ff1ab88d49b346ff87e7791a06..b8a79c06035825fd92050a1e0c610ac6b77bd122 100644 (file)
@@ -23,8 +23,9 @@ class ListSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "list.seqs";                           }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/List.seqs"; }
                string getDescription()         { return "lists sequences from a list, fasta, name, group, alignreport or taxonomy file"; }
 
index 66eb7b685d318805a7ec0d92ce3b722e9a9e1778..63c249ca63e0cf46b8156638023b064f9713b4b5 100644 (file)
@@ -14,9 +14,9 @@
 //**********************************************************************************************************************
 vector<string> LoadLogfileCommand::setParameters(){    
        try {
-        CommandParameter plogfile("logfile", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plogfile);         
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter plogfile("logfile", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(plogfile);         
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -141,14 +141,14 @@ int LoadLogfileCommand::execute(){
             //look for "mothur >"
             int pos = line.find("mothur > "); //command line
             int pos2 = line.find("Output File "); //indicates command completed and we can update the current file
-            int pos3 = line.find("*****************"); 
+            int pos3 = line.find("/*****************"); 
             
             //skipping over parts where a command runs another command
             if (pos3 != string::npos) {
                 while (!in.eof()) {
                     if (m->control_pressed) { break; }
                     line = m->getline(in); m->gobble(in); 
-                    int posTemp = line.find("*****************");
+                    int posTemp = line.find("/*****************");
                     if (posTemp != string::npos) { break; }
                 }
             }
@@ -184,6 +184,7 @@ int LoadLogfileCommand::execute(){
                 Command* command = cFactory->getCommand(commandName);
                 map<string, vector<string> > thisOutputTypes = command->getOutputFiles();
                 
+                
                 for (map<string, vector<string> >::iterator it = thisOutputTypes.begin(); it != thisOutputTypes.end(); it++) {
                     if (currentTypes.count((it->first)) != 0) {  //do we save this type
                         //if yes whats its tag
@@ -191,25 +192,14 @@ int LoadLogfileCommand::execute(){
                         string thisTypesCurrentFile = "";
                         if (itCurrentFiles != currentFiles.end()) { thisTypesCurrentFile = itCurrentFiles->second;  }
                         
-                        string tag = command->getOutputFileNameTag(it->first, thisTypesCurrentFile); //pass it "fasta" and the current fasta file name.  some commands use the current name to get the extension, the others wont care.
-                        //search for the tag in the list of output files
-                        for (int h = 0; h < theseOutputNames.size(); h++) {
-                            string ending = theseOutputNames[h].substr(theseOutputNames[h].length()-tag.length(), tag.length());
-                            if (ending == tag) { //if it's there and this is a type we save a current version of, save it
-                                if ((it->first == "column") || (it->first == "phylip")) { //check for format
-                                    string RippedName = "";
-                                    bool foundDot = false;
-                                    for (int i = theseOutputNames[h].length()-1; i >= 0; i--) {
-                                        if (foundDot && (theseOutputNames[h][i] != '.')) {  RippedName = theseOutputNames[h][i] + RippedName; }
-                                        else if (foundDot && (theseOutputNames[h][i] == '.')) {  break; }
-                                        else if (!foundDot && (theseOutputNames[h][i] == '.')) {  foundDot = true; }
-                                    }
-                                    if ((RippedName == "phylip") || (RippedName == "lt") || (RippedName == "square"))  {  currentFiles["phylip"] = theseOutputNames[h];  }
-                                    else {  currentFiles["column"] = theseOutputNames[h]; }
-                                }else {  currentFiles[it->first] = theseOutputNames[h]; }
-                                break;
-                            }
-                        }
+                        //outputfilename pattern for this input type
+                        string pattern = command->getOutputPattern(it->first);
+                        updateCurrent(pattern, it->first, thisTypesCurrentFile, theseOutputNames, currentFiles);
+                        
+                        //cout << "current=\n\n";
+                        //for (map<string, string>::iterator itcc = currentFiles.begin(); itcc != currentFiles.end(); itcc++) {
+                          //  cout << itcc->first << '\t' << itcc->second << endl;
+                       // }
                     }
                 }
             }
@@ -248,4 +238,51 @@ int LoadLogfileCommand::execute(){
 }
 //**********************************************************************************************************************
 
+int LoadLogfileCommand::updateCurrent(string pattern, string type, string thisTypesCurrentFile, vector<string> filenames, map<string, string>& currentFiles){
+       try {
+        
+        vector<string> patterns; m->splitAtChar(pattern, patterns, '-');
+        
+        for (int i = 0; i < patterns.size(); i++) {
+            
+            vector<string> peices; m->splitAtChar(patterns[i], peices, ',');
+            //cout << "patterns i = " << patterns[i] << endl;
+            if (peices.size() != 0) {
+                string tag = peices[peices.size()-1];
+                //cout << "tag = " << tag << endl;
+                if (peices[peices.size()-1] == "[extension]") {  tag = m->getExtension(thisTypesCurrentFile);  }
+               
+                //search for the tag in the list of output files
+                for (int h = 0; h < filenames.size(); h++) {
+                    
+                    if (m->control_pressed) { return 0; }
+                    //cout << "filename h = " << filenames[h]<< endl;
+                    string ending = filenames[h].substr(filenames[h].length()-tag.length(), tag.length());
+                    if (ending == tag) { //if it's there and this is a type we save a current version of, save it
+                        if ((type == "column") || (type == "phylip")) { //check for format
+                            string RippedName = "";
+                            bool foundDot = false;
+                            for (int i = filenames[h].length()-1; i >= 0; i--) {
+                                if (foundDot && (filenames[h][i] != '.')) {  RippedName = filenames[h][i] + RippedName; }
+                                else if (foundDot && (filenames[h][i] == '.')) {  break; }
+                                else if (!foundDot && (filenames[h][i] == '.')) {  foundDot = true; }
+                            }
+                            if ((RippedName == "phylip") || (RippedName == "lt") || (RippedName == "square"))  {  currentFiles["phylip"] = filenames[h];  }
+                            else {  currentFiles["column"] = filenames[h]; }
+                        }else {  currentFiles[type] = filenames[h]; }
+                        break;
+                    }
+                }
+            }
+        }
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "LoadLogfileCommand", "updateCurrent");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
 
index 0fd82a86b56a364a0397207580b3954cd43a2ed2..ab8cacdc0f7229d13397c88499d458fdb3fe9858 100644 (file)
@@ -23,8 +23,8 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "load.logfile";                }
     string getCommandCategory()                { return "General";             } 
-    string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
+    string getOutputPattern(string) { return ""; }     
     string getCitation() { return "http://www.mothur.org/wiki/Load.logfile"; }
     string getDescription()            { return "extracts current files from a logfile"; }
     
@@ -35,6 +35,8 @@ private:
     bool abort;
     string outputDir, logfile;
     vector<string> outputNames;
+    
+    int updateCurrent(string pattern, string type, string, vector<string> outputNames, map<string, string>& currentFiles);
 };
 
 /**************************************************************************************************/
index 6385adef0fd1c36f73e509604f10b082a75e54a5..a19e2e39dd805a40daee5a1ca61c3f045b6899cc 100644 (file)
 //**********************************************************************************************************************
 vector<string> MakeBiomCommand::setParameters(){       
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-        CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcontaxonomy);
-        CommandParameter pmetadata("metadata", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pmetadata);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-        CommandParameter pmatrixtype("matrixtype", "Multiple", "sparse-dense", "sparse", "", "", "",false,false); parameters.push_back(pmatrixtype);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","biom",false,true,true); parameters.push_back(pshared);
+        CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pcontaxonomy);
+        CommandParameter pmetadata("metadata", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pmetadata);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+        CommandParameter pmatrixtype("matrixtype", "Multiple", "sparse-dense", "sparse", "", "", "","",false,false); parameters.push_back(pmatrixtype);
 
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -133,24 +133,19 @@ string MakeBiomCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MakeBiomCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MakeBiomCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "biom")             {   outputFileName =  "biom";       }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "biom") {  pattern = "[filename],[distance],biom"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MakeBiomCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -388,8 +383,10 @@ int MakeBiomCommand::execute(){
 //**********************************************************************************************************************
 int MakeBiomCommand::getBiom(vector<SharedRAbundVector*>& lookup){
        try {
-        
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("biom");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[distance]"] = lookup[0]->getLabel();
+        string outputFileName = getOutputFileName("biom",variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["biom"].push_back(outputFileName);
index ee9bd1c99cf415c93b57fc85087a06d870298115..7ea381f145af343213a25bd32109d20fa1fb1dee 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.biom";   }
        string getCommandCategory()             { return "General";             }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://biom-format.org/documentation/biom_format.html, http://www.mothur.org/wiki/Make.biom"; }
        string getDescription()         { return "creates a biom file"; }
     
index f2f6449a383cb58c746ea0ccee9fd2ed1483b246..bf55165dc96a6792a8f1de079dfb259b702df061 100644 (file)
 //**********************************************************************************************************************
 vector<string> MakeContigsCommand::setParameters(){    
        try {
-               CommandParameter pfasta("ffastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter prfasta("rfastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(prfasta);
-        CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
+               CommandParameter pfasta("ffastq", "InputTypes", "", "", "none", "none", "none","fasta-qfile",false,true,true); parameters.push_back(pfasta);
+        CommandParameter prfasta("rfastq", "InputTypes", "", "", "none", "none", "none","fasta-qfile",false,true,true); parameters.push_back(prfasta);
+        CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","group",false,false,true); parameters.push_back(poligos);
+               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
 //        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
 //             CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
 
-        CommandParameter palign("align", "Multiple", "needleman-gotoh", "needleman", "", "", "",false,false); parameters.push_back(palign);
-        CommandParameter pallfiles("allfiles", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pallfiles);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-        CommandParameter pthreshold("threshold", "Number", "", "40", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter palign("align", "Multiple", "needleman-gotoh", "needleman", "", "", "","",false,false); parameters.push_back(palign);
+        CommandParameter pallfiles("allfiles", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pallfiles);
+               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pmatch);
+               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pmismatch);
+               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "","",false,false); parameters.push_back(pgapopen);
+               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pgapextend);
+        CommandParameter pthreshold("threshold", "Number", "", "40", "", "", "","",false,false); parameters.push_back(pthreshold);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -72,27 +72,22 @@ string MakeContigsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MakeContigsCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MakeContigsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")             {   outputFileName =  "contigs.fasta";         }
-            else if (type == "qfile")        {   outputFileName =  "contigs.qual";          }
-            else if (type == "group")            {   outputFileName =  "groups";   }
-            else if (type == "mismatch")     {   outputFileName =  "contigs.mismatch";      }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeContigsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],[tag],contigs.fasta"; } 
+        else if (type == "qfile") {  pattern = "[filename],[tag],contigs.qual"; } 
+        else if (type == "group") {  pattern = "[filename],[tag],groups"; }
+        else if (type == "mismatch") {  pattern = "[filename],[tag],contigs.mismatch"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MakeContigsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MakeContigsCommand::MakeContigsCommand(){      
@@ -220,13 +215,15 @@ MakeContigsCommand::MakeContigsCommand(string option)  {
                        temp = validParameter.validFile(parameters, "pdiffs", false);           if (temp == "not found") { temp = "0"; }
                        m->mothurConvert(temp, pdiffs);
             
//           temp = validParameter.validFile(parameters, "ldiffs", false);            if (temp == "not found") { temp = "0"; }
 //          temp = validParameter.validFile(parameters, "ldiffs", false);            if (temp == "not found") { temp = "0"; }
 //                     m->mothurConvert(temp, ldiffs);
+            ldiffs = 0;
             
  //           temp = validParameter.validFile(parameters, "sdiffs", false);            if (temp == "not found") { temp = "0"; }
-//             m->mothurConvert(temp, sdiffs);
+ //           m->mothurConvert(temp, sdiffs);
+            sdiffs = 0;
                        
-                       temp = validParameter.validFile(parameters, "tdiffs", false);           if (temp == "not found") { int tempTotal = pdiffs + bdiffs + ldiffs + sdiffs;  temp = toString(tempTotal); }
+                       temp = validParameter.validFile(parameters, "tdiffs", false);           if (temp == "not found") { int tempTotal = pdiffs + bdiffs;  temp = toString(tempTotal); }
                        m->mothurConvert(temp, tdiffs);
                        
                        if(tdiffs == 0){        tdiffs = bdiffs + pdiffs;       }  //+ ldiffs + sdiffs;
@@ -265,20 +262,26 @@ int MakeContigsCommand::execute(){
                vector<vector<string> > qualFileNames;
         createGroup = false;
         string outputGroupFileName;
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(ffastqfile));
+        variables["[tag]"] = "";
         if(oligosfile != ""){
                        createGroup = getOligos(fastaFileNames, qualFileNames);
             if (createGroup) { 
-                outputGroupFileName = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + getOutputFileNameTag("group");
+                outputGroupFileName = getOutputFileName("group",variables);
                 outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName);
             }
                }
         
-        string outFastaFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "trim." + getOutputFileNameTag("fasta");
-        string outQualFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "trim." + getOutputFileNameTag("qfile");
-        string outScrapFastaFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "scrap." + getOutputFileNameTag("fasta");
-        string outScrapQualFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "scrap." + getOutputFileNameTag("qfile");
+        variables["[tag]"] = "trim";
+        string outFastaFile = getOutputFileName("fasta",variables);
+        string outQualFile = getOutputFileName("qfile",variables);
+        variables["[tag]"] = "scrap";
+        string outScrapFastaFile = getOutputFileName("fasta",variables);
+        string outScrapQualFile = getOutputFileName("qfile",variables);
 
-        string outMisMatchFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + getOutputFileNameTag("mismatch");
+        variables["[tag]"] = "";
+        string outMisMatchFile = getOutputFileName("mismatch",variables);
         outputNames.push_back(outFastaFile); outputTypes["fasta"].push_back(outFastaFile);
         outputNames.push_back(outQualFile); outputTypes["qfile"].push_back(outQualFile);
         outputNames.push_back(outScrapFastaFile); outputTypes["fasta"].push_back(outScrapFastaFile);
@@ -330,7 +333,7 @@ int MakeContigsCommand::execute(){
                 
                 ofstream out;
                 string thisGroupName = outputDir + m->getRootName(m->getSimpleName(it->first));
-                thisGroupName += getOutputFileNameTag("group"); outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName); 
+                thisGroupName += getOutputFileName("group",variables); outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName); 
                 m->openOutputFile(thisGroupName, out);
                  
                 while (!in.eof()){
index 86a8450afaf76ba3be6a167ce8b856a605f09166..d641ec9b26065723ec91eabc70367017ac2f160d 100644 (file)
@@ -49,8 +49,9 @@ public:
     string getCommandName()                    { return "make.contigs";                        }
     string getCommandCategory()                { return "Sequence Processing";         } 
     //commmand category choices: Sequence Processing, OTU-Based Approaches, Hypothesis Testing, Phylotype Analysis, General, Clustering and Hidden
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/Make.contigs"; }
     string getDescription()            { return "description"; }
     
index c6dcf2c83092303abdd685848efe9c875ca75976..6712196bdfb3e5d76d76a4503289f943e9c72ce8 100644 (file)
 //**********************************************************************************************************************
 vector<string> MakeFastQCommand::setParameters(){      
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pqfile);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fastq",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none","fastq",false,true,true); parameters.push_back(pqfile);
+               CommandParameter pformat("format", "Multiple", "sanger-illumina", "sanger", "", "", "","",false,false); parameters.push_back(pformat);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -32,9 +33,9 @@ vector<string> MakeFastQCommand::setParameters(){
 string MakeFastQCommand::getHelpString(){      
        try {
                string helpString = "";
-               helpString += "The make.fastq command read a fasta and quality file and creates a fastq file.\n";
-               helpString += "The make.fastq command parameters are fasta and qfile, both are required.\n";
-               helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
+               helpString += "The make.fastq command reads a fasta and quality file and creates a fastq file.\n";
+               helpString += "The make.fastq command parameters are fasta, qfile and format.  fasta and qfile are required.\n";
+               helpString += "The format parameter is used to indicate whether your sequences are sanger or illumina, default=sanger.\n";
                helpString += "The make.fastq command should be in the following format: make.fastq(qfile=yourQualityFile, fasta=yourFasta).\n";
                helpString += "Example make.fastq(fasta=amazon.fasta, qfile=amazon.qual).\n";
                helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
@@ -46,24 +47,19 @@ string MakeFastQCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MakeFastQCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MakeFastQCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fastq")             {   outputFileName =  "fastq";         }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fastq") {  pattern = "[filename],fastq"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MakeFastQCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MakeFastQCommand::MakeFastQCommand(){  
@@ -148,6 +144,14 @@ MakeFastQCommand::MakeFastQCommand(string option)  {
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);              }
+            
+            format = validParameter.validFile(parameters, "format", false);            if (format == "not found"){     format = "sanger";      }
+            
+            if ((format != "sanger") && (format != "illumina") && (format != "solexa"))  { 
+                               m->mothurOut(format + " is not a valid format. Your format choices are sanger, solexa and illumina, aborting." ); m->mothurOutEndLine();
+                               abort=true;
+                       }
+
 
                }
                
@@ -164,8 +168,9 @@ int MakeFastQCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fastq");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+               string outputFile = getOutputFileName("fastq",variables);
                outputNames.push_back(outputFile); outputTypes["fastq"].push_back(outputFile);
                
                ofstream out;
@@ -176,7 +181,7 @@ int MakeFastQCommand::execute(){
                
                ifstream fFile;
                m->openInputFile(fastafile, fFile);
-               
+        
                while (!fFile.eof() && !qFile.eof()) {
                        
                        if (m->control_pressed) { break; }
@@ -221,9 +226,10 @@ string MakeFastQCommand::convertQual(vector<int> qual) {
        try {
                string qualScores;
                
-               int controlChar = int('@');
-               
-               for (int i = 0; i < qual.size(); i++) { 
+        for (int i = 0; i < qual.size(); i++) { 
+            int controlChar = int('!');
+            if (format == "illumina") {  controlChar = int('@');  }
+            
                        int temp = qual[i] + controlChar;
                        char qualChar = (char) temp;
                        
index 9119ebd50c4c9362e73a72902b888d4f1d06b887..e3e0b70b087b17e5d6299052cb06567e9b7c9f69 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.fastq";                          }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Make.fastq"; }
        string getDescription()         { return "creates a fastq file from a fasta and quality file"; }
 
@@ -36,7 +37,7 @@ public:
        
 private:
        
-       string fastafile, qualfile, outputDir;
+       string fastafile, qualfile, outputDir, format;
        bool abort;
        vector<string> outputNames;
        
index a3aca93002977fae7cb5f4fb559f77936ba01bfc..68b1e84d0e7e6eb811971128d14490832ad390ae 100644 (file)
 //**********************************************************************************************************************
 vector<string> MakeGroupCommand::setParameters(){      
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","group",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false,true); parameters.push_back(pgroups);
+               CommandParameter poutput("output", "String", "", "", "", "", "","",false,false); parameters.push_back(poutput);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,24 +48,19 @@ string MakeGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MakeGroupCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MakeGroupCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "group")             {   outputFileName =  "groups";         }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "group") {  pattern = "[filename],groups"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MakeGroupCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MakeGroupCommand::MakeGroupCommand(){  
@@ -185,8 +180,10 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                }
                                
                                //prevent giantic file name
-                               if (fastaFileNames.size() > 3) { filename = outputDir + "merge." + getOutputFileNameTag("group"); }
-                               else {  filename += getOutputFileNameTag("group");  }
+                map<string, string> variables; 
+                variables["[filename]"] = filename;
+                               if (fastaFileNames.size() > 3) { variables["[filename]"] = outputDir + "merge"; }
+                               filename = getOutputFileName("group",variables);  
                                
                                //make sure there is at least one valid file left
                                if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
index b8521d76b1d398dd0cde7419e10750931a7b8fc4..f86c707d4516160d0dc9cc99243f54bea34d191a 100644 (file)
@@ -22,8 +22,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.group";  }
        string getCommandCategory()             { return "General";             }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Make.group"; }
        string getDescription()         { return "creates a group file"; }
 
index f3259e6096c3e0c1373e1c091078c9ceac377f82..b9e4df93eff8b19bece4740e22c6526736b1faf2 100644 (file)
 //**********************************************************************************************************************
 vector<string> MantelCommand::setParameters(){ 
        try {
-               CommandParameter pphylip1("phylip1", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip1);
-               CommandParameter pphylip2("phylip2", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip2);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip1("phylip1", "InputTypes", "", "", "none", "none", "none","mantel",false,true,true); parameters.push_back(pphylip1);
+               CommandParameter pphylip2("phylip2", "InputTypes", "", "", "none", "none", "none","mantel",false,true,true); parameters.push_back(pphylip2);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -50,24 +50,19 @@ string MantelCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MantelCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MantelCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "mantel")             {   outputFileName =  "mantel";       }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "mantel") {  pattern = "[filename],mantel"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MantelCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MantelCommand::MantelCommand(){        
@@ -226,7 +221,9 @@ int MantelCommand::execute(){
                
                if (m->control_pressed) { return 0; }
                
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(phylipfile1)) + getOutputFileNameTag("mantel");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipfile1));
+               string outputFile = getOutputFileName("mantel",variables);
                outputNames.push_back(outputFile); outputTypes["mantel"].push_back(outputFile);
                ofstream out;
                
index 644d9b21ded9302bc8be1eff6b011b17fec278ac..33fa3ea21e91fa2663994947720080933fad3d61 100644 (file)
@@ -22,8 +22,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "mantel";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Mantel"; }
        string getDescription()         { return "Mantel’s test for correlation between matrices"; }
 
index ccd4f538ab03f7ea86c59b2d3381d2de1a2de52f..b7e1dae2f5c37e4deffc613ba5024f977906b7da 100644 (file)
 //**********************************************************************************************************************
 vector<string> MatrixOutputCommand::setParameters(){   
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "",false,false); parameters.push_back(poutput);
-        CommandParameter pmode("mode", "Multiple", "average-median", "average", "", "", "",false,false); parameters.push_back(pmode);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","phylip",false,true,true); parameters.push_back(pshared);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "","",false,false); parameters.push_back(poutput);
+        CommandParameter pmode("mode", "Multiple", "average-median", "average", "", "", "","",false,false); parameters.push_back(pmode);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+        CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -61,24 +61,19 @@ string MatrixOutputCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MatrixOutputCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MatrixOutputCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "phylip")             {   outputFileName =  "dist";         }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "phylip") {  pattern = "[filename],[calc],[distance],[outputtag],dist-[filename],[calc],[distance],[outputtag],[tag2],dist"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MatrixOutputCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MatrixOutputCommand::MatrixOutputCommand(){    
@@ -486,8 +481,12 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
        try {
                vector< vector< vector<seqDist> > > calcDistsTotals;  //each iter, one for each calc, then each groupCombos dists. this will be used to make .dist files
         vector< vector<seqDist>  > calcDists; calcDists.resize(matrixCalculators.size());              
-
+                  
         for (int thisIter = 0; thisIter < iters+1; thisIter++) {
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+            variables["[distance]"] = thisLookup[0]->getLabel();
+            variables["[tag2]"] = "";
             
             vector<SharedRAbundVector*> thisItersLookup = thisLookup;
             
@@ -673,7 +672,9 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                         matrix[column][row] = dist;
                     }
                     
-                    string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + "." + getOutputFileNameTag("phylip");
+                    variables["[outputtag]"] = output;
+                    variables["[calc]"] = matrixCalculators[i]->getName();
+                    string distFileName = getOutputFileName("phylip",variables);
                     outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                     
                     ofstream outDist;
@@ -777,8 +778,14 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                     stdmatrix[row][column] = stdDist;
                     stdmatrix[column][row] = stdDist;
                 }
-            
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave." + getOutputFileNameTag("phylip");
+                
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+                variables["[distance]"] = thisLookup[0]->getLabel();
+                variables["[outputtag]"] = output;
+                variables["[tag2]"] = "ave";
+                variables["[calc]"] = matrixCalculators[i]->getName();
+                string distFileName = getOutputFileName("phylip",variables);
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outAve;
                 m->openOutputFile(distFileName, outAve);
@@ -788,7 +795,8 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                 
                 outAve.close();
                 
-                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std." + getOutputFileNameTag("phylip");
+                variables["[tag2]"] = "std";
+                distFileName = outputDir + getOutputFileName("phylip",variables);
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outSTD;
                 m->openOutputFile(distFileName, outSTD);
index ff05ef70a30736f661379608ecd291e388cf9301..8a04c96a32ed6fa769a4e14474dfb624451751d1 100644 (file)
@@ -73,8 +73,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "dist.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Dist.shared"; }
        string getDescription()         { return "generate a distance matrix that describes the dissimilarity among multiple groups"; }
 
index f68bbbedd4b7704a85b55a41a90bc2aa855902ef..643cf287bb9aded0847390aeea1091c12e95dd74 100644 (file)
 //**********************************************************************************************************************
 vector<string> MergeFileCommand::setParameters(){      
        try {
-               CommandParameter pinput("input", "String", "", "", "", "", "",false,true); parameters.push_back(pinput);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,true); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pinput("input", "String", "", "", "", "", "","",false,true,true); parameters.push_back(pinput);
+               CommandParameter poutput("output", "String", "", "", "", "", "","",false,true,true); parameters.push_back(poutput);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 9cb999bba52122480ae3a8f8d889281f9b5dd758..d7b0aff0f9691622ebc2484776ff1ba5eb5dde35 100644 (file)
@@ -22,8 +22,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "merge.files"; }
        string getCommandCategory()             { return "General";             }
-       string getOutputFileNameTag(string, string) { return "";  }
        string getHelpString(); 
+    string getOutputPattern(string){ return "";  }     
        string getCitation() { return "http://www.mothur.org/wiki/Merge.files"; }
        string getDescription()         { return "appends files creating one file"; }
 
index 5a672204973d252ce0fca2968c97acfdd112c5b5..bfd1b8484eee963c897000a20024aae831c531f5 100644 (file)
 //**********************************************************************************************************************
 vector<string> MergeGroupsCommand::setParameters(){    
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none","shared",false,false,true); parameters.push_back(pshared);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pdesign);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,26 +52,22 @@ string MergeGroupsCommand::getHelpString(){
                exit(1);
        }
 }
+
 //**********************************************************************************************************************
-string MergeGroupsCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MergeGroupsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "shared")        {   outputFileName = "merge" +  m->getExtension(inputName);       }
-            else if (type == "group")    {   outputFileName =   "merge" +  m->getExtension(inputName);     }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "shared") {  pattern = "[filename],merge,[extension]"; } 
+        else if (type == "group") {  pattern = "[filename],merge,[extension]"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MergeGroupsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 MergeGroupsCommand::MergeGroupsCommand(){      
@@ -305,7 +301,10 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("shared", sharedfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
+               string outputFileName = getOutputFileName("shared", variables);
         outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
@@ -408,7 +407,10 @@ int MergeGroupsCommand::processGroupFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
index 4db344763950b4d53376b3d44e5afebef61db2f8..3e3d337ffa0309f5132d2d88cc3b4c0b81684869 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "merge.groups";        }
        string getCommandCategory()             { return "General";                     }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Merge.groups"; }
        string getDescription()         { return "reads shared file and a design file and merges the groups in the shared file that are in the same grouping in the design file"; }
 
index b5b01e7f97166ed80143d349b9ae8c340d53e654..3eaee9652fa230281e47d77bfcf0430b3be4afa5 100644 (file)
 //**********************************************************************************************************************
 vector<string> MetaStatsCommand::setParameters(){      
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pthreshold("threshold", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","metastats",false,true,true); parameters.push_back(pshared);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pdesign);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pthreshold("threshold", "Number", "", "0.05", "", "", "","",false,false); parameters.push_back(pthreshold);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter psets("sets", "String", "", "", "", "", "","",false,false); parameters.push_back(psets);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -61,26 +61,20 @@ string MetaStatsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MetaStatsCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MetaStatsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "metastats")        {   outputFileName = "metastats";       }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "metastats") {  pattern = "[filename],[distance],[groups],metastats"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MetaStatsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 MetaStatsCommand::MetaStatsCommand(){  
        try {
@@ -470,7 +464,11 @@ int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& th
                        string setB = namesOfGroupCombos[c][1];
                
                        //get filename
-                       string outputFileName = outputDir +  m->getRootName(m->getSimpleName(sharedfile)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + "." + getOutputFileNameTag("metastats");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+            variables["[distance]"] = thisLookUp[0]->getLabel();
+            variables["[group]"] = setA + "-" + setB;
+                       string outputFileName = getOutputFileName("metastats",variables);
                        outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
                        //int nameLength = outputFileName.length();
                        //char * output = new char[nameLength];
index 377adf18db177f145e1578d41e455fd7c70d6733..7884130ad55dda3fff3fb7880a4c80e6fe15ed9b 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "metastats";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "White JR, Nagarajan N, Pop M (2009). Statistical methods for detecting differentially abundant features in clinical metagenomic samples. PLoS Comput Biol 5: e1000352. \nhttp://www.mothur.org/wiki/Metastats"; }
        string getDescription()         { return "detects differentially abundant features in clinical metagenomic samples"; }
 
index 1861aa5b5d8c19f547ed90e3ec57866a3b53ecd2..b9c9d1eb845543bc38893068081b9367b913980b 100644 (file)
 //**********************************************************************************************************************
 vector<string> MGClusterCommand::setParameters(){      
        try {
-               CommandParameter pblast("blast", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pblast);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter plength("length", "Number", "", "5", "", "", "",false,false); parameters.push_back(plength);
-               CommandParameter ppenalty("penalty", "Number", "", "0.10", "", "", "",false,false); parameters.push_back(ppenalty);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pmin("min", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmin);
-               CommandParameter pmerge("merge", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmerge);
-               CommandParameter phcluster("hcluster", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phcluster);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pblast("blast", "InputTypes", "", "", "none", "none", "none","list",false,true,true); parameters.push_back(pblast);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName","rabund-sabund",false,false,true); parameters.push_back(pname);
+               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter plength("length", "Number", "", "5", "", "", "","",false,false); parameters.push_back(plength);
+               CommandParameter ppenalty("penalty", "Number", "", "0.10", "", "", "","",false,false); parameters.push_back(ppenalty);
+               CommandParameter pcutoff("cutoff", "Number", "", "0.70", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average", "average", "", "", "","",false,false); parameters.push_back(pmethod);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+               CommandParameter pmin("min", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmin);
+               CommandParameter pmerge("merge", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmerge);
+               CommandParameter phcluster("hcluster", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(phcluster);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -62,28 +62,23 @@ string MGClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string MGClusterCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string MGClusterCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MGClusterCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-//**********************************************************************************************************************
+//*******************************************************************************************************************
 MGClusterCommand::MGClusterCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -274,11 +269,13 @@ int MGClusterCommand::execute(){
                else if (method == "nearest")   { tag = "nn";  }
                else                                                    { tag = "an";  }
                
-        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
-        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
-        string listFileName = fileroot+ tag + ".";
-        if (countfile != "") { listFileName += "unique_"; }
-        listFileName += getOutputFileNameTag("list");
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+        if (countfile != "") { variables["[tag2]"] = "unique_list"; }
+        variables["[clustertag]"] = tag;
+        string sabundFileName = getOutputFileName("sabund", variables);
+        string rabundFileName = getOutputFileName("rabund", variables);
+        string listFileName = getOutputFileName("list", variables);
         
         if (countfile == "") {
             m->openOutputFile(sabundFileName,  sabundFile);
index b5b295f1edb4495d321a7e614db1e8309d8bc481..008bd222a0a91869e14895738ea852b383c0395f 100644 (file)
@@ -31,8 +31,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "mgcluster";   }
        string getCommandCategory()             { return "Clustering";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Handelsman J (2008). A statistical toolbox for metagenomics. BMC Bioinformatics 9: 34. \nhttp://www.mothur.org/wiki/Mgcluster"; }
        string getDescription()         { return "cluster your sequences into OTUs using a blast file"; }
 
index 085039eb1b9c3313acb5541744c5484abf49312a..b2426f5c1bf0cf38306bea7bf756c01743a21f5a 100644 (file)
 vector<string> NewCommand::setParameters(){    
        try {
                //eaxamples of each type of parameter. more info on the types of parameters can be found in commandparameter.h
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pprocessors);
         
         //files that have dependancies
-        CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);              
+        CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","outputType",false,false); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName","outputType",false,false); parameters.push_back(pname);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName","outputType",false,false); parameters.push_back(pcolumn);         
         //files that do not have dependancies - fasta is set to not be required whereas shared is set to be required
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);            
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","outputType",false,false); parameters.push_back(pfasta);
+        CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","outputType",false,true); parameters.push_back(pshared);               
 
         
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
+        CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
                
         //choose more than one multiple options
-        CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
+        CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "","",true,false); parameters.push_back(pcalc);
         //choose only one multiple options
-        CommandParameter pdistance("distance", "Multiple", "column-lt-square", "column", "", "", "",false,false); parameters.push_back(pdistance);
+        CommandParameter pdistance("distance", "Multiple", "column-lt-square", "column", "", "", "","",false,false); parameters.push_back(pdistance);
         
-        CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);
+        CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
         
         //every command must have inputdir and outputdir.  This allows mothur users to redirect input and output files.
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -64,26 +64,21 @@ string NewCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string NewCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string tag = "";
-               map<string, vector<string> >::iterator it;
+string NewCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fileType1") {  tag = "tag1"; }
-            else if (type == "fileType2") {  tag = "tag2"; }
-            else if (type == "fileType3") {  tag = "tag3"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return tag;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NewCommand", "getOutputFileName");
-               exit(1);
-       }
+        if (type == "fileType1") {  pattern = "[filename],tag1"; }
+        else if (type == "fileType2") {  pattern = "[filename],tag2"; }
+        else if (type == "fileType3") {  pattern = "[filename],tag3"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "NewCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 NewCommand::NewCommand(){      
index ae57bd81de4b78d5aff12757341dec0068139d0c..8d1173192b35189bc7151d81b6c23bacc7f31a57 100644 (file)
@@ -35,9 +35,10 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "newCommandNameToBeSeenByUser";                        }
     string getCommandCategory()                { return "commandCategory";             } 
-    string getOutputFileNameTag(string, string);
+    
+    string getOutputPattern(string);
     //commmand category choices: Sequence Processing, OTU-Based Approaches, Hypothesis Testing, Phylotype Analysis, General, Clustering and Hidden
-       string getHelpString();         
+       string getHelpString(); 
     string getCitation() { return "http://www.mothur.org/wiki/newCommandNameToBeSeenByUser"; }
     string getDescription()            { return "brief description"; }
     
index 900f50bd43ffb2aaee98f279023e684bb8d7c00d..a90ed2965888928f4a90049fe04fe888d773c450 100644 (file)
 //**********************************************************************************************************************
 vector<string> NMDSCommand::setParameters(){   
        try {
-               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paxes);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pmaxdim("maxdim", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmaxdim);
-               CommandParameter pmindim("mindim", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmindim);
-               CommandParameter piters("iters", "Number", "", "10", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pmaxiters("maxiters", "Number", "", "500", "", "", "",false,false); parameters.push_back(pmaxiters);
-               CommandParameter pepsilon("epsilon", "Number", "", "0.000000000001", "", "", "",false,false); parameters.push_back(pepsilon);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(paxes);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","nmds-stress",false,true,true); parameters.push_back(pphylip);
+               CommandParameter pmaxdim("maxdim", "Number", "", "2", "", "", "","",false,false); parameters.push_back(pmaxdim);
+               CommandParameter pmindim("mindim", "Number", "", "2", "", "", "","",false,false); parameters.push_back(pmindim);
+               CommandParameter piters("iters", "Number", "", "10", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pmaxiters("maxiters", "Number", "", "500", "", "", "","",false,false); parameters.push_back(pmaxiters);
+               CommandParameter pepsilon("epsilon", "Number", "", "0.000000000001", "", "", "","",false,false); parameters.push_back(pepsilon);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -55,27 +55,23 @@ string NMDSCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string NMDSCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string NMDSCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "nmds") {  outputFileName =  "nmds.axes"; }
-            else if (type == "stress") {  outputFileName =  "nmds.stress"; }
-            else if (type == "iters") {  outputFileName =  "nmds.iters"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "nmds") {  pattern = "[filename],nmds.axes"; } 
+        else if (type == "stress") {  pattern = "[filename],nmds.stress"; } 
+        else if (type == "iters") {  pattern = "[filename],nmds.iters"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "NMDSCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 NMDSCommand::NMDSCommand(){    
        try {
@@ -208,8 +204,10 @@ int NMDSCommand::execute(){
                vector< vector<double> > axes;
                if (axesfile != "") {  axes = readAxes(names);          }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("iters");
-               string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("stress");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(phylipfile));
+               string outputFileName = getOutputFileName("iters",variables);
+               string stressFileName = getOutputFileName("stress",variables);
                outputNames.push_back(outputFileName); outputTypes["iters"].push_back(outputFileName);
                outputNames.push_back(stressFileName); outputTypes["stress"].push_back(stressFileName);
                
@@ -278,7 +276,7 @@ int NMDSCommand::execute(){
                out.close(); out2.close();
                
                //output best config
-               string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("nmds");
+               string BestFileName = getOutputFileName("nmds",variables);
                outputNames.push_back(BestFileName); outputTypes["nmds"].push_back(BestFileName);
                
                m->mothurOut("\nNumber of dimensions:\t" + toString(bestDim) + "\n");
index 90364adcdc03198320a12c86fc0ef4b7f970c650..92b694864a6d15f5b5dc20f176a271a7506ae6eb 100644 (file)
@@ -37,8 +37,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "nmds";                                        }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Borg, Groenen (1997). Non-metric multidimensional scaling function using the majorization algorithm, in Modern Multidimensional Scaling. Ed. T.F. Cox and M.A.A. Cox. Chapman and Hall. \nhttp://www.mothur.org/wiki/Nmds"; }
        string getDescription()         { return "nmds"; }
 
index a5855dced6a50c8a808464421ceb34dd6cd5aa24..8c1d7222964a40de5cd06835260c2a5323238584 100644 (file)
@@ -25,7 +25,7 @@ public:
        string getCommandName()             { return "NoCommand";       }
        string getCommandCategory()         { return "Hidden";          }
        string getHelpString()              { return "No Command";      }       
-    string getOutputFileNameTag(string, string) { return "";                }
+    string getOutputPattern(string) { return "";                }
        string getCitation()                { return "no citation";     }
        string getDescription()             { return "no description";  }
 
index e41cfd9355ce1e08157069e59880aa32066e1505..acd8208ea7ebb20a3d3810d254d0b24f5386d4d3 100644 (file)
 //**********************************************************************************************************************
 vector<string> NormalizeSharedCommand::setParameters(){        
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "totalgroup-zscore", "totalgroup", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pnorm("norm", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnorm);
-               CommandParameter pmakerelabund("makerelabund", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pmakerelabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","shared",false,false,true); parameters.push_back(pshared);      
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none","shared",false,false,true); parameters.push_back(prelabund);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pmethod("method", "Multiple", "totalgroup-zscore", "totalgroup", "", "", "","",false,false,true); parameters.push_back(pmethod);
+               CommandParameter pnorm("norm", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pnorm);
+               CommandParameter pmakerelabund("makerelabund", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pmakerelabund);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,26 +53,20 @@ string NormalizeSharedCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string NormalizeSharedCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string NormalizeSharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "shared") {  outputFileName =  "norm.shared"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "shared") {  pattern = "[filename],[distance],norm.shared"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "NormalizeSharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 NormalizeSharedCommand::NormalizeSharedCommand(){      
@@ -468,7 +462,11 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
                
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+        variables["[distance]"] = thisLookUp[0]->getLabel();
+               string outputFileName = getOutputFileName("shared",variables);
+        
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
@@ -559,7 +557,10 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLook
                //save mothurOut's binLabels to restore for next label
                vector<string> saveBinLabels = m->currentBinLabels;
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+        variables["[distance]"] = thisLookUp[0]->getLabel();
+               string outputFileName = getOutputFileName("shared",variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
index 2feb40d1bcf105a485b5790ebc3be2484a94f0d5..53bcd6b5e4aac7d0a463fa436fc8ed6346f5f069 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "normalize.shared";            }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Normalize.shared"; }
        string getDescription()         { return "normalize samples in a shared or relabund file"; }
 
index 968d76744be5b296a9b9f98a5294356366783bce..23cac294cad4f1b25caa0e4f4d55de40f1fb2876 100644 (file)
 //**********************************************************************************************************************
 vector<string> OTUAssociationCommand::setParameters(){ 
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(prelabund);
-        CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pmetadata);
-        CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","otucorr",false,false,true); parameters.push_back(pshared);
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none","otucorr",false,false); parameters.push_back(prelabund);
+        CommandParameter pmetadata("metadata", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pmetadata);
+        CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "","",false,false,true); parameters.push_back(pmethod);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -55,24 +55,19 @@ string OTUAssociationCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string OTUAssociationCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string OTUAssociationCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "otucorr") {  outputFileName =  "otu.corr"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "otucorr") {  pattern = "[filename],[distance],[tag],otu.corr"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "OTUAssociationCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 OTUAssociationCommand::OTUAssociationCommand(){        
@@ -331,8 +326,11 @@ int OTUAssociationCommand::processShared(){
 //**********************************************************************************************************************
 int OTUAssociationCommand::process(vector<SharedRAbundVector*>& lookup){
        try {
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr");
+               map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[distance]"] = lookup[0]->getLabel();
+        variables["[tag]"] = method;
+               string outputFileName = getOutputFileName("otucorr",variables);
                outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName);
                
                ofstream out;
@@ -492,7 +490,11 @@ int OTUAssociationCommand::processRelabund(){
 int OTUAssociationCommand::process(vector<SharedRAbundFloatVector*>& lookup){
        try {
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr");
+               map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName));
+        variables["[distance]"] = lookup[0]->getLabel();
+        variables["[tag]"] = method;
+        string outputFileName = getOutputFileName("otucorr",variables);
                outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName);
                
                ofstream out;
index 7f7664be5eda5568f17723e8ccede599c1169f8b..e9cdb2a290fb5a778bf936e3040b97433121be32 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "otu.association";                     }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Otu.association"; }
        string getDescription()         { return "calculate the correlation coefficient for the otus in a shared/relabund file"; }
        
index 091bf9bb0659dd0895bf47a414fa4ea86692f026..dc026decc9db9916513fcbd1d41fe23298173717 100644 (file)
 //**********************************************************************************************************************
 vector<string> OtuHierarchyCommand::setParameters(){   
        try {
-               CommandParameter poutput("output", "Multiple", "name-number", "name", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter poutput("output", "Multiple", "name-number", "name", "", "", "","",false,false); parameters.push_back(poutput);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","otuheirarchy",false,true,true); parameters.push_back(plist);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -47,24 +47,19 @@ string OtuHierarchyCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string OtuHierarchyCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string OtuHierarchyCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "otuheirarchy") {  outputFileName =  "otu.hierarchy"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "otuheirarchy") {  pattern = "[filename],[distance1],[tag],[distance2],otu.hierarchy"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "OtuHierarchyCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 OtuHierarchyCommand::OtuHierarchyCommand(){    
@@ -199,7 +194,12 @@ int OtuHierarchyCommand::execute(){
                }
                
                ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + "." + getOutputFileNameTag("otuheirarchy");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listFile));
+        variables["[distance1]"] = lists[0].getLabel();
+        variables["[tag]"] = "-"; 
+        variables["[distance2]"] = lists[1].getLabel();
+               string outputFileName = getOutputFileName("otuheirarchy",variables);
                m->openOutputFile(outputFileName, out);
                
                //go through each bin in "big" otu and output the bins in "little" otu which created it
index ad6da0cf529121202b3bfc5d1c1d6bdc166cba16..cd106ece49d90dcfe28a0d272b672919281a912b 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "otu.hierarchy";                       }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Otu.hierarchy"; }
        string getDescription()         { return "relates OTUs at different distances"; }
 
index dd824316744eda7025026869c0aebb44256f98dd..0f8602871561c20804b49bdc948da6194b25adbe 100644 (file)
 //**********************************************************************************************************************
 vector<string> PairwiseSeqsCommand::setParameters(){   
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "",false,false); parameters.push_back(palign);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter poutput("output", "Multiple", "column-lt-square-phylip", "column", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcountends);
-               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcompress);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","phylip-column",false,true,true); parameters.push_back(pfasta);
+               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "","",false,false); parameters.push_back(palign);
+               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pmatch);
+               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pmismatch);
+               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "","",false,false); parameters.push_back(pgapopen);
+               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "","",false,false); parameters.push_back(pgapextend);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter poutput("output", "Multiple", "column-lt-square-phylip", "column", "", "", "","phylip-column",false,false,true); parameters.push_back(poutput);
+               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "","",false,false); parameters.push_back(pcalc);
+               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pcountends);
+               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pcompress);
+               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,25 +65,20 @@ string PairwiseSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string PairwiseSeqsCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PairwiseSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "phylip") {  outputFileName =  "dist"; }
-            else if (type == "column") {  outputFileName =  "dist"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "phylip") {  pattern = "[filename],[outputtag],dist"; } 
+        else if (type == "column") { pattern = "[filename],dist"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PairwiseSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 PairwiseSeqsCommand::PairwiseSeqsCommand(){    
@@ -291,16 +286,20 @@ int PairwiseSeqsCommand::execute(){
                        int numSeqs = alignDB.getNumSeqs();
                        int startTime = time(NULL);
                        string outputFile = "";
-                               
+                       
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]));
                        if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "phylip." + getOutputFileNameTag("phylip");
+                               variables["[outputtag]"] = "phylip";
+                outputFile = getOutputFileName("phylip", variables);
                                m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile);
                        }else if (output == "column") { //user wants column format
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("column");
+                               outputFile = getOutputFileName("column", variables);
                                outputTypes["column"].push_back(outputFile);
                                m->mothurRemove(outputFile);
                        }else { //assume square
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "square." + getOutputFileNameTag("phylip");
+                variables["[outputtag]"] = "square";
+                outputFile = getOutputFileName("phylip", variables);
                                m->mothurRemove(outputFile);
                                outputTypes["phylip"].push_back(outputFile);
                        }
index 0e749d5c7e252ceb7c777de1e8878084f61b0a4d..33fcfca0b6d0207ed1f282a36061893805745203 100644 (file)
@@ -40,8 +40,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pairwise.seqs";               }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Needleman SB, Wunsch CD (1970). A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48: 443-53. [ for needleman ]\nGotoh O (1982). An improved algorithm for matching biological sequences. J Mol Biol 162: 705-8. [ for gotoh ] \nhttp://www.mothur.org/wiki/Pairwise.seqs"; }
        string getDescription()         { return "calculates pairwise distances from an unaligned fasta file"; }
 
index ba23ae3253eed3c9ef3f5cbd8dc0b927348875a6..63ed3144ad2a2b86ed33c6f9449b8d8143d38204 100644 (file)
 //**********************************************************************************************************************
 vector<string> ParseFastaQCommand::setParameters(){    
        try {
-               CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfastq);
-               CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pqual("qfile", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqual);
-               CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa", "sanger", "", "", "",false,false); parameters.push_back(pformat);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pfastq);
+               CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "","fasta",false,false); parameters.push_back(pfasta);
+               CommandParameter pqual("qfile", "Boolean", "", "T", "", "", "","qfile",false,false); parameters.push_back(pqual);
+               CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa", "sanger", "", "", "","",false,false,true); parameters.push_back(pformat);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -49,27 +49,21 @@ string ParseFastaQCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ParseFastaQCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ParseFastaQCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "fasta"; }
-            else if (type == "qfile") {  outputFileName =  "qual"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],fasta"; } 
+        else if (type == "qfile") {  pattern = "[filename],qual"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ParseFastaQCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ParseFastaQCommand::ParseFastaQCommand(){      
        try {
@@ -163,8 +157,10 @@ int ParseFastaQCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //open Output Files
-               string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("fasta");
-               string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("qfile");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaQFile));
+               string fastaFile = getOutputFileName("fasta",variables);
+               string qualFile = getOutputFileName("qfile",variables);
                ofstream outFasta, outQual;
                
                if (fasta) { m->openOutputFile(fastaFile, outFasta);  outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile);      }
@@ -261,9 +257,9 @@ vector<int> ParseFastaQCommand::convertQual(string qual) {
                 temp -= 64; //char '@'
             }else if (format == "solexa") {
                 temp = int(convertTable[temp]); //convert to sanger
-                temp -= 33; //char '!'
+                temp -= int('!'); //char '!'
             }else {
-                temp -= 33; //char '!'
+                temp -= int('!'); //char '!'
             }
                        qualScores.push_back(temp);
                }
index 96fcb7d6799358ff4e10f930d1ad4165763b46a0..b4d90e542a98f329dd166a93c54d57852e0f54dd 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parse.fastq";         }
        string getCommandCategory()             { return "Sequence Processing"; }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Parse.fastq"; }
        string getDescription()         { return "reads a fastq file and creates a fasta and quality file"; }
 
index 4e61a58d9e5cb4bc640c544797c87a363580575e..61cb2454b52ee9e05cf1027995906371b5463762 100644 (file)
 //**********************************************************************************************************************
 vector<string> ParseListCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","list",false,true,true); parameters.push_back(plist);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pgroup);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,26 +46,20 @@ string ParseListCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ParseListCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ParseListCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[group],list"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ParseListCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ParseListCommand::ParseListCommand(){  
        try {
@@ -191,7 +185,8 @@ int ParseListCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //set fileroot
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
+               map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
                
                //fill filehandles with neccessary ofstreams
                int i;
@@ -201,7 +196,8 @@ int ParseListCommand::execute(){
                        temp = new ofstream;
                        filehandles[gGroups[i]] = temp;
                        
-                       string filename = fileroot +  gGroups[i] + "." + getOutputFileNameTag("list");
+            variables["[group]"] = gGroups[i];
+                       string filename = getOutputFileName("list",variables);
                        outputNames.push_back(filename); outputTypes["list"].push_back(filename);
                        m->openOutputFile(filename, *temp);
                }
index 1faeaeb9f31f13ce0b3a5e4f1fbbe1f524ac6501..b366d28a6a84a7558cda6547497130ef0c09cbdc 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parse.list";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Parse.list"; }
        string getDescription()         { return "parses a list file by group"; }
        
index eabbb5934445f92345eccd30f9bfb2139e652543..64d249831ad56f5501dd6dd4d44f17bda35daf78 100644 (file)
 //**********************************************************************************************************************
 vector<string> ParsimonyCommand::setParameters(){      
        try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter prandom("random", "String", "", "", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","parsimony-psummary",false,true,true); parameters.push_back(ptree);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter prandom("random", "String", "", "", "", "", "","",false,false); parameters.push_back(prandom);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,27 +54,21 @@ string ParsimonyCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ParsimonyCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ParsimonyCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "parsimony") {  outputFileName =  "parsimony"; }
-            else if (type == "psummary") {  outputFileName =  "psummary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "parsimony") {  pattern = "[filename],parsimony"; } 
+        else if (type == "psummary") {  pattern = "[filename],psummary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ParsimonyCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ParsimonyCommand::ParsimonyCommand(){  
        try {
@@ -252,11 +246,14 @@ int ParsimonyCommand::execute() {
             delete reader;
        
                        if(outputDir == "") { outputDir += m->hasPath(treefile); }
-                       output = new ColumnFile(outputDir + m->getSimpleName(treefile)  +  "." + getOutputFileNameTag("parsimony"), itersString);
-                       outputNames.push_back(outputDir + m->getSimpleName(treefile)  +  "." + getOutputFileNameTag("parsimony"));
-                       outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(treefile)  + "." + getOutputFileNameTag("parsimony"));
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getSimpleName(treefile) +  ".";
+            
+                       output = new ColumnFile(getOutputFileName("parsimony",variables), itersString);
+                       outputNames.push_back(getOutputFileName("parsimony",variables));
+                       outputTypes["parsimony"].push_back(getOutputFileName("parsimony",variables));
                                
-                       sumFile = outputDir + m->getSimpleName(treefile) + "." + getOutputFileNameTag("psummary");
+                       sumFile = getOutputFileName("psummary",variables);
                        m->openOutputFile(sumFile, outSum);
                        outputNames.push_back(sumFile);
                        outputTypes["psummary"].push_back(sumFile);
@@ -579,7 +576,7 @@ void ParsimonyCommand::getUserInput() {
             
                        //set tmaps namesOfSeqs
                        for (int j = 0; j < num; j++) {
-                               groupMap[toString(count)] = i;
+                               groupMap[toString(count)] = toString(i);
                                nameMap.insert(toString(count));
                                count++;
                        }
@@ -591,6 +588,7 @@ void ParsimonyCommand::getUserInput() {
                getline(cin, s);
                
                m->Treenames = ct->getNamesOfSeqs(); 
+        m->runParse = false;
        }
        catch(exception& e) {
                m->errorOut(e, "ParsimonyCommand", "getUserInput");
index 38a7505125e52b39ad37f36df592dfc9cac3b54c..7f7ad893b74140087248edfd7deb7b8c3441e671 100644 (file)
@@ -28,8 +28,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parsimony";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Slatkin M, Maddison WP (1989). A cladistic measure of gene flow inferred from the phylogenies of alleles. Genetics 123: 603-13. \nSlatkin M, Maddison WP (1990). Detecting isolation by distance using phylogenies of genes. Genetics 126: 249-60. \nMartin AP (2002). Phylogenetic approaches for describing and comparing the diversity of microbial communities. Appl Environ Microbiol 68: 3673-82. \nSchloss PD, Handelsman J (2006). Introducing TreeClimber, a test to compare microbial community structure. Appl Environ Microbiol 72: 2379-84.\nhttp://www.mothur.org/wiki/Parsimony"; }
        string getDescription()         { return "generic test that describes whether two or more communities have the same structure"; }
 
index 2cb37bda8896f8f2cb1f64521f1a73232507f24b..7103adb8a150a3e6f9871989ba94bd45d2b6a542 100644 (file)
 //**********************************************************************************************************************
 vector<string> PCACommand::setParameters(){    
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","pca-loadings",false,false,true); parameters.push_back(pshared);        
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none","pca-loadings",false,false,true); parameters.push_back(prelabund);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmetric);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -49,25 +49,20 @@ string PCACommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string PCACommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PCACommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "pca") {  outputFileName =  "pca.axes"; }
-            else if (type == "loadings") {  outputFileName =  "pca.loadings"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "pca") {  pattern = "[filename],[distance],pca.axes"; } 
+        else if (type == "loadings") {  pattern = "[filename],[distance],pca.loadings"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PCACommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -386,8 +381,8 @@ int PCACommand::process(vector<SharedRAbundFloatVector*>& lookupFloat){
                if (m->control_pressed) { return 0; }
                
                string fbase = outputDir + m->getRootName(m->getSimpleName(inputFile));
-               string outputFileName = fbase + lookupFloat[0]->getLabel();
-               output(outputFileName, m->getGroups(), X, d);
+               //string outputFileName = fbase + lookupFloat[0]->getLabel();
+               output(fbase, lookupFloat[0]->getLabel(), m->getGroups(), X, d);
                
                if (metric) {   
                        
@@ -416,7 +411,7 @@ int PCACommand::process(vector<SharedRAbundFloatVector*>& lookupFloat){
 }
 /*********************************************************************************************************************************/
 
-void PCACommand::output(string fnameRoot, vector<string> name_list, vector<vector<double> >& G, vector<double> d) {
+void PCACommand::output(string fbase, string label, vector<string> name_list, vector<vector<double> >& G, vector<double> d) {
        try {
 
                int numEigenValues = d.size();
@@ -426,18 +421,23 @@ void PCACommand::output(string fnameRoot, vector<string> name_list, vector<vecto
                }
                
                ofstream pcaData;
-        m->openOutputFile((fnameRoot+"."+getOutputFileNameTag("pca")), pcaData);
+        map<string, string> variables; 
+        variables["[filename]"] = fbase;
+        variables["[distance]"] = label;
+        string pcaFileName = getOutputFileName("pca",variables);
+        m->openOutputFile(pcaFileName, pcaData);
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
-               outputNames.push_back(fnameRoot+"."+getOutputFileNameTag("pca"));
-               outputTypes["pca"].push_back(fnameRoot+"."+getOutputFileNameTag("pca"));
+               outputNames.push_back(pcaFileName);
+               outputTypes["pca"].push_back(pcaFileName);
                
                ofstream pcaLoadings;
-         m->openOutputFile((fnameRoot+"."+getOutputFileNameTag("loadings")), pcaLoadings);
+        string loadingsFilename = getOutputFileName("loadings",variables);
+         m->openOutputFile(loadingsFilename, pcaLoadings);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+"."+getOutputFileNameTag("loadings"));
-               outputTypes["loadings"].push_back(fnameRoot+"."+getOutputFileNameTag("loadings"));      
+               outputNames.push_back(loadingsFilename);
+               outputTypes["loadings"].push_back(loadingsFilename);    
                
                pcaLoadings << "axis\tloading\n";
                for(int i=0;i<numEigenValues;i++){
index 64235841a9a29b651ea4f1fe2b64e2125876bc43..482ecc3fecf678cca5853eb9c1160f005204a604 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pca";                                 }
        string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Pca"; }
        string getDescription()         { return "pca"; }
 
@@ -44,7 +45,7 @@ private:
        
        //vector< vector<double> > createMatrix(vector<SharedRAbundFloatVector*>);
        int process(vector<SharedRAbundFloatVector*>&);
-       void output(string, vector<string>, vector<vector<double> >&, vector<double>);
+       void output(string, string, vector<string>, vector<vector<double> >&, vector<double>);
        
 };
 
index 354826f8c0b27a359b1eb1530e6a0d7a9fbaf32f..2043a128bd94bc755cb7ef10f5a8b8d9bdb5a6be 100644 (file)
 //**********************************************************************************************************************
 vector<string> PCOACommand::setParameters(){   
        try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","pcoa-loadings",false,true,true); parameters.push_back(pphylip);
+               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pmetric);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -45,29 +45,24 @@ string PCOACommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string PCOACommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PCOACommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "pcoa") {  outputFileName =  "pcoa.axes"; }
-            else if (type == "loadings") {  outputFileName =  "pcoa.loadings"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "pcoa") {  pattern = "[filename],pcoa.axes"; } 
+        else if (type == "loadings") {  pattern = "[filename],pcoa.loadings"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PCOACommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
+
 //**********************************************************************************************************************
 PCOACommand::PCOACommand(){    
        try {
@@ -251,7 +246,9 @@ void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vect
                }
                
                ofstream pcaData;
-        string pcoaDataFile = fnameRoot+getOutputFileNameTag("pcoa");
+        map<string, string> variables; 
+        variables["[filename]"] = fnameRoot;
+        string pcoaDataFile = getOutputFileName("pcoa",variables);
         m->openOutputFile(pcoaDataFile, pcaData);
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
@@ -259,7 +256,7 @@ void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vect
                outputTypes["pcoa"].push_back(pcoaDataFile);
                
                ofstream pcaLoadings;
-        string loadingsFile = fnameRoot+getOutputFileNameTag("loadings");
+        string loadingsFile = getOutputFileName("loadings",variables);
         m->openOutputFile(loadingsFile, pcaLoadings);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);
index 93feefa3dec06bc6084055fc701a6cd8baf058de..29957f1140e81517cc5a244a696eba7aaf1db49a 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pcoa";                                        }
        string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Pcoa"; }
        string getDescription()         { return "pcoa"; }
 
index d35850ce74296fa4f4471927817becd21145dbee..9fc40419411ff2535f01eb150699b30227225a3b 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pcr.seqs";    }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Pcr.seqs"; }
        string getDescription()         { return "pcr.seqs"; }
     
index b0c11f68ff26dad59634375c80c44ecf0dd0382b..002c577798cd3977fa68ba1557b196cf90bf716b 100644 (file)
 vector<string> PhyloDiversityCommand::setParameters(){ 
        try {
 
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prarefy("rarefy", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prarefy);
-               CommandParameter psummary("summary", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(psummary);
-               CommandParameter pcollect("collect", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcollect);
-               CommandParameter pscale("scale", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","phylodiv",false,true,true); parameters.push_back(ptree);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter prarefy("rarefy", "Boolean", "", "F", "", "", "","rarefy",false,false); parameters.push_back(prarefy);
+               CommandParameter psummary("summary", "Boolean", "", "T", "", "", "","summary",false,false); parameters.push_back(psummary);
+               CommandParameter pcollect("collect", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pcollect);
+               CommandParameter pscale("scale", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pscale);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -63,26 +63,21 @@ string PhyloDiversityCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string PhyloDiversityCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PhyloDiversityCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "phylodiv") {  outputFileName =  "phylodiv"; }
-            else if (type == "rarefy") {  outputFileName =  "phylodiv.rarefaction"; }
-            else if (type == "summary") {  outputFileName =  "phylodiv.summary"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "phylodiv") {  pattern = "[filename],[tag],phylodiv"; } 
+        else if (type == "rarefy") {  pattern = "[filename],[tag],phylodiv.rarefaction"; } 
+        else if (type == "summary") {  pattern = "[filename],[tag],phylodiv.summary"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PhyloDiversityCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -284,9 +279,12 @@ int PhyloDiversityCommand::execute(){
                        if (m->control_pressed) { delete ct; for (int j = 0; j < trees.size(); j++) { delete trees[j]; } for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } return 0; }
                        
                        ofstream outSum, outRare, outCollect;
-                       string outSumFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + "." + getOutputFileNameTag("summary");
-                       string outRareFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + "." + getOutputFileNameTag("rarefy");
-                       string outCollectFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + "." + getOutputFileNameTag("phylodiv");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+            variables["[tag]"] = toString(i+1);
+                       string outSumFile = getOutputFileName("summary",variables);
+                       string outRareFile = getOutputFileName("rarefy",variables);
+                       string outCollectFile = getOutputFileName("phylodiv",variables);
                        
                        if (summary)    { m->openOutputFile(outSumFile, outSum); outputNames.push_back(outSumFile);             outputTypes["summary"].push_back(outSumFile);                   }
                        if (rarefy)             { m->openOutputFile(outRareFile, outRare); outputNames.push_back(outRareFile);  outputTypes["rarefy"].push_back(outRareFile);                   }
@@ -301,6 +299,31 @@ int PhyloDiversityCommand::execute(){
                                        randomLeaf.push_back(j); 
                                }
                        }
+            
+           /* float sum = 0;
+            vector<float> sums; sums.resize(m->getGroups().size(), 0);
+            vector<float> sumsAboveRoot; sumsAboveRoot.resize(m->getGroups().size(), 0);
+            for (int j = 0; j < trees[i]->getNumNodes(); j++) { 
+                if (trees[i]->tree[j].getBranchLength() < 0) { cout << j << '\t' << trees[i]->tree[j].getName() << '\t' << trees[i]->tree[j].getBranchLength() << endl; }
+                
+                               sum += abs(trees[i]->tree[j].getBranchLength());
+                for (int k = 0; k < m->getGroups().size(); k++) {
+                    map<string, int>::iterator itGroup = trees[i]->tree[j].pcount.find(m->getGroups()[k]);
+                    if (itGroup != trees[i]->tree[j].pcount.end()) {  //this branch belongs to a group we care about
+                        if (j < rootForGroup[m->getGroups()[k]]) {
+                            sums[k] += abs(trees[i]->tree[j].getBranchLength());
+                        }else {
+                            sumsAboveRoot[k] += abs(trees[i]->tree[j].getBranchLength());
+                        }
+                    } 
+                }
+                       }
+            cout << sum << endl; //exit(1);
+            
+            for (int k = 0; k < m->getGroups().size(); k++) {
+                cout << m->getGroups()[k] << "root node = " << rootForGroup[m->getGroups()[k]] << "sum below root = " << sums[k] << "sum above root = " << sumsAboveRoot[k] << endl;
+            }
+             exit(1);  */ 
                        
                        numLeafNodes = randomLeaf.size();  //reset the number of leaf nodes you are using 
                        
@@ -571,6 +594,7 @@ void PhyloDiversityCommand::printSumData(map< string, vector<float> >& div, ofst
                        else            {       score = div[mGroups[j]][numSampled] / (float)numIters;  }
                                
                        out << setprecision(4) << score << endl;
+            cout << mGroups[j] << '\t' << numSampled << '\t'<< setprecision(4) << score << endl;
                }
                                        
                out.close();
@@ -635,7 +659,7 @@ vector<float> PhyloDiversityCommand::calcBranchLength(Tree* t, int leaf, vector<
         //you are a leaf
                if(t->tree[index].getBranchLength() != -1){     
                        for (int k = 0; k < groups.size(); k++) { 
-                               sums[k] += abs(t->tree[index].getBranchLength());       
+                sums[k] += abs(t->tree[index].getBranchLength());      
                        }
                }
         
@@ -686,10 +710,10 @@ map<string, int> PhyloDiversityCommand::getRootForGroups(Tree* t){
             
             for (int j = 0; j < groups.size(); j++) {
                 
-                if (done[groups[j]] == false) { //we haven't found the root for this group yet
-                    
-                    done[groups[j]] = true;
-                    roots[groups[j]] = i; //set root to self to start
+                    if (done[groups[j]] == false) { //we haven't found the root for this group yet, initialize it
+                        done[groups[j]] = true;
+                        roots[groups[j]] = i; //set root to self to start
+                    }
                     
                     //while you aren't at root
                     while(t->tree[index].getParent() != -1){
@@ -709,15 +733,17 @@ map<string, int> PhyloDiversityCommand::getRootForGroups(Tree* t){
                         if (itGroup != t->tree[rc].pcount.end()) { RpcountSize++;  } 
                         
                         if ((LpcountSize != 0) && (RpcountSize != 0)) { //possible root
-                            roots[groups[j]] = index;
+                            if (index > roots[groups[j]]) {  roots[groups[j]] = index; }
                         }else { ;}
                         
                         index = t->tree[index].getParent();    
                     }
-                }
+                //}
             }
         }
         
+        
+        
         return roots;
         
        }
index ee76f05697cfce07213857432c9d786b150fc033..ec372ba20acac93709ca4fff0b58c8a42dadf048 100644 (file)
@@ -25,8 +25,9 @@ class PhyloDiversityCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "phylo.diversity";                     }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "Faith DP (1994). Phylogenetic pattern and the quantification of organismal biodiversity. Philos Trans R Soc Lond B Biol Sci 345: 45-58. \nhttp://www.mothur.org/wiki/Phylo.diversity"; }
                string getDescription()         { return "phylo.diversity"; }
 
index eddddfa0534f547cfa1802b75211f1c6c9950f65..fbc7c6003989044eba397ba7d8d6d58fa37c768a 100644 (file)
 //**********************************************************************************************************************
 vector<string> PhylotypeCommand::setParameters(){      
        try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pcutoff("cutoff", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none","list-rabund-sabund",false,true,true); parameters.push_back(ptaxonomy);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(pname);
+               CommandParameter pcutoff("cutoff", "Number", "", "-1", "", "", "","",false,false,true); parameters.push_back(pcutoff);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,26 +54,21 @@ string PhylotypeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string PhylotypeCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PhylotypeCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "list") {  outputFileName =  "list"; }
-            else if (type == "rabund") {  outputFileName =  "rabund"; }
-            else if (type == "sabund") {  outputFileName =  "sabund"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "list") {  pattern = "[filename],[tag],list"; } 
+        else if (type == "rabund") {  pattern = "[filename],[tag],rabund"; } 
+        else if (type == "sabund") {  pattern = "[filename],[tag],sabund"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PhylotypeCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 PhylotypeCommand::PhylotypeCommand(){  
@@ -217,15 +212,17 @@ int PhylotypeCommand::execute(){
                if (m->control_pressed) { delete tree; return 0; }
                
                string fileroot = outputDir + m->getRootName(m->getSimpleName(taxonomyFileName));
-               
-               ofstream outList;
-               string outputListFile = fileroot + "tx." + getOutputFileNameTag("list");
+               map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+        variables["[tag]"] = "tx";
+        ofstream outList;
+               string outputListFile = getOutputFileName("list",variables);
                m->openOutputFile(outputListFile, outList);
                ofstream outSabund;
-               string outputSabundFile = fileroot + "tx." + getOutputFileNameTag("sabund");
+               string outputSabundFile = getOutputFileName("sabund",variables);
                m->openOutputFile(outputSabundFile, outSabund);
                ofstream outRabund;
-               string outputRabundFile = fileroot + "tx." + getOutputFileNameTag("rabund");
+               string outputRabundFile = getOutputFileName("rabund",variables);
                m->openOutputFile(outputRabundFile, outRabund);
                
                outputNames.push_back(outputListFile); outputTypes["list"].push_back(outputListFile);
index 0e315ec7c4ef4fcdabc34b4037d7f8bba53cfea2..7fe10af58dde8ae842be2496376b3569df49bd29 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "phylotype";           }
        string getCommandCategory()             { return "Clustering";          }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Phylotype"; }
        string getDescription()         { return "cluster your sequences into OTUs based on their classifications"; }
 
index 968ba4f66a9d233a14e5f579e9563ac4d9bbd706..958201d0f5590118e26897613f3d0b0ed384abe9 100644 (file)
 //**********************************************************************************************************************
 vector<string> PipelineCommand::setParameters(){       
        try {
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(psff);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(poligos);
-               CommandParameter palign("align", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(palign);
-               CommandParameter pchimera("chimera", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(pchimera);
-               CommandParameter pclassify("classify", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(pclassify);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter ppipeline("pipeline", "InputTypes", "", "", "none", "oneRequired", "none",false,false); parameters.push_back(ppipeline);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter psff("sff", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(psff);
+               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(poligos);
+               CommandParameter palign("align", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(palign);
+               CommandParameter pchimera("chimera", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(pchimera);
+               CommandParameter pclassify("classify", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(pclassify);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "oneRequired", "pipe","",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter ppipeline("pipeline", "InputTypes", "", "", "none", "oneRequired", "none","",false,false,true); parameters.push_back(ppipeline);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 4697f405f6045cabad7f225641c4544a36ca6e9f..22386bcc697c2e3c64767ad99dd9fafaaa5d206f 100644 (file)
@@ -26,8 +26,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pipeline.pds";        }
        string getCommandCategory()             { return "Hidden";                      }
-       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
+    string getOutputPattern(string) { return ""; }     
        string getCitation() { return "Schloss PD, Gevers D, Westcott SL (2011).  Reducing the effects of PCR amplification and sequencing artifacts on 16S rRNA-based studies.  PLoS ONE.  6:e27310.\nhttp://www.mothur.org/wiki/Pipeline.pds"; }
        string getDescription()         { return "pat's pipeline"; }
 
index de2cb2058a064b043f424921f599edd6f7f8bf24..5fc9f988be038bb02a724e38cc11b2d9ddf1fa3e 100644 (file)
 //**********************************************************************************************************************
 vector<string> PcrSeqsCommand::setParameters(){        
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "ecolioligos", "none", "none",false,false); parameters.push_back(poligos);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptax);
-        CommandParameter pecoli("ecoli", "InputTypes", "", "", "ecolioligos", "none", "none",false,false); parameters.push_back(pecoli);
-               CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart);
-               CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend);
-               CommandParameter pnomatch("nomatch", "Multiple", "reject-keep", "reject", "", "", "",false,false); parameters.push_back(pnomatch);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pkeepprimer("keepprimer", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepprimer);
-        CommandParameter pkeepdots("keepdots", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pkeepdots);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+               CommandParameter poligos("oligos", "InputTypes", "", "", "ecolioligos", "none", "none","",false,false,true); parameters.push_back(poligos);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false,true); parameters.push_back(pgroup);
+        CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none","taxonomy",false,false,true); parameters.push_back(ptax);
+        CommandParameter pecoli("ecoli", "InputTypes", "", "", "ecolioligos", "none", "none","",false,false); parameters.push_back(pecoli);
+               CommandParameter pstart("start", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pstart);
+               CommandParameter pend("end", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pend);
+               CommandParameter pnomatch("nomatch", "Multiple", "reject-keep", "reject", "", "", "","",false,false); parameters.push_back(pnomatch);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pkeepprimer("keepprimer", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkeepprimer);
+        CommandParameter pkeepdots("keepdots", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pkeepdots);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
         
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -58,31 +58,25 @@ string PcrSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string PcrSeqsCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PcrSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "pcr.fasta"; }
-            else if (type == "taxonomy") {  outputFileName =  "pcr" + m->getExtension(inputName); }
-            else if (type == "group") {  outputFileName =  "pcr" + m->getExtension(inputName); }
-            else if (type == "name") {  outputFileName =  "pcr" + m->getExtension(inputName); }
-            else if (type == "count") {  outputFileName =  "pcr" + m->getExtension(inputName); }
-            else if (type == "accnos") {  outputFileName =  "bad.accnos"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pcr,[extension]-[filename],[tag],pcr,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pcr,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pcr,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pcr,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pcr,[extension]";    }
+        else if (type == "accnos")      {   pattern = "[filename],bad.accnos";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PcrSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 
@@ -315,10 +309,13 @@ int PcrSeqsCommand::execute(){
         
         string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string trimSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string trimSeqFile = getOutputFileName("fasta",variables);
                outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
-        
-        string badSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "scrap." + getOutputFileNameTag("fasta");
+        variables["[tag]"] = "scrap";
+        string badSeqFile = getOutputFileName("fasta",variables);
                
                
         length = 0;
@@ -914,7 +911,9 @@ int PcrSeqsCommand::writeAccnos(set<string> badNames){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+               string outputFileName = getOutputFileName("accnos",variables);
         outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
         
         ofstream out;
@@ -976,7 +975,10 @@ int PcrSeqsCommand::readName(set<string>& names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -1034,7 +1036,10 @@ int PcrSeqsCommand::readGroup(set<string> names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -1081,7 +1086,11 @@ int PcrSeqsCommand::readTax(set<string> names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
+
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
@@ -1128,7 +1137,11 @@ int PcrSeqsCommand::readCount(set<string> badSeqNames){
                m->openInputFile(countfile, in);
                set<string>::iterator it;
                
-               string goodCountFile = outputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string goodCountFile = getOutputFileName("count", variables);
+
         outputNames.push_back(goodCountFile);  outputTypes["count"].push_back(goodCountFile);
                ofstream goodCountOut;  m->openOutputFile(goodCountFile, goodCountOut);
                
index dadc9186f243952445db24766cf3a08c9dc4d5d0..0c7895cfd3c4b5c1988977f102d5523bfe20f9e0 100644 (file)
 //**********************************************************************************************************************
 vector<string> PreClusterCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pdiffs);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -54,27 +54,22 @@ string PreClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string PreClusterCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string PreClusterCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta") {  outputFileName =  "precluster" + m->getExtension(inputName); }
-            else if (type == "name") {  outputFileName =  "precluster.names"; }
-            else if (type == "count") {  outputFileName =  "precluster.count_table"; }
-            else if (type == "map") {  outputFileName =  "precluster.map"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],precluster,[extension]"; } 
+        else if (type == "name") {  pattern = "[filename],precluster.names"; } 
+        else if (type == "count") {  pattern = "[filename],precluster.count_table"; }
+        else if (type == "map") {  pattern =  "[filename],precluster.map"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "PreClusterCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 PreClusterCommand::PreClusterCommand(){        
@@ -239,10 +234,13 @@ int PreClusterCommand::execute(){
                int start = time(NULL);
                
                string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               string newFastaFile = fileroot + getOutputFileNameTag("fasta", fastafile);
-               string newNamesFile = fileroot + getOutputFileNameTag("name");
-        string newCountFile = fileroot + getOutputFileNameTag("count");
-               string newMapFile = fileroot + getOutputFileNameTag("map"); //add group name if by group
+        map<string, string> variables; 
+        variables["[filename]"] = fileroot;
+               string newNamesFile = getOutputFileName("name",variables);
+        string newCountFile = getOutputFileName("count",variables);
+               string newMapFile = getOutputFileName("map",variables); //add group name if by group
+        variables["[extension]"] = m->getExtension(fastafile);
+               string newFastaFile = getOutputFileName("fasta", variables);
                outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile);
                if (countfile == "") { outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile); }
                else { outputNames.push_back(newCountFile); outputTypes["count"].push_back(newCountFile); }
index e63afa6c8af8ee442e267714fcfccd140d4f79dd..0bd56c8662a5b8c622b57a4628f23cc829828f90 100644 (file)
@@ -48,8 +48,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pre.cluster";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Gevers D, Westcott SL (2011).  Reducing the effects of PCR amplification and sequencing artifacts on 16S rRNA-based studies.  PLoS ONE.  6:e27310.\nhttp://www.mothur.org/wiki/Pre.cluster"; }
        string getDescription()         { return "implements a pseudo-single linkage algorithm with the goal of removing sequences that are likely due to pyrosequencing errors"; }
 
index 63d6fd5c39576222d2b3b864cc8e50420de972bc..9a6ea290748e6637162244e0d4790b594ee83b18 100644 (file)
@@ -27,7 +27,7 @@ public:
        string getCommandName()                 { return "quit";                }
        string getCommandCategory()             { return "Hidden";              }
        string getHelpString() { return "The quit command will terminate mothur and should be in the following format: quit() or quit. \n"; }   
-    string getOutputFileNameTag(string, string) { return "";        }
+    string getOutputPattern(string) { return "";                }
        string getCitation() { return "no citation"; }
        string getDescription()         { return "quit"; }
 
index c4a104b6c2d10468777fe673567de1c05544a1a9..75a87efa3a2f95259488b0abf15887fb39ee1955 100644 (file)
 //**********************************************************************************************************************
 vector<string> RareFactCommand::setParameters(){       
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap", "sobs", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false); parameters.push_back(psabund);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","",false,false,true); parameters.push_back(pshared);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap", "sobs", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pabund("abund", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pabund);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pgroupmode);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -75,39 +75,33 @@ string RareFactCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RareFactCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RareFactCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        if (type == "rarefaction") {  pattern =  "[filename],rarefaction"; }
+        else if (type == "r_chao") {  pattern =  "[filename],r_chao"; }
+        else if (type == "r_ace") {  pattern =  "[filename],r_ace"; }
+        else if (type == "r_jack") {  pattern =  "[filename],r_jack"; }
+        else if (type == "r_shannon") {  pattern =  "[filename],r_shannon"; }
+        else if (type == "r_shannoneven") {  pattern =  "[filename],r_shannoneven"; }
+        else if (type == "r_smithwilson") {  pattern =  "[filename],r_smithwilson"; }
+        else if (type == "r_npshannon") {  pattern =  "[filename],r_npshannon"; }
+        else if (type == "r_simpson") {  pattern =  "[filename],r_simpson"; }
+        else if (type == "r_simpsoneven") {  pattern =  "[filename],r_simpsoneven"; }
+        else if (type == "r_invsimpson") {  pattern =  "[filename],r_invsimpson"; }
+        else if (type == "r_bootstrap") {  pattern =  "[filename],r_bootstrap"; }
+        else if (type == "r_coverage") {  pattern =  "[filename],r_coverage"; }
+        else if (type == "r_nseqs") {  pattern =  "[filename],r_nseqs"; }
+        else if (type == "r_heip") {  pattern =  "[filename],r_heip"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "rarefaction") {  outputFileName =  "rarefaction"; }
-            else if (type == "r_chao") {  outputFileName =  "r_chao"; }
-            else if (type == "r_ace") {  outputFileName =  "r_ace"; }
-            else if (type == "r_jack") {  outputFileName =  "r_jack"; }
-            else if (type == "r_shannon") {  outputFileName =  "r_shannon"; }
-            else if (type == "r_shannoneven") {  outputFileName =  "r_shannoneven"; }
-            else if (type == "r_smithwilson") {  outputFileName =  "r_smithwilson"; }
-            else if (type == "r_npshannon") {  outputFileName =  "r_npshannon"; }
-            else if (type == "r_simpson") {  outputFileName =  "r_simpson"; }
-            else if (type == "r_simpsoneven") {  outputFileName =  "r_simpsoneven"; }
-            else if (type == "r_invsimpson") {  outputFileName =  "r_invsimpson"; }
-            else if (type == "r_bootstrap") {  outputFileName =  "r_bootstrap"; }
-            else if (type == "r_coverage") {  outputFileName =  "r_coverage"; }
-            else if (type == "r_nseqs") {  outputFileName =  "r_nseqs"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RareFactCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 RareFactCommand::RareFactCommand(){    
        try {
@@ -334,56 +328,58 @@ int RareFactCommand::execute(){
                        int i;
                        ValidCalculators validCalculator;
                        
+            map<string, string> variables; 
+            variables["[filename]"] = fileNameRoot;
                          
                        for (i=0; i<Estimators.size(); i++) {
                                if (validCalculator.isValidCalculator("rarefaction", Estimators[i]) == true) { 
                                        if (Estimators[i] == "sobs") { 
-                                               rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("rarefaction"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("rarefaction")); outputTypes["rarefaction"].push_back(fileNameRoot+getOutputFileNameTag("rarefaction"));
+                                               rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(getOutputFileName("rarefaction",variables))));
+                                               outputNames.push_back(getOutputFileName("rarefaction",variables)); outputTypes["rarefaction"].push_back(getOutputFileName("rarefaction",variables));
                                        }else if (Estimators[i] == "chao") { 
-                                               rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_chao"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_chao")); outputTypes["r_chao"].push_back(fileNameRoot+getOutputFileNameTag("r_chao"));
+                                               rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(getOutputFileName("r_chao",variables))));
+                                               outputNames.push_back(getOutputFileName("r_chao",variables)); outputTypes["r_chao"].push_back(getOutputFileName("r_chao",variables));
                                        }else if (Estimators[i] == "ace") { 
                                                if(abund < 5)
                                                        abund = 10;
-                                               rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_ace"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_ace")); outputTypes["r_ace"].push_back(fileNameRoot+getOutputFileNameTag("r_ace"));
+                                               rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(getOutputFileName("r_ace",variables))));
+                                               outputNames.push_back(getOutputFileName("r_ace",variables)); outputTypes["r_ace"].push_back(getOutputFileName("r_ace",variables));
                                        }else if (Estimators[i] == "jack") { 
-                                               rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_jack"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_jack")); outputTypes["r_jack"].push_back(fileNameRoot+getOutputFileNameTag("r_jack"));
+                                               rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(getOutputFileName("r_jack",variables))));
+                                               outputNames.push_back(getOutputFileName("r_jack",variables)); outputTypes["r_jack"].push_back(getOutputFileName("r_jack",variables));
                                        }else if (Estimators[i] == "shannon") { 
-                                               rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_shannon"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_shannon")); outputTypes["r_shannon"].push_back(fileNameRoot+getOutputFileNameTag("r_shannon"));
+                                               rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(getOutputFileName("r_shannon",variables))));
+                                               outputNames.push_back(getOutputFileName("r_shannon",variables)); outputTypes["r_shannon"].push_back(getOutputFileName("r_shannon",variables));
                                        }else if (Estimators[i] == "shannoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new ShannonEven(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_shannoneven"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_shannoneven")); outputTypes["r_shannoneven"].push_back(fileNameRoot+getOutputFileNameTag("r_shannoneven"));
+                                               rDisplays.push_back(new RareDisplay(new ShannonEven(), new ThreeColumnFile(getOutputFileName("r_shannoneven",variables))));
+                                               outputNames.push_back(getOutputFileName("r_shannoneven",variables)); outputTypes["r_shannoneven"].push_back(getOutputFileName("r_shannoneven",variables));
                                        }else if (Estimators[i] == "heip") { 
-                                               rDisplays.push_back(new RareDisplay(new Heip(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_heip"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_heip")); outputTypes["r_heip"].push_back(fileNameRoot+getOutputFileNameTag("r_heip"));
+                                               rDisplays.push_back(new RareDisplay(new Heip(), new ThreeColumnFile(getOutputFileName("r_heip",variables))));
+                                               outputNames.push_back(getOutputFileName("r_heip",variables)); outputTypes["r_heip"].push_back(getOutputFileName("r_heip",variables));
                                        }else if (Estimators[i] == "smithwilson") { 
-                                               rDisplays.push_back(new RareDisplay(new SmithWilson(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_smithwilson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_smithwilson")); outputTypes["r_smithwilson"].push_back(fileNameRoot+getOutputFileNameTag("r_smithwilson"));
+                                               rDisplays.push_back(new RareDisplay(new SmithWilson(), new ThreeColumnFile(getOutputFileName("r_smithwilson",variables))));
+                                               outputNames.push_back(getOutputFileName("r_smithwilson",variables)); outputTypes["r_smithwilson"].push_back(getOutputFileName("r_smithwilson",variables));
                                        }else if (Estimators[i] == "npshannon") { 
-                                               rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_npshannon"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_npshannon")); outputTypes["r_npshannon"].push_back(fileNameRoot+getOutputFileNameTag("r_npshannon"));
+                                               rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(getOutputFileName("r_npshannon",variables))));
+                                               outputNames.push_back(getOutputFileName("r_npshannon",variables)); outputTypes["r_npshannon"].push_back(getOutputFileName("r_npshannon",variables));
                                        }else if (Estimators[i] == "simpson") { 
-                                               rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_simpson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_simpson")); outputTypes["r_simpson"].push_back(fileNameRoot+getOutputFileNameTag("r_simpson"));
+                                               rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(getOutputFileName("r_simpson",variables))));
+                                               outputNames.push_back(getOutputFileName("r_simpson",variables)); outputTypes["r_simpson"].push_back(getOutputFileName("r_simpson",variables));
                                        }else if (Estimators[i] == "simpsoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new SimpsonEven(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_simpsoneven"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_simpsoneven")); outputTypes["r_simpsoneven"].push_back(fileNameRoot+getOutputFileNameTag("r_simpsoneven"));
+                                               rDisplays.push_back(new RareDisplay(new SimpsonEven(), new ThreeColumnFile(getOutputFileName("r_simpsoneven",variables))));
+                                               outputNames.push_back(getOutputFileName("r_simpsoneven",variables)); outputTypes["r_simpsoneven"].push_back(getOutputFileName("r_simpsoneven",variables));
                                        }else if (Estimators[i] == "invsimpson") { 
-                                               rDisplays.push_back(new RareDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_invsimpson"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_invsimpson")); outputTypes["r_invsimpson"].push_back(fileNameRoot+getOutputFileNameTag("r_invsimpson"));
+                                               rDisplays.push_back(new RareDisplay(new InvSimpson(), new ThreeColumnFile(getOutputFileName("r_invsimpson",variables))));
+                                               outputNames.push_back(getOutputFileName("r_invsimpson",variables)); outputTypes["r_invsimpson"].push_back(getOutputFileName("r_invsimpson",variables));
                                        }else if (Estimators[i] == "bootstrap") { 
-                                               rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_bootstrap"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_bootstrap")); outputTypes["r_bootstrap"].push_back(fileNameRoot+getOutputFileNameTag("r_bootstrap"));
+                                               rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(getOutputFileName("r_bootstrap",variables))));
+                                               outputNames.push_back(getOutputFileName("r_bootstrap",variables)); outputTypes["r_bootstrap"].push_back(getOutputFileName("r_bootstrap",variables));
                                        }else if (Estimators[i] == "coverage") { 
-                                               rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_coverage"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_coverage")); outputTypes["r_coverage"].push_back(fileNameRoot+getOutputFileNameTag("r_coverage"));
+                                               rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(getOutputFileName("r_coverage",variables))));
+                                               outputNames.push_back(getOutputFileName("r_coverage",variables)); outputTypes["r_coverage"].push_back(getOutputFileName("r_coverage",variables));
                                        }else if (Estimators[i] == "nseqs") { 
-                                               rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+getOutputFileNameTag("r_nseqs"))));
-                                               outputNames.push_back(fileNameRoot+getOutputFileNameTag("r_nseqs")); outputTypes["r_nseqs"].push_back(fileNameRoot+getOutputFileNameTag("r_nseqs"));
+                                               rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(getOutputFileName("r_nseqs",variables))));
+                                               outputNames.push_back(getOutputFileName("r_nseqs",variables)); outputTypes["r_nseqs"].push_back(getOutputFileName("r_nseqs",variables));
                                        }
                     if (inputFileNames.size() > 1) { file2Group[outputNames.size()-1] = groups[p]; }
                                }
index 9c7e1ed34fcffebaf73f4499bd6637d0d36c2b68..02fe6e3aa4355a107e76f06d8f8f9a7f0df19118 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "rarefaction.single";          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Magurran AE (2004). Measuring biological diversity. Blackwell Pub.: Malden, Ma. \nhttp://www.mothur.org/wiki/Rarefaction.single"; }
        string getDescription()         { return "generate intra-sample rarefaction curves using a re-sampling without replacement approach"; }
 
index 6451041461a21255ff929feba717a0fd02fd96fa..64b40aad41b9fb520892cab6969c98fa0a83a80d 100644 (file)
 //**********************************************************************************************************************
 vector<string> RareFactSharedCommand::setParameters(){ 
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-        CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pdesign);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pcalc("calc", "Multiple", "sharednseqs-sharedobserved", "sharedobserved", "", "", "",true,false); parameters.push_back(pcalc);
-        CommandParameter psubsampleiters("subsampleiters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(psubsampleiters);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-               CommandParameter pjumble("jumble", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pjumble);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-        CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets);
-               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pshared);
+        CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pdesign);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pcalc("calc", "Multiple", "sharednseqs-sharedobserved", "sharedobserved", "", "", "","",true,false,true); parameters.push_back(pcalc);
+        CommandParameter psubsampleiters("subsampleiters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(psubsampleiters);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+               CommandParameter pjumble("jumble", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pjumble);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+        CommandParameter psets("sets", "String", "", "", "", "", "","",false,false); parameters.push_back(psets);
+               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pgroupmode);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -68,25 +68,20 @@ string RareFactSharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RareFactSharedCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RareFactSharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "sharedrarefaction") {  outputFileName =  "shared.rarefaction"; }
-            else if (type == "sharedr_nseqs") {  outputFileName =  "shared.r_nseqs"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "sharedrarefaction") {  pattern = "[filename],shared.rarefaction"; }
+        else if (type == "sharedr_nseqs") {  pattern = "[filename],shared.r_nseqs"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RareFactSharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 RareFactSharedCommand::RareFactSharedCommand(){        
@@ -346,16 +341,18 @@ int RareFactSharedCommand::process(GroupMap& designMap, string thisSet){
             if (subset.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
         }
         /******************************************************/
-                       
+        
+        map<string, string> variables; 
+        variables["[filename]"] = fileNameRoot;
                ValidCalculators validCalculator;
                for (int i=0; i<Estimators.size(); i++) {
                        if (validCalculator.isValidCalculator("sharedrarefaction", Estimators[i]) == true) { 
                                if (Estimators[i] == "sharedobserved") { 
-                                       rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+getOutputFileNameTag("sharedrarefaction"), "")));
-                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharedrarefaction")); outputTypes["sharedrarefaction"].push_back(fileNameRoot+getOutputFileNameTag("sharedrarefaction"));
+                                       rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(getOutputFileName("sharedrarefaction",variables), "")));
+                                       outputNames.push_back(getOutputFileName("sharedrarefaction",variables)); outputTypes["sharedrarefaction"].push_back(getOutputFileName("sharedrarefaction",variables));
                                }else if (Estimators[i] == "sharednseqs") { 
-                                       rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+getOutputFileNameTag("sharedr_nseqs"), "")));
-                                       outputNames.push_back(fileNameRoot+getOutputFileNameTag("sharedr_nseqs")); outputTypes["sharedr_nseqs"].push_back(fileNameRoot+getOutputFileNameTag("sharedr_nseqs"));
+                                       rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(getOutputFileName("sharedr_nseqs",variables), "")));
+                                       outputNames.push_back(getOutputFileName("sharedr_nseqs",variables)); outputTypes["sharedr_nseqs"].push_back(getOutputFileName("sharedr_nseqs",variables));
                                }
                        }
             file2Group[outputNames.size()-1] = thisSet;
@@ -546,15 +543,18 @@ int RareFactSharedCommand::subsampleLookup(vector<SharedRAbundVector*>& thisLook
             
             string thisfileNameRoot = fileNameRoot + toString(thisIter);
             
+            map<string, string> variables; 
+            variables["[filename]"] = thisfileNameRoot;
+            
             ValidCalculators validCalculator;
             for (int i=0; i<Estimators.size(); i++) {
                 if (validCalculator.isValidCalculator("sharedrarefaction", Estimators[i]) == true) { 
                     if (Estimators[i] == "sharedobserved") { 
-                        rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(thisfileNameRoot+getOutputFileNameTag("sharedrarefaction"), "")));
-                        filenames["sharedrarefaction"].push_back(thisfileNameRoot+getOutputFileNameTag("sharedrarefaction"));
+                        rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(getOutputFileName("sharedrarefaction",variables), "")));
+                        filenames["sharedrarefaction"].push_back(getOutputFileName("sharedrarefaction",variables));
                     }else if (Estimators[i] == "sharednseqs") { 
-                        rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(thisfileNameRoot+getOutputFileNameTag("sharedr_nseqs"), "")));
-                        filenames["sharedr_nseqs"].push_back(thisfileNameRoot+getOutputFileNameTag("sharedr_nseqs"));
+                        rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(getOutputFileName("sharedr_nseqs",variables), "")));
+                        filenames["sharedr_nseqs"].push_back(getOutputFileName("sharedr_nseqs",variables));
                     }
                 }
             }
@@ -597,7 +597,9 @@ int RareFactSharedCommand::subsampleLookup(vector<SharedRAbundVector*>& thisLook
             
             if (!m->control_pressed) {
                 //process results
-                string outputFile = fileNameRoot + "ave-std." + thisLookup[0]->getLabel() + "." + getOutputFileNameTag(it->first);
+                map<string, string> variables; variables["[filename]"] = fileNameRoot + "ave-std." + thisLookup[0]->getLabel() + ".";
+
+                string outputFile = getOutputFileName(it->first,variables);
                 ofstream out;
                 m->openOutputFile(outputFile, out);
                 outputNames.push_back(outputFile); outputTypes[it->first].push_back(outputFile);
index af73e132001d1e80bf239362b5541cd08c99d85e..4f08d00d7332ae32824464b809744042bd997d7f 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "rarefaction.shared";          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Magurran AE (2004). Measuring biological diversity. Blackwell Pub.: Malden, Ma. \nhttp://www.mothur.org/wiki/Rarefaction.shared"; }
        string getDescription()         { return "generate inter-sample rarefaction curves using a re-sampling without replacement approach"; }
 
index 71c4bd5b96fcd1cc435f2954616899fdde3eedb8..4c9def84dcb08fb28084b52c8464f2fc98f0da85 100644 (file)
@@ -378,7 +378,7 @@ int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T, CountTable* ct) {
                
                        //set group info
                        vector<string> group = ct->getGroups(name);
-                       
+            //cout << name << endl;    
                        //find index in tree of name
                        int n1 = T->getIndex(name);
                        
index a29906c5f41769c93b3675b88eb1267fa2eb7127..4f4b1580582b953c3b8318acc68345cc8d45ae48 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveGroupsCommand::setParameters(){   
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(pfasta);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "sharedGroup", "FNGLT",false,false); parameters.push_back(pgroup);         CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pdesign);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT","fasta",false,false,true); parameters.push_back(pfasta);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none","shared",false,false,true); parameters.push_back(pshared);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "sharedGroup", "FNGLT","group",false,false,true); parameters.push_back(pgroup);            
+        CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT","design",false,false); parameters.push_back(pdesign);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT","list",false,false,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT","taxonomy",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -58,31 +59,26 @@ string RemoveGroupsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveGroupsCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveGroupsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "shared")      {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "design")      {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "shared")      {   pattern = "[filename],[tag],pick,[extension]";    }
+        else if (type == "design")      {   pattern = "[filename],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RemoveGroupsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 RemoveGroupsCommand::RemoveGroupsCommand(){    
@@ -468,7 +464,10 @@ int RemoveGroupsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -529,6 +528,10 @@ int RemoveGroupsCommand::readShared(){
                //that way we can take advantage of the reads in inputdata and sharedRabundVector
                InputData* tempInput = new InputData(sharedfile, "sharedfile");
                vector<SharedRAbundVector*> lookup = tempInput->getSharedRAbundVectors();
+        
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
        
                //save m->Groups
                vector<string> allGroupsNames = m->getAllGroups();
@@ -560,7 +563,8 @@ int RemoveGroupsCommand::readShared(){
                
                while(lookup[0] != NULL) {
                        
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("shared", sharedfile);
+                       variables["[tag]"] = lookup[0]->getLabel();
+            string outputFileName = getOutputFileName("shared", variables);
                        ofstream out;
                        m->openOutputFile(outputFileName, out);
                        outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -608,7 +612,11 @@ int RemoveGroupsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
+
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -698,7 +706,10 @@ int RemoveGroupsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);            
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);   
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -778,7 +789,10 @@ int RemoveGroupsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);  
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -824,7 +838,10 @@ int RemoveGroupsCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -905,7 +922,10 @@ int RemoveGroupsCommand::readDesign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + getOutputFileNameTag("design", designfile);
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(designfile));
+        variables["[extension]"] = m->getExtension(designfile);
+               string outputFileName = getOutputFileName("design", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -953,7 +973,10 @@ int RemoveGroupsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index c36998ad8bb52349d3c5d0ee73812dd8a6f50c07..c6e9d645c9f7fff26e2c23c634b6264a4614e01b 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.groups";                       }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Remove.groups"; }
        string getDescription()         { return "removes sequences from a list, fasta, name, group, shared, design or taxonomy file from a given group or set of groups"; }
        
index 56b24cd99d359c312fbac29f3457fe3f8dba3749..5b6fc252c4ae8c78619d0f3ad76afbb9792cbddd 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveLineageCommand::setParameters(){  
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptaxon("taxon", "String", "", "", "", "", "",false,true); parameters.push_back(ptaxon);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none","taxonomy",false,true,true); parameters.push_back(ptaxonomy);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none","alignreport",false,false); parameters.push_back(palignreport);
+               CommandParameter ptaxon("taxon", "String", "", "", "", "", "","",false,true,true); parameters.push_back(ptaxon);
+               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pdups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -60,31 +60,27 @@ string RemoveLineageCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveLineageCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveLineageCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";   }
-            else if (type == "alignreport")      {   outputFileName =  "pick.align.report";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RemoveLineageCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 RemoveLineageCommand::RemoveLineageCommand(){  
        try {
@@ -365,7 +361,10 @@ int RemoveLineageCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);         
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);  
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -410,7 +409,10 @@ int RemoveLineageCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);   
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -480,7 +482,10 @@ int RemoveLineageCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -556,7 +561,11 @@ int RemoveLineageCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
+
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -609,7 +618,11 @@ int RemoveLineageCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
+       
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -651,7 +664,10 @@ int RemoveLineageCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -858,7 +874,10 @@ int RemoveLineageCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(alignfile));
+        variables["[extension]"] = m->getExtension(alignfile);
+               string outputFileName = getOutputFileName("alignreport", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
index a756d24f583be82eac03634ebcd8496c4fd687b6..f644972c2672aa19509059c78d631ef0618eba28 100644 (file)
@@ -23,8 +23,9 @@ class RemoveLineageCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "remove.lineage";                      }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Remove.lineage"; }
                string getDescription()         { return "removes sequences from a list, fasta, name, group, alignreport or taxonomy file from a given taxonomy or set of taxonomies"; }
 
index a05e08154b10c6c0123a5f3f93847db520ee7959..5359db8de28e3bfb6a0aa1611e6407e830ddd68b 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveOtuLabelsCommand::setParameters(){        
        try {
-        CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-        CommandParameter pconstaxonomy("constaxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pconstaxonomy);
-               CommandParameter potucorr("otucorr", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(potucorr);
-        CommandParameter pcorraxes("corraxes", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pcorraxes);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(paccnos);
+        CommandParameter pconstaxonomy("constaxonomy", "InputTypes", "", "", "none", "FNGLT", "none","constaxonomy",false,false); parameters.push_back(pconstaxonomy);
+               CommandParameter potucorr("otucorr", "InputTypes", "", "", "none", "FNGLT", "none","otucorr",false,false); parameters.push_back(potucorr);
+        CommandParameter pcorraxes("corraxes", "InputTypes", "", "", "none", "FNGLT", "none","corraxes",false,false); parameters.push_back(pcorraxes);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,26 +46,21 @@ string RemoveOtuLabelsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveOtuLabelsCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveOtuLabelsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "constaxonomy") {  outputFileName =  "pick.taxonomy"; }
-            else if (type == "otucorr") {  outputFileName =  "pick.corr"; }
-            else if (type == "corraxes") {  outputFileName =  "pick.axes"; }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtuLabelsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "constaxonomy")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "otucorr")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "corraxes")        {   pattern = "[filename],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RemoveOtuLabelsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 RemoveOtuLabelsCommand::RemoveOtuLabelsCommand(){      
@@ -73,7 +68,7 @@ RemoveOtuLabelsCommand::RemoveOtuLabelsCommand(){
                abort = true; calledHelp = true;
                setParameters();
         vector<string> tempOutNames;
-               outputTypes["contaxonomy"] = tempOutNames; 
+               outputTypes["constaxonomy"] = tempOutNames; 
         outputTypes["otucorr"] = tempOutNames;
         outputTypes["corraxes"] = tempOutNames;
        }
@@ -226,7 +221,10 @@ int RemoveOtuLabelsCommand::readClassifyOtu(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(constaxonomyfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + getOutputFileNameTag("constaxonomy");
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile));
+        variables["[extension]"] = m->getExtension(constaxonomyfile);
+               string outputFileName = getOutputFileName("constaxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -275,7 +273,10 @@ int RemoveOtuLabelsCommand::readOtuAssociation(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(otucorrfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + getOutputFileNameTag("otucorr");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile));
+        variables["[extension]"] = m->getExtension(otucorrfile);
+               string outputFileName = getOutputFileName("otucorr", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -325,7 +326,10 @@ int RemoveOtuLabelsCommand::readCorrAxes(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(corraxesfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + getOutputFileNameTag("corraxes");
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile));
+        variables["[extension]"] = m->getExtension(corraxesfile);
+               string outputFileName = getOutputFileName("corraxes", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index ea596624ddfab5111a2c95f8619e4a4681bd1d10..03d2da3392443f3ebf70a60a1b4b318fa5b24e8a 100644 (file)
@@ -23,8 +23,9 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "remove.otulabels";          }
     string getCommandCategory()                { return "OTU-Based Approaches";        } 
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/Get.otulabels"; }
     string getDescription()            { return "Can be used with output from classify.otu, otu.association, or corr.axes to remove specific otus."; }
     
index 54adeb244693bb13e22884248e71deadeb5e2144..16fd8dce8bab96b030a57effd81d218e122628a5 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveOtusCommand::setParameters(){     
        try {
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","group",false,true,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","list",false,true,true); parameters.push_back(plist);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,25 +53,20 @@ string RemoveOtusCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveOtusCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveOtusCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "group")            {   outputFileName = "pick" + m->getExtension(inputName);  }
-            else if (type == "list")        {   outputFileName = "pick" + m->getExtension(inputName);  }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "group")       {   pattern = "[filename],[tag],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],[tag],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RemoveOtusCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 ///**********************************************************************************************************************
 RemoveOtusCommand::RemoveOtusCommand(){        
@@ -250,14 +245,20 @@ int RemoveOtusCommand::readListGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("list", listfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[tag]"] = label;
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
                string GroupOutputDir = outputDir;
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + label + "." + getOutputFileNameTag("group", groupfile);
+               variables["[filename]"] = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputGroupFileName = getOutputFileName("group", variables);
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
index 3a52a39f120a0d2af788478df3a590c64a7f9306..a7fcf0eaa1316203f0ec65c79094a2ef6f809ac3 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.otus";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Remove.otus"; }
        string getDescription()         { return "outputs a new list file containing the otus NOT containing sequences from the groups specified"; }
 
index ded26bbae7b81082f45710c03066dd27145c95a9..c0694480bcebf7a3738c17ef812720577dc99c7d 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveRareCommand::setParameters(){     
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pshared);
-        CommandParameter pcount("count", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pnseqs("nseqs", "Number", "", "0", "", "", "",false,true); parameters.push_back(pnseqs);
-               CommandParameter pbygroup("bygroup", "Boolean", "", "f", "", "", "",false,true); parameters.push_back(pbygroup);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "atleast", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "atleast", "none","rabund",false,false,true); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "atleast", "none","sabund",false,false,true); parameters.push_back(psabund);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "atleast", "none","shared",false,false,true); parameters.push_back(pshared);
+        CommandParameter pcount("count", "InputTypes", "", "", "CountGroup", "none", "none","count",false,false); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pnseqs("nseqs", "Number", "", "0", "", "", "","",false,true,true); parameters.push_back(pnseqs);
+               CommandParameter pbygroup("bygroup", "Boolean", "", "f", "", "", "","",false,false); parameters.push_back(pbygroup);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -60,31 +60,25 @@ string RemoveRareCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveRareCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveRareCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "rabund")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "sabund")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "shared")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "rabund")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "sabund")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "shared")      {   pattern = "[filename],[tag],pick,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "RemoveRareCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 RemoveRareCommand::RemoveRareCommand(){        
        try {
@@ -352,9 +346,16 @@ int RemoveRareCommand::processList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
-               string outputGroupFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
-        string outputCountFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputGroupFileName = getOutputFileName("group", variables);
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+        string outputCountFileName = getOutputFileName("count", variables);
         
                ofstream out, outGroup;
                m->openOutputFile(outputFileName, out);
@@ -519,7 +520,10 @@ int RemoveRareCommand::processSabund(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + getOutputFileNameTag("sabund", sabundfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile));
+        variables["[extension]"] = m->getExtension(sabundfile);
+               string outputFileName = getOutputFileName("sabund", variables);
                outputTypes["sabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
 
                ofstream out;
@@ -618,7 +622,10 @@ int RemoveRareCommand::processRabund(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + getOutputFileNameTag("rabund", rabundfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile));
+        variables["[extension]"] = m->getExtension(rabundfile);
+               string outputFileName = getOutputFileName("rabund", variables);
                outputTypes["rabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
@@ -725,7 +732,10 @@ int RemoveRareCommand::processShared(){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("shared", sharedfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
+               string outputFileName = getOutputFileName("shared", variables);
                outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
index 7b4c6fb44f80b4d2ac1a96e9a11d3a417e2cc918..2cab7be6fa870d763de76a559b4dfbb72823cfb6 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.rare";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Remove.rare"; }
        string getDescription()         { return "removes rare sequences from a sabund, rabund, shared or list and group file"; }
 
index 00b94a9dac842ceeca4a2a0362d87f14ba12ca1b..5c0216366a98c83bc11c776ad31b0da1086120cd 100644 (file)
 //**********************************************************************************************************************
 vector<string> RemoveSeqsCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none","taxonomy",false,false,true); parameters.push_back(ptaxonomy);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none","alignreport",false,false); parameters.push_back(palignreport);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none","qfile",false,false); parameters.push_back(pqfile);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(paccnos);
+               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pdups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -56,33 +56,27 @@ string RemoveSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string RemoveSeqsCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string RemoveSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "qfile")       {   outputFileName =  "pick" + m->getExtension(inputName);   }
-            else if (type == "alignreport") {   outputFileName =  "pick.align.report";                   }
-            else if (type == "count")       {   outputFileName =  "pick.count_table";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "qfile")       {   pattern = "[filename],pick,[extension]";    }
+        else if (type == "alignreport")      {   pattern = "[filename],pick.align.report";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 RemoveSeqsCommand::RemoveSeqsCommand(){        
        try {
@@ -390,7 +384,10 @@ int RemoveSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -445,7 +442,10 @@ int RemoveSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(qualfile));
+        variables["[extension]"] = m->getExtension(qualfile);
+               string outputFileName = getOutputFileName("qfile", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -519,7 +519,10 @@ int RemoveSeqsCommand::readCount(){
         
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -576,7 +579,10 @@ int RemoveSeqsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);   
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -654,7 +660,10 @@ int RemoveSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -738,7 +747,10 @@ int RemoveSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);  
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -784,7 +796,10 @@ int RemoveSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -836,7 +851,9 @@ int RemoveSeqsCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(alignfile));
+               string outputFileName = getOutputFileName("alignreport", variables);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
index e26e751032402cd39dac933acf3f57814ab2fc0f..1a6365dac35b9e18669f8827c4054268b9123d9e 100644 (file)
@@ -23,8 +23,9 @@ class RemoveSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "remove.seqs";                         }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Remove.seqs"; }
                string getDescription()         { return "removes sequences from a list, fasta, name, group, alignreport, quality or taxonomy file"; }
 
index 96a216ab4a76f551cf1e1eef9972e60d728a72a3..a9b297731a346999b155c61d7cab47ff7089063c 100644 (file)
 //**********************************************************************************************************************
 vector<string> ReverseSeqsCommand::setParameters(){    
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "fastaQual", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "fastaQual", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "fastaQual", "none","fasta",false,false,true); parameters.push_back(pfasta);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "fastaQual", "none","qfile",false,false,true); parameters.push_back(pqfile);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -44,25 +44,20 @@ string ReverseSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ReverseSeqsCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ReverseSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "rc" + m->getExtension(inputName);   }
-            else if (type == "qfile")       {   outputFileName =  "rc" + m->getExtension(inputName);   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],rc,[extension]"; } 
+        else if (type == "qfile") {  pattern = "[filename],rc,[extension]"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ReverseSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 ReverseSeqsCommand::ReverseSeqsCommand(){      
@@ -182,7 +177,10 @@ int ReverseSeqsCommand::execute(){
                        ofstream outFASTA;
                        string tempOutputDir = outputDir;
                        if (outputDir == "") { tempOutputDir += m->hasPath(fastaFileName); } //if user entered a file with a path then preserve it
-                       fastaReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName)) + getOutputFileNameTag("fasta", fastaFileName);
+            map<string, string> variables; 
+            variables["[filename]"] = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName));
+            variables["[extension]"] = m->getExtension(fastaFileName);
+                       fastaReverseFileName = getOutputFileName("fasta", variables);
                        m->openOutputFile(fastaReverseFileName, outFASTA);
                        
                        while(!inFASTA.eof()){
@@ -210,7 +208,10 @@ int ReverseSeqsCommand::execute(){
                        ofstream outQual;
                        string tempOutputDir = outputDir;
                        if (outputDir == "") { tempOutputDir += m->hasPath(qualFileName); } //if user entered a file with a path then preserve it
-                       string qualReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName)) + getOutputFileNameTag("qfile", qualFileName);
+            map<string, string> variables; 
+            variables["[filename]"] = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName));
+            variables["[extension]"] = m->getExtension(qualFileName);
+                       string qualReverseFileName = getOutputFileName("qfile", variables);
             m->openOutputFile(qualReverseFileName, outQual);
 
                        while(!inQual.eof()){
index 2c7a9e4ee025e3ce8e94f328eb2cb1e676611cf6..f7f729c9848ae0fa972944ae5b51ec18cceaca1d 100644 (file)
@@ -21,8 +21,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "reverse.seqs";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Reverse.seqs"; }
        string getDescription()         { return "outputs a fasta file containing the reverse-complements"; }
 
index 2b5ebc1a844420e699b04df0dcd6e144befbf1fe..5a9c0c8320b7305834cdf4bb544effd515728417 100644 (file)
 //**********************************************************************************************************************
 vector<string> ScreenSeqsCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptax);
-               CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart);
-               CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend);
-               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxambig);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pminlength("minlength", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pminlength);
-               CommandParameter pmaxlength("maxlength", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxlength);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcriteria("criteria", "Number", "", "90", "", "", "",false,false); parameters.push_back(pcriteria);
-               CommandParameter poptimize("optimize", "Multiple", "none-start-end-maxambig-maxhomop-minlength-maxlength", "none", "", "", "",true,false); parameters.push_back(poptimize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none","qfile",false,false); parameters.push_back(pqfile);
+               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "none", "none","alignreport",false,false); parameters.push_back(palignreport);
+               CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none","taxonomy",false,false); parameters.push_back(ptax);
+               CommandParameter pstart("start", "Number", "", "-1", "", "", "","",false,false,true); parameters.push_back(pstart);
+               CommandParameter pend("end", "Number", "", "-1", "", "", "","",false,false,true); parameters.push_back(pend);
+               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxambig);
+               CommandParameter pmaxhomop("maxhomop", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxhomop);
+               CommandParameter pminlength("minlength", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pminlength);
+               CommandParameter pmaxlength("maxlength", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxlength);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pcriteria("criteria", "Number", "", "90", "", "", "","",false,false); parameters.push_back(pcriteria);
+               CommandParameter poptimize("optimize", "Multiple", "none-start-end-maxambig-maxhomop-minlength-maxlength", "none", "", "", "","",true,false); parameters.push_back(poptimize);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -72,33 +72,27 @@ string ScreenSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ScreenSeqsCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ScreenSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "count")        {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "accnos")      {   outputFileName =  "bad.accnos";   }
-            else if (type == "qfile")       {   outputFileName =  "good" + m->getExtension(inputName);   }
-            else if (type == "alignreport") {   outputFileName =  "good.align.report";                   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],good,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],good,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],good,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],good,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],good,[extension]";    }
+        else if (type == "accnos")      {   pattern = "[filename],bad.accnos";          }
+        else if (type == "qfile")       {   pattern = "[filename],good,[extension]";    }
+        else if (type == "alignreport")      {   pattern = "[filename],good.align.report";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ScreenSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 ScreenSeqsCommand::ScreenSeqsCommand(){        
        try {
@@ -367,9 +361,13 @@ int ScreenSeqsCommand::execute(){
                 }
                        #endif
                }
-                                       
-               string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
-               string badAccnosFile =  outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
+        
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+        string badAccnosFile =  getOutputFileName("accnos",variables);
+        variables["[extension]"] = m->getExtension(fastafile);
+               string goodSeqFile = getOutputFileName("fasta", variables);
+               
                
                int numFastaSeqs = 0;
                set<string> badSeqNames;
@@ -579,8 +577,10 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                set<string> badSeqGroups;
                string seqName, seqList, group;
                set<string>::iterator it;
-
-               string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string goodNameFile = getOutputFileName("name", variables);
                outputNames.push_back(goodNameFile);  outputTypes["name"].push_back(goodNameFile);
                
                ofstream goodNameOut;   m->openOutputFile(goodNameFile, goodNameOut);
@@ -625,8 +625,10 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                        
                        ifstream inputGroups;
                        m->openInputFile(groupfile, inputGroups);
-
-                       string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(groupfile));
+            variables["[extension]"] = m->getExtension(groupfile);
+            string goodGroupFile = getOutputFileName("group", variables);
+                       
                        outputNames.push_back(goodGroupFile);   outputTypes["group"].push_back(goodGroupFile);
                        
                        ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
@@ -958,8 +960,10 @@ int ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
                m->openInputFile(groupfile, inputGroups);
                string seqName, group;
                set<string>::iterator it;
-               
-               string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+               map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+        string goodGroupFile = getOutputFileName("group", variables);
         outputNames.push_back(goodGroupFile);  outputTypes["group"].push_back(goodGroupFile);
                ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
                
@@ -1007,8 +1011,11 @@ int ScreenSeqsCommand::screenCountFile(set<string> badSeqNames){
                ifstream in;
                m->openInputFile(countfile, in);
                set<string>::iterator it;
+               map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+        string goodCountFile = getOutputFileName("count", variables);
                
-               string goodCountFile = outputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
         outputNames.push_back(goodCountFile);  outputTypes["count"].push_back(goodCountFile);
                ofstream goodCountOut;  m->openOutputFile(goodCountFile, goodCountOut);
                
@@ -1073,7 +1080,10 @@ int ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
                string seqName, group;
                set<string>::iterator it;
                
-               string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + getOutputFileNameTag("alignreport");
+        map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(alignreport));
+        string goodAlignReportFile = getOutputFileName("alignreport", variables);
+               
                outputNames.push_back(goodAlignReportFile);  outputTypes["alignreport"].push_back(goodAlignReportFile);
                ofstream goodAlignReportOut;    m->openOutputFile(goodAlignReportFile, goodAlignReportOut);
 
@@ -1136,8 +1146,11 @@ int ScreenSeqsCommand::screenTaxonomy(set<string> badSeqNames){
                m->openInputFile(taxonomy, input);
                string seqName, tax;
                set<string>::iterator it;
-               
-               string goodTaxFile = outputDir + m->getRootName(m->getSimpleName(taxonomy)) + getOutputFileNameTag("taxonomy", taxonomy);
+        map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(taxonomy));
+        variables["[extension]"] = m->getExtension(taxonomy);
+        string goodTaxFile = getOutputFileName("taxonomy", variables);
+
                outputNames.push_back(goodTaxFile);  outputTypes["taxonomy"].push_back(goodTaxFile);
                ofstream goodTaxOut;    m->openOutputFile(goodTaxFile, goodTaxOut);
                                
@@ -1185,8 +1198,11 @@ int ScreenSeqsCommand::screenQual(set<string> badSeqNames){
                ifstream in;
                m->openInputFile(qualfile, in);
                set<string>::iterator it;
+               map<string, string> variables;
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(qualfile));
+        variables["[extension]"] = m->getExtension(qualfile);
+        string goodQualFile = getOutputFileName("qfile", variables);
                
-               string goodQualFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
                outputNames.push_back(goodQualFile);  outputTypes["qfile"].push_back(goodQualFile);
                ofstream goodQual;      m->openOutputFile(goodQualFile, goodQual);
                
index b0d7c7c18f3852dd40395b0f699749fc885cc14b..284c9a5ac1a0bd5c90dca6b4854b725d6b428023 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "screen.seqs";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Screen.seqs"; }
        string getDescription()         { return "enables you to keep sequences that fulfill certain user defined criteria"; }
 
index 870283c460e6946ed5aab103cd4d2f84a714aee2..c1cdb6b90c910c2e58c5d016a6c2293f7d7aa8ce 100644 (file)
 //**********************************************************************************************************************
 vector<string> AlignCheckCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pmap("map", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pmap);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","aligncheck",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pmap("map", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pmap);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","",false,false); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false); parameters.push_back(pcount);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,24 +48,19 @@ string AlignCheckCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string AlignCheckCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string AlignCheckCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "aligncheck")            {   outputFileName =  "align.check";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "aligncheck") {  pattern = "[filename],align.check"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "AlignCheckCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 AlignCheckCommand::AlignCheckCommand(){        
@@ -215,7 +210,9 @@ int AlignCheckCommand::execute(){
                m->openInputFile(fastafile, in);
                
                ofstream out;
-               string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("aligncheck");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+               string outfile = getOutputFileName("aligncheck",variables);
                m->openOutputFile(outfile, out);
                
                                
index becafc5bb3f29073d0e72859e495f0364c351dfb..ce97a2243c2b9da797e5a34da3454050b5002396 100644 (file)
@@ -39,8 +39,9 @@ class AlignCheckCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "align.check";                         }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Align.check"; }
                string getDescription()         { return "calculate the number of potentially misaligned bases in a 16S rRNA gene sequence alignment"; }
 
index 5a1ead5c75a30d699787f52fed09139989ba46dd..dfb89b927c2de8dd34dcda801fae80d93281cc63 100644 (file)
 //**********************************************************************************************************************
 vector<string> SensSpecCommand::setParameters(){       
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pcolumn);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "-1.00", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","sensspec",false,true,true); parameters.push_back(plist);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","",false,false); parameters.push_back(pphylip);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","",false,false); parameters.push_back(pcolumn);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcutoff("cutoff", "Number", "", "-1.00", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
+               CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -44,24 +44,19 @@ string SensSpecCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SensSpecCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SensSpecCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "sensspec")            {   outputFileName =  "sensspec";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "sensspec") {  pattern = "[filename],sensspec"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SensSpecCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SensSpecCommand::SensSpecCommand(){    
@@ -201,7 +196,9 @@ SensSpecCommand::SensSpecCommand(string option)  {
                                else { allLines = 1;  }
                        }
                        
-                       sensSpecFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + getOutputFileNameTag("sensspec");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listFile));
+                       sensSpecFileName = getOutputFileName("sensspec",variables);
                }
        }
        catch(exception& e) {
index be5e975f0d6b6bc33db2d40564a6ca5df3b08703..73b74e3983a9b1e4078a5ee55e5ae975fd40f944 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sens.spec";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol 77:3219.\nhttp://www.mothur.org/wiki/Sens.spec"; }
        string getDescription()         { return "sens.spec"; }
 
index 5ec6cf2d1cc4778399d289ea2280c882f936b944..87d45242a08c9e7ab351dbcb029c6eae9458398f 100644 (file)
 //**********************************************************************************************************************
 vector<string> SeqErrorCommand::setParameters(){       
        try {
-               CommandParameter pquery("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pquery);
-               CommandParameter preference("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(preference);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "QualReport",false,false); parameters.push_back(pqfile);
-               CommandParameter preport("report", "InputTypes", "", "", "none", "none", "QualReport",false,false); parameters.push_back(preport);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pignorechimeras("ignorechimeras", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pignorechimeras);
-               CommandParameter pthreshold("threshold", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pquery("fasta", "InputTypes", "", "", "none", "none", "none","errorType",false,true,true); parameters.push_back(pquery);
+               CommandParameter preference("reference", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(preference);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "QualReport","",false,false); parameters.push_back(pqfile);
+               CommandParameter preport("report", "InputTypes", "", "", "none", "none", "QualReport","",false,false); parameters.push_back(preport);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pname);
+               CommandParameter pignorechimeras("ignorechimeras", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pignorechimeras);
+               CommandParameter pthreshold("threshold", "Number", "", "1.0", "", "", "","",false,false); parameters.push_back(pthreshold);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter psave("save", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psave);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -63,34 +63,29 @@ string SeqErrorCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SeqErrorCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SeqErrorCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "errorsummary")            {   outputFileName =  "error.summary";   }
-            else if (type == "errorseq")            {   outputFileName =  "error.seq";   }
-            else if (type == "errorquality")            {   outputFileName =  "error.quality";   }
-            else if (type == "errorqualforward")            {   outputFileName =  "error.qual.forward";   }
-            else if (type == "errorqualreverse")            {   outputFileName =  "error.qual.reverse";   }
-            else if (type == "errorforward")            {   outputFileName =  "error.seq.forward";   }
-            else if (type == "errorreverse")            {   outputFileName =  "error.seq.reverse";   }
-            else if (type == "errorcount")            {   outputFileName =  "error.count";   }
-            else if (type == "errormatrix")            {   outputFileName =  "error.matrix";   }
-            else if (type == "errorchimera")            {   outputFileName =  "error.chimera";   }
-            else if (type == "errorref-query")            {   outputFileName =  "error.ref-query";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "errorsummary")            {   pattern = "[filename],error.summary";   }
+        else if (type == "errorseq")            {   pattern = "[filename],error.seq";   }
+        else if (type == "errorquality")            {   pattern = "[filename],error.quality";   }
+        else if (type == "errorqualforward")            {   pattern = "[filename],error.qual.forward";   }
+        else if (type == "errorqualreverse")            {   pattern = "[filename],error.qual.reverse";   }
+        else if (type == "errorforward")            {   pattern = "[filename],error.seq.forward";   }
+        else if (type == "errorreverse")            {   pattern = "[filename],error.seq.reverse";   }
+        else if (type == "errorcount")            {   pattern = "[filename],error.count";   }
+        else if (type == "errormatrix")            {   pattern = "[filename],error.matrix";   }
+        else if (type == "errorchimera")            {   pattern = "[filename],error.chimera";   }
+        else if (type == "errorref-query")            {   pattern = "[filename],error.ref-query";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SeqErrorCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SeqErrorCommand::SeqErrorCommand(){    
@@ -304,13 +299,15 @@ int SeqErrorCommand::execute(){
                totalMatches = 0;
                
         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
-               string errorSummaryFileName = fileNameRoot + getOutputFileNameTag("errorsummary");
+        map<string, string> variables; 
+               variables["[filename]"] = fileNameRoot;
+               string errorSummaryFileName = getOutputFileName("errorsummary",variables);
                outputNames.push_back(errorSummaryFileName); outputTypes["errorsummary"].push_back(errorSummaryFileName);
                        
-               string errorSeqFileName = fileNameRoot + getOutputFileNameTag("errorseq");
+               string errorSeqFileName = getOutputFileName("errorseq",variables);
                outputNames.push_back(errorSeqFileName); outputTypes["errorseq"].push_back(errorSeqFileName);
                
-               string errorChimeraFileName = fileNameRoot + getOutputFileNameTag("errorchimera");
+               string errorChimeraFileName = getOutputFileName("errorchimera",variables);
                outputNames.push_back(errorChimeraFileName); outputTypes["errorchimera"].push_back(errorChimeraFileName);
                
                getReferences();        //read in reference sequences - make sure there's no ambiguous bases
@@ -352,7 +349,7 @@ int SeqErrorCommand::execute(){
                
                if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
 
-               string errorCountFileName = fileNameRoot + getOutputFileNameTag("errorcount");
+               string errorCountFileName = getOutputFileName("errorcount",variables);
                ofstream errorCountFile;
                m->openOutputFile(errorCountFileName, errorCountFile);
                outputNames.push_back(errorCountFileName);  outputTypes["errorcount"].push_back(errorCountFileName);
@@ -369,7 +366,7 @@ int SeqErrorCommand::execute(){
 
                printSubMatrix();
                                
-               string megAlignmentFileName = fileNameRoot + getOutputFileNameTag("errorref-query");
+               string megAlignmentFileName = getOutputFileName("errorref-query",variables);
                ofstream megAlignmentFile;
                m->openOutputFile(megAlignmentFileName, megAlignmentFile);
                outputNames.push_back(megAlignmentFileName);  outputTypes["errorref-query"].push_back(megAlignmentFileName);
@@ -1088,7 +1085,9 @@ void SeqErrorCommand::printErrorData(Compare error, int numParentSeqs, ofstream&
 void SeqErrorCommand::printSubMatrix(){
        try {
         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
-               string subMatrixFileName = fileNameRoot + getOutputFileNameTag("errormatrix");
+        map<string, string> variables; 
+               variables["[filename]"] = fileNameRoot;
+               string subMatrixFileName = getOutputFileName("errormatrix",variables);
                ofstream subMatrixFile;
                m->openOutputFile(subMatrixFileName, subMatrixFile);
                outputNames.push_back(subMatrixFileName);  outputTypes["errormatrix"].push_back(subMatrixFileName);
@@ -1135,7 +1134,9 @@ void SeqErrorCommand::printSubMatrix(){
 void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map<char, vector<int> > errorReverse){
        try{
         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
-               string errorForwardFileName = fileNameRoot + getOutputFileNameTag("errorforward");
+        map<string, string> variables; 
+               variables["[filename]"] = fileNameRoot;
+               string errorForwardFileName = getOutputFileName("errorforward",variables);
                ofstream errorForwardFile;
                m->openOutputFile(errorForwardFileName, errorForwardFile);
                outputNames.push_back(errorForwardFileName);  outputTypes["errorforward"].push_back(errorForwardFileName);
@@ -1153,7 +1154,7 @@ void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map
                }
                errorForwardFile.close();
 
-               string errorReverseFileName = fileNameRoot + getOutputFileNameTag("errorreverse");
+               string errorReverseFileName = getOutputFileName("errorreverse",variables);
                ofstream errorReverseFile;
                m->openOutputFile(errorReverseFileName, errorReverseFile);
                outputNames.push_back(errorReverseFileName);  outputTypes["errorreverse"].push_back(errorReverseFileName);
@@ -1182,7 +1183,9 @@ void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map
 void SeqErrorCommand::printErrorQuality(map<char, vector<int> > qScoreErrorMap){
        try{
         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
-               string errorQualityFileName = fileNameRoot + getOutputFileNameTag("errorquality");
+        map<string, string> variables; 
+               variables["[filename]"] = fileNameRoot;
+               string errorQualityFileName = getOutputFileName("errorquality",variables);
                ofstream errorQualityFile;
                m->openOutputFile(errorQualityFileName, errorQualityFile);
                outputNames.push_back(errorQualityFileName);  outputTypes["errorquality"].push_back(errorQualityFileName);
@@ -1216,7 +1219,9 @@ void SeqErrorCommand::printQualityFR(vector<vector<int> > qualForwardMap, vector
                        }
                }
         string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
-               string qualityForwardFileName = fileNameRoot + getOutputFileNameTag("errorqualforward");
+        map<string, string> variables; 
+               variables["[filename]"] = fileNameRoot;
+               string qualityForwardFileName = getOutputFileName("errorqualforward",variables);
                ofstream qualityForwardFile;
                m->openOutputFile(qualityForwardFileName, qualityForwardFile);
                outputNames.push_back(qualityForwardFileName);  outputTypes["errorqualforward"].push_back(qualityForwardFileName);
@@ -1234,7 +1239,7 @@ void SeqErrorCommand::printQualityFR(vector<vector<int> > qualForwardMap, vector
                qualityForwardFile.close();
 
                
-               string qualityReverseFileName = fileNameRoot + getOutputFileNameTag("errorqualreverse");
+               string qualityReverseFileName = getOutputFileName("errorqualreverse",variables);
                ofstream qualityReverseFile;
                m->openOutputFile(qualityReverseFileName, qualityReverseFile);
                outputNames.push_back(qualityReverseFileName);  outputTypes["errorqualreverse"].push_back(qualityReverseFileName);
index fba392d800a1f2454310ff57904a40454b231fd4..6c7af2cc5a3977db356ed0806d5e4cff48e701ce 100644 (file)
@@ -24,8 +24,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "seq.error";                           }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Gevers D, Westcott SL (2011).  Reducing the effects of PCR amplification and sequencing artifacts on 16S rRNA-based studies.  PLoS ONE.  6:e27310.\nhttp://www.mothur.org/wiki/Seq.error"; }
        string getDescription()         { return "seq.error"; }
 
index fb43503b2e7cc987e56ee58f591f5fe75d47aaa1..8f27b8c7beaf797775f680bdef5c34bcf7f980c8 100644 (file)
 //**********************************************************************************************************************
 vector<string> SeqSummaryCommand::setParameters(){     
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,24 +48,19 @@ string SeqSummaryCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SeqSummaryCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SeqSummaryCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SeqSummaryCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -193,7 +188,9 @@ int SeqSummaryCommand::execute(){
                //set current fasta to fastafile
                m->setFastaFile(fastafile);
                
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+               string summaryFile = getOutputFileName("summary",variables);
                                
                int numSeqs = 0;
                
index 3926e25f3c2ebb484b357464d1514dfc957c4000..c4e6131524d9c64b4496df7f9d5d34a315e6b34e 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.seqs";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.seqs"; }
        string getDescription()         { return "summarize the quality of sequences in an unaligned or aligned fasta file"; }
        
index 27d7b92764bda85599b2f18cbdafb3e486e704ef..9d277f3e71ae3635d5f14cf468822fa3e1181e8c 100644 (file)
 vector<string> SetCurrentCommand::setParameters(){     
        try {
                
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pflow);
-        CommandParameter pbiom("biom", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pbiom);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcolumn);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);            
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pdesign);
-               CommandParameter porder("order", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(porder);
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptree);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
-        CommandParameter pcount("count", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psff);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pclear("clear", "String", "", "", "", "", "",false,false); parameters.push_back(pclear);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pflow);
+        CommandParameter pbiom("biom", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pbiom);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pphylip);
+               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pcolumn);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pname);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(plist);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(ptaxonomy);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pqfile);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);         
+               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(psabund);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pdesign);
+               CommandParameter porder("order", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(porder);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(ptree);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pshared);
+               CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pordergroup);
+        CommandParameter pcount("count", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pcount);
+               CommandParameter prelabund("relabund", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(prelabund);
+               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(psff);
+               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(poligos);
+               CommandParameter pclear("clear", "String", "", "", "", "", "","",false,false); parameters.push_back(pclear);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index e741399844347f3db0a936cd2581ce9ba45dd7b2..190bf77f2889211f90a0be91c5f3073d02c017b9 100644 (file)
@@ -23,8 +23,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.current"; }
        string getCommandCategory()             { return "General";             }
-       string getOutputFileNameTag(string, string) { return ""; }
+       
        string getHelpString(); 
+    string getOutputPattern(string){ return ""; }      
        string getCitation() { return "http://www.mothur.org/wiki/Set.current"; }
        string getDescription()         { return "set current files for mothur"; }
 
index ca8c62d43821652d6bf4ea868e9444d54c256ff4..4536d9516688fe6db1d9c10e709e789c40abe93c 100644 (file)
 //**********************************************************************************************************************
 vector<string> SetDirectoryCommand::setParameters(){   
        try {
-               CommandParameter ptempdefault("tempdefault", "String", "", "", "", "", "",false,false); parameters.push_back(ptempdefault);
-        CommandParameter pdebug("debug", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pdebug);
-               CommandParameter pinput("input", "String", "", "", "", "", "",false,false); parameters.push_back(pinput);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptempdefault("tempdefault", "String", "", "", "", "", "","",false,false); parameters.push_back(ptempdefault);
+        CommandParameter pdebug("debug", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pdebug);
+               CommandParameter pinput("input", "String", "", "", "", "", "","",false,false,true); parameters.push_back(pinput);
+               CommandParameter poutput("output", "String", "", "", "", "", "","",false,false,true); parameters.push_back(poutput);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 837a8b58053cc7b2f5491d8fb59ba00c7c758328..ab174c2b783eca5c3a7fc0d74a8a2f6c5abf4a70 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.dir";             }
        string getCommandCategory()             { return "General";             }
-       string getOutputFileNameTag(string, string) { return ""; }
+       
        string getHelpString(); 
+    string getOutputPattern(string){ return ""; }      
        string getCitation() { return "http://www.mothur.org/wiki/Set.dir"; }
        string getDescription()         { return "set input, output and default directories"; }
 
index 576a37c11a26a656d34a9af69972dc4c3a329233..128c5671ed55712d2293e0b3c3959da17a7e9f05 100644 (file)
 //**********************************************************************************************************************
 vector<string> SetLogFileCommand::setParameters(){     
        try {
-               CommandParameter pappend("append", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pappend);
-               CommandParameter pname("name", "String", "", "", "", "", "",false,true); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pappend("append", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pappend);
+               CommandParameter pname("name", "String", "", "", "", "", "","",false,true,true); parameters.push_back(pname);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index a97c7910ad6ccc2ad63544c0f2f6b9b875af1da8..0354971a0b2d92cf2edc7cf742b80beae1a9be17 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.logfile";         }
        string getCommandCategory()             { return "General";                     }
-       string getOutputFileNameTag(string, string) { return ""; }
+       
        string getHelpString(); 
+    string getOutputPattern(string){ return ""; }      
        string getCitation() { return "http://www.mothur.org/wiki/Set.logfile"; }
        string getDescription()         { return "set logfile name"; }
 
index c50255aeb2ae9c202074b78d89d460651cefdc43..a1b7066482b973bcbaeebefdc718c5c96d70aae9 100644 (file)
 //**********************************************************************************************************************
 vector<string> SffInfoCommand::setParameters(){        
        try {           
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psff);
-        CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter psfftxt("sfftxt", "String", "", "", "", "", "",false,false); parameters.push_back(psfftxt);
-               CommandParameter pflow("flow", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pflow);
-               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(ptrim);
-               CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pqfile("name", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqfile);
-        CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(psff);
+        CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(poligos);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+               CommandParameter psfftxt("sfftxt", "String", "", "", "", "", "","",false,false); parameters.push_back(psfftxt);
+               CommandParameter pflow("flow", "Boolean", "", "T", "", "", "","flow",false,false); parameters.push_back(pflow);
+               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(ptrim);
+               CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "","fasta",false,false); parameters.push_back(pfasta);
+               CommandParameter pqfile("qfile", "Boolean", "", "T", "", "", "","qfile",false,false); parameters.push_back(pqfile);
+        CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pbdiffs);
+        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
+               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -70,32 +70,26 @@ string SffInfoCommand::getHelpString(){
                exit(1);
        }
 }
+
 //**********************************************************************************************************************
-string SffInfoCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SffInfoCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "fasta";   }
-            else if (type == "flow")    {   outputFileName =  "flow";   }
-            else if (type == "sfftxt")        {   outputFileName =  "sff.txt";   }
-            else if (type == "sff")        {   outputFileName =  "sff";   }
-            else if (type == "qfile")       {   outputFileName =  "qual";   }
-             else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern =  "[filename],fasta-[filename],[tag],fasta";   }
+        else if (type == "flow")    {   pattern =  "[filename],flow";   }
+        else if (type == "sfftxt")        {   pattern =  "[filename],sff.txt";   }
+        else if (type == "sff")        {   pattern =  "[filename],[group],sff";   }
+        else if (type == "qfile")       {   pattern =  "[filename],qual-[filename],[tag],qual";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SffInfoCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
-
 //**********************************************************************************************************************
 SffInfoCommand::SffInfoCommand(){      
        try {
@@ -504,16 +498,14 @@ int SffInfoCommand::extractSffInfo(string input, string accnos, string oligos){
         string rootName = outputDir + m->getRootName(m->getSimpleName(input));
         if(rootName.find_last_of(".") == rootName.npos){ rootName += "."; }
         
-               string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("sfftxt");
-               string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("flow");
-               if (trim) {
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("fasta");
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("qfile");
-               }else{
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("fasta");
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("qfile");
-               }
-               
+        map<string, string> variables; 
+               variables["[filename]"] = rootName;
+               string sfftxtFileName = getOutputFileName("sfftxt",variables);
+               string outFlowFileName = getOutputFileName("flow",variables);
+               if (!trim) { variables["[tag]"] = "raw"; }
+               outFastaFileName = getOutputFileName("fasta",variables);
+        outQualFileName = getOutputFileName("qfile",variables);
+        
                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["qfile"].push_back(outQualFileName);  }
@@ -1396,14 +1388,13 @@ int SffInfoCommand::parseSffTxt() {
                        fileRoot = m->getRootName(fileRoot);
                }
                
-               string outFlowFileName = outputDir + fileRoot + getOutputFileNameTag("flow");
-               if (trim) {
-                       outFastaFileName = outputDir + fileRoot + getOutputFileNameTag("fasta");
-                       outQualFileName = outputDir + fileRoot + getOutputFileNameTag("qfile");
-               }else{
-                       outFastaFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("fasta");
-                       outQualFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("qfile");
-               }
+        map<string, string> variables; 
+               variables["[filename]"] = fileRoot;
+               string sfftxtFileName = getOutputFileName("sfftxt",variables);
+               string outFlowFileName = getOutputFileName("flow",variables);
+               if (!trim) { variables["[tag]"] = "raw"; }
+               outFastaFileName = getOutputFileName("fasta",variables);
+        outQualFileName = getOutputFileName("qfile",variables);
                
                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["qfile"].push_back(outQualFileName);  }
@@ -1731,7 +1722,10 @@ bool SffInfoCommand::readOligos(string oligoFile){
                                        }
                                        
                                        ofstream temp;
-                                       string thisFilename = outputDir + m->getRootName(m->getSimpleName(currentFileName)) + comboGroupName + "." + getOutputFileNameTag("sff");
+                    map<string, string> variables; 
+                    variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(currentFileName));
+                    variables["[group]"] = comboGroupName;
+                                       string thisFilename = getOutputFileName("sff",variables);
                                        if (uniqueNames.count(thisFilename) == 0) {
                                                outputNames.push_back(thisFilename);
                                                outputTypes["sff"].push_back(thisFilename);
@@ -1746,7 +1740,10 @@ bool SffInfoCommand::readOligos(string oligoFile){
                numFPrimers = primers.size();
         numLinkers = linker.size();
         numSpacers = spacer.size();
-               noMatchFile = outputDir + m->getRootName(m->getSimpleName(currentFileName)) + "scrap." + getOutputFileNameTag("sff");
+        map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(currentFileName));
+        variables["[group]"] = "scrap";
+               noMatchFile = getOutputFileName("sff",variables);
         m->mothurRemove(noMatchFile);
         
                bool allBlank = true;
index 4917a274029f778e957791a744d66b5ff059890c..5ec6e72239d0772548ce10f584ebccb435230d25 100644 (file)
@@ -69,8 +69,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sffinfo";                                     }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; }
        string getDescription()         { return "extract sequences reads from a .sff file"; }
 
index 05bc9aafb5d38a90ca48f0356504ddbf9adb7708..91d8b0152bf1db087f8243fc80e8c39b8dac57b9 100644 (file)
 //**********************************************************************************************************************
 vector<string> SffMultipleCommand::setParameters(){    
        try {           
-               CommandParameter pfile("file", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfile);
+               CommandParameter pfile("file", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfile);
         
         //sffinfo
-               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(ptrim);
+               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(ptrim);
         
         //trim.flows
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pmaxflows);
-               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pminflows);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(psignal);
-               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pnoise);
-               CommandParameter porder("order", "String", "", "TACG", "", "", "",false,false); parameters.push_back(porder);
+               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "","",false,false); parameters.push_back(pmaxhomop);
+               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pmaxflows);
+               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pminflows);
+               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
+        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
+               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
+               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "","",false,false); parameters.push_back(psignal);
+               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "","",false,false); parameters.push_back(pnoise);
+               CommandParameter porder("order", "String", "", "TACG", "", "", "","",false,false); parameters.push_back(porder);
 
         //shhh.flows
-        CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plookup);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pmaxiter);
-        CommandParameter plarge("large", "Number", "", "-1", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter psigma("sigma", "Number", "", "60", "", "", "",false,false); parameters.push_back(psigma);
-               CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "",false,false); parameters.push_back(pmindelta);
+        CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(plookup);
+               CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(pmaxiter);
+        CommandParameter plarge("large", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter psigma("sigma", "Number", "", "60", "", "", "","",false,false); parameters.push_back(psigma);
+               CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "","",false,false); parameters.push_back(pmindelta);
         
         //trim.seqs parameters
-        CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "",false,false); parameters.push_back(pallfiles);
-        CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxambig);
-               CommandParameter pminlength("minlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pminlength);
-               CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxlength);
-               CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepforward);
-        CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "",false,false); parameters.push_back(pkeepfirst);
-               CommandParameter premovelast("removelast", "Number", "", "0", "", "", "",false,false); parameters.push_back(premovelast);
+        CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "","",false,false); parameters.push_back(pallfiles);
+        CommandParameter pflip("flip", "Boolean", "", "F", "", "", "","",false,false,true); parameters.push_back(pflip);
+               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxambig);
+               CommandParameter pminlength("minlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pminlength);
+               CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxlength);
+               CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkeepforward);
+        CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pkeepfirst);
+               CommandParameter premovelast("removelast", "Number", "", "0", "", "", "","",false,false); parameters.push_back(premovelast);
 
         
-        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -100,29 +100,22 @@ string SffMultipleCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SffMultipleCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SffMultipleCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "fasta";   }
-            else if (type == "name")    {   outputFileName =  "names";   }
-            else if (type == "group")        {   outputFileName =  "groups";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffMultipleCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],fasta"; } 
+        else if (type == "name") {  pattern = "[filename],names"; } 
+        else if (type == "group") {  pattern = "[filename],groups"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SffMultipleCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
-
 //**********************************************************************************************************************
 SffMultipleCommand::SffMultipleCommand(){      
        try {
@@ -132,8 +125,6 @@ SffMultipleCommand::SffMultipleCommand(){
                outputTypes["fasta"] = tempOutNames;
         outputTypes["name"] = tempOutNames;
         outputTypes["group"] = tempOutNames;
-               outputTypes["flow"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "SffMultipleCommand", "SffMultipleCommand");
@@ -168,8 +159,6 @@ SffMultipleCommand::SffMultipleCommand(string option)  {
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
-                       outputTypes["flow"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
             outputTypes["name"] = tempOutNames;
             outputTypes["group"] = tempOutNames;
 
@@ -379,9 +368,11 @@ int SffMultipleCommand::execute(){
         
         outputDir = m->hasPath(filename);
         string fileroot = outputDir + m->getRootName(m->getSimpleName(filename));
-        string fasta = fileroot + getOutputFileNameTag("fasta");
-        string name = fileroot + getOutputFileNameTag("name");
-        string group = fileroot + getOutputFileNameTag("group");
+        map<string, string> variables; 
+               variables["[filename]"] = fileroot;
+        string fasta = fileroot + getOutputFileName("fasta",variables);
+        string name = fileroot + getOutputFileName("name",variables);
+        string group = fileroot + getOutputFileName("group",variables);
         
         if (m->control_pressed) { return 0; }
         
index 4ab2c972557500c059b48ef38f712483f5731231..ee83d727ad3b3a1e910f4b3cb633eae53938f87a 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sff.multiple";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Sff.multiple"; }
        string getDescription()         { return "run multiple sff files through, sffinfo, trim.flow, shhh.flows and trim.seqs combining the results"; }
     
index 542f8d346447322aea63491e092b97632449bd62..91ca1a15cc7b3d6bad67331e129b57c6819e34b4 100644 (file)
@@ -19,15 +19,15 @@ inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* r
 //**********************************************************************************************************************
 vector<string> SharedCommand::setParameters(){ 
        try {
-        CommandParameter pbiom("biom", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "none",false,false); parameters.push_back(pbiom);
-               CommandParameter plist("list", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "ListGroup",false,false); parameters.push_back(plist);
-        CommandParameter pcount("count", "InputTypes", "", "", "", "GroupCount", "",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "GroupCount", "ListGroup",false,false); parameters.push_back(pgroup);
+        CommandParameter pbiom("biom", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "none","shared",false,false); parameters.push_back(pbiom);
+               CommandParameter plist("list", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "ListGroup","shared",false,false,true); parameters.push_back(plist);
+        CommandParameter pcount("count", "InputTypes", "", "", "none", "GroupCount", "none","",false,false); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "GroupCount", "ListGroup","",false,false,true); parameters.push_back(pgroup);
                //CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","group",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -56,28 +56,22 @@ string SharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SharedCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "shared")            {   outputFileName =  "shared";   }
-            else if (type == "rabund")    {   outputFileName =  "rabund";   }
-            else if (type == "group")        {   outputFileName =  "groups";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "shared") {  pattern = "[filename],shared"; } 
+        else if (type == "rabund") {  pattern = "[filename],[group],rabund"; } 
+        else if (type == "group") {  pattern = "[filename],[group],groups"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 SharedCommand::SharedCommand(){        
        try {
@@ -263,8 +257,9 @@ int SharedCommand::execute(){
                
                if (outputDir == "") { outputDir += m->hasPath(filename); }
                
-               filename = outputDir + m->getRootName(m->getSimpleName(filename));
-               filename = filename + getOutputFileNameTag("shared");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(filename));
+               filename = getOutputFileName("shared",variables);
                outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
                
         if (listfile != "") {  createSharedFromListGroup(filename);  }
@@ -795,12 +790,15 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         
         //set fileroot
         fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
-        
+        map<string, string> variables; 
+               variables["[filename]"] = fileroot;
         //clears file before we start to write to it below
         for (int i=0; i<Groups.size(); i++) {
-            m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
-            outputNames.push_back((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
-            outputTypes["rabund"].push_back((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
+            variables["[group]"] = Groups[i];
+            string rabundFIleName = getOutputFileName("rabund",variables);
+            m->mothurRemove(rabundFIleName);
+            outputNames.push_back(rabundFIleName);
+            outputTypes["rabund"].push_back(rabundFIleName);
         }
         
         string errorOff = "no error";
@@ -817,7 +815,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
             delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
             for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
             out.close(); m->mothurRemove(filename); 
-            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
+            for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                string rabundFIleName = getOutputFileName("rabund",variables);
+                m->mothurRemove(rabundFIleName);               }
             return 0; 
         }
         
@@ -849,8 +849,10 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                     groups += (m->getGroups())[i] + ".";
                 }
             }else { groups = "merge"; }
-            
-            string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + getOutputFileNameTag("group");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+            variables["[group]"] = groups;
+            string newGroupFile = getOutputFileName("group",variables);
             outputTypes["group"].push_back(newGroupFile); 
             outputNames.push_back(newGroupFile);
             ofstream outGroups;
@@ -876,7 +878,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 delete SharedList; if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
                 out.close(); m->mothurRemove(filename); 
-                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));         }
+                for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                    string rabundFIleName = getOutputFileName("rabund",variables);
+                    m->mothurRemove(rabundFIleName);           }
                 return 0; 
             }
             
@@ -894,7 +898,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
                     out.close(); m->mothurRemove(filename); 
-                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
+                    for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                        string rabundFIleName = getOutputFileName("rabund",variables);
+                        m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
@@ -924,7 +930,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                     for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                     for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
                     out.close(); m->mothurRemove(filename); 
-                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
+                    for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                        string rabundFIleName = getOutputFileName("rabund",variables);
+                        m->mothurRemove(rabundFIleName);               }
                     return 0; 
                 }
                 
@@ -970,7 +978,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 if (groupMap != NULL) { delete groupMap; } if (countTable != NULL) { delete countTable; }
                 for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;   }
                 out.close(); m->mothurRemove(filename); 
-                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));         }
+                for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                    string rabundFIleName = getOutputFileName("rabund",variables);
+                    m->mothurRemove(rabundFIleName);           }
                 return 0; 
             }
             
@@ -990,7 +1000,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                
         if (m->control_pressed) { 
             m->mothurRemove(filename); 
-            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
+            for (int i=0; i<Groups.size(); i++) {  variables["[group]"] = Groups[i];
+                string rabundFIleName = getOutputFileName("rabund",variables);
+                m->mothurRemove(rabundFIleName);               }
             return 0; 
         }
 
@@ -1019,7 +1031,10 @@ void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup, ofst
                                Groups.push_back(thislookup[i]->getGroup());
                                
                                RAbundVector rav = thislookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + "." + getOutputFileNameTag("rabund"), *(filehandles[thislookup[i]->getGroup()]));
+                map<string, string> variables; 
+                variables["[filename]"] = fileroot;
+                variables["[group]"] = thislookup[i]->getGroup();
+                               m->openOutputFileAppend(getOutputFileName("rabund",variables), *(filehandles[thislookup[i]->getGroup()]));
                                rav.print(*(filehandles[thislookup[i]->getGroup()]));
                                (*(filehandles[thislookup[i]->getGroup()])).close();
                        }
@@ -1047,7 +1062,10 @@ void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup, ofst
                                        Groups.push_back((myIt->second)->getGroup());
                                
                                        RAbundVector rav = (myIt->second)->getRAbundVector();
-                                       m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + "." + getOutputFileNameTag("rabund"), *(filehandles[(myIt->second)->getGroup()]));
+                    map<string, string> variables; 
+                    variables["[filename]"] = fileroot;
+                    variables["[group]"] = (myIt->second)->getGroup();
+                                       m->openOutputFileAppend(getOutputFileName("rabund",variables), *(filehandles[(myIt->second)->getGroup()]));
                                        rav.print(*(filehandles[(myIt->second)->getGroup()]));
                                        (*(filehandles[(myIt->second)->getGroup()])).close();
                                }else{
index 9d9c194dbbaab4ff7a079058c1c43421937659fe..39ef9a7a1ebc17f830103cf33d84520aca975f97 100644 (file)
@@ -30,8 +30,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Make.shared"; }
        string getDescription()         { return "make a shared file from a list and group file"; }
 
index 19ffc899d60ac778ac4eedbeb2034a62b5e04bd7..a859d145b49e261bace85fb973d3aa9466bc1123 100644 (file)
 //**********************************************************************************************************************
 vector<string> ShhherCommand::setParameters(){ 
        try {
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pflow);
-               CommandParameter pfile("file", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pfile);
-               CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plookup);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pmaxiter);
-        CommandParameter plarge("large", "Number", "", "-1", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter psigma("sigma", "Number", "", "60", "", "", "",false,false); parameters.push_back(psigma);
-               CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "",false,false); parameters.push_back(pmindelta);
-               CommandParameter porder("order", "String", "", "", "", "", "",false,false); parameters.push_back(porder);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pflow("flow", "InputTypes", "", "", "none", "fileflow", "none","fasta-name-group-counts-qfile",false,false,true); parameters.push_back(pflow);
+               CommandParameter pfile("file", "InputTypes", "", "", "none", "fileflow", "none","fasta-name-group-counts-qfile",false,false,true); parameters.push_back(pfile);
+               CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(plookup);
+               CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(pmaxiter);
+        CommandParameter plarge("large", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter psigma("sigma", "Number", "", "60", "", "", "","",false,false); parameters.push_back(psigma);
+               CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "","",false,false); parameters.push_back(pmindelta);
+               CommandParameter porder("order", "String", "", "", "", "", "","",false,false); parameters.push_back(porder);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -47,28 +47,23 @@ string ShhherCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ShhherCommand::getOutputFileNameTag(string type, string inputName=""){  
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
-        
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "shhh.fasta";   }
-            else if (type == "name")    {   outputFileName =  "shhh.names";   }
-            else if (type == "group")        {   outputFileName =  "shhh.groups";   }
-            else if (type == "counts")        {   outputFileName =  "shhh.counts";   }
-            else if (type == "qfile")        {   outputFileName =  "shhh.qual";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+string ShhherCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        
+        if (type == "fasta")            {   pattern = "[filename],shhh.fasta";   }
+        else if (type == "name")    {   pattern = "[filename],shhh.names";   }
+        else if (type == "group")        {   pattern = "[filename],shhh.groups";   }
+        else if (type == "counts")        {   pattern = "[filename],shhh.counts";   }
+        else if (type == "qfile")        {   pattern = "[filename],shhh.qual";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ShhherCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 
@@ -801,8 +796,9 @@ string ShhherCommand::createNamesFile(){
                for(int i=0;i<numSeqs;i++){
                        duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
                }
-               
-               string nameFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("name");
+               map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
+               string nameFileName = getOutputFileName("name",variables);
                
                ofstream nameFile;
                m->openOutputFile(nameFileName, nameFile);
@@ -1651,7 +1647,9 @@ void ShhherCommand::writeQualities(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("qfile");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
+        string qualityFileName = getOutputFileName("qfile",variables);
         
         ofstream qualityFile;
         m->openOutputFile(qualityFileName, qualityFile);
@@ -1758,7 +1756,9 @@ void ShhherCommand::writeSequences(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("fasta");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
+        string fastaFileName = getOutputFileName("fasta",variables);
         ofstream fastaFile;
         m->openOutputFile(fastaFileName, fastaFile);
         
@@ -1806,7 +1806,9 @@ void ShhherCommand::writeNames(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("name");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
+        string nameFileName = getOutputFileName("name",variables);
         ofstream nameFile;
         m->openOutputFile(nameFileName, nameFile);
         
@@ -1848,7 +1850,9 @@ void ShhherCommand::writeGroups(){
         int pos = fileRoot.find_first_of('.');
         string fileGroup = fileRoot;
         if (pos != string::npos) {  fileGroup = fileRoot.substr(pos+1, (fileRoot.length()-1-(pos+1)));  }
-        string groupFileName = thisOutputDir + fileRoot + getOutputFileNameTag("group");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + fileRoot;
+        string groupFileName = getOutputFileName("group",variables);
         ofstream groupFile;
         m->openOutputFile(groupFileName, groupFile);
         
@@ -1872,7 +1876,9 @@ void ShhherCommand::writeClusters(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) +getOutputFileNameTag("counts");
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
+        string otuCountsFileName = getOutputFileName("counts",variables);
         ofstream otuCountsFile;
         m->openOutputFile(otuCountsFileName, otuCountsFile);
         
@@ -2323,15 +2329,17 @@ int ShhherCommand::driver(vector<string> filenames, string thisCompositeFASTAFil
                 if ((large) && (g == 0)) {  flowFileName = filenames[i]; theseFlowFileNames[0] = filenames[i]; }
                 string thisOutputDir = outputDir;
                 if (outputDir == "") {  thisOutputDir = m->hasPath(flowFileName);  }
-                string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("qfile");
-                string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("fasta");
-                string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("name");
-                string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("counts");
+                map<string, string> variables; 
+                variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
+                string qualityFileName = getOutputFileName("qfile",variables);
+                string fastaFileName = getOutputFileName("fasta",variables);
+                string nameFileName = getOutputFileName("name",variables);
+                string otuCountsFileName = getOutputFileName("counts",variables);
                 string fileRoot = m->getRootName(m->getSimpleName(flowFileName));
                 int pos = fileRoot.find_first_of('.');
                 string fileGroup = fileRoot;
                 if (pos != string::npos) {  fileGroup = fileRoot.substr(pos+1, (fileRoot.length()-1-(pos+1)));  }
-                string groupFileName = thisOutputDir + fileRoot + getOutputFileNameTag("group");
+                string groupFileName = getOutputFileName("group",variables);
 
                 
                 writeQualities(numOTUs, numFlowCells, qualityFileName, otuCounts, nSeqsPerOTU, seqNumber, singleTau, flowDataIntI, uniqueFlowgrams, cumNumSeqs, mapUniqueToSeq, seqNameVector, centroids, aaI); if (m->control_pressed) { break; }
@@ -2342,15 +2350,16 @@ int ShhherCommand::driver(vector<string> filenames, string thisCompositeFASTAFil
                 
                 if (large) {
                     if (g > 0) {
-                        m->appendFiles(qualityFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("qfile")));
+                        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0]));
+                        m->appendFiles(qualityFileName, getOutputFileName("qfile",variables));
                         m->mothurRemove(qualityFileName);
-                        m->appendFiles(fastaFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("fasta")));
+                        m->appendFiles(fastaFileName, getOutputFileName("fasta",variables));
                         m->mothurRemove(fastaFileName);
-                        m->appendFiles(nameFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("name")));
+                        m->appendFiles(nameFileName, getOutputFileName("name",variables));
                         m->mothurRemove(nameFileName);
-                        m->appendFiles(otuCountsFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("counts")));
+                        m->appendFiles(otuCountsFileName, getOutputFileName("counts",variables));
                         m->mothurRemove(otuCountsFileName);
-                        m->appendFiles(groupFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("group")));
+                        m->appendFiles(groupFileName, getOutputFileName("group",variables));
                         m->mothurRemove(groupFileName);
                     }
                     m->mothurRemove(theseFlowFileNames[g]);
index ef52dcd1d761cb26d67bb3c8556e7358c3d57440..3b757241eacee655570ef823bfed96bfd39abe64 100644 (file)
@@ -40,8 +40,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "shhh.flows";  }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Gevers D, Westcott SL (2011).  Reducing the effects of PCR amplification and sequencing artifacts on 16S rRNA-based studies.  PLoS ONE.  6:e27310.\nQuince C, Lanzen A, Davenport RJ, Turnbaugh PJ (2011).  Removing noise from pyrosequenced amplicons.  BMC Bioinformatics  12:38.\nQuince C, Lanzén A, Curtis TP, Davenport RJ, Hall N, Head IM, Read LF, Sloan WT (2009).  Accurate determination of microbial diversity from 454 pyrosequencing data.  Nat. Methods 6:639.\nhttp://www.mothur.org/wiki/Shhh.flows"; }
        string getDescription()         { return "shhh.flows"; }
 
index 63de2bb5541ddbd653b90eced12b4d59a9084629..3e3e5863c59abc69e4175eba7cb5b7d6f0e173c8 100644 (file)
 //**********************************************************************************************************************
 vector<string> ShhhSeqsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psigma("sigma", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(psigma);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta-map",false,true,true); parameters.push_back(pfasta);
+               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","name",false,true,true); parameters.push_back(pname);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pgroup);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+               CommandParameter psigma("sigma", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(psigma);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -55,26 +55,21 @@ string ShhhSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string ShhhSeqsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string ShhhSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "shhh_seqs.fasta";   }
-            else if (type == "name")    {   outputFileName =  "shhh_seqs.names";   }
-            else if (type == "map")        {   outputFileName =  "shhh_seqs.map";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],shhh_seqs.fasta";   }
+        else if (type == "name")    {   pattern = "[filename],shhh_seqs.names";   }
+        else if (type == "map")        {   pattern = "[filename],shhh_seqs.map";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ShhhSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
@@ -207,10 +202,13 @@ int ShhhSeqsCommand::execute() {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               if (outputDir == "") { outputDir = m->hasPath(fastafile);  }//if user entered a file with a path then preserve it                               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
-               string nameFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + getOutputFileNameTag("name");
-               string mapFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + getOutputFileNameTag("map");
+               if (outputDir == "") { outputDir = m->hasPath(fastafile);  }//if user entered a file with a path then preserve it               
+               
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+               string outputFileName = getOutputFileName("fasta",variables);
+               string nameFileName = getOutputFileName("name",variables);
+               string mapFileName = getOutputFileName("map",variables);
                
                if (groupfile != "") {
                        //Parse sequences by group
index 85be58c307e8a425e9ac4de4b7c2a99e3fe201d7..4da1a840c7d3c591f589ad6ea0103da4d9fbf1ce 100644 (file)
@@ -29,8 +29,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "shhh.seqs";   }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "Schloss PD, Gevers D, Westcott SL (2011).  Reducing the effects of PCR amplification and sequencing artifacts on 16S rRNA-based studies.  PLoS ONE.  6:e27310.\nQuince C, Lanzen A, Davenport RJ, Turnbaugh PJ (2011).  Removing noise from pyrosequenced amplicons.  BMC Bioinformatics  12:38.\nhttp://www.mothur.org/wiki/Shhh.seqs"; }
        string getDescription()         { return "shhh.seqs"; }
        
index b0af15441aaedcebb325294e1c91b8b7ab5389b1..d844452e1f72376535bc6edb57c36d3e2c808474 100644 (file)
 //**********************************************************************************************************************
 vector<string> SortSeqsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pflow("flow", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pflow);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false); parameters.push_back(pfasta);
+        CommandParameter pflow("flow", "InputTypes", "", "", "none", "FNGLT", "none","flow",false,false); parameters.push_back(pflow);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false); parameters.push_back(pgroup);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none","taxonomy",false,false); parameters.push_back(ptaxonomy);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none","qfile",false,false); parameters.push_back(pqfile);
+               CommandParameter plarge("large", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(plarge);
+               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -52,34 +52,27 @@ string SortSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-string SortSeqsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SortSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "taxonomy")    {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "count")       {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "flow")        {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else if (type == "qfile")       {   outputFileName =  "sorted" + m->getExtension(inputName);   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "taxonomy")    {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "flow")        {   pattern = "[filename],sorted,[extension]";    }
+        else if (type == "qfile")      {   pattern = "[filename],sorted,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SortSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 SortSeqsCommand::SortSeqsCommand(){    
        try {
@@ -358,7 +351,10 @@ int SortSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);
                outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -531,7 +527,10 @@ int SortSeqsCommand::readFlow(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(flowfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowfile)) + getOutputFileNameTag("flow", flowfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(flowfile));
+        variables["[extension]"] = m->getExtension(flowfile);
+               string outputFileName = getOutputFileName("flow", variables);
                outputTypes["flow"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -709,7 +708,10 @@ int SortSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(qualfile));
+        variables["[extension]"] = m->getExtension(qualfile);
+               string outputFileName = getOutputFileName("qfile", variables);
         outputTypes["qfile"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -889,7 +891,10 @@ int SortSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile); 
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+        variables["[extension]"] = m->getExtension(namefile);
+               string outputFileName = getOutputFileName("name", variables);
         outputTypes["name"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -965,7 +970,10 @@ int SortSeqsCommand::readCount(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(countfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile); 
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[extension]"] = m->getExtension(countfile);
+               string outputFileName = getOutputFileName("count", variables);
         outputTypes["count"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -1047,7 +1055,10 @@ int SortSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile); 
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
         outputTypes["group"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -1123,7 +1134,11 @@ int SortSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile); 
+               map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
+        variables["[extension]"] = m->getExtension(taxfile);
+               string outputFileName = getOutputFileName("taxonomy", variables);
+
         outputTypes["taxonomy"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
index 4ba8e4294d4b7d01bc8de7ba57cef84817f718ce..c1de84e3876464a2216dbfaeeec3b153048ae34c 100644 (file)
@@ -25,8 +25,9 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "sort.seqs";                           }
     string getCommandCategory()                { return "Sequence Processing";         }
-    string getOutputFileNameTag(string, string);
+    
        string getHelpString(); 
+    string getOutputPattern(string);   
     string getCitation() { return "http://www.mothur.org/wiki/Sort.seqs"; }
     string getDescription()            { return "puts sequences from a fasta, name, group, quality, flow or taxonomy file in the same order"; }
     
index 48fada8eb7fc89d858f24c4d54dcc0a64d8a8225..2d37e8d459857f7f0161ba87111df0403ff9c827 100644 (file)
 //**********************************************************************************************************************
 vector<string> SplitAbundCommand::setParameters(){     
        try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter paccnos("accnos", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(paccnos);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "","",false,true); parameters.push_back(pcutoff);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter paccnos("accnos", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(paccnos);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -58,30 +58,26 @@ string SplitAbundCommand::getHelpString(){
                exit(1);
        }
 }
+
 //**********************************************************************************************************************
-string SplitAbundCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SplitAbundCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "fasta";   }
-            else if (type == "list")    {   outputFileName =  "list";   }
-            else if (type == "name")        {   outputFileName =  "names";   }
-            else if (type == "count")        {   outputFileName =  "count_table";   }
-            else if (type == "group")       {   outputFileName =  "groups";   }
-            else if (type == "accnos")        {   outputFileName =  "accnos";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")        {  pattern = "[filename],[tag],[tag2],fasta-[filename],[tag],[group],[tag2],fasta";            } 
+        else if (type == "list")    {   pattern = "[filename],[tag],[tag2],list-[filename],[group],[tag],[tag2],list";            }
+        else if (type == "name")    {   pattern = "[filename],[tag],names-[filename],[group],[tag],names";           }
+        else if (type == "count")   {   pattern = "[filename],[tag],[tag2],count_table-[filename],[tag],count_table";     }
+        else if (type == "group")   {   pattern = "[filename],[tag],[tag2],groups-[filename],[tag],[group],[tag2],groups";          }
+        else if (type == "accnos")  {   pattern = "[filename],[tag],[tag2],accnos-[filename],[tag],[group],[tag2],accnos";          }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SplitAbundCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SplitAbundCommand::SplitAbundCommand(){        
@@ -471,7 +467,7 @@ int SplitAbundCommand::splitList(ListVector* thisList) {
                }//end for
 
                
-               string tag = thisList->getLabel() + ".";
+               string tag = thisList->getLabel();
        
                writeList(thisList, tag, numRareBins);
     
@@ -500,11 +496,16 @@ int SplitAbundCommand::writeList(ListVector* thisList, string tag, int numRareBi
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare." + getOutputFileNameTag("list");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+            variables["[tag]"] = tag;
+            variables["[tag2]"] = "rare";
+                       string rare = getOutputFileName("list",variables);
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["list"].push_back(rare);
                        
-                       string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund." + getOutputFileNameTag("list");
+            variables["[tag2]"] = "abund";
+                       string abund = getOutputFileName("list",variables);
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["list"].push_back(abund);
 
@@ -548,8 +549,14 @@ int SplitAbundCommand::writeList(ListVector* thisList, string tag, int numRareBi
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                string rareGroupFileName = fileroot + Groups[i] +"."+ tag + "rare." + getOutputFileNameTag("list");
-                string abundGroupFileName = fileroot + Groups[i] +"."+ tag + "abund." + getOutputFileNameTag("list");
+                map<string, string> variables; 
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = "rare";
+                variables["[group]"] = Groups[i];
+                string rareGroupFileName = getOutputFileName("list",variables);
+                variables["[tag2]"] = "abund";
+                string abundGroupFileName = getOutputFileName("list",variables);
                                m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
                                m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
                                outputNames.push_back(rareGroupFileName); outputTypes["list"].push_back(rareGroupFileName);
@@ -759,10 +766,14 @@ int SplitAbundCommand::parseCount(string tag) { //namefile
                map<string, ofstream*> filehandles;
         
                if (Groups.size() == 0) {
-                       string rare = outputDir + m->getRootName(m->getSimpleName(countfile))  + tag + "rare." + getOutputFileNameTag("count");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+            variables["[tag]"] = tag;
+            variables["[tag2]"] = "rare";
+                       string rare = getOutputFileName("count",variables);
             outputNames.push_back(rare); outputTypes["count"].push_back(rare);
-                       
-                       string abund = outputDir + m->getRootName(m->getSimpleName(countfile))  + tag + "abund." + getOutputFileNameTag("count");
+                       variables["[tag2]"] = "abund";
+                       string abund = getOutputFileName("count",variables);
                        outputNames.push_back(abund); outputTypes["count"].push_back(abund);
                        
             CountTable rareTable;
@@ -846,7 +857,10 @@ int SplitAbundCommand::parseCount(string tag) { //namefile
                        
                        for (it3 = countTableMap.begin(); it3 != countTableMap.end(); it3++) { 
                 string fileroot =  outputDir + m->getRootName(m->getSimpleName(countfile));
-                string filename = fileroot + it3->first + "." + getOutputFileNameTag("count");
+                map<string, string> variables; 
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = it3->first;
+                string filename = getOutputFileName("count",variables);
                 outputNames.push_back(filename);  outputTypes["count"].push_back(filename);
                 (it3->second)->printTable(filename);
                                delete it3->second;
@@ -871,11 +885,15 @@ int SplitAbundCommand::writeNames() { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare." + getOutputFileNameTag("name");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(namefile));
+            variables["[tag]"] = "rare";
+                       string rare = getOutputFileName("name", variables);
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["name"].push_back(rare);
                        
-                       string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund." + getOutputFileNameTag("name");
+            variables["[tag]"] = "abund";
+                       string abund = getOutputFileName("name", variables);
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["name"].push_back(abund);
                        
@@ -906,8 +924,13 @@ int SplitAbundCommand::writeNames() { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                string rareGroupFileName = fileroot + Groups[i] + ".rare." + getOutputFileNameTag("name");
-                string abundGroupFileName = fileroot + Groups[i] + ".abund." + getOutputFileNameTag("name");
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = "rare";
+                variables["[group]"] = Groups[i];
+                string rareGroupFileName = getOutputFileName("name",variables);
+                variables["[tag]"] = "abund";
+                string abundGroupFileName = getOutputFileName("name",variables);
                                m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
                                m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
                        }
@@ -945,7 +968,10 @@ int SplitAbundCommand::writeNames() { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + it3->first + "." + getOutputFileNameTag("name"));  outputTypes["name"].push_back(fileroot + it3->first + "." + getOutputFileNameTag("name"));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = it3->first;
+                               outputNames.push_back(getOutputFileName("name",variables));  outputTypes["name"].push_back(getOutputFileName("name",variables));
                                delete it3->second;
                        }
                }
@@ -969,8 +995,11 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        ofstream aout;
                        ofstream rout;
                        
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare." + getOutputFileNameTag("accnos");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFile));
+            variables["[tag]"] = tag;
+            variables["[tag2]"] = "rare";
+                       string rare = getOutputFileName("accnos",variables);
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["accnos"].push_back(rare); 
                        
@@ -979,7 +1008,8 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        }
                        rout.close();
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund." + getOutputFileNameTag("accnos");
+            variables["[tag2]"] = "abund";
+                       string abund = getOutputFileName("accnos",variables);
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
                        
@@ -1001,8 +1031,14 @@ int SplitAbundCommand::writeAccnos(string tag) {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("accnos"), *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("accnos"), *(filehandles[Groups[i]+".abund"]));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = "rare";
+                variables["[group]"] = Groups[i];
+                               m->openOutputFile(getOutputFileName("accnos",variables), *(filehandles[Groups[i]+".rare"]));
+                variables["[tag2]"] = "abund";
+                               m->openOutputFile(getOutputFileName("accnos",variables), *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        //write rare
@@ -1026,7 +1062,11 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        //close files
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos"));  outputTypes["accnos"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos"));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = it3->first;
+                               outputNames.push_back(getOutputFileName("accnos",variables));  outputTypes["accnos"].push_back(getOutputFileName("accnos",variables));
                                delete it3->second;
                        }
                }
@@ -1049,11 +1089,16 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare." + getOutputFileNameTag("group");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(groupfile));
+            variables["[tag]"] = tag;
+            variables["[tag2]"] = "rare";
+                       string rare = getOutputFileName("group",variables);
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["group"].push_back(rare);
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund." + getOutputFileNameTag("group");
+            variables["[tag2]"] = "abund";
+                       string abund = getOutputFileName("group",variables);
 ;
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["group"].push_back(abund);
@@ -1094,8 +1139,14 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("group"), *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("group"), *(filehandles[Groups[i]+".abund"]));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = "rare";
+                variables["[group]"] = Groups[i];
+                               m->openOutputFile(getOutputFileName("group",variables), *(filehandles[Groups[i]+".rare"]));
+                variables["[tag2]"] = "abund";
+                               m->openOutputFile(getOutputFileName("group",variables), *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
@@ -1121,7 +1172,11 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group"));  outputTypes["group"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group"));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = it3->first;
+                               outputNames.push_back(getOutputFileName("group",variables));  outputTypes["group"].push_back(getOutputFileName("group",variables));
                                delete it3->second;
                        }
                }
@@ -1144,11 +1199,16 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare." + getOutputFileNameTag("fasta");
+            map<string, string> variables;
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+            variables["[tag]"] = tag;
+            variables["[tag2]"] = "rare";
+                       string rare = getOutputFileName("fasta",variables);
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund." + getOutputFileNameTag("fasta");
+            variables["[tag2]"] = "abund";
+                       string abund = getOutputFileName("fasta",variables);
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
                
@@ -1195,8 +1255,14 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("fasta"), *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("fasta"), *(filehandles[Groups[i]+".abund"]));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = "rare";
+                variables["[group]"] = Groups[i];
+                               m->openOutputFile(getOutputFileName("fasta",variables), *(filehandles[Groups[i]+".rare"]));
+                variables["[tag2]"] = "abund";
+                               m->openOutputFile(getOutputFileName("fasta",variables), *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        //open input file
@@ -1249,7 +1315,11 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta"));  outputTypes["fasta"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta"));
+                map<string, string> variables;
+                variables["[filename]"] = fileroot;
+                variables["[tag]"] = tag;
+                variables["[tag2]"] = it3->first;
+                               outputNames.push_back(getOutputFileName("fasta",variables));  outputTypes["fasta"].push_back(getOutputFileName("fasta",variables));
                                delete it3->second;
                        }
                }
index d0542642a85d1efe0ea19280cceaaebc584911df..9929b7967050308c2563561896fa615a6f371d12 100644 (file)
@@ -36,8 +36,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "split.abund";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Split.abund"; }
        string getDescription()         { return "split a list, name, group or fasta file based on abundance"; }
        
index bc521127a57a8c3a4537ab0dfdd4ed187543d46d..238eda55e04a3df6e43a2fae8cee5736c4f6febc 100644 (file)
 //**********************************************************************************************************************
 vector<string> SplitGroupCommand::setParameters(){     
        try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "CountGroup", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "CountGroup", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "CountGroup", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "CountGroup", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -53,27 +53,23 @@ string SplitGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SplitGroupCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SplitGroupCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "fasta";   }
-            else if (type == "name")        {   outputFileName =  "names";   }
-            else if (type == "count")        {   outputFileName =  "count_table";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta") {  pattern = "[filename],[group],fasta"; } 
+        else if (type == "name") {  pattern = "[filename],[group],names"; } 
+        else if (type == "count") {  pattern = "[filename],[group],count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SplitGroupCommand", "getOutputPattern");
+        exit(1);
+    }
 }
+
 //**********************************************************************************************************************
 SplitGroupCommand::SplitGroupCommand(){        
        try {
@@ -289,8 +285,13 @@ int SplitGroupCommand::runNameGroup(){
                        
                        m->mothurOut("Processing group: " + Groups[i]); m->mothurOutEndLine();
                        
-                       string newFasta = fastafileRoot + Groups[i] + "." + getOutputFileNameTag("fasta");
-                       string newName = namefileRoot + Groups[i] + "." + getOutputFileNameTag("name");
+            map<string, string> variables; 
+            variables["[filename]"] = fastafileRoot;
+            variables["[group]"] = Groups[i];
+
+                       string newFasta = getOutputFileName("fasta",variables);
+            variables["[filename]"] = namefileRoot;
+                       string newName = getOutputFileName("name",variables);
                        
                        parser->getSeqs(Groups[i], newFasta, false);
                        outputNames.push_back(newFasta); outputTypes["fasta"].push_back(newFasta);
@@ -334,12 +335,16 @@ int SplitGroupCommand::runCount(){
         for (int i=0; i<Groups.size(); i++) {
             temp = new ofstream;
             ffiles[Groups[i]] = temp;
-            string newFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + Groups[i] + "." + getOutputFileNameTag("fasta");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+            variables["[group]"] = Groups[i];
+            string newFasta = getOutputFileName("fasta",variables);
             outputNames.push_back(newFasta); outputTypes["fasta"].push_back(newFasta);
             m->openOutputFile(newFasta, (*temp));
             temp = new ofstream;
             cfiles[Groups[i]] = temp;
-            string newCount = outputDir + m->getRootName(m->getSimpleName(countfile)) + Groups[i] + "." + getOutputFileNameTag("count");
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+            string newCount = getOutputFileName("count",variables);
             m->openOutputFile(newCount, (*temp));
             outputNames.push_back(newCount); outputTypes["count"].push_back(newCount);
             (*temp) << "Representative_Sequence\ttotal\t" << Groups[i] << endl;
index 62e063d8a0fe93c3942959527cde646996e3430d..b251fe55bc4fd010582c82297e8b757a0f17113e 100644 (file)
@@ -30,8 +30,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "split.group";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Split.group"; }
        string getDescription()         { return "split a name or fasta file by group"; }
 
index aea99ef2cccc3dbc070b251d4691209efacd2cbc..a5ae3cbda79fd52a9358464eab1941c96a69bd63 100644 (file)
@@ -191,8 +191,12 @@ int SplitMatrix::createDistanceFilesFromTax(map<string, int>& seqGroup, int numG
             else { options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff); }
                        if (outputDir != "") { options += ", outputdir=" + outputDir; }
                        
+            m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
+            
                        Command* command = new DistanceCommand(options);
                        
+            m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
+            
                        command->execute();
                        delete command;
                        
index a6b1b2d58da2daa5cc53d17d4bbb814b56921ffd..392f97bd51f1d2ac67d6d0a810a408ab507fdcee 100644 (file)
@@ -24,7 +24,7 @@ Tree* SubSample::getSample(Tree* T, CountTable* ct, CountTable* newCt, int size)
         for (int i = 0; i < Groups.size(); i++) {
             if (m->inUsersGroups(Groups[i], m->getGroups())) {
                 if (m->control_pressed) { break; }
-                cout << Groups[i] << endl;
+        
                 int thisSize = ct->getGroupCount(Groups[i]);
                 
                 if (thisSize >= size) {        
index e1793f415ff98daa180e7ace0b8bff3d52e5f3b9..cfc7b1d9283779fdf9cc4a21a60c3f6d49d5177b 100644 (file)
 //**********************************************************************************************************************
 vector<string> SubSampleCommand::setParameters(){      
        try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(plist);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(psabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppersample);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FLSSR", "none","fasta",false,false,true); parameters.push_back(pfasta);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter plist("list", "InputTypes", "", "", "none", "FLSSR", "none","list",false,false,true); parameters.push_back(plist);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "FLSSR", "none","shared",false,false,true); parameters.push_back(pshared);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "FLSSR", "none","rabund",false,false); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "FLSSR", "none","sabund",false,false); parameters.push_back(psabund);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter psize("size", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(psize);
+               CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "","",false,false,true); parameters.push_back(ppersample);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,33 +65,27 @@ string SubSampleCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SubSampleCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SubSampleCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "fasta")            {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "sabund")    {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "name")        {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "count")        {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "group")       {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "list")        {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "rabund")       {   outputFileName =  "subsample" + m->getExtension(inputName);   }
-            else if (type == "shared") {   outputFileName =  "subsample" + m->getExtension(inputName);        }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "fasta")            {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "sabund")    {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "name")        {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "group")       {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "count")       {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "list")        {   pattern = "[filename],subsample,[extension]";    }
+        else if (type == "shared")      {   pattern = "[filename],[distance],subsample,[extension]";    }
+        else if (type == "rabund")      {   pattern = "[filename],subsample,[extension]";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SubSampleCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 SubSampleCommand::SubSampleCommand(){  
        try {
@@ -545,7 +539,10 @@ int SubSampleCommand::getSubSampleFasta() {
                 
                 string countOutputDir = outputDir;
                 if (outputDir == "") {  countOutputDir += m->hasPath(countfile);  }
-                string countOutputFileName = countOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+                map<string, string> variables; 
+                variables["[filename]"] = countOutputDir + m->getRootName(m->getSimpleName(countfile));
+                variables["[extension]"] = m->getExtension(countfile);
+                string countOutputFileName = getOutputFileName("count", variables);
                 outputTypes["count"].push_back(countOutputFileName);  outputNames.push_back(countOutputFileName);
                 sampledCt.printTable(countOutputFileName);
             }
@@ -579,7 +576,10 @@ int SubSampleCommand::getSubSampleFasta() {
                 
                 string countOutputDir = outputDir;
                 if (outputDir == "") {  countOutputDir += m->hasPath(countfile);  }
-                string countOutputFileName = countOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+                map<string, string> variables; 
+                variables["[filename]"] = countOutputDir + m->getRootName(m->getSimpleName(countfile));
+                variables["[extension]"] = m->getExtension(countfile);
+                string countOutputFileName = getOutputFileName("count", variables);
                 outputTypes["count"].push_back(countOutputFileName);  outputNames.push_back(countOutputFileName);
                 sampledCt.printTable(countOutputFileName);
             }
@@ -589,7 +589,10 @@ int SubSampleCommand::getSubSampleFasta() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);         
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
+        variables["[extension]"] = m->getExtension(fastafile);
+               string outputFileName = getOutputFileName("fasta", variables);          
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -636,8 +639,10 @@ int SubSampleCommand::getSubSampleFasta() {
                
                if (namefile != "") {
                        m->mothurOut("Deconvoluting subsampled fasta file... "); m->mothurOutEndLine();
-                       
-            string outputNameFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
+                       map<string, string> variables; 
+            variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
+            variables["[extension]"] = m->getExtension(namefile);
+            string outputNameFileName = getOutputFileName("name", variables);
                        //use unique.seqs to create new name and fastafile
                        string inputString = "fasta=" + outputFileName;
                        m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
@@ -669,7 +674,10 @@ int SubSampleCommand::getSubSampleFasta() {
                        
                        string groupOutputDir = outputDir;
                        if (outputDir == "") {  groupOutputDir += m->hasPath(groupfile);  }
-                       string groupOutputFileName = groupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+            map<string, string> variables; 
+            variables["[filename]"] = groupOutputDir + m->getRootName(m->getSimpleName(groupfile));
+            variables["[extension]"] = m->getExtension(groupfile);
+                       string groupOutputFileName = getOutputFileName("group", variables);
                        
                        ofstream outGroup;
                        m->openOutputFile(groupOutputFileName, outGroup);
@@ -891,7 +899,11 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + thislookup[0]->getLabel() + "." +getOutputFileNameTag("shared", sharedfile);        
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
+        variables["[distance]"] = thislookup[0]->getLabel();
+               string outputFileName = getOutputFileName("shared", variables);        
         SubSample sample;
         vector<string> subsampledLabels = sample.getSample(thislookup, size);
         
@@ -929,7 +941,10 @@ int SubSampleCommand::getSubSampleList() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
+               map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+        variables["[extension]"] = m->getExtension(listfile);
+               string outputFileName = getOutputFileName("list", variables);   
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -1113,7 +1128,10 @@ int SubSampleCommand::getSubSampleList() {
         
             string countOutputDir = outputDir;
             if (outputDir == "") {  countOutputDir += m->hasPath(countfile);  }
-            string countOutputFileName = countOutputDir + m->getRootName(m->getSimpleName(countfile)) + getOutputFileNameTag("count", countfile);
+            map<string, string> variables; 
+            variables["[filename]"] = countOutputDir + m->getRootName(m->getSimpleName(countfile));
+            variables["[extension]"] = m->getExtension(countfile);
+            string countOutputFileName = getOutputFileName("count", variables);
             outputTypes["count"].push_back(countOutputFileName);  outputNames.push_back(countOutputFileName);
             sampledCt.printTable(countOutputFileName);
         }
@@ -1260,7 +1278,10 @@ int SubSampleCommand::getSubSampleRabund() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + getOutputFileNameTag("rabund", rabundfile);              
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile));
+        variables["[extension]"] = m->getExtension(rabundfile);
+               string outputFileName = getOutputFileName("rabund", variables);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["rabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -1414,7 +1435,10 @@ int SubSampleCommand::getSubSampleSabund() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + getOutputFileNameTag("sabund", sabundfile);              
+        map<string, string> variables; 
+               variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile));
+        variables["[extension]"] = m->getExtension(sabundfile);
+               string outputFileName = getOutputFileName("sabund", variables);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["sabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
index 7116909e3f97ec758ff4b9de178e0d9ebd0dded1..7bafd9bfb573a03527b95d179130fc066e9234bb 100644 (file)
@@ -29,8 +29,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sub.sample";  }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Sub.sample"; }
        string getDescription()         { return "get a sampling of sequences from a list, shared, rabund, sabund or fasta file"; }
 
index 7a167a6432015b41cbd2b8304aaa7c3415542624..43202e56cd2b86d7224a8b46b26526a511c6d55a 100644 (file)
 //**********************************************************************************************************************
 vector<string> SummaryCommand::setParameters(){        
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","summary",false,false,true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","summary",false,false); parameters.push_back(prabund);
+               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none","summary",false,false); parameters.push_back(psabund);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","summary",false,false,true); parameters.push_back(pshared);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+        CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "","",true,false,true); parameters.push_back(pcalc);
+               CommandParameter pabund("abund", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pabund);
+               CommandParameter psize("size", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psize);
+               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pgroupmode);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -85,24 +85,19 @@ string SummaryCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SummaryCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SummaryCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],summary-[filename],[tag],summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SummaryCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SummaryCommand::SummaryCommand(){      
@@ -273,7 +268,7 @@ SummaryCommand::SummaryCommand(string option)  {
                 else { subsample = false; subsampleSize = -1; }
             }
             
-            if (subsample == false) { iters = 1; }
+            if (subsample == false) { iters = 0; }
             else {
                 //if you did not set a samplesize and are not using a sharedfile
                 if ((subsampleSize == -1) && (format != "sharedfile"))  { m->mothurOut("[ERROR]: If you want to subsample with a list, rabund or sabund file, you must provide the sample size.  You can do this by setting subsample=yourSampleSize.\n");  abort=true; }
@@ -307,8 +302,11 @@ int SummaryCommand::execute(){
                        numLines = 0;
                        numCols = 0;
                        
-                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + getOutputFileNameTag("summary");
-            string fileNameAve = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "ave-std." + getOutputFileNameTag("summary");
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
+                       string fileNameRoot = getOutputFileName("summary",variables);
+            variables["[tag]"] = "ave-std";
+            string fileNameAve = getOutputFileName("summary",variables);
             outputNames.push_back(fileNameRoot); outputTypes["summary"].push_back(fileNameRoot);
             
                        if (inputFileNames.size() > 1) {
index 4936dd8e9ad004bbf18352bb36659463c62be746..3c8420795550e1f39ef5529ad235d13e11e5e7a5 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.single";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.single"; }
        string getDescription()         { return "generate summary file that has the calculator value for each line in the OTU data"; }
 
index 48852a7d7d5d46491340062c4b989cc425bc6512..ae5b652a3cbfa0e43aa74e495bb28eb16775d9d3 100644 (file)
 //**********************************************************************************************************************
 vector<string> SummaryQualCommand::setParameters(){    
        try {
-               CommandParameter pqual("qfile", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pqual);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pqual("qfile", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pqual);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -48,24 +48,19 @@ string SummaryQualCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SummaryQualCommand::getOutputFileNameTag(string type, string inputName=""){     
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SummaryQualCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "qual.summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],qual.summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SummaryQualCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SummaryQualCommand::SummaryQualCommand(){      
@@ -233,7 +228,9 @@ int SummaryQualCommand::execute(){
                if (m->control_pressed) {  return 0; }
                
                //print summary file
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(qualfile));
+               string summaryFile = getOutputFileName("summary",variables);
                printQual(summaryFile, position, averageQ, scores);
                
                if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
index ac65938bc23075fc7db7cb40b9ce6d05d0d5d64e..49583b059f5380ce049ac759dd94d8d25b1c7193 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.qual";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.qual"; }
        string getDescription()         { return "summarize the quality of a set of sequences"; }
        
index 6147832f70a750e1424939c9928a50db643fb8b8..85eb448916d5058b80ea7dade2b98d3f5e3148f9 100644 (file)
 //**********************************************************************************************************************
 vector<string> SummarySharedCommand::setParameters(){  
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-               CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pdistance);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
-        CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall);
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pshared);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","phylip",false,false); parameters.push_back(psubsample);
+               CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "","phylip",false,false); parameters.push_back(pdistance);
+               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc);
+        CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "","",false,false); parameters.push_back(poutput);
+               CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall);
+        CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -64,25 +64,20 @@ string SummarySharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SummarySharedCommand::getOutputFileNameTag(string type, string inputName=""){   
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SummarySharedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "shared.summary";   }
-            else if (type == "phylip")            {   outputFileName =  "dist";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],summary-[filename],[tag],summary"; } 
+        else if (type == "phylip") {  pattern = "[filename],[calc],[distance],[outputtag],[tag2],dist"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SummarySharedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SummarySharedCommand::SummarySharedCommand(){  
@@ -205,7 +200,7 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                 else { subsample = false; }
             }
             
-            if (subsample == false) { iters = 1; }
+            if (subsample == false) { iters = 0; }
             
                        temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
                        m->setProcessors(temp);
@@ -317,7 +312,9 @@ int SummarySharedCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                ofstream outputFileHandle, outAll;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+               string outputFileName = getOutputFileName("summary",variables);
                
                //if the users entered no valid calculators don't execute command
                if (sumCalculators.size() == 0) { return 0; }
@@ -348,7 +345,8 @@ int SummarySharedCommand::execute(){
                outputFileHandle.close();
                
                //create file and put column headers for multiple groups file
-               string outAllFileName = ((m->getRootName(sharedfile)) + "multiple." + getOutputFileNameTag("summary"));
+        variables["[tag]"]= "multiple";
+               string outAllFileName = getOutputFileName("summary",variables);
                if (mult == true) {
                        m->openOutputFile(outAllFileName, outAll);
                        outputNames.push_back(outAllFileName);
@@ -786,7 +784,12 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                             matrix[column][row] = dist;
                         }
                         
-                        string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + "." + getOutputFileNameTag("phylip");
+                        map<string, string> variables; 
+                        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+                        variables["[calc]"] = sumCalculators[i]->getName();
+                        variables["[distance]"] = thisLookup[0]->getLabel();
+                        variables["[outputtag]"] = output;
+                        string distFileName = getOutputFileName("phylip",variables);
                         outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                         ofstream outDist;
                         m->openOutputFile(distFileName, outDist);
@@ -879,7 +882,13 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                     stdmatrix[column][row] = stdDist;
                 }
                 
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave." + getOutputFileNameTag("phylip");
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+                variables["[calc]"] = sumCalculators[i]->getName();
+                variables["[distance]"] = thisLookup[0]->getLabel();
+                variables["[outputtag]"] = output;
+                variables["[tag2]"] = "ave";
+                string distFileName = getOutputFileName("phylip",variables);
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outAve;
                 m->openOutputFile(distFileName, outAve);
@@ -889,7 +898,8 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                 
                 outAve.close();
                 
-                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std." + getOutputFileNameTag("phylip");
+                variables["[tag2]"] = "std";
+                distFileName = getOutputFileName("phylip",variables);
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outSTD;
                 m->openOutputFile(distFileName, outSTD);
index 7c6a4b2965783a8145d311cfae05a150d82c2ce7..f486d520216bd8ec4858d50cd7f2d92b7fd23537 100644 (file)
@@ -67,8 +67,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.shared";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Summary.shared"; }
        string getDescription()         { return "generate a summary file containing calculator values for each line in the OTU data and for all possible comparisons between groups"; }
 
index d33b4f014a07b46e252e36e24a68bd2db8fc6d5a..c76f175b047ef9ee46eff28911c1a21cd6310a97 100644 (file)
 //**********************************************************************************************************************
 vector<string> SummaryTaxCommand::setParameters(){     
        try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(preftaxonomy);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(ptaxonomy);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(preftaxonomy);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -51,24 +51,19 @@ string SummaryTaxCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string SummaryTaxCommand::getOutputFileNameTag(string type, string inputName=""){      
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string SummaryTaxCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "summary")            {   outputFileName =  "tax.summary";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "summary") {  pattern = "[filename],tax.summary"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "SummaryTaxCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 SummaryTaxCommand::SummaryTaxCommand(){        
@@ -283,7 +278,9 @@ int SummaryTaxCommand::execute(){
                
                //print summary file
                ofstream outTaxTree;
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("summary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(taxfile));
+               string summaryFile = getOutputFileName("summary",variables);
                m->openOutputFile(summaryFile, outTaxTree);
                taxaSum->print(outTaxTree);
                outTaxTree.close();
index e8033e23c76837809aa7828389b9cbae13b9c639..5f61d13849fbfb332c8927445825bc5447b4ce8f 100644 (file)
@@ -24,8 +24,9 @@ class SummaryTaxCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "summary.tax";                 }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "http://www.mothur.org/wiki/Summary.tax"; }
                string getDescription()         { return "summarize the taxonomies of a set of sequences"; }
                
index c07deff1f19c0315b29e0f488572b3feacb7114f..b5b4945b92b6d664e6d81aa2dc6911a2d30414c3 100644 (file)
@@ -12,7 +12,7 @@
 //**********************************************************************************************************************
 vector<string> SystemCommand::setParameters(){ 
        try {
-               CommandParameter pcommand("command", "String", "", "", "", "", "",false,false); parameters.push_back(pcommand);
+               CommandParameter pcommand("command", "String", "", "", "", "", "","",false,false); parameters.push_back(pcommand);
                                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
index 6dc09ef75690b43eb0e5045788308c1a4d26d93b..27adf7c5993289bc0edeeb9f56b8de5939b2bfb0 100644 (file)
@@ -24,8 +24,8 @@ class SystemCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "system";              }
                string getCommandCategory()             { return "General";             }
-        string getOutputFileNameTag(string, string) { return ""; }
         string getHelpString();        
+        string getOutputPattern(string){ return ""; }  
                string getCitation() { return "http://www.mothur.org/wiki/System"; }
                string getDescription()         { return "execute system commands from within mothur"; }
 
index 0bd98e01f1c305d93851e1a5e465c92a22fc9a1f..6b799f479d12dd13da3e1579c19167dda056ba43 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -1344,7 +1344,7 @@ int Tree::readTreeString(ifstream& filehandle)    {
                                c = filehandle.get();
                        //k = c;
 //cout << k << endl;
-                               while ((c != '(') && (c != ')') && (c != ',') && (c != ':') && (c != '\n') && (c != 32) && (c != '\t')) {                       
+                               while ((c != '(') && (c != ')') && (c != ',') && (c != ':')  && (c != '\n') && (c != 32) && (c != '\t')) {                      
                                        name += c;
                                        c = filehandle.get();
                        //k = c;
@@ -1352,7 +1352,9 @@ int Tree::readTreeString(ifstream& filehandle)    {
                                }
                                
 //cout << "name = " << name << endl;
-                               m->Treenames.push_back(name);
+                if (name != "\r" ) {
+                    m->Treenames.push_back(name);   } //cout << m->Treenames.size() << '\t' << name << endl;
+                
                                filehandle.putback(c);
 //k = c;
 //cout << " after putback" <<  k << endl;
index 8ee11d3421f19a19b49ad9d797dfb25db0abc405..90d336da38f57f70fa0f5ddb59125cc2099ec346 100644 (file)
 //**********************************************************************************************************************
 vector<string> TreeGroupCommand::setParameters(){      
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "countcolumn",false,false); parameters.push_back(pcount);
-        CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName-countcolumn",false,false); parameters.push_back(pcolumn);             
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);                
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
+               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none","tree",false,false,true); parameters.push_back(pshared);
+               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none","tree",false,false); parameters.push_back(pphylip);
+               CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName","",false,false); parameters.push_back(pname);
+               CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "countcolumn","",false,false); parameters.push_back(pcount);
+        CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName-countcolumn","tree",false,false); parameters.push_back(pcolumn);              
+        CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+        CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pcutoff);
+               CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);             
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "","",true,false,true); parameters.push_back(pcalc);
                
-        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
+        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
 //CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -71,24 +71,19 @@ string TreeGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string TreeGroupCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string TreeGroupCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "tree")            {   outputFileName =  "tre";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "tree") {  pattern = "[filename],[calc],[distance],[tag],tre-[filename],tre"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "TreeGroupCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 TreeGroupCommand::TreeGroupCommand(){  
@@ -504,7 +499,9 @@ int TreeGroupCommand::execute(){
                        if (m->control_pressed) { return 0; }
 
                        //create a new filename
-                       string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("tree");     
+            map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+                       string outputFile = getOutputFileName("tree",variables);        
                        outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                                
                        Tree* newTree = createTree(matrix);
@@ -961,7 +958,12 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                 }
                 
                 //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".ave." + getOutputFileNameTag("tree");                                
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+                variables["[calc]"] = treeCalculators[i]->getName();
+                variables["[distance]"] = thisLookup[0]->getLabel();
+                variables["[tag]"] = "ave";
+                string outputFile = getOutputFileName("tree",variables);                               
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 //creates tree from similarity matrix and write out file
@@ -974,7 +976,13 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                 if (m->control_pressed) { break; }
                 
                 //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".all." + getOutputFileNameTag("tree");                                
+                //create a new filename
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+                variables["[calc]"] = treeCalculators[i]->getName();
+                variables["[distance]"] = thisLookup[0]->getLabel();
+                variables["[tag]"] = "all";
+                string outputFile = getOutputFileName("tree",variables);                               
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 ofstream outAll;
@@ -1015,7 +1023,8 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                 Tree* conTree = consensus.getTree(trees);
                 
                 //create a new filename
-                string conFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".cons." + getOutputFileNameTag("tree");                          
+                variables["[tag]"] = "cons";
+                string conFile = getOutputFileName("tree",variables);                          
                 outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
                 ofstream outTree;
                 m->openOutputFile(conFile, outTree);
@@ -1043,7 +1052,12 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                 }
                 
                 //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + getOutputFileNameTag("tree");                            
+                map<string, string> variables; 
+                variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+                variables["[calc]"] = treeCalculators[i]->getName();
+                variables["[distance]"] = thisLookup[0]->getLabel();
+                variables["[tag]"] = "";
+                string outputFile = getOutputFileName("tree",variables);                                       
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 //creates tree from similarity matrix and write out file
index b29670ae614205a7ee286116379ddda86f0e7cf9..979612f4aea3aa41187ea520483afadfa05b1782 100644 (file)
@@ -78,8 +78,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "tree.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Tree.shared"; }
        string getDescription()         { return "generate a tree file that describes the dissimilarity among groups"; }
 
index 296a6fe37d0449bb719d69c4001429583bcb74ee..cc49755d2ced89f31aa60258de2abc18838e9967 100644 (file)
 //**********************************************************************************************************************
 vector<string> TrimFlowsCommand::setParameters(){      
        try {
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pflow);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pmaxflows);
-               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pminflows);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(psignal);
-               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pnoise);
-               CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "",false,false); parameters.push_back(pallfiles);
-               CommandParameter porder("order", "String", "", "TACG", "", "", "",false,false); parameters.push_back(porder);
-               CommandParameter pfasta("fasta", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none","flow",false,true,true); parameters.push_back(pflow);
+               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(poligos);
+               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "","",false,false); parameters.push_back(pmaxhomop);
+               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pmaxflows);
+               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pminflows);
+               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
+        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
+               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "","",false,false); parameters.push_back(psignal);
+               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "","",false,false); parameters.push_back(pnoise);
+               CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "","",false,false); parameters.push_back(pallfiles);
+               CommandParameter porder("order", "String", "", "TACG", "", "", "","",false,false); parameters.push_back(porder);
+               CommandParameter pfasta("fasta", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pfasta);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -57,26 +57,21 @@ string TrimFlowsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string TrimFlowsCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string TrimFlowsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "flow")            {   outputFileName =  "flow";   }
-            else if (type == "fasta")            {   outputFileName =  "flow.fasta";   }
-            else if (type == "file")            {   outputFileName =  "flow.files";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "flow") {  pattern = "[filename],[tag],flow"; } 
+        else if (type == "fasta") {  pattern = "[filename],flow.fasta"; } 
+        else if (type == "file") {  pattern = "[filename],flow.files"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "TrimFlowsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 
@@ -248,16 +243,20 @@ int TrimFlowsCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
 
-               string trimFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "trim." + getOutputFileNameTag("flow");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
+        string fastaFileName = getOutputFileName("fasta",variables);
+               if(fasta){ outputNames.push_back(fastaFileName); outputTypes["fasta"].push_back(fastaFileName); }
+        
+        variables["[tag]"] = "trim";
+               string trimFlowFileName = getOutputFileName("flow",variables);
                outputNames.push_back(trimFlowFileName); outputTypes["flow"].push_back(trimFlowFileName);
                
-               string scrapFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "scrap." + getOutputFileNameTag("flow");;
+        variables["[tag]"] = "scrap";
+               string scrapFlowFileName = getOutputFileName("flow",variables);
                outputNames.push_back(scrapFlowFileName); outputTypes["flow"].push_back(scrapFlowFileName);
 
-               string fastaFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("fasta");
-               if(fasta){
-                       outputNames.push_back(fastaFileName); outputTypes["fasta"].push_back(fastaFileName);
-               }
+               
                
                vector<unsigned long long> flowFilePos;
        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
@@ -307,7 +306,8 @@ int TrimFlowsCommand::execute(){
                
                if(allFiles){
                        set<string> namesAlreadyProcessed;
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("file");
+            variables["[tag]"] = "";
+                       flowFilesFileName = getOutputFileName("file",variables);
                        m->openOutputFile(flowFilesFileName, output);
 
                        for(int i=0;i<barcodePrimerComboFileNames.size();i++){
@@ -340,7 +340,8 @@ int TrimFlowsCommand::execute(){
                        output.close();
                }
                else{
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("file");
+            variables["[tag]"] = "";
+                       flowFilesFileName = getOutputFileName("file",variables);
                        m->openOutputFile(flowFilesFileName, output);
                        
                        output << m->getFullPathName(trimFlowFileName) << endl;
@@ -623,9 +624,13 @@ void TrimFlowsCommand::getOligos(vector<vector<string> >& outFlowFileNames){
                                        string comboGroupName = "";
                                        string fileName = "";
                                        
+                    map<string, string> variables; 
+                    variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(flowFileName));
+                    
                                        if(primerName == ""){
                                                comboGroupName = barcodeNameVector[itBar->second];
-                                               fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow";
+                        variables["[tag]"] = comboGroupName;
+                                               fileName = getOutputFileName("flow", variables);
                                        }
                                        else{
                                                if(barcodeName == ""){
@@ -634,7 +639,8 @@ void TrimFlowsCommand::getOligos(vector<vector<string> >& outFlowFileNames){
                                                else{
                                                        comboGroupName = barcodeNameVector[itBar->second] + "." + primerNameVector[itPrimer->second];
                                                }
-                                               fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow";
+                        variables["[tag]"] = comboGroupName;
+                                               fileName = getOutputFileName("flow", variables);
                                        }
                                        
                                        outFlowFileNames[itBar->second][itPrimer->second] = fileName;
index b7fbf4342b821d1f6eb6dbb7094d94c3e85d19a3..065e6b4532e071383c39c54e38047b01a2b45344 100644 (file)
@@ -26,8 +26,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "trim.flows";  }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Trim.flows"; }
        string getDescription()         { return "trim.flows"; }
 
index ba368fc8569fdfde5d3587ffc5a1e65240e8acdf..64d9d9ec161b5615ef59f3ae57429e38bdd49cdd 100644 (file)
 //**********************************************************************************************************************
 vector<string> TrimSeqsCommand::setParameters(){       
        try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxambig);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pminlength("minlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pminlength);
-               CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxlength);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pallfiles("allfiles", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pallfiles);
-               CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepforward);
-               CommandParameter pqtrim("qtrim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqtrim);
-               CommandParameter pqthreshold("qthreshold", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqthreshold);
-               CommandParameter pqaverage("qaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqaverage);
-               CommandParameter prollaverage("rollaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(prollaverage);
-               CommandParameter pqwindowaverage("qwindowaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqwindowaverage);
-               CommandParameter pqstepsize("qstepsize", "Number", "", "1", "", "", "",false,false); parameters.push_back(pqstepsize);
-               CommandParameter pqwindowsize("qwindowsize", "Number", "", "50", "", "", "",false,false); parameters.push_back(pqwindowsize);
-               CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "",false,false); parameters.push_back(pkeepfirst);
-               CommandParameter premovelast("removelast", "Number", "", "0", "", "", "",false,false); parameters.push_back(premovelast);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","group",false,false,true); parameters.push_back(poligos);
+               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none","qfile",false,false,true); parameters.push_back(pqfile);
+               CommandParameter pname("name", "InputTypes", "", "", "namecount", "none", "none","name",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "namecount", "none", "none","count",false,false,true); parameters.push_back(pcount);
+               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "","",false,false,true); parameters.push_back(pflip);
+               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxambig);
+               CommandParameter pmaxhomop("maxhomop", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxhomop);
+               CommandParameter pminlength("minlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pminlength);
+               CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxlength);
+               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
+               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
+        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
+               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
+        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter pallfiles("allfiles", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pallfiles);
+               CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkeepforward);
+               CommandParameter pqtrim("qtrim", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pqtrim);
+               CommandParameter pqthreshold("qthreshold", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pqthreshold);
+               CommandParameter pqaverage("qaverage", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pqaverage);
+               CommandParameter prollaverage("rollaverage", "Number", "", "0", "", "", "","",false,false); parameters.push_back(prollaverage);
+               CommandParameter pqwindowaverage("qwindowaverage", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pqwindowaverage);
+               CommandParameter pqstepsize("qstepsize", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pqstepsize);
+               CommandParameter pqwindowsize("qwindowsize", "Number", "", "50", "", "", "","",false,false); parameters.push_back(pqwindowsize);
+               CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pkeepfirst);
+               CommandParameter premovelast("removelast", "Number", "", "0", "", "", "","",false,false); parameters.push_back(premovelast);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                        
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -101,31 +101,24 @@ string TrimSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string TrimSeqsCommand::getOutputFileNameTag(string type, string inputName=""){        
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string TrimSeqsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "qfile")            {   outputFileName =  "qual";   }
-            else if (type == "fasta")            {   outputFileName =  "fasta";   }
-            else if (type == "group")            {   outputFileName =  "groups";   }
-            else if (type == "name")            {   outputFileName =  "names";   }
-            else if (type == "count")            {   outputFileName =  "count_table";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "qfile") {  pattern = "[filename],[tag],qual"; } 
+        else if (type == "fasta") {  pattern = "[filename],[tag],fasta"; } 
+        else if (type == "group") {  pattern = "[filename],groups"; }
+        else if (type == "name") {  pattern = "[filename],[tag],names"; }
+        else if (type == "count") {  pattern = "[filename],count_table"; }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "TrimSeqsCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
-
 //**********************************************************************************************************************
 
 TrimSeqsCommand::TrimSeqsCommand(){    
@@ -382,15 +375,18 @@ int TrimSeqsCommand::execute(){
                vector<vector<string> > qualFileNames;
                vector<vector<string> > nameFileNames;
                
-               string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim." + getOutputFileNameTag("fasta");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFile));
+        variables["[tag]"] = "trim";
+               string trimSeqFile = getOutputFileName("fasta",variables);
+        string trimQualFile = getOutputFileName("qfile",variables);
                outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
-               
-               string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap." + getOutputFileNameTag("fasta");
+        
+        variables["[tag]"] = "scrap";
+               string scrapSeqFile = getOutputFileName("fasta",variables);
+        string scrapQualFile = getOutputFileName("qfile",variables);
                outputNames.push_back(scrapSeqFile); outputTypes["fasta"].push_back(scrapSeqFile);
                
-               string trimQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim." + getOutputFileNameTag("qfile");
-               string scrapQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap." + getOutputFileNameTag("qfile");
-               
                if (qFileName != "") {
                        outputNames.push_back(trimQualFile);
                        outputNames.push_back(scrapQualFile);
@@ -398,8 +394,11 @@ int TrimSeqsCommand::execute(){
                        outputTypes["qfile"].push_back(scrapQualFile); 
                }
                
-               string trimNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "trim." + getOutputFileNameTag("name");
-               string scrapNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "scrap." + getOutputFileNameTag("name");
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(nameFile));
+        variables["[tag]"] = "trim";
+               string trimNameFile = getOutputFileName("name",variables);
+        variables["[tag]"] = "scrap";
+               string scrapNameFile = getOutputFileName("name",variables);
                
                if (nameFile != "") {
                        m->readNames(nameFile, nameMap);
@@ -409,8 +408,11 @@ int TrimSeqsCommand::execute(){
                        outputTypes["name"].push_back(scrapNameFile); 
                }
         
-        string trimCountFile = outputDir + m->getRootName(m->getSimpleName(countfile)) + "trim." + getOutputFileNameTag("count");
-               string scrapCountFile = outputDir + m->getRootName(m->getSimpleName(countfile)) + "scrap." + getOutputFileNameTag("count");
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+        variables["[tag]"] = "trim";
+        string trimCountFile = getOutputFileName("count",variables);
+        variables["[tag]"] = "scrap";
+               string scrapCountFile = getOutputFileName("count",variables);
                
                if (countfile != "") {
             CountTable ct;
@@ -429,7 +431,9 @@ int TrimSeqsCommand::execute(){
                if(oligoFile != ""){
                        createGroup = getOligos(fastaFileNames, qualFileNames, nameFileNames);
                        if ((createGroup) && (countfile == "")){
-                               outputGroupFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + getOutputFileNameTag("group");
+                map<string, string> myvariables; 
+                myvariables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFile));
+                               outputGroupFileName = getOutputFileName("group",myvariables);
                                outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName);
                        }
                }
@@ -488,9 +492,11 @@ int TrimSeqsCommand::execute(){
                 m->openInputFile(it->first, in);
                 
                 ofstream out;
-                string thisGroupName = outputDir + m->getRootName(m->getSimpleName(it->first));
-                if (countfile == "") { thisGroupName += getOutputFileNameTag("group"); outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName); }
-                else {  thisGroupName += getOutputFileNameTag("count"); outputNames.push_back(thisGroupName); outputTypes["count"].push_back(thisGroupName);  }
+                map<string, string> myvariables; 
+                myvariables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(it->first));
+                string thisGroupName = "";
+                if (countfile == "") { thisGroupName = getOutputFileName("group",variables); outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName); }
+                else {  thisGroupName = getOutputFileName("count",variables); outputNames.push_back(thisGroupName); outputTypes["count"].push_back(thisGroupName);  }
                 m->openOutputFile(thisGroupName, out);
                 
                 if (countfile != "") {  out << "Representative_Sequence\ttotal\t" << it->second << endl;  }
@@ -1519,7 +1525,10 @@ bool TrimSeqsCommand::getOligos(vector<vector<string> >& fastaFileNames, vector<
                                        
                                        
                                        ofstream temp;
-                                       fastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + comboGroupName + ".fasta";
+                    map<string, string> variables; 
+                    variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastaFile));
+                    variables["[tag]"] = comboGroupName;
+                                       fastaFileName = getOutputFileName("fasta", variables);
                                        if (uniqueNames.count(fastaFileName) == 0) {
                                                outputNames.push_back(fastaFileName);
                                                outputTypes["fasta"].push_back(fastaFileName);
@@ -1530,7 +1539,8 @@ bool TrimSeqsCommand::getOligos(vector<vector<string> >& fastaFileNames, vector<
                                        m->openOutputFile(fastaFileName, temp);         temp.close();
                                        
                                        if(qFileName != ""){
-                                               qualFileName = outputDir + m->getRootName(m->getSimpleName(qFileName)) + comboGroupName + ".qual";
+                        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(qFileName));
+                                               qualFileName = getOutputFileName("qfile", variables);
                                                if (uniqueNames.count(qualFileName) == 0) {
                                                        outputNames.push_back(qualFileName);
                                                        outputTypes["qfile"].push_back(qualFileName);
@@ -1541,7 +1551,8 @@ bool TrimSeqsCommand::getOligos(vector<vector<string> >& fastaFileNames, vector<
                                        }
                                        
                                        if(nameFile != ""){
-                                               nameFileName = outputDir + m->getRootName(m->getSimpleName(nameFile)) + comboGroupName + ".names";
+                        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(nameFile));
+                                               nameFileName = getOutputFileName("name", variables);
                                                if (uniqueNames.count(nameFileName) == 0) {
                                                        outputNames.push_back(nameFileName);
                                                        outputTypes["name"].push_back(nameFileName);
index 1ffad218ccee951e7ac9097d04f84327099fda9d..60d29f9e56024de7a0d6d39478ce12872788acd5 100644 (file)
@@ -27,8 +27,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "trim.seqs";   }
        string getCommandCategory()             { return "Sequence Processing";         }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Trim.seqs"; }
        string getDescription()         { return "provides the preprocessing features needed to screen and sort pyrosequences"; }
 
index edc4bbc027edf761568919163ca8f696096c7900..5f3cffc2b1ab807b279ba3185444dc96a0a3b863 100644 (file)
 //**********************************************************************************************************************
 vector<string> UnifracUnweightedCommand::setParameters(){      
        try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prandom("random", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "",false,false); parameters.push_back(pdistance);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pconsensus);
-        CommandParameter proot("root", "Boolean", "F", "", "", "", "",false,false); parameters.push_back(proot);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","unweighted-uwsummary",false,true,true); parameters.push_back(ptree);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+               CommandParameter prandom("random", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(prandom);
+               CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "","phylip-column",false,false); parameters.push_back(pdistance);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "","tree",false,false); parameters.push_back(pconsensus);
+        CommandParameter proot("root", "Boolean", "F", "", "", "", "","",false,false); parameters.push_back(proot);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,30 +65,23 @@ string UnifracUnweightedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string UnifracUnweightedCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
-        
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "unweighted")            {   outputFileName =  "unweighted";   }
-            else if (type == "uwsummary")        {   outputFileName =  "uwsummary";   }
-            else if (type == "phylip")           {   outputFileName =  "dist";   }
-            else if (type == "column")           {   outputFileName =  "dist";   }
-            else if (type == "tree")             {   outputFileName =  "tre";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+string UnifracUnweightedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        if (type == "unweighted")            {  pattern = "[filename],unweighted-[filename],[tag],unweighted";   }
+        else if (type == "uwsummary")        {  pattern = "[filename],uwsummary";   }
+        else if (type == "phylip")           {  pattern = "[filename],[tag],[tag2],dist";   }
+        else if (type == "column")           {  pattern = "[filename],[tag],[tag2],dist";   }
+        else if (type == "tree")             {  pattern = "[filename],[tag],[tag2],tre";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "UnifracUnweightedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
-
 //**********************************************************************************************************************
 UnifracUnweightedCommand::UnifracUnweightedCommand(){  
        try {
@@ -304,7 +297,9 @@ int UnifracUnweightedCommand::execute() {
         ct = T[0]->getCountTable();
         delete reader;
         
-               sumFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("uwsummary");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+               sumFile = getOutputFileName("uwsummary",variables);
                outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile);
                m->openOutputFile(sumFile, outSum);
                
@@ -362,9 +357,11 @@ int UnifracUnweightedCommand::execute() {
             counter = 0;
                        
                        if (random)  {  
-                               output = new ColumnFile(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("unweighted"), itersString);
-                               outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("unweighted"));
-                               outputTypes["unweighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("unweighted"));
+                variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+                variables["[tag]"] = toString(i+1);
+                string unFileName = getOutputFileName("unweighted", variables);
+                               output = new ColumnFile(unFileName, itersString);
+                               outputNames.push_back(unFileName); outputTypes["unweighted"].push_back(unFileName);
                        }
                        
                        
@@ -406,9 +403,13 @@ int UnifracUnweightedCommand::execute() {
                 CountTable* newCt = new CountTable();
                  
                 //uses method of setting groups to doNotIncludeMe
+                int sampleTime = 0;
+                if (m->debug) { sampleTime = time(NULL); }
                 SubSample sample;
                 Tree* subSampleTree = sample.getSample(T[i], ct, newCt, subsampleSize);
                 
+                if (m->debug) { m->mothurOut("[DEBUG]: iter " + toString(thisIter) + " took " + toString(time(NULL) - sampleTime) + " seconds to sample tree.\n"); }
+                
                 //call new weighted function
                 vector<double> iterData; iterData.resize(numComp,0);
                 Unweighted thisUnweighted(includeRoot);
@@ -529,13 +530,18 @@ int UnifracUnweightedCommand::getAverageSTDMatrices(vector< vector<double> >& di
             }
         }
         
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.ave." + getOutputFileNameTag("phylip");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "unweighted.ave";
+        string aveFileName = getOutputFileName("phylip",variables);
         if (outputForm != "column") { outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName);  }
         else { outputNames.push_back(aveFileName); outputTypes["column"].push_back(aveFileName);  }
         ofstream out;
         m->openOutputFile(aveFileName, out);
         
-        string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.std." + getOutputFileNameTag("phylip");
+        variables["[tag2]"] = "unweighted.std";
+        string stdFileName = getOutputFileName("phylip",variables);
         if (outputForm != "column") { outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); }
         else { outputNames.push_back(stdFileName); outputTypes["column"].push_back(stdFileName); }
         ofstream outStd;
@@ -626,7 +632,11 @@ int UnifracUnweightedCommand::getConsensusTrees(vector< vector<double> >& dists,
         Tree* conTree = con.getTree(newTrees);
         
         //create a new filename
-        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.cons." + getOutputFileNameTag("tree");                            
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "unweighted.cons";
+        string conFile = getOutputFileName("tree",variables);                          
         outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
         ofstream outTree;
         m->openOutputFile(conFile, outTree);
@@ -650,7 +660,11 @@ vector<Tree*> UnifracUnweightedCommand::buildTrees(vector< vector<double> >& dis
         vector<Tree*> trees;
         
         //create a new filename
-        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.all." + getOutputFileNameTag("tree");                          
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "unweighted.all";
+        string outputFile = getOutputFileName("tree",variables);                               
         outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
         
         ofstream outAll;
@@ -816,11 +830,16 @@ void UnifracUnweightedCommand::printUWSummaryFile(int i) {
 void UnifracUnweightedCommand::createPhylipFile(int i) {
        try {
                string phylipFileName;
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+        variables["[tag]"] = toString(i+1);
                if ((outputForm == "lt") || (outputForm == "square")) {
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.phylip." + getOutputFileNameTag("phylip");
+            variables["[tag2]"] = "unweighted.phylip";
+                       phylipFileName = getOutputFileName("phylip",variables);
                        outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
                }else { //column
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.column." + getOutputFileNameTag("column");
+            variables["[tag2]"] = "unweighted.column";
+                       phylipFileName = getOutputFileName("column",variables);
                        outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
                }
                
index 107083fa41a3dc80f922a74ce6c95c18201511a2..3961e53cb68c96e70dd5bcd55449ed5d72346cd9 100644 (file)
@@ -27,8 +27,9 @@ class UnifracUnweightedCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "unifrac.unweighted";          }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "Lozupone C, Knight R (2005). UniFrac: a new phylogenetic method for comparing microbial communities. Appl Environ Microbiol 71: 8228-35. \nhttp://www.mothur.org/wiki/Unifrac.unweighted"; }
                string getDescription()         { return "generic tests that describes whether two or more communities have the same structure"; }
 
index 541131efd5b15401c229a21966655d39e320a496..47adc9a55b4ba929796fca2993138b89584bdee1 100644 (file)
 //**********************************************************************************************************************
 vector<string> UnifracWeightedCommand::setParameters(){        
        try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
-               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pconsensus);
-        CommandParameter prandom("random", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "",false,false); parameters.push_back(pdistance);
-               CommandParameter proot("root", "Boolean", "F", "", "", "", "",false,false); parameters.push_back(proot);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","weighted-wsummary",false,true,true); parameters.push_back(ptree);
+        CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname);
+        CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount);
+               CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters);
+               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
+        CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample);
+        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "","tree",false,false); parameters.push_back(pconsensus);
+        CommandParameter prandom("random", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(prandom);
+               CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "","phylip-column",false,false); parameters.push_back(pdistance);
+               CommandParameter proot("root", "Boolean", "F", "", "", "", "","",false,false); parameters.push_back(proot);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -65,28 +65,22 @@ string UnifracWeightedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string UnifracWeightedCommand::getOutputFileNameTag(string type, string inputName=""){ 
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string UnifracWeightedCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        if (type == "weighted")            {  pattern = "[filename],weighted-[filename],[tag],weighted";   }
+        else if (type == "wsummary")        {  pattern = "[filename],wsummary";   }
+        else if (type == "phylip")           {  pattern = "[filename],[tag],[tag2],dist";   }
+        else if (type == "column")           {  pattern = "[filename],[tag],[tag2],dist";   }
+        else if (type == "tree")             {  pattern = "[filename],[tag],[tag2],tre";   }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "weighted")            {   outputFileName =  "weighted";   }
-            else if (type == "wsummary")        {   outputFileName =  "wsummary";   }
-            else if (type == "phylip")           {   outputFileName =  "dist";   }
-            else if (type == "column")           {   outputFileName =  "dist";   }
-            else if (type == "tree")             {   outputFileName =  "tre";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "UnifracWeightedCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 UnifracWeightedCommand::UnifracWeightedCommand(){      
@@ -296,8 +290,10 @@ int UnifracWeightedCommand::execute() {
         delete reader;
         
         if (m->control_pressed) {  delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; } return 0; }
-                               
-               sumFile = outputDir + m->getSimpleName(treefile) + getOutputFileNameTag("wsummary");
+               
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+               sumFile = getOutputFileName("wsummary",variables);
                m->openOutputFile(sumFile, outSum);
                outputNames.push_back(sumFile);  outputTypes["wsummary"].push_back(sumFile);
                
@@ -359,9 +355,11 @@ int UnifracWeightedCommand::execute() {
             vector<double> randomData; randomData.resize(numComp,0); //weighted score info for random trees. data[0] = weightedscore AB, data[1] = weightedscore AC...
             
             if (random) {  
-                output = new ColumnFile(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("weighted"), itersString);  
-                outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("weighted"));
-                outputTypes["weighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + "." + getOutputFileNameTag("weighted"));
+                variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+                variables["[tag]"] = toString(i+1);
+                string wFileName = getOutputFileName("weighted", variables);
+                output = new ColumnFile(wFileName, itersString);
+                               outputNames.push_back(wFileName); outputTypes["wweighted"].push_back(wFileName);
             } 
             
             userData = weighted.getValues(T[i], processors, outputDir); //userData[0] = weightedscore
@@ -514,13 +512,18 @@ int UnifracWeightedCommand::getAverageSTDMatrices(vector< vector<double> >& dist
             }
         }
         
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.ave." + getOutputFileNameTag("phylip");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "weighted.ave";
+        string aveFileName = getOutputFileName("phylip",variables);
         if (outputForm != "column") { outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName);  }
         else { outputNames.push_back(aveFileName); outputTypes["column"].push_back(aveFileName);  }
         ofstream out;
         m->openOutputFile(aveFileName, out);
         
-        string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.std." + getOutputFileNameTag("phylip");
+        variables["[tag2]"] = "weighted.std";
+        string stdFileName = getOutputFileName("phylip",variables);
         if (outputForm != "column") { outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); }
         else { outputNames.push_back(stdFileName); outputTypes["column"].push_back(stdFileName); }        
         ofstream outStd;
@@ -611,7 +614,11 @@ int UnifracWeightedCommand::getConsensusTrees(vector< vector<double> >& dists, i
         Tree* conTree = con.getTree(newTrees);
         
         //create a new filename
-        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.cons." + getOutputFileNameTag("tree");                              
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "weighted.cons";
+        string conFile = getOutputFileName("tree",variables);                                                  
         outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
         ofstream outTree;
         m->openOutputFile(conFile, outTree);
@@ -635,7 +642,11 @@ vector<Tree*> UnifracWeightedCommand::buildTrees(vector< vector<double> >& dists
         vector<Tree*> trees;
         
         //create a new filename
-        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.all." + getOutputFileNameTag("tree");                            
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile));
+        variables["[tag]"] = toString(treeNum+1);
+        variables["[tag2]"] = "weighted.all";
+        string outputFile = getOutputFileName("tree",variables);                               
         outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
         
         ofstream outAll;
@@ -943,14 +954,20 @@ void UnifracWeightedCommand::createPhylipFile() {
                //for each tree
                for (int i = 0; i < T.size(); i++) { 
                
-                       string phylipFileName;
-                       if ((outputForm == "lt") || (outputForm == "square")) {
-                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.phylip." + getOutputFileNameTag("phylip");
-                               outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
-                       }else { //column
-                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.column." + getOutputFileNameTag("column");
-                               outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
-                       }
+            string phylipFileName;
+                       map<string, string> variables; 
+            variables["[filename]"] = outputDir + m->getSimpleName(treefile);
+            variables["[tag]"] = toString(i+1);
+            if ((outputForm == "lt") || (outputForm == "square")) {
+                variables["[tag2]"] = "weighted.phylip";
+                phylipFileName = getOutputFileName("phylip",variables);
+                outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
+            }else { //column
+                variables["[tag2]"] = "weighted.column";
+                phylipFileName = getOutputFileName("column",variables);
+                outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
+            }
+
                        
                        ofstream out;
                        m->openOutputFile(phylipFileName, out);
index fead41b0e8cb5dae95eed551ff76427b8c8d85f3..1c67c32f81afb2535943934ab82d66629bbc05b2 100644 (file)
@@ -28,8 +28,9 @@ class UnifracWeightedCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "unifrac.weighted";            }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getOutputFileNameTag(string, string);
+               
        string getHelpString(); 
+    string getOutputPattern(string);   
                string getCitation() { return "Lozupone CA, Hamady M, Kelley ST, Knight R (2007). Quantitative and qualitative beta diversity measures lead to different insights into factors that structure microbial communities. Appl Environ Microbiol 73: 1576-85. \nhttp://www.mothur.org/wiki/Unifrac.weighted"; }
                string getDescription()         { return "generic tests that describes whether two or more communities have the same structure"; }
 
index c918500270a537ac909326f3edc10ad068dc3ac5..9c234959f0e96040c2d6655649d69f10c0ee66a6 100644 (file)
 //**********************************************************************************************************************
 vector<string> VennCommand::setParameters(){   
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "String", "", "", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter pnseqs("nseqs", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pnseqs);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter ppermute("permute", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppermute);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false,true); parameters.push_back(plist);
+               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none","svg",false,false,true); parameters.push_back(pshared); 
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pcalc("calc", "String", "", "", "", "", "","",false,false); parameters.push_back(pcalc);
+               CommandParameter pabund("abund", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pabund);
+               CommandParameter pnseqs("nseqs", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pnseqs);
+               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "","",false,false); parameters.push_back(pfontsize);
+               CommandParameter ppermute("permute", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ppermute);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -67,25 +67,19 @@ string VennCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-
-string VennCommand::getOutputFileNameTag(string type, string inputName=""){    
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string VennCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //is this a type this command creates
-        it = outputTypes.find(type);
-        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
-        else {
-            if (type == "svg")            {   outputFileName =  "svg";   }
-            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
-        }
-        return outputFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "getOutputFileNameTag");
-               exit(1);
-       }
+        if (type == "svg") {  pattern = "[filename],svg"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "VennCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 
 //**********************************************************************************************************************
index 9f369280fc66e53754da98a4b6252568a7960d90..15932ecd5cdc2da8cbc362d0a3b55ff206a748b0 100644 (file)
@@ -25,8 +25,9 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "venn";                                        }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getOutputFileNameTag(string, string);
+       
        string getHelpString(); 
+    string getOutputPattern(string);   
        string getCitation() { return "http://www.mothur.org/wiki/Venn"; }
        string getDescription()         { return "generates a Venn diagram from data provided in a shared file"; }