]> git.donarmstrong.com Git - mothur.git/commitdiff
added load.logfile command. changed summary.single output for subsample=t.
authorSarah Westcott <mothur.westcott@gmail.com>
Tue, 19 Jun 2012 12:48:32 +0000 (08:48 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Tue, 19 Jun 2012 12:48:32 +0000 (08:48 -0400)
260 files changed:
Mothur.xcodeproj/project.pbxproj
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
classify.cpp
classifyotucommand.cpp
classifyotucommand.h
classifyseqscommand.cpp
classifyseqscommand.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
commandfactory.cpp
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.h
getcoremicrobiomecommand.cpp
getcoremicrobiomecommand.h
getcurrentcommand.h
getgroupcommand.cpp
getgroupcommand.h
getgroupscommand.cpp
getgroupscommand.h
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 [new file with mode: 0644]
loadlogfilecommand.h [new file with mode: 0644]
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
mothurout.cpp
mothurout.h
newcommandtemplate.cpp
newcommandtemplate.h
nmdscommand.cpp
nmdscommand.h
nocommands.h
normalizesharedcommand.cpp
normalizesharedcommand.h
optionparser.cpp
optionparser.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
phylosummary.cpp
phylotree.cpp
phylotypecommand.cpp
phylotypecommand.h
pipelinepdscommand.h
prcseqscommand.cpp
preclustercommand.cpp
preclustercommand.h
quitcommand.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h
readdistcommand.cpp [deleted file]
readdistcommand.h [deleted file]
readotucommand.cpp [deleted file]
readotucommand.h [deleted file]
readtreecommand.cpp [deleted file]
readtreecommand.h [deleted file]
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
sequenceparser.cpp
setcurrentcommand.h
setdircommand.h
setlogfilecommand.h
sffinfocommand.cpp
sffinfocommand.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
subsamplecommand.cpp
subsamplecommand.h
summarycommand.cpp
summarycommand.h
summaryqualcommand.cpp
summaryqualcommand.h
summarysharedcommand.cpp
summarysharedcommand.h
summarytaxcommand.cpp
summarytaxcommand.h
systemcommand.h
treegroupscommand.cpp
treegroupscommand.h
treemap.cpp
trimflowscommand.cpp
trimflowscommand.h
trimseqscommand.cpp
trimseqscommand.h
unifracunweightedcommand.cpp
unifracunweightedcommand.h
unifracweightedcommand.cpp
unifracweightedcommand.h
venncommand.cpp
venncommand.h

index d98b28443921915890802e12777ab374aa31d402..6db66c6184bc3798ee4d8ba2fc7247a9feb6acb4 100644 (file)
@@ -21,6 +21,7 @@
                A721765713BB9F7D0014DAAE /* referencedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A721765613BB9F7D0014DAAE /* referencedb.cpp */; };
                A724D2B7153C8628000A826F /* makebiomcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A724D2B6153C8628000A826F /* makebiomcommand.cpp */; };
                A727864412E9E28C00F86ABA /* removerarecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A727864312E9E28C00F86ABA /* removerarecommand.cpp */; };
+               A73901081588C40900ED2ED6 /* loadlogfilecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73901071588C40900ED2ED6 /* loadlogfilecommand.cpp */; };
                A73DDBBA13C4A0D1006AAE38 /* clearmemorycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */; };
                A73DDC3813C4BF64006AAE38 /* mothurmetastats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */; };
                A74A9A9F148E881E00AB5E3E /* spline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74A9A9E148E881E00AB5E3E /* spline.cpp */; };
                A7E9B92912D37EC400DA6239 /* readblast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7B012D37EC400DA6239 /* readblast.cpp */; };
                A7E9B92A12D37EC400DA6239 /* readcluster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7B212D37EC400DA6239 /* readcluster.cpp */; };
                A7E9B92B12D37EC400DA6239 /* readcolumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7B412D37EC400DA6239 /* readcolumn.cpp */; };
-               A7E9B92C12D37EC400DA6239 /* readdistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7B612D37EC400DA6239 /* readdistcommand.cpp */; };
-               A7E9B92E12D37EC400DA6239 /* readotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7BB12D37EC400DA6239 /* readotucommand.cpp */; };
                A7E9B92F12D37EC400DA6239 /* readphylip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7BD12D37EC400DA6239 /* readphylip.cpp */; };
                A7E9B93012D37EC400DA6239 /* readtree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7BF12D37EC400DA6239 /* readtree.cpp */; };
-               A7E9B93112D37EC400DA6239 /* readtreecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7C112D37EC400DA6239 /* readtreecommand.cpp */; };
                A7E9B93212D37EC400DA6239 /* removegroupscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7C312D37EC400DA6239 /* removegroupscommand.cpp */; };
                A7E9B93312D37EC400DA6239 /* removelineagecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7C512D37EC400DA6239 /* removelineagecommand.cpp */; };
                A7E9B93412D37EC400DA6239 /* removeotuscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7C712D37EC400DA6239 /* removeotuscommand.cpp */; };
                A724D2B6153C8628000A826F /* makebiomcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makebiomcommand.cpp; sourceTree = "<group>"; };
                A727864212E9E28C00F86ABA /* removerarecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removerarecommand.h; sourceTree = "<group>"; };
                A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removerarecommand.cpp; sourceTree = "<group>"; };
+               A73901051588C3EF00ED2ED6 /* loadlogfilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = loadlogfilecommand.h; sourceTree = "<group>"; };
+               A73901071588C40900ED2ED6 /* loadlogfilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = loadlogfilecommand.cpp; sourceTree = "<group>"; };
                A73DDBB813C4A0D1006AAE38 /* clearmemorycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearmemorycommand.h; sourceTree = "<group>"; };
                A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearmemorycommand.cpp; sourceTree = "<group>"; };
                A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurmetastats.h; sourceTree = "<group>"; };
                A7E9B7B312D37EC400DA6239 /* readcluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readcluster.h; sourceTree = "<group>"; };
                A7E9B7B412D37EC400DA6239 /* readcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readcolumn.cpp; sourceTree = "<group>"; };
                A7E9B7B512D37EC400DA6239 /* readcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readcolumn.h; sourceTree = "<group>"; };
-               A7E9B7B612D37EC400DA6239 /* readdistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readdistcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7B712D37EC400DA6239 /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readdistcommand.h; sourceTree = "<group>"; };
                A7E9B7B812D37EC400DA6239 /* readmatrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = readmatrix.hpp; sourceTree = "<group>"; };
-               A7E9B7BB12D37EC400DA6239 /* readotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readotucommand.cpp; sourceTree = "<group>"; };
-               A7E9B7BC12D37EC400DA6239 /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotucommand.h; sourceTree = "<group>"; };
                A7E9B7BD12D37EC400DA6239 /* readphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readphylip.cpp; sourceTree = "<group>"; };
                A7E9B7BE12D37EC400DA6239 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylip.h; sourceTree = "<group>"; };
                A7E9B7BF12D37EC400DA6239 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtree.cpp; sourceTree = "<group>"; };
                A7E9B7C012D37EC400DA6239 /* readtree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtree.h; sourceTree = "<group>"; };
-               A7E9B7C112D37EC400DA6239 /* readtreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtreecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7C212D37EC400DA6239 /* readtreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtreecommand.h; sourceTree = "<group>"; };
                A7E9B7C312D37EC400DA6239 /* removegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removegroupscommand.cpp; sourceTree = "<group>"; };
                A7E9B7C412D37EC400DA6239 /* removegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removegroupscommand.h; sourceTree = "<group>"; };
                A7E9B7C512D37EC400DA6239 /* removelineagecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removelineagecommand.cpp; sourceTree = "<group>"; };
                                A7A067191562946F0095C8C5 /* listotulabelscommand.cpp */,
                                A7E9B73E12D37EC400DA6239 /* listseqscommand.h */,
                                A7E9B73D12D37EC400DA6239 /* listseqscommand.cpp */,
+                               A73901051588C3EF00ED2ED6 /* loadlogfilecommand.h */,
+                               A73901071588C40900ED2ED6 /* loadlogfilecommand.cpp */,
                                A7FA10001302E096003860FE /* mantelcommand.h */,
                                A7FA10011302E096003860FE /* mantelcommand.cpp */,
                                A724D2B4153C8600000A826F /* makebiomcommand.h */,
                                A7E9B7AB12D37EC400DA6239 /* rarefactcommand.cpp */,
                                A7E9B7AF12D37EC400DA6239 /* rarefactsharedcommand.h */,
                                A7E9B7AE12D37EC400DA6239 /* rarefactsharedcommand.cpp */,
-                               A7E9B7B712D37EC400DA6239 /* readdistcommand.h */,
-                               A7E9B7B612D37EC400DA6239 /* readdistcommand.cpp */,
-                               A7E9B7BC12D37EC400DA6239 /* readotucommand.h */,
-                               A7E9B7BB12D37EC400DA6239 /* readotucommand.cpp */,
-                               A7E9B7C212D37EC400DA6239 /* readtreecommand.h */,
-                               A7E9B7C112D37EC400DA6239 /* readtreecommand.cpp */,
                                A7E9B7C412D37EC400DA6239 /* removegroupscommand.h */,
                                A7E9B7C312D37EC400DA6239 /* removegroupscommand.cpp */,
                                A7E9B7C612D37EC400DA6239 /* removelineagecommand.h */,
                                A7E9B92912D37EC400DA6239 /* readblast.cpp in Sources */,
                                A7E9B92A12D37EC400DA6239 /* readcluster.cpp in Sources */,
                                A7E9B92B12D37EC400DA6239 /* readcolumn.cpp in Sources */,
-                               A7E9B92C12D37EC400DA6239 /* readdistcommand.cpp in Sources */,
-                               A7E9B92E12D37EC400DA6239 /* readotucommand.cpp in Sources */,
                                A7E9B92F12D37EC400DA6239 /* readphylip.cpp in Sources */,
                                A7E9B93012D37EC400DA6239 /* readtree.cpp in Sources */,
-                               A7E9B93112D37EC400DA6239 /* readtreecommand.cpp in Sources */,
                                A7E9B93212D37EC400DA6239 /* removegroupscommand.cpp in Sources */,
                                A7E9B93312D37EC400DA6239 /* removelineagecommand.cpp in Sources */,
                                A7E9B93412D37EC400DA6239 /* removeotuscommand.cpp in Sources */,
                                A7A0671F1562AC3E0095C8C5 /* makecontigscommand.cpp in Sources */,
                                A70056E6156A93D000924A2D /* getotulabelscommand.cpp in Sources */,
                                A70056EB156AB6E500924A2D /* removeotulabelscommand.cpp in Sources */,
+                               A73901081588C40900ED2ED6 /* loadlogfilecommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 75466f95b242ae08a71a88a40efec3a8fd230c86..a68fbfcba365207d7847c7eeaff12d9e4a4914e2 100644 (file)
@@ -75,6 +75,29 @@ string AlignCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string AlignCommand::getOutputFileNameTag(string type, string inputName=""){   
+       try {
+        string tag = "";
+               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") {  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);
+       }
+}
+
 //**********************************************************************************************************************
 AlignCommand::AlignCommand(){  
        try {
@@ -305,9 +328,9 @@ 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])) + "align";
-                       string reportFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "align.report";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "flip.accnos";
+                       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");
                        bool hasAccnos = true;
                        
                        int numFastaSeqs = 0;
index d4b7e78ce01ba2b9e6507a2b5a502bae9dbb8b68..5432d00564b2151fabaf09e9d16258dff0d298ae 100644 (file)
@@ -34,6 +34,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "align.seqs";                  }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 3ec14bf7c06af5883e7eb6d9b3b38449ceac83be..c4260fb096dd8b0b253f5239f7ce265376d24ed5 100644 (file)
@@ -51,6 +51,26 @@ string AmovaCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string AmovaCommand::getOutputFileNameTag(string type, string inputName=""){   
+       try {
+        string tag = "";
+               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 == "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);
+       }
+}
+//**********************************************************************************************************************
 AmovaCommand::AmovaCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -187,7 +207,7 @@ int AmovaCommand::execute(){
                
                //create a new filename
                ofstream AMOVAFile;
-               string AMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "amova";                         
+               string AMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("amova");                            
                m->openOutputFile(AMOVAFileName, AMOVAFile);
                outputNames.push_back(AMOVAFileName); outputTypes["amova"].push_back(AMOVAFileName);
                
index 50dc81a517dbbe89f39d9a4e1ca858ed3488a402..6b3c83a4fb09c51f23b01ff38abeb2d939e8e79a 100644 (file)
@@ -23,6 +23,7 @@ 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 getDescription()         { return "analysis of molecular variance"; }
index 1b6afe35b760ed140b6747d02a41ce5d4424fca1..bd4e6b0683886bd0012e6b222a12592c8e594107 100644 (file)
@@ -49,7 +49,26 @@ string AnosimCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string AnosimCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 AnosimCommand::AnosimCommand(){        
        try {
@@ -188,7 +207,7 @@ int AnosimCommand::execute(){
                
                //create a new filename
                ofstream ANOSIMFile;
-               string ANOSIMFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "anosim";                               
+               string ANOSIMFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("anosim");                          
                m->openOutputFile(ANOSIMFileName, ANOSIMFile);
                outputNames.push_back(ANOSIMFileName); outputTypes["anosim"].push_back(ANOSIMFileName);
                m->mothurOut("\ncomparison\tR-value\tP-value\n");
index 4b650705ace41501f3d85d672638a47f48a91ce3..ff1b683fac8a45e4146789f7c09a0503c0c39392 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "anosim";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+    string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 2117daff4f2558e26bcf0008666f87bee0180f4d..7569a4be3113144a96048f5a4d624d271c15b9f4 100644 (file)
@@ -50,6 +50,26 @@ string BinSeqCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string BinSeqCommand::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 =  "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);
+       }
+}
+//**********************************************************************************************************************
 BinSeqCommand::BinSeqCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -344,8 +364,8 @@ int BinSeqCommand::process(ListVector* list) {
        try {
                                string binnames, name, sequence;
                                
-                               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".fasta";
-                               m->openOutputFile(outputFileName, out);
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + getOutputFileNameTag("fasta");
+        m->openOutputFile(outputFileName, out);
                                
                                //save to output list of output file names
                                outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
index 365fb3c3afdaf8cedd788b83e1ef2a29a4e9b00b..1fb5664b0c018c4120881055014ec08a4e6d5559 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "bin.seqs";                    }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Bin.seqs"; }
        string getDescription()         { return "maps sequences to otus"; }
index 329b56a2c24dcf024ca66cab0f160b76438c0922..1cfd4154686cd4884e275f4c3ea8c8ca3d5624d3 100644 (file)
@@ -49,6 +49,27 @@ string CatchAllCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string CatchAllCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 CatchAllCommand::CatchAllCommand(){    
        try {
                abort = true; calledHelp = true;
@@ -236,7 +257,7 @@ int CatchAllCommand::execute() {
                        set<string> processedLabels;
                        set<string> userLabels = labels;
                        
-                       string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "catchall.summary";
+                       string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + getOutputFileNameTag("summary");
                        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"); } 
@@ -283,10 +304,10 @@ 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.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
+                                               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"); }
                     
@@ -336,10 +357,10 @@ 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.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
+                        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"); }
@@ -410,11 +431,10 @@ 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.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");        
-                               if (m->debug) { m->mothurOut("[DEBUG]: About to create summary file for: " + filename + ".\n[DEBUG]: sabund label = " + sabund->getLabel() + ".\n"); }
+                               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"); }
                 
                                createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
                 
@@ -491,7 +511,7 @@ string CatchAllCommand::combineSummmary(vector<string>& outputNames) {
        try {
                
                ofstream out;
-               string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "catchall.summary";
+               string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
                
                //open combined file
                m->openOutputFile(combineFileName, out);
index 238dfb608bb412a311f184d8df2f5dd4d4db9ab9..d1b8a2a8dfabf300d4d6cb7591e043e2ea48b113 100644 (file)
@@ -31,6 +31,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "catchall";                    }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "Bunge, J. (2011). Estimating the number of species with CatchAll. Forthcoming in Proceedings of the Pacific Symposium on Biocomputing 2011.\nhttp://www.northeastern.edu/catchall/index.html http://www.mothur.org/wiki/Catchall"; }
        string getDescription()         { return "estimate number of species"; }
index c519f91ede4bafbf1802dc813d2679be4a792c17..82400112bc8770ca2ded637853028d86e6aede99 100644 (file)
@@ -57,6 +57,27 @@ string ChimeraBellerophonCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraBellerophonCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraBellerophonCommand::ChimeraBellerophonCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -222,8 +243,8 @@ 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])) +  "bellerophon.chimeras";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "bellerophon.accnos";
+                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) +  getOutputFileNameTag("chimera");
+                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) +  getOutputFileNameTag("accnos");
                        
                        chimera->getChimeras();
                        
index b759d5a99dd8f1864506e3dd81eac46bedab235e..015f2b78a6d412deda2dc639b4c7a2b3b055ec17 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.bellerophon"; }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 fc98e0fc45c3b576a3e2420ac415c016266b4c1c..942635ea183cedee17550fd85df3c3daa68d9979 100644 (file)
@@ -64,6 +64,28 @@ string ChimeraCcodeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraCcodeCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraCcodeCommand::ChimeraCcodeCommand(){    
        try {
                abort = true; calledHelp = true;
@@ -284,14 +306,16 @@ 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 + ".ccode.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.accnos";
+                               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]))  + "ccode.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "ccode.accnos";
+                               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])) + "mapinfo";
+                       string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("mapinfo");
+
                        
                        if (m->control_pressed) { delete chimera;  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } outputTypes.clear(); return 0;        }
                        
index 5b8092b6f7075111c7fa8c5c58caf14ef3ebaeca..408e2feb05f541cd46945c231df7b70f8dea276e 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.ccode";               }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 cc486d3ab690fd655c1de8a22ae406eafc2c242f..87f51e7c95c136403024c593e681a844ca18d006 100644 (file)
@@ -65,6 +65,26 @@ string ChimeraCheckCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraCheckCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraCheckCommand::ChimeraCheckCommand(){    
        try {
                abort = true; calledHelp = true;
@@ -342,7 +362,7 @@ 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]))  + "chimeracheck.chimeras";
+                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + getOutputFileNameTag("chimera");
                        outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
                        
                #ifdef USE_MPI
index 918b4e5e9bf8aa4a16a1e0ba0716e09753a29cea..61129cd618264c62322ccfe8a0a2107140170358 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.check";               }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 e7294a854ec4134ccad5e17aa0ed8abb51876d09..e3691e8b942c2f34da91cec14691e717d5c16c1a 100644 (file)
@@ -58,6 +58,27 @@ string ChimeraPerseusCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraPerseusCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraPerseusCommand::ChimeraPerseusCommand(){        
        try {
                abort = true; calledHelp = true;
@@ -376,8 +397,9 @@ int ChimeraPerseusCommand::execute(){
                        
                        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])) + "perseus.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "perseus.accnos";
+                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
+                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
+
                        //string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
                        
                        //you provided a groupfile
index 01f5768a0c070c70aa6c7264b6d482b3636d7148..1c4baa3f8f0d5a8b5724af661f51850b6d0b4762 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.perseus";             }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Chimera.perseus\n"; }
        string getDescription()         { return "detect chimeric sequences"; }
index 7311173265d55bbac59af028922de1f7f7e5d447..c5c678e78a344eed06ea0308c0df6178e7f22a51 100644 (file)
@@ -69,6 +69,27 @@ string ChimeraPintailCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraPintailCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraPintailCommand::ChimeraPintailCommand(){        
        try {
                abort = true; calledHelp = true;
@@ -397,11 +418,11 @@ 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)) + ".pintail.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + ".pintail.accnos";
+                               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]))  + "pintail.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "pintail.accnos";
+                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("chimera");
+                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("accnos");
                        }
                        
                        if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0;    }
index ddbb648593c349bc52ca13bf990a5bc7f31bf50a..1f30b7d32ef8e826fa0479ff10dcd529982c2b00 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.pintail";             }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 e2b93316a4ade033f6ce4db3988cfd09cbf432e9..59dd0a55a27c13eb80dd521ea83516770c97ed4a 100644 (file)
@@ -98,6 +98,28 @@ string ChimeraSlayerCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraSlayerCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraSlayerCommand::ChimeraSlayerCommand(){  
        try {
                abort = true; calledHelp = true;
@@ -556,9 +578,9 @@ int ChimeraSlayerCommand::execute(){
                
                        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])) + "slayer.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "slayer.accnos";
-                       string trimFastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "slayer.fasta";           
+                       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");             
                        
                        //clears files
                        ofstream out, out1, out2;
index 2c6fec8d8d1082ea270f5e2c2a8832a7b57033a4..a2e22ae527d465b475a4f89b5fa606198315c3a4 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.slayer";              }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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. \nhttp://www.mothur.org/wiki/Chimera.slayer"; }
        string getDescription()         { return "detect chimeric sequences"; }
index b1d996b0f8d971c0fca0124b29031f2c88e5fecb..bd31c193e82aa0725cc8920336ec310cc19db820 100644 (file)
@@ -98,6 +98,28 @@ string ChimeraUchimeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ChimeraUchimeCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ChimeraUchimeCommand::ChimeraUchimeCommand(){  
        try {
                abort = true; calledHelp = true;
@@ -522,9 +544,9 @@ 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])) + "uchime.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "uchime.accnos";
-                       string alnsFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "uchime.alns";
+                       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");
                        string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
                                
                        //you provided a groupfile
index dfb410f1acf31390df8c511b87e5a0f9dce74283..5423a171d5698bda82c5869401e3509e1f059439 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "chimera.uchime";              }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "uchime by Robert C. Edgar\nhttp://drive5.com/uchime\nThis code is donated to the public domain.\nhttp://www.mothur.org/wiki/Chimera.uchime\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection, Bioinformatics, in press.\n"; }
        string getDescription()         { return "detect chimeric sequences"; }
index 4e06201cd352104b5ee9c9d1c41764d16473003e..05037f6817a5a554a029a7d635460d048bf73203 100644 (file)
@@ -51,7 +51,27 @@ string ChopSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string ChopSeqsCommand::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 =  "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);
+       }
+}
 //**********************************************************************************************************************
 ChopSeqsCommand::ChopSeqsCommand(){    
        try {
@@ -147,8 +167,8 @@ int ChopSeqsCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta";
-               string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
+               string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
index e73714d2e98406da2a05e54bb34f61398bd0143c..cc22c751483a75f246f69e4955985f158d041638 100644 (file)
@@ -25,7 +25,8 @@ class ChopSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "chop.seqs";           }
                string getCommandCategory()             { return "Sequence Processing"; }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+        string getHelpString();        
                string getCitation() { return "http://www.mothur.org/wiki/Chops.seqs"; }
                string getDescription()         { return "trim sequence length"; }
        
index 7726b3e00cca9de19971b70656f9581e43e97c8a..212e563f94c4ae7af3ba0916d1040afd9b0e11fa 100644 (file)
@@ -306,28 +306,12 @@ int Classify::readTaxonomy(string file) {
                
                MPI_File_close(&inMPI);
                MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#else                          
-               ifstream inTax;
-               m->openInputFile(file, inTax);
-       
-               //read template seqs and save
-               while (!inTax.eof()) {
-                       inTax >> name; m->gobble(inTax);
-            inTax >> taxInfo;
-            
-            if (m->debug) {  m->mothurOut("[DEBUG]: name = '" + name + "' tax = '" + taxInfo + "'\n");  }
-
-                       taxonomy[name] = taxInfo;
-                       
-                       phyloTree->addSeqToTree(name, taxInfo);
-               
-                       m->gobble(inTax);
-               }
-               inTax.close();
-#endif 
-        
+#else  
         
-       
+        taxonomy.clear(); 
+        m->readTax(file, taxonomy);
+        for (map<string, string>::iterator itTax = taxonomy.begin(); itTax != taxonomy.end(); itTax++) {  phyloTree->addSeqToTree(itTax->first, itTax->second);  }
+#endif 
                phyloTree->assignHeirarchyIDs(0);
                
                phyloTree->setUp(file);
index ef41ee1bab8853f6741938005f775076b60723ab..00ae690214177d94020069986aedbbb0cb118b9e 100644 (file)
@@ -63,6 +63,27 @@ string ClassifyOtuCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClassifyOtuCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ClassifyOtuCommand::ClassifyOtuCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -234,10 +255,10 @@ int ClassifyOtuCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //if user gave a namesfile then use it
-               if (namefile != "") {   readNamesFile();        }
+               if (namefile != "") {   m->readNames(namefile, nameMap, true);  }
                
                //read taxonomy file and save in map for easy access in building bin trees
-               readTaxonomyFile();
+               m->readTax(taxfile, taxMap);
                
                if (m->control_pressed) { return 0; }
                
@@ -327,67 +348,6 @@ int ClassifyOtuCommand::execute(){
                exit(1);
        }
 }
-
-//**********************************************************************************************************************
-int ClassifyOtuCommand::readNamesFile() {
-       try {
-               
-               ifstream inNames;
-               m->openInputFile(namefile, inNames);
-               
-               string name, names;
-       
-               while(!inNames.eof()){
-                       inNames >> name;                        //read from first column  A
-                       inNames >> names;               //read from second column  A,B,C,D
-                       m->gobble(inNames);
-                       
-                       //parse names into vector
-                       vector<string> theseNames;
-                       m->splitAtComma(names, theseNames);
-
-                       for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = name;  }
-                       
-                       if (m->control_pressed) { inNames.close(); nameMap.clear(); return 0; }
-               }
-               inNames.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "readNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ClassifyOtuCommand::readTaxonomyFile() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               
-               string name, tax;
-       
-               while(!in.eof()){
-                       in >> name >> tax;              
-                       m->gobble(in);
-                       
-                       //are there confidence scores, if so remove them
-                       if (tax.find_first_of('(') != -1) {  m->removeConfidences(tax); }
-                       
-                       taxMap[name] = tax;
-                       
-                       if (m->control_pressed) { in.close(); taxMap.clear(); return 0; }
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "readTaxonomyFile");
-               exit(1);
-       }
-}
 //**********************************************************************************************************************
 vector<string> ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList, int& size, string& conTax) {
        try{
@@ -526,12 +486,12 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
                                
                ofstream out;
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".cons.taxonomy";
+               string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + getOutputFileNameTag("constaxonomy");
                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() + ".cons.tax.summary";
+               string outputSumFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + getOutputFileNameTag("taxsummary");
                m->openOutputFile(outputSumFile, outSum);
                outputNames.push_back(outputSumFile); outputTypes["taxsummary"].push_back(outputSumFile);
                
index a0baf1849d92935fec3ca360a135805d3c41ddbc..b924775cf5b30436c1783714a758281cf072c32f 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.otu";                }
        string getCommandCategory()             { return "Phylotype Analysis";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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. \nhttp://www.mothur.org/wiki/Classify.otu"; }
        string getDescription()         { return "find the concensus taxonomy for each OTU"; }
@@ -44,8 +45,6 @@ private:
        map<string, string> nameMap;
        map<string, string> taxMap;
 
-       int readNamesFile();
-       int readTaxonomyFile();
        int process(ListVector*);
        string addUnclassifieds(string, int);
        vector<string> findConsensusTaxonomy(int, ListVector*, int&, string&);  // returns the name of the "representative" taxonomy of given bin
index 158069e7ae596e3eebd6a9d2da5834ec3529dcdc..c76b047cbd064a5b7b967ab388109bb4e46cc0cc 100644 (file)
@@ -85,6 +85,29 @@ string ClassifySeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClassifySeqsCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ClassifySeqsCommand::ClassifySeqsCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -506,7 +529,6 @@ int ClassifySeqsCommand::execute(){
                        string RippedTaxName = "";
             bool foundDot = false;
             for (int i = baseTName.length()-1; i >= 0; i--) {
-                cout << baseTName[i] << endl;
                 if (foundDot && (baseTName[i] != '.')) {  RippedTaxName = baseTName[i] + RippedTaxName; }
                 else if (foundDot && (baseTName[i] == '.')) {  break; }
                 else if (!foundDot && (baseTName[i] == '.')) {  foundDot = true; }
@@ -514,13 +536,13 @@ int ClassifySeqsCommand::execute(){
             if (RippedTaxName != "") { RippedTaxName +=  "."; }   
           
                        if (outputDir == "") { outputDir += m->hasPath(fastaFileNames[s]); }
-                       string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy";
-                       string newaccnosFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "flip.accnos";
+                       string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + getOutputFileNameTag("taxonomy");
+                       string newaccnosFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + getOutputFileNameTag("accnos");
                        string tempTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
-                       string taxSummary = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "tax.summary";
+                       string taxSummary = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + getOutputFileNameTag("taxsummary");
                        
                        if ((method == "knn") && (search == "distance")) { 
-                               string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "match.dist";
+                               string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("matchdist");
                                classify->setDistName(DistName);  outputNames.push_back(DistName); outputTypes["matchdist"].push_back(DistName);
                        }
                        
@@ -666,23 +688,8 @@ int ClassifySeqsCommand::execute(){
                        if(namefile != "") {
                        
                            m->mothurOut("Reading " + namefileNames[s] + "..."); cout.flush();
-                               
                                nameMap.clear(); //remove old names
-                               
-                               ifstream inNames;
-                               m->openInputFile(namefileNames[s], inNames);
-                               
-                               string firstCol, secondCol;
-                               while(!inNames.eof()) {
-                                       inNames >> firstCol >> secondCol; m->gobble(inNames);
-                                       
-                                       vector<string> temp;
-                                       m->splitAtComma(secondCol, temp);
-                       
-                                       nameMap[firstCol] = temp;  
-                               }
-                               inNames.close();
-                               
+                               m->readNames(namefileNames[s], nameMap);                                
                                m->mothurOut("  Done."); m->mothurOutEndLine();
                        }
                #endif
index 1316a250cc8418843e542dd446e021769d6f6ebd..4965642e7f77f0d8638bceb177bd79788c8e39ad 100644 (file)
@@ -41,6 +41,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.seqs";               }
        string getCommandCategory()             { return "Phylotype Analysis";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 bcf27698ce2bf68bf3dc6a3909228a9d4ccd5cb2..7861a01bab3420f1598e351b30765dbd0ae5f124 100644 (file)
@@ -49,7 +49,27 @@ string ClassifyTreeCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string ClassifyTreeCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 ClassifyTreeCommand::ClassifyTreeCommand(){    
        try {
@@ -197,11 +217,11 @@ int ClassifyTreeCommand::execute(){
         Tree* outputTree = T[0];
         delete reader;
 
-        if (namefile != "") { readNamesFile(); }
+        if (namefile != "") { m->readNames(namefile, nameMap, nameCount); }
                         
         if (m->control_pressed) { delete tmap;  delete outputTree;  return 0; }
                
-        readTaxonomyFile();
+        m->readTax(taxonomyfile, taxMap);
         
         /***************************************************/
         //             get concensus taxonomies                    //
@@ -242,7 +262,7 @@ int ClassifyTreeCommand::getClassifications(Tree*& T){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(treefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(treefile)) + "taxonomy.summary";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("summary");
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -256,7 +276,7 @@ int ClassifyTreeCommand::getClassifications(Tree*& T){
                
                string treeOutputDir = outputDir;
                if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + "taxonomy.tre";
+               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
                
                //create a map from tree node index to names of descendants, save time later
                map<int, map<string, set<string> > > nodeToDescendants; //node# -> (groupName -> groupMembers)
@@ -453,68 +473,6 @@ map<string, set<string> > ClassifyTreeCommand::getDescendantList(Tree*& T, int i
                exit(1);
        }
 }
-//**********************************************************************************************************************
-int ClassifyTreeCommand::readTaxonomyFile() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(taxonomyfile, in);
-               
-               string name, tax;
-        
-               while(!in.eof()){
-                       in >> name >> tax;              
-                       m->gobble(in);
-                       
-                       //are there confidence scores, if so remove them
-                       if (tax.find_first_of('(') != -1) {  m->removeConfidences(tax); }
-                       
-                       taxMap[name] = tax;
-                       
-                       if (m->control_pressed) { in.close(); taxMap.clear(); return 0; }
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "readTaxonomyFile");
-               exit(1);
-       }
-}
-
-/*****************************************************************/
-int ClassifyTreeCommand::readNamesFile() {
-       try {
-               ifstream inNames;
-               m->openInputFile(namefile, inNames);
-               
-               string name, names;
-        
-               while(!inNames.eof()){
-                       inNames >> name;                        //read from first column  A
-                       inNames >> names;               //read from second column  A,B,C,D
-                       m->gobble(inNames);
-                       
-                       //parse names into vector
-                       vector<string> theseNames;
-                       m->splitAtComma(names, theseNames);
-            
-                       for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = name;  }
-            nameCount[name] = theseNames.size();
-                       
-                       if (m->control_pressed) { inNames.close(); nameMap.clear(); return 0; }
-               }
-               inNames.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
 /*****************************************************************/
 
 
index 30957af065686f1f8958f7ea84d4be49c187debe..758a438dc068f0790aab0b8b309f32a0fb6f24a5 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "classify.tree";                               }
        string getCommandCategory()             { return "Phylotype Analysis";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Classify.tree"; }
        string getDescription()         { return "Find the consensus taxonomy for the descendant of each tree node"; }
@@ -41,8 +42,6 @@ private:
        int getClassifications(Tree*&);
        map<string, set<string> > getDescendantList(Tree*&, int, map<int, map<string, set<string> > >);
     string getTaxonomy(set<string>, int&);
-    int readNamesFile(); 
-    int readTaxonomyFile();
        
 };
 
index d3c7fa48128246f8f4cb28ad53727329b3de856c..6a0eb259379df8480341a5542a7456fc674aea74 100644 (file)
@@ -86,7 +86,27 @@ string ClearcutCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string ClearcutCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 ClearcutCommand::ClearcutCommand(){    
        try {
@@ -244,7 +264,7 @@ int ClearcutCommand::execute() {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //prepare filename
-               string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
+               string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + getOutputFileNameTag("tree");
                outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
                
                vector<char*> cPara;
index 942953f71bef907980d93355c5a1070599383f61..8f3773eef5cafc5b4a18c56da51df9bdb9606be6 100644 (file)
@@ -30,6 +30,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "clearcut";                    }
        string getCommandCategory()             { return "Hypothesis Testing";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 abdc5558ae1aa26ab7c2d21454f8ff0696802ad1..e1f39723c6b6b9d56c961fa16345c6194f9c8a7c 100644 (file)
@@ -22,6 +22,25 @@ 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 901756164ff2cee9fc04561050ba3fdb8d188168..1208315a54c880e39c1bfd4a3316fe3a47cab33d 100644 (file)
@@ -21,6 +21,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "clear.memory";                        }
        string getCommandCategory()             { return "General";     }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Clear.memory"; }
        string getDescription()         { return "remove saved references from memory"; }
index 528f71c11c24f7a47133bef2d60a6906249abe92..8019def31cad9acc54c1308171bf796e949890a1 100644 (file)
@@ -54,6 +54,28 @@ string ClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClusterCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ClusterCommand::ClusterCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -287,13 +309,17 @@ int ClusterCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(distfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
                
-               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-               m->openOutputFile(fileroot+ tag + ".list",              listFile);
+        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+        string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+        
+               m->openOutputFile(sabundFileName,       sabundFile);
+               m->openOutputFile(rabundFileName,       rabundFile);
+               m->openOutputFile(listFileName, listFile);
                
-               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
+               outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+               outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+               outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                
                
                time_t estart = time(NULL);
index 268ec315a81e1bbbcbd80051986703f3e02f03d4..7349961e252104c93cf26942d79b44f11ba7c0f5 100644 (file)
@@ -34,6 +34,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster";             }
        string getCommandCategory()             { return "Clustering";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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. \nhttp://www.mothur.org/wiki/Cluster"; }
        string getDescription()         { return "cluster your sequences into OTUs using a distance matrix"; }
index 603bd73d680b485fb4df6ef6cf62e935af3f1ff5..9bfb52b9d92b0222af2e4b1acff37c82f968349f 100644 (file)
@@ -49,6 +49,28 @@ string ClusterDoturCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClusterDoturCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ClusterDoturCommand::ClusterDoturCommand(){    
        try {
                abort = true; calledHelp = true;
@@ -201,13 +223,17 @@ int ClusterDoturCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(phylipfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(phylipfile));
                        
-               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-                               
-               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
+        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+        string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+        
+               m->openOutputFile(sabundFileName,       sabundFile);
+               m->openOutputFile(rabundFileName,       rabundFile);
+               m->openOutputFile(listFileName, listFile);
+               
+               outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+               outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+               outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                
                float previousDist = 0.00000;
                float rndPreviousDist = 0.00000;
index 643551a35c0289efe46a9bd5f2e280566faea31e..ec2f083e987e47f3125f381bd0c1199307dbdaf8 100644 (file)
@@ -27,7 +27,8 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.classic";             }
        string getCommandCategory()             { return "Clustering";                  }
-       string getHelpString(); 
+    string getOutputFileNameTag(string, string);
+       string getHelpString();         
        string getCitation() { return "Schloss 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"; }
        string getDescription()         { return "cluster your sequences into OTUs using DOTUR’s method"; }
        
index 772113baf83e9fbbd057794103f46ffa21c21fda..4a338419af8900f8b7ebd693225a7e9f4d193481 100644 (file)
@@ -66,6 +66,28 @@ string ClusterFragmentsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ClusterFragmentsCommand::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 =  "fragclust.fasta"; }
+            else if (type == "name") {  outputFileName =  "fragclust.names"; }
+            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);
+       }
+}
+
 //**********************************************************************************************************************
 ClusterFragmentsCommand::ClusterFragmentsCommand(){    
        try {
@@ -230,8 +252,8 @@ int ClusterFragmentsCommand::execute(){
                
                string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
                
-               string newFastaFile = fileroot + "fragclust.fasta";
-               string newNamesFile = fileroot + "fragclust.names";
+               string newFastaFile = fileroot + getOutputFileNameTag("fasta");
+               string newNamesFile = fileroot + getOutputFileNameTag("name");
                
                if (m->control_pressed) { return 0; }
                
index c7ea7e0d078f0abfe404afd41cab0b4500bc5c48..c322529f3bedf95600a8b30e0ac013be2870d290 100644 (file)
@@ -37,6 +37,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.fragments";           }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 2eee59f6165e28c50f86fd6ab9b1db0920135040..fc0211ee5a5432ef610c6f22696bff74adf0c72b 100644 (file)
@@ -77,6 +77,29 @@ string ClusterSplitCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ClusterSplitCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 ClusterSplitCommand::ClusterSplitCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -750,14 +773,17 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> us
                if (outputDir == "") { outputDir += m->hasPath(distfile); }
                fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
                
-               m->openOutputFile(fileroot+ tag + ".sabund",    outSabund);
-               m->openOutputFile(fileroot+ tag + ".rabund",    outRabund);
-               m->openOutputFile(fileroot+ tag + ".list",              outList);
-                               
-               outputNames.push_back(fileroot+ tag + ".sabund");  outputTypes["list"].push_back(fileroot+ tag + ".list");
-               outputNames.push_back(fileroot+ tag + ".rabund");  outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list");    outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
+        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+        string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+        
+               m->openOutputFile(sabundFileName,       outSabund);
+               m->openOutputFile(rabundFileName,       outRabund);
+               m->openOutputFile(listFileName, outList);
                
+               outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+               outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+               outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);               
                map<float, int>::iterator itLabel;
 
                //for each label needed
@@ -1331,7 +1357,7 @@ int ClusterSplitCommand::createMergedDistanceFile(vector< map<string, string> >
                
                string thisOutputDir = outputDir;
                if (outputDir == "") { thisOutputDir = m->hasPath(fastafile); }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("column");
                m->mothurRemove(outputFileName);
                
                
index a82d02270ecc37f1c85e93c9fe51b70e29288081..28de9488b68516e2e194db0dd35920c7078e91f9 100644 (file)
@@ -35,6 +35,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "cluster.split";               }
        string getCommandCategory()             { return "Clustering";                  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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. \nhttp://www.mothur.org/wiki/Cluster.split"; }
        string getDescription()         { return "splits your sequences by distance or taxonomy then clusters into OTUs"; }
index 7ad41367f795abe7aeeda1052a8211daf72aeaf4..73de2a42ffb7fecfa6b5591f076bf7f893271b53 100644 (file)
@@ -81,6 +81,50 @@ string CollectCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string CollectCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 CollectCommand::CollectCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -322,80 +366,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+"sobs")));
-                                               outputNames.push_back(fileNameRoot+"sobs"); outputTypes["sobs"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "chao") { 
-                                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
-                                               outputNames.push_back(fileNameRoot+"chao"); outputTypes["chao"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "nseqs") { 
-                                               cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
-                                               outputNames.push_back(fileNameRoot+"nseqs"); outputTypes["nseqs"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "coverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+"coverage")));
-                                               outputNames.push_back(fileNameRoot+"coverage"); outputTypes["coverage"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "ace") { 
-                                               cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
-                                               outputNames.push_back(fileNameRoot+"ace"); outputTypes["ace"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "jack") { 
-                                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
-                                               outputNames.push_back(fileNameRoot+"jack"); outputTypes["jack"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "shannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
-                                               outputNames.push_back(fileNameRoot+"shannon"); outputTypes["shannon"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "shannoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new ShannonEven(), new OneColumnFile(fileNameRoot+"shannoneven")));
-                                               outputNames.push_back(fileNameRoot+"shannoneven"); outputTypes["shannoneven"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "npshannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"npshannon")));
-                                               outputNames.push_back(fileNameRoot+"npshannon"); outputTypes["npshannon"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "heip") { 
-                                               cDisplays.push_back(new CollectDisplay(new Heip(), new OneColumnFile(fileNameRoot+"heip")));
-                                               outputNames.push_back(fileNameRoot+"heip"); outputTypes["heip"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "smithwilson") { 
-                                               cDisplays.push_back(new CollectDisplay(new SmithWilson(), new OneColumnFile(fileNameRoot+"smithwilson")));
-                                               outputNames.push_back(fileNameRoot+"smithwilson"); outputTypes["smithwilson"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "simpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
-                                               outputNames.push_back(fileNameRoot+"simpson"); outputTypes["simpson"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "simpsoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new SimpsonEven(), new OneColumnFile(fileNameRoot+"simpsoneven")));
-                                               outputNames.push_back(fileNameRoot+"simpsoneven"); outputTypes["simpsoneven"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "invsimpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"invsimpson")));
-                                               outputNames.push_back(fileNameRoot+"invsimpson"); outputTypes["invsimpson"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "bootstrap") { 
-                                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
-                                               outputNames.push_back(fileNameRoot+"bootstrap"); outputTypes["bootstrap"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "geometric") { 
-                                               cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geometric")));
-                                               outputNames.push_back(fileNameRoot+"geometric"); outputTypes["geometric"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "qstat") { 
-                                               cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat")));
-                                               outputNames.push_back(fileNameRoot+"qstat"); outputTypes["qstat"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "logseries") { 
-                                               cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logseries")));
-                                               outputNames.push_back(fileNameRoot+"logseries"); outputTypes["logseries"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "bergerparker") { 
-                                               cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker")));
-                                               outputNames.push_back(fileNameRoot+"bergerparker"); outputTypes["bergerparker"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "bstick") { 
-                                               cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick")));
-                                               outputNames.push_back(fileNameRoot+"bstick"); outputTypes["bstick"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "goodscoverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage")));
-                                               outputNames.push_back(fileNameRoot+"goodscoverage"); outputTypes["goodscoverage"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "efron") {
-                                               cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron")));
-                                               outputNames.push_back(fileNameRoot+"efron"); outputTypes["efron"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "boneh") {
-                                               cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh")));
-                                               outputNames.push_back(fileNameRoot+"boneh"); outputTypes["boneh"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "solow") {
-                                               cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
-                                               outputNames.push_back(fileNameRoot+"solow"); outputTypes["solow"].push_back(fileNameRoot+"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"));
                                        }else if (Estimators[i] == "shen") {
-                                               cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(fileNameRoot+"shen")));
-                                               outputNames.push_back(fileNameRoot+"shen"); outputTypes["shen"].push_back(fileNameRoot+"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"));
                                        }
                                }
                        }
index b882013942e0555be7897a3278b5ccbcb6a20c62..1d8734fa5d713ad4535e067af55d3c56d699573c 100644 (file)
@@ -38,6 +38,7 @@ 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 getDescription()         { return "generates collector's curves using calculators, that describe the richness, diversity, and other features of individual samples"; }
        
index f3a320b89e0695483a5124b6336d68cf89179293..baebeb16298b28c3cd6372fe06a2de547e7bfbdc 100644 (file)
@@ -98,6 +98,64 @@ string CollectSharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string CollectSharedCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 CollectSharedCommand::CollectSharedCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -288,122 +346,122 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                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+"shared.chao")));
-                                                       outputNames.push_back(fileNameRoot+"shared.chao"); outputTypes["sharedchao"].push_back(fileNameRoot+"shared.chao");
+                                                       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"));
                                                }else if (Estimators[i] == "sharedsobs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.sobs"); outputTypes["sharedsobs"].push_back(fileNameRoot+"shared.sobs");
+                                                       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"));
                                                }else if (Estimators[i] == "sharedace") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
-                                                       outputNames.push_back(fileNameRoot+"shared.ace"); outputTypes["sharedace"].push_back(fileNameRoot+"shared.ace");
+                                                       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"));
                                                }else if (Estimators[i] == "jabund") {  
-                                                       cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(fileNameRoot+"jabund")));
-                                                       outputNames.push_back(fileNameRoot+"jabund"); outputTypes["jabund"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "sorabund") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(fileNameRoot+"sorabund")));
-                                                       outputNames.push_back(fileNameRoot+"sorabund"); outputTypes["sorabund"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "jclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(fileNameRoot+"jclass")));
-                                                       outputNames.push_back(fileNameRoot+"jclass"); outputTypes["jclass"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "sorclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(fileNameRoot+"sorclass")));
-                                                       outputNames.push_back(fileNameRoot+"sorclass"); outputTypes["sorclass"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "jest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(fileNameRoot+"jest")));
-                                                       outputNames.push_back(fileNameRoot+"jest"); outputTypes["jest"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "sorest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(fileNameRoot+"sorest")));
-                                                       outputNames.push_back(fileNameRoot+"sorest"); outputTypes["sorest"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "thetayc") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(fileNameRoot+"thetayc")));
-                                                       outputNames.push_back(fileNameRoot+"thetayc"); outputTypes["thetayc"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "thetan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(fileNameRoot+"thetan")));
-                                                       outputNames.push_back(fileNameRoot+"thetan"); outputTypes["thetan"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "kstest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(fileNameRoot+"kstest")));
-                                                       outputNames.push_back(fileNameRoot+"kstest"); outputTypes["kstest"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "whittaker") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(fileNameRoot+"whittaker")));
-                                                       outputNames.push_back(fileNameRoot+"whittaker"); outputTypes["whittaker"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "sharednseqs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+"shared.nseqs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.nseqs"); outputTypes["shared.nseqs"].push_back(fileNameRoot+"shared.nseqs");
+                                                       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"));
                                                }else if (Estimators[i] == "ochiai") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(fileNameRoot+"ochiai")));
-                                                       outputNames.push_back(fileNameRoot+"ochiai"); outputTypes["ochiai"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "anderberg") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+"anderberg")));
-                                                       outputNames.push_back(fileNameRoot+"anderberg"); outputTypes["anderberg"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "kulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+"kulczynski")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynski"); outputTypes["kulczynski"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "kulczynskicody") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(fileNameRoot+"kulczynskicody")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynskicody"); outputTypes["kulczynskicody"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "lennon") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(fileNameRoot+"lennon")));
-                                                       outputNames.push_back(fileNameRoot+"lennon"); outputTypes["lennon"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "morisitahorn") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(fileNameRoot+"morisitahorn")));
-                                                       outputNames.push_back(fileNameRoot+"morisitahorn"); outputTypes["morisitahorn"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "braycurtis") { 
-                                                       cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
-                                                       outputNames.push_back(fileNameRoot+"braycurtis"); outputTypes["braycurtis"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "odum") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(fileNameRoot+"odum")));
-                                                       outputNames.push_back(fileNameRoot+"odum"); outputTypes["odum"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "canberra") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(fileNameRoot+"canberra")));
-                                                       outputNames.push_back(fileNameRoot+"canberra"); outputTypes["canberra"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "structeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructEuclidean(), new SharedOneColumnFile(fileNameRoot+"structeuclidean")));
-                                                       outputNames.push_back(fileNameRoot+"structeuclidean"); outputTypes["structeuclidean"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "structchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChord(), new SharedOneColumnFile(fileNameRoot+"structchord")));
-                                                       outputNames.push_back(fileNameRoot+"structchord"); outputTypes["structchord"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "hellinger") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(fileNameRoot+"hellinger")));
-                                                       outputNames.push_back(fileNameRoot+"hellinger"); outputTypes["hellinger"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "manhattan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(fileNameRoot+"manhattan")));
-                                                       outputNames.push_back(fileNameRoot+"manhattan"); outputTypes["manhattan"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "structpearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructPearson(), new SharedOneColumnFile(fileNameRoot+"structpearson")));
-                                                       outputNames.push_back(fileNameRoot+"structpearson"); outputTypes["structpearson"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "soergel") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(fileNameRoot+"soergel")));
-                                                       outputNames.push_back(fileNameRoot+"soergel"); outputTypes["soergel"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "spearman") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(fileNameRoot+"spearman")));
-                                                       outputNames.push_back(fileNameRoot+"spearman"); outputTypes["spearman"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "structkulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructKulczynski(), new SharedOneColumnFile(fileNameRoot+"structkulczynski")));
-                                                       outputNames.push_back(fileNameRoot+"structkulczynski"); outputTypes["structkulczynski"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "speciesprofile") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(fileNameRoot+"speciesprofile")));
-                                                       outputNames.push_back(fileNameRoot+"speciesprofile"); outputTypes["speciesprofile"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "hamming") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(fileNameRoot+"hamming")));
-                                                       outputNames.push_back(fileNameRoot+"hamming"); outputTypes["hamming"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "structchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChi2(), new SharedOneColumnFile(fileNameRoot+"structchi2")));
-                                                       outputNames.push_back(fileNameRoot+"structchi2"); outputTypes["structchi2"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "gower") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Gower(), new SharedOneColumnFile(fileNameRoot+"gower")));
-                                                       outputNames.push_back(fileNameRoot+"gower"); outputTypes["gower"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "memchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChi2(), new SharedOneColumnFile(fileNameRoot+"memchi2")));
-                                                       outputNames.push_back(fileNameRoot+"memchi2"); outputTypes["memchi2"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "memchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChord(), new SharedOneColumnFile(fileNameRoot+"memchord")));
-                                                       outputNames.push_back(fileNameRoot+"memchord"); outputTypes["memchord"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "memeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemEuclidean(), new SharedOneColumnFile(fileNameRoot+"memeuclidean")));
-                                                       outputNames.push_back(fileNameRoot+"memeuclidean"); outputTypes["memeuclidean"].push_back(fileNameRoot+"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"));
                                                }else if (Estimators[i] == "mempearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemPearson(), new SharedOneColumnFile(fileNameRoot+"mempearson")));
-                                                       outputNames.push_back(fileNameRoot+"mempearson"); outputTypes["mempearson"].push_back(fileNameRoot+"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"));
                                                }
                                                
                                        }
index 71c11d62666149a57f88703b253b55c774cb3e70..d0908de54afb261e4e8184efd6910c3238848d2b 100644 (file)
@@ -29,6 +29,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "collect.shared";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 22f118164eb04e7d22c0438e3e42c56b79ed0f3d..f5e09042234f1c39ac8010f859e6f69708871dc3 100644 (file)
@@ -33,6 +33,7 @@ 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.
                virtual vector<string> setParameters() = 0; //to fill parameters
                virtual vector<CommandParameter> getParameters() { return parameters; }
        
index 2822d0b9920a0f5cc5005cf01ce653b38b9ede6d..54ff4a12d120ddcc482d84876ac53a04f6e3a04a 100644 (file)
@@ -8,9 +8,6 @@
  */
 
 #include "command.hpp"
-#include "readdistcommand.h"
-#include "readtreecommand.h"
-#include "readotucommand.h"
 #include "clustercommand.h"
 #include "collectcommand.h"
 #include "collectsharedcommand.h"
 #include "getotulabelscommand.h"
 #include "removeotulabelscommand.h"
 #include "makecontigscommand.h"
+#include "loadlogfilecommand.h"
 
 /*******************************************************/
 
@@ -168,9 +166,6 @@ CommandFactory::CommandFactory(){
        append = false;
        
        //initialize list of valid commands
-       commands["read.dist"]                   = "read.dist"; 
-       commands["read.otu"]                    = "read.otu";
-       commands["read.tree"]                   = "read.tree"; 
        commands["make.shared"]                 = "make.shared"; 
        commands["bin.seqs"]                    = "bin.seqs"; 
        commands["get.oturep"]                  = "get.oturep";
@@ -293,6 +288,7 @@ CommandFactory::CommandFactory(){
     commands["get.otulabels"]       = "get.otulabels";
     commands["remove.otulabels"]    = "remove.otulabels";
     commands["make.contigs"]        = "make.contigs";
+    commands["load.logfile"]        = "load.logfile";
        commands["quit"]                                = "MPIEnabled"; 
 
 }
@@ -382,10 +378,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                        else { optionString += "inputdir=" + inputDir; }
                }
                
-               if(commandName == "read.dist")                                  {       command = new ReadDistCommand(optionString);                            }
-               else if(commandName == "read.otu")                              {       command = new ReadOtuCommand(optionString);                                     }
-               else if(commandName == "read.tree")                             {       command = new ReadTreeCommand(optionString);                            }
-               else if(commandName == "cluster")                               {       command = new ClusterCommand(optionString);                                     }
+               if(commandName == "cluster")                            {       command = new ClusterCommand(optionString);                                     }
                else if(commandName == "unique.seqs")                   {       command = new DeconvoluteCommand(optionString);                         }
                else if(commandName == "parsimony")                             {       command = new ParsimonyCommand(optionString);                           }
                else if(commandName == "help")                                  {       command = new HelpCommand(optionString);                                        }
@@ -508,6 +501,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
         else if(commandName == "get.otulabels")         {      command = new GetOtuLabelsCommand(optionString);            }
         else if(commandName == "remove.otulabels")      {      command = new RemoveOtuLabelsCommand(optionString);         }
         else if(commandName == "make.contigs")          {      command = new MakeContigsCommand(optionString);             }
+        else if(commandName == "load.logfile")          {      command = new LoadLogfileCommand(optionString);             }
                else                                                                                    {       command = new NoCommand(optionString);                                          }
 
                return command;
@@ -539,10 +533,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str
                        else { optionString += "inputdir=" + inputDir; }
                }
                
-               if(commandName == "read.dist")                                  {       pipecommand = new ReadDistCommand(optionString);                                }
-               else if(commandName == "read.otu")                              {       pipecommand = new ReadOtuCommand(optionString);                                 }
-               else if(commandName == "read.tree")                             {       pipecommand = new ReadTreeCommand(optionString);                                }
-               else if(commandName == "cluster")                               {       pipecommand = new ClusterCommand(optionString);                                 }
+               if(commandName == "cluster")                            {       pipecommand = new ClusterCommand(optionString);                                 }
                else if(commandName == "unique.seqs")                   {       pipecommand = new DeconvoluteCommand(optionString);                             }
                else if(commandName == "parsimony")                             {       pipecommand = new ParsimonyCommand(optionString);                               }
                else if(commandName == "help")                                  {       pipecommand = new HelpCommand(optionString);                                    }
@@ -664,6 +655,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str
         else if(commandName == "get.otulabels")         {      pipecommand = new GetOtuLabelsCommand(optionString);            }
         else if(commandName == "remove.otulabels")      {      pipecommand = new RemoveOtuLabelsCommand(optionString);         }
         else if(commandName == "make.contigs")          {      pipecommand = new MakeContigsCommand(optionString);             }
+        else if(commandName == "load.logfile")          {      pipecommand = new LoadLogfileCommand(optionString);             }
                else                                                                                    {       pipecommand = new NoCommand(optionString);                                              }
 
                return pipecommand;
@@ -681,10 +673,7 @@ Command* CommandFactory::getCommand(string commandName){
        try {
                delete shellcommand;   //delete the old command
                
-               if(commandName == "read.dist")                                  {       shellcommand = new ReadDistCommand();                           }
-               else if(commandName == "read.otu")                              {       shellcommand = new ReadOtuCommand();                            }
-               else if(commandName == "read.tree")                             {       shellcommand = new ReadTreeCommand();                           }
-               else if(commandName == "cluster")                               {       shellcommand = new ClusterCommand();                            }
+               if(commandName == "cluster")                            {       shellcommand = new ClusterCommand();                            }
                else if(commandName == "unique.seqs")                   {       shellcommand = new DeconvoluteCommand();                        }
                else if(commandName == "parsimony")                             {       shellcommand = new ParsimonyCommand();                          }
                else if(commandName == "help")                                  {       shellcommand = new HelpCommand();                                       }
@@ -806,6 +795,7 @@ Command* CommandFactory::getCommand(string commandName){
         else if(commandName == "get.otulabels")         {      shellcommand = new GetOtuLabelsCommand();           }
         else if(commandName == "remove.otulabels")      {      shellcommand = new RemoveOtuLabelsCommand();        }
         else if(commandName == "make.contigs")          {      shellcommand = new MakeContigsCommand();            }
+        else if(commandName == "load.logfile")          {      shellcommand = new LoadLogfileCommand();            }
                else                                                                                    {       shellcommand = new NoCommand();                                         }
 
                return shellcommand;
index 55ec8023270cd17d38b830f519ad9f62518e635e..d6158ba3ed3bc147027d54098aa71398182dc2f6 100644 (file)
@@ -53,6 +53,28 @@ string ConsensusSeqsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ConsensusSeqsCommand::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 =  "cons.fasta"; }
+            else if (type == "name") {  outputFileName =  "cons.names"; }
+            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);
+       }
+}
 
 //**********************************************************************************************************************
 ConsensusSeqsCommand::ConsensusSeqsCommand(){  
@@ -194,7 +216,7 @@ int ConsensusSeqsCommand::execute(){
                if (listfile == "") {
                        
                        ofstream outSummary;
-                       string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.summary";
+                       string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary");
                        m->openOutputFile(outputSummaryFile, outSummary);
                        outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
                        outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
@@ -202,7 +224,7 @@ int ConsensusSeqsCommand::execute(){
                        outSummary << "PositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
                        
                        ofstream outFasta;
-                       string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.fasta";
+                       string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
                        m->openOutputFile(outputFastaFile, outFasta);
                        outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
                        
@@ -370,18 +392,18 @@ int ConsensusSeqsCommand::processList(ListVector*& list){
        try{
                
                ofstream outSummary;
-               string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.summary";
+               string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("summary");
                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() + ".cons.names";
+               string outputNameFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("name");
                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() + ".cons.fasta";
+               string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + getOutputFileNameTag("fasta");
                m->openOutputFile(outputFastaFile, outFasta);
                outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
                
index 423c4e48796a2a9294dc8373fd29823b3418abb0..1459b43d25bd54b525459721b5de55a5a1d6d9f6 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "consensus.seqs";              }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 e4c915d6a14e4a9755a17d64c073fdda1440803b..00de4d6ee612439732207872eba327b8a03f699e 100644 (file)
@@ -51,6 +51,26 @@ string CooccurrenceCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string CooccurrenceCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 CooccurrenceCommand::CooccurrenceCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -176,7 +196,7 @@ int CooccurrenceCommand::execute(){
                set<string> userLabels = labels;
 
         ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "cooccurence.summary";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
         m->openOutputFile(outputFileName, out);
         outputNames.push_back(outputFileName);  outputTypes["summary"].push_back(outputFileName);
         out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
index 8f60e08330ced9099c8b3b777e618a94ca2f9ed1..530db9e2d27cad41cda6dc4f37ad07b01c570009 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "Cooccurrence";                        }
        string getCommandCategory()             { return "Hypothesis Testing";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://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 c27eb4b9ac335112f19244c708cee9bb8630feda..f8083cc01c10a23b4626c6ea2ccd285a15f59c87 100644 (file)
@@ -56,12 +56,32 @@ string CorrAxesCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string CorrAxesCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 CorrAxesCommand::CorrAxesCommand(){    
        try {
                abort = true; calledHelp = true; 
                setParameters();
                vector<string> tempOutNames;
-               outputTypes["corr.axes"] = tempOutNames;
+               outputTypes["corraxes"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "CorrAxesCommand", "CorrAxesCommand");
@@ -92,7 +112,7 @@ CorrAxesCommand::CorrAxesCommand(string option)  {
                        }
                        
                        vector<string> tempOutNames;
-                       outputTypes["corr.axes"] = tempOutNames;
+                       outputTypes["corraxes"] = 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);              
@@ -266,8 +286,8 @@ int CorrAxesCommand::execute(){
                // calc the r values                                                                                                                            //
                /************************************************************************************/
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + ".corr.axes";
-               outputNames.push_back(outputFileName); outputTypes["corr.axes"].push_back(outputFileName);      
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + "." + getOutputFileNameTag("corraxes");
+               outputNames.push_back(outputFileName); outputTypes["corraxes"].push_back(outputFileName);       
                ofstream out;
                m->openOutputFile(outputFileName, out);
                out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
index 2aa7ae0d345cff024b7485ad856013f88895edd9..067228f88ae5c55406021880ea21f4dde2018ce0 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "corr.axes";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 0c03882a459135afaad797728f2ed268b17c9abb..ccf8988e39308fd2816f6eb0a6ff0454ab944d19 100644 (file)
@@ -170,7 +170,7 @@ int CountGroupsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
+               if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); }
                
                if (groupfile != "") {
                        GroupMap groupMap(groupfile);
@@ -208,31 +208,5 @@ int CountGroupsCommand::execute(){
        }
 }
 //**********************************************************************************************************************
-void CountGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 
 
index 2532a80eca171fefd776e3722474084e42a1f396..dd0e0a23eb3ccb9a5f4072aa9bb076228f2fb8b2 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "count.groups";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Count.groups"; }
        string getDescription()         { return "counts the number of sequences in each group"; }
@@ -35,8 +36,6 @@ private:
        string sharedfile, groupfile, outputDir, groups, accnosfile;
        bool abort;
        vector<string> Groups;
-       
-       void readAccnos();
 };
 
 #endif
index e83c6035731aa5509655dcd25a7a45995c1a0004..8a18fc755e66a04d6013ecbf7dd088821088501a 100644 (file)
@@ -46,7 +46,26 @@ string CountSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string CountSeqsCommand::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 == "summary") {  outputFileName =  "seq.count"; }
+            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);
+       }
+}
 //**********************************************************************************************************************
 CountSeqsCommand::CountSeqsCommand(){  
        try {
@@ -147,7 +166,7 @@ int CountSeqsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "seq.count";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("summary");
                m->openOutputFile(outputFileName, out); outputTypes["summary"].push_back(outputFileName);
                out << "Representative_Sequence\ttotal\t";
                
index 89549a9ac0b0c74e6cdd18372ac4cdb834b5e8be..54982c11939e82fae8de341f74c1aa3a01e4f609 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "count.seqs";                          }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 57d5264b8b151d4175b6754ab2ee75732e1e597e..febd762592acdca2df39b7d8d076f0020dfa444d 100644 (file)
@@ -53,6 +53,27 @@ string CreateDatabaseCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string CreateDatabaseCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 CreateDatabaseCommand::CreateDatabaseCommand(){        
        try {
@@ -244,7 +265,7 @@ int CreateDatabaseCommand::execute(){
         if (m->control_pressed) { delete list; if (groupfile != "") { delete groupmap; } return 0; }
         
         if (outputDir == "") { outputDir += m->hasPath(listfile); }
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "database";
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("database");
         outputNames.push_back(outputFileName); outputTypes["database"].push_back(outputFileName);
         
         ofstream out;
index 37e3013607f5f19585a39299a7c22b92a7e8cd24..85e23675b2b770d476dfff45b901da03f6581546 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "create.database";             }
        string getCommandCategory()             { return "OTU-Based Approaches"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 3d0c0d51acaac8844b71a3efa40c7925674ad4c5..bab5a634cd101507957dabc22e34e429c5ec5b1b 100644 (file)
@@ -45,6 +45,27 @@ string DeconvoluteCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DeconvoluteCommand::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 =  "unique" + m->getExtension(inputName); }
+            else if (type == "name") {  outputFileName =  "names"; }
+            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);
+       }
+}
+//**********************************************************************************************************************
 DeconvoluteCommand::DeconvoluteCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -149,14 +170,14 @@ 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)) + "names";
-               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName);
+               string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("name");
+               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + getOutputFileNameTag("fasta", inFastaName);
                
                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.names";   }
+            if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique." + getOutputFileNameTag("name");   }
         }
                
                if (m->control_pressed) { return 0; }
index 487c4601780a209418be72b8eb8c04edd0a55442..7d4cb50023eb6312b652a8368d2d862882b3ffd4 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "unique.seqs";         }
        string getCommandCategory()             { return "Sequence Processing";         }
+    string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 1d83f3bef00d08574a66d7e5ecf21efa148452a4..318a05ec0bee7765f835cce4301d2b7a97d16978 100644 (file)
@@ -46,6 +46,26 @@ string DegapSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DegapSeqsCommand::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 =  "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);
+       }
+}
+//**********************************************************************************************************************
 DegapSeqsCommand::DegapSeqsCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -193,7 +213,7 @@ int DegapSeqsCommand::execute(){
                        ofstream outFASTA;
                        string tempOutputDir = outputDir;
                        if (outputDir == "") { tempOutputDir = m->hasPath(fastaFileNames[s]); }
-                       string degapFile = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ng.fasta";
+                       string degapFile = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("fasta");
                        m->openOutputFile(degapFile, outFASTA);
                        
                        while(!inFASTA.eof()){
index 342cd366cd53ce4b8300e2f7d5cd748b04a21668..c6adac214e0339807ac9fee9845ef404dee311cb 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "degap.seqs";          }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Degap.seqs"; }
        string getDescription()         { return "removes gap characters from sequences"; }
index 7481416f649ddad983877ab02cac08e5668316d1..918079cfe45aa2fbe6f14b155a6edd494e555c1d 100644 (file)
@@ -45,6 +45,26 @@ string DeUniqueSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DeUniqueSeqsCommand::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 =  "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);
+       }
+}
+//**********************************************************************************************************************
 DeUniqueSeqsCommand::DeUniqueSeqsCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -148,9 +168,9 @@ int DeUniqueSeqsCommand::execute() {
                string outFastaFile = m->getRootName(m->getSimpleName(fastaFile));
                int pos = outFastaFile.find("unique");
                if (pos != string::npos) {
-                       outFastaFile = outputDir + outFastaFile.substr(0, pos) + "redundant" + m->getExtension(fastaFile);
+                       outFastaFile = outputDir + outFastaFile.substr(0, pos) + getOutputFileNameTag("fasta");
                }else{
-                       outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "redundant" + m->getExtension(fastaFile);
+                       outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + getOutputFileNameTag("fasta");
                }
                m->openOutputFile(outFastaFile, out);
                
index 300a1caeab4ce8b6b2febb10b6082c857fcfeb93..5310b83b3002c8b3d52b32bdb56bf8cc772eddd2 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "deunique.seqs";               }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 c33c8e4ce19014c0059a89469217993a3f2fe59d..662282b1d05d57e25ee2c259f178d00c5ecf96ca 100644 (file)
@@ -43,6 +43,26 @@ string DeuniqueTreeCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DeuniqueTreeCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 DeuniqueTreeCommand::DeuniqueTreeCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -145,7 +165,7 @@ int DeuniqueTreeCommand::execute() {
         delete reader;         
                
                //print new Tree
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + "deunique.tre";
+               string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
                outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                ofstream out;
                m->openOutputFile(outputFile, out);
index 18a6e5e95491603f051b847467db80512d3ad517..afb25a4a2b777c49f57f16884e36f871568ab1ac 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "deunique.tree";               }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 79b8fe7c10544dafd2675a963a2229eb2e3e7046..99e89bafecdf8c2d5740aeb12446d04b8d9e4fdd 100644 (file)
@@ -59,6 +59,27 @@ string DistanceCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string DistanceCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 DistanceCommand::DistanceCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -229,12 +250,12 @@ int DistanceCommand::execute(){
                string outputFile;
                                
                if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip.dist";
+                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip." + getOutputFileNameTag("phylip");
                        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)) + "dist";
+                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("column");
                        outputTypes["column"].push_back(outputFile);
                        
                        //so we don't accidentally overwrite
@@ -245,7 +266,7 @@ int DistanceCommand::execute(){
                        
                        m->mothurRemove(outputFile);
                }else { //assume square
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist";
+                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square." + getOutputFileNameTag("phylip");
                        m->mothurRemove(outputFile);
                        outputTypes["phylip"].push_back(outputFile);
                }
index 91f0ed50b3003345454690b7aecc049c449854d8..9dea351250b7c7550a1071ca3189051345245d01 100644 (file)
@@ -178,6 +178,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "dist.seqs";                   }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 a7d42b331bc3044de372c030175da4663f9e3a9c..7a8fbc8cdfe6236601dbc0b369f6ef415a5c7c48 100644 (file)
@@ -57,6 +57,27 @@ string FilterSeqsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string FilterSeqsCommand::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 =  "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);
+       }
+}
+//**********************************************************************************************************************
 FilterSeqsCommand::FilterSeqsCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -278,8 +299,8 @@ int FilterSeqsCommand::execute() {
                
                //prevent giantic file name
                string filterFile;
-               if (fastafileNames.size() > 3) { filterFile = outputDir + "merge.filter"; }
-               else {  filterFile = outputDir + filterFileName + ".filter";  }
+               if (fastafileNames.size() > 3) { filterFile = outputDir + "merge." + getOutputFileNameTag("filter"); }
+               else {  filterFile = outputDir + filterFileName + "." + getOutputFileNameTag("filter");  }
                
                m->openOutputFile(filterFile, outFilter);
                outFilter << filter << endl;
@@ -342,7 +363,7 @@ 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])) + "filter.fasta";
+                               string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + getOutputFileNameTag("fasta");
 #ifdef USE_MPI 
                                int pid, numSeqsPerProcessor, num; 
                                int tag = 2001;
index 4405c33f52165d5c89cbe47e8513147cb14dd879..b2322379d6eb0467c2e64ba5e98c28e6d604181c 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();\r
        string getCommandName()                 { return "filter.seqs";                 }\r
        string getCommandCategory()             { return "Sequence Processing"; }\r
+       string getOutputFileNameTag(string, string);\r
        string getHelpString(); \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
index 463c94c41f62d994b0e462cc3c745ac73b733ad0..b72c2368a911996fcdc71d67748533766f9fe637 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.commandinfo";             }
        string getCommandCategory()             { return "Hidden";                              }
+       string getOutputFileNameTag(string, string) {  return "";  }
        string getHelpString(); 
        string getCitation() { return "no citation"; }
        string getDescription()         { return "get.commandinfo"; }
index 47dc963f1bf657ce334326d90d28068df1be44d7..63af3abb3a595cff133a2caac91dea1aa1e420c1 100644 (file)
@@ -51,6 +51,27 @@ string GetCoreMicroBiomeCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string GetCoreMicroBiomeCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 GetCoreMicroBiomeCommand::GetCoreMicroBiomeCommand(){  
        try {
@@ -287,7 +308,7 @@ int GetCoreMicroBiomeCommand::execute(){
 int GetCoreMicroBiomeCommand::createTable(vector<SharedRAbundFloatVector*>& lookup){
        try {
         
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + ".core.microbiome";
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + getOutputFileNameTag("coremicrobiome");
         outputNames.push_back(outputFileName);  outputTypes["coremicrobiome"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
index c8aaab349efdf568b5a24556cf81280e178f3bc5..469214c2916e3e00c466c4f0c1183809382aa3b5 100644 (file)
@@ -26,7 +26,8 @@ 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 getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     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 dfff0fa27d09573ab35d95ddb8c1375f77d9ac5e..f10e6d4e556878d6cb55e30cd7b4ce1138a896da 100644 (file)
@@ -22,7 +22,8 @@ class GetCurrentCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.current"; }
                string getCommandCategory()             { return "General";             }
-               string getHelpString(); 
+        string getOutputFileNameTag(string, string) { return ""; }
+        string getHelpString();        
                string getCitation() { return "http://www.mothur.org/wiki/Get.current"; }
                string getDescription()         { return "get current files saved by mothur"; }
 
index 8dae3f30092d0ae94e8b709119e933252f946f4a..faef2accee559eb7816f8e305c3ee8e5bd2f9c33 100644 (file)
@@ -31,7 +31,6 @@ string GetgroupCommand::getHelpString(){
        try {
                string helpString = "";
                helpString += "The get.group command parameter is shared and it's required if you have no valid current file.\n";
-               //m->mothurOut("The get.group command outputs a .bootGroups file to you can use in addition to the tree file generated by the bootstrap.shared command to run the consensus command.\n");
                helpString += "You may not use any parameters with the get.group command.\n";
                helpString += "The get.group command should be in the following format: \n";
                helpString += "get.group()\n";
@@ -43,13 +42,12 @@ string GetgroupCommand::getHelpString(){
                exit(1);
        }
 }
+
 //**********************************************************************************************************************
 GetgroupCommand::GetgroupCommand(){    
        try {
                abort = true; calledHelp = true; 
                setParameters();
-               vector<string> tempOutNames;
-               outputTypes["bootgroup"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
@@ -78,10 +76,6 @@ GetgroupCommand::GetgroupCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["bootgroup"] = 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);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -122,27 +116,17 @@ int GetgroupCommand::execute(){
        try {
        
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-                       
-               //open output file
-               outputFile = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "bootGroups";
-               m->openOutputFile(outputFile, out);
-               
+                                       
                InputData input(sharedfile, "sharedfile");
                vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
                
                for (int i = 0; i < lookup.size(); i++) {
-                       out << lookup[i]->getGroup() << '\t' << lookup[i]->getGroup() << endl;
                        m->mothurOut(lookup[i]->getGroup()); m->mothurOutEndLine();
                        delete lookup[i];
                }
-               
-               out.close();
-               
-               if (m->control_pressed) {  m->mothurRemove(outputFile);   return 0; }
-               
+                       
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFile); m->mothurOutEndLine();        outputNames.push_back(outputFile); outputTypes["bootgroup"].push_back(outputFile);
                m->mothurOutEndLine();
                
                return 0;       
@@ -153,5 +137,6 @@ int GetgroupCommand::execute(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
 
 
index a3e47e0204e36bfa54970c1d5c0e3ecb9398ab90..7924d7b55a708886c0875bf26f173ffa13cc9da1 100644 (file)
@@ -21,6 +21,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.group";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string) { return "";  }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.group"; }
        string getDescription()         { return "outputs group names"; }
index 5ed31dd84b55ba26ee64a45e9298c84fb60a6be2..fe6f571669bf820d1a153ef3f44327611666b8a1 100644 (file)
@@ -57,6 +57,33 @@ string GetGroupsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string GetGroupsCommand::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 =  "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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 GetGroupsCommand::GetGroupsCommand(){  
        try {
@@ -293,7 +320,7 @@ int GetGroupsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
+               if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); }
                
                if (groupfile != "") {
                        groupMap = new GroupMap(groupfile);
@@ -385,7 +412,7 @@ int GetGroupsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -453,7 +480,7 @@ int GetGroupsCommand::readShared(){
                
                while(lookup[0] != NULL) {
                        
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
+                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("shared", sharedfile);
                        ofstream out;
                        m->openOutputFile(outputFileName, out);
                        outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -498,7 +525,7 @@ int GetGroupsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -591,7 +618,7 @@ int GetGroupsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -672,7 +699,7 @@ int GetGroupsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -719,7 +746,7 @@ int GetGroupsCommand::readDesign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + "pick" + m->getExtension(designfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + getOutputFileNameTag("design", designfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -769,7 +796,7 @@ int GetGroupsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -814,32 +841,6 @@ int GetGroupsCommand::readTax(){
        }
 }
 //**********************************************************************************************************************
-void GetGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 int GetGroupsCommand::fillNames(){
        try {
                vector<string> seqs = groupMap->getNamesSeqs();
index 224f4f07ea1c45d3e734d8f6406e8a17f40fd1fd..80230b49b9872ab4633dbd2d4120826b3cc1ee82 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.groups";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
@@ -47,7 +48,6 @@ private:
        int readFasta();
        int readName();
        int readGroup();
-       void readAccnos();
        int readList();
        int readTax();
        int fillNames();
index c5dc1a119969e3ac10b0462c4ad5090bee1333f3..7a4d9b5885214696ac38a289f95f8ae20af0c239 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.label";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.label"; }
        string getDescription()         { return "outputs labels"; }
index c2be580bb73313c91322e903c87027dc5da405d9..1aba0fed4e6e772de07718a544335b6e6bb58db9 100644 (file)
@@ -57,7 +57,31 @@ string GetLineageCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string GetLineageCommand::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 =  "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 == "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);
+       }
+}
 //**********************************************************************************************************************
 GetLineageCommand::GetLineageCommand(){        
        try {
@@ -298,7 +322,7 @@ int GetLineageCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" +  m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -345,7 +369,7 @@ int GetLineageCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -417,7 +441,7 @@ int GetLineageCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" +  m->getExtension(namefile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -503,7 +527,7 @@ int GetLineageCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -550,7 +574,7 @@ int GetLineageCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -739,7 +763,7 @@ int GetLineageCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
index a6770614b6dfffac32f4e57ce65f451a0046085e..0ab042bac365b64840e32212a6705f62d46d5ff1 100644 (file)
@@ -23,7 +23,8 @@ class GetLineageCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.lineage";                         }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 980c886cc0cb79f51f892ee13fe4dc2c3061b812..b7c4f1790b152371a6e302f3d56ae79fc60badf1 100644 (file)
@@ -49,6 +49,26 @@ string GetListCountCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string GetListCountCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 GetListCountCommand::GetListCountCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -234,7 +254,7 @@ void GetListCountCommand::process(ListVector* list) {
        try {
                string binnames;
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + "." +getOutputFileNameTag("otu");
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
                
index 7a0c1098f331beffdf06829f7c804032f45a8d8b..629e9b98991fa839ccca7a704d582150f47f7d5f 100644 (file)
@@ -28,6 +28,7 @@ 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(); 
        
        int execute(); 
index 40ad69f771c0b7b58602666c22d0c4587486ebdf..a281f9f8a23f98d36f7a4b303bdf7804d945c4c7 100644 (file)
@@ -46,14 +46,36 @@ string GetOtuLabelsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string GetOtuLabelsCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 GetOtuLabelsCommand::GetOtuLabelsCommand(){    
        try {
                abort = true; calledHelp = true;
                setParameters();
         vector<string> tempOutNames;
-               outputTypes["contaxonomy"] = tempOutNames; 
-        outputTypes["otu.corr"] = tempOutNames;
-        outputTypes["corr.axes"] = tempOutNames;
+               outputTypes["constaxonomy"] = tempOutNames; 
+        outputTypes["otucorr"] = tempOutNames;
+        outputTypes["corraxes"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "GetOtuLabelsCommand", "GetOtuLabelsCommand");
@@ -126,9 +148,9 @@ GetOtuLabelsCommand::GetOtuLabelsCommand(string option)  {
             }
             
             vector<string> tempOutNames;
-            outputTypes["contaxonomy"] = tempOutNames; 
-            outputTypes["otu.corr"] = tempOutNames;
-            outputTypes["corr.axes"] = tempOutNames;
+            outputTypes["constaxonomy"] = tempOutNames; 
+            outputTypes["otucorr"] = tempOutNames;
+            outputTypes["corraxes"] = tempOutNames;
             
                        //check for parameters
             accnosfile = validParameter.validFile(parameters, "accnos", true);
@@ -175,7 +197,7 @@ int GetOtuLabelsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
         
         //get labels you want to keep
-               readAccnos();
+               labels = m->readAccnos(accnosfile);
                
                if (m->control_pressed) { return 0; }
                
@@ -204,7 +226,7 @@ int GetOtuLabelsCommand::readClassifyOtu(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(constaxonomyfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + "pick.taxonomy";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + getOutputFileNameTag("constaxonomy");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -255,7 +277,7 @@ int GetOtuLabelsCommand::readOtuAssociation(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(otucorrfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + "pick.corr";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + getOutputFileNameTag("otucorr");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -289,7 +311,7 @@ int GetOtuLabelsCommand::readOtuAssociation(){
         out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any labels from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["otu.corr"].push_back(outputFileName);
+               outputNames.push_back(outputFileName);  outputTypes["otucorr"].push_back(outputFileName);
                
                m->mothurOut("Selected " + toString(selectedCount) + " lines from your otu.corr file."); m->mothurOutEndLine();
                
@@ -306,7 +328,7 @@ int GetOtuLabelsCommand::readCorrAxes(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(corraxesfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + "pick.axes";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + getOutputFileNameTag("corraxes");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -340,7 +362,7 @@ int GetOtuLabelsCommand::readCorrAxes(){
         out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any labels from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["corr.axes"].push_back(outputFileName);
+               outputNames.push_back(outputFileName);  outputTypes["corraxes"].push_back(outputFileName);
                
                m->mothurOut("Selected " + toString(selectedCount) + " lines from your corr.axes file."); m->mothurOutEndLine();
                
@@ -352,30 +374,4 @@ int GetOtuLabelsCommand::readCorrAxes(){
                exit(1);
        }
 }
-
-//**********************************************************************************************************************
-int GetOtuLabelsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-            
-                       labels.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtuLabelsCommand", "readAccnos");
-               exit(1);
-       }
-}
 //**********************************************************************************************************************
index bad0f55beb921acc8907016e0d27b180271a716b..8cfe8b96617516b00bf4809963a361695c457a5c 100644 (file)
@@ -23,7 +23,8 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "get.otulabels";          }
     string getCommandCategory()                { return "OTU-Based Approaches";        } 
-    string getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     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."; }
     
@@ -39,8 +40,6 @@ private:
     int readClassifyOtu();
     int readOtuAssociation();
     int readCorrAxes();
-    int readAccnos();
-    
 };
 
 /**************************************************************************************************/
index 35437e760ac636e51cf9f960d8c36e8a6dfce47e..4ebde29f912f6e9a02d88dbee301488b52d4a082 100644 (file)
@@ -95,6 +95,27 @@ string GetOTURepCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string GetOTURepCommand::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 =  "rep.fasta";   }
+            else if (type == "name")        {   outputFileName =  "rep.names";   }
+            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);
+       }
+}
+//**********************************************************************************************************************
 GetOTURepCommand::GetOTURepCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -771,7 +792,7 @@ int GetOTURepCommand::process(ListVector* processList) {
                map<string, ofstream*> filehandles;
                
                if (Groups.size() == 0) { //you don't want to use groups
-                       outputNamesFile  = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
+                       outputNamesFile  = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + getOutputFileNameTag("name");
                        m->openOutputFile(outputNamesFile, newNamesOutput);
                        outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile); 
                        outputNameFiles[outputNamesFile] = processList->getLabel();
@@ -780,7 +801,7 @@ int GetOTURepCommand::process(ListVector* processList) {
                        for (int i=0; i<Groups.size(); i++) {
                                temp = new ofstream;
                                filehandles[Groups[i]] = temp;
-                               outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".rep.names";
+                               outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + "." + getOutputFileNameTag("name");
                                
                                m->openOutputFile(outputNamesFile, *(temp));
                                outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile);
@@ -868,7 +889,7 @@ 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 + ".rep.fasta";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("fasta");
                m->openOutputFile(outputFileName, out);
                vector<repStruct> reps;
                outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
index 41680008c7dc27b28eb7e9a50ea8e9e621bfeb72..5af0340b4b920a4fab3decc79bd2b3b4237f85ef 100644 (file)
@@ -43,6 +43,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.oturep";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.oturep"; }
        string getDescription()         { return "gets a representative sequence for each OTU"; }
index 4e8d3198c9b6c560d57ff579b26eb9985e452b35..8d20e63b65b9a99b6476608fe4a108ce233718f0 100644 (file)
@@ -53,7 +53,27 @@ string GetOtusCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string GetOtusCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 GetOtusCommand::GetOtusCommand(){      
        try {
@@ -182,7 +202,7 @@ int GetOtusCommand::execute(){
                groupMap->readMap();
                
                //get groups you want to get
-               if (accnosfile != "") { readAccnos(); }
+               if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); }
                
                //make sure groups are valid
                //takes care of user setting groupNames that are invalid or setting groups=all
@@ -231,14 +251,14 @@ int GetOtusCommand::readListGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick." + label +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("list", listfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
                string GroupOutputDir = outputDir;
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick." + label  + m->getExtension(groupfile);
+               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + label + "." + getOutputFileNameTag("group", groupfile);
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
@@ -400,29 +420,5 @@ int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream
        }
 }
 //**********************************************************************************************************************
-void GetOtusCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 
 
index 1a784935c476c22c798f8dfda33008606cc43439..4eff4b69569625561788804e16cf09379c4e97fb 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.otus";                            }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
@@ -42,7 +43,6 @@ private:
        vector<string> outputNames, Groups;
        GroupMap* groupMap;
        
-       void readAccnos();
        int readListGroup();
        int processList(ListVector*&, GroupMap*&, ofstream&, ofstream&, bool&);
        
index 5a33253ff1ec2b67a9e995b940f09349241494f5..5f33f3a1fbab70aad5764b20f4e1d8633c8a865b 100644 (file)
@@ -47,7 +47,26 @@ string GetRAbundCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string GetRAbundCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 GetRAbundCommand::GetRAbundCommand(){  
        try {
@@ -173,7 +192,7 @@ int GetRAbundCommand::execute(){
        
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "rabund";
+               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("rabund");
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);
index cb9e270d170e0ab9dde910fdb7d24ef6c293828f..7e9363080e7bf7b794b3797c37df9527d8f84764 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.rabund";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.rabund"; }
        string getDescription()         { return "creates a rabund file"; }
index 8c8d8e1539b8be7e76656be1304ee1f1f01f9a02..7c623fbfd8ced3cd88bff70b3579e893d6e6cfa0 100644 (file)
@@ -49,6 +49,26 @@ string GetRelAbundCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string GetRelAbundCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 GetRelAbundCommand::GetRelAbundCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -154,7 +174,7 @@ int GetRelAbundCommand::execute(){
        
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "relabund";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("relabund");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
index 1d5163d2bf662566f2ad5923980dfc96f081231f..c5b50e602ef133913061f56b11cc9cadae874d34 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.relabund";                        }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.relabund"; }
        string getDescription()         { return "calculates the relative abundance of each OTU in a sample"; }
index 4ae2eaa004f9df9cc75c12b63626ffa7fad71ea7..5425c41a917f4b02d67c5b4dfcb63e1b2fc6159b 100644 (file)
@@ -45,7 +45,26 @@ string GetSAbundCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string GetSAbundCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 GetSAbundCommand::GetSAbundCommand(){  
        try {
@@ -166,7 +185,7 @@ int GetSAbundCommand::execute(){
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "sabund";
+               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("sabund");
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);
index 5be00df16ebffdb079273befc3f1d03324256c88..4c967b5e9f3455c3a7ceea5fd3dac67a99f9695b 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "get.sabund";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Get.sabund"; }
        string getDescription()         { return "creates a sabund file"; }
index 84fe0acab9abc0ec603df10896be1c0fe1e7f47c..ccabafb6d19c008eb6957a35e79b5cd0623021d0 100644 (file)
@@ -76,6 +76,33 @@ GetSeqsCommand::GetSeqsCommand(){
        }
 }
 //**********************************************************************************************************************
+string GetSeqsCommand::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 =  "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 == "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);
+       }
+}
+//**********************************************************************************************************************
 GetSeqsCommand::GetSeqsCommand(string option)  {
        try {
                abort = false; calledHelp = false;   
@@ -270,7 +297,7 @@ int GetSeqsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get names you want to keep
-               readAccnos();
+               names = m->readAccnos(accnosfile);
                
                if (m->control_pressed) { return 0; }
                
@@ -343,7 +370,7 @@ int GetSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" +  m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -399,7 +426,7 @@ int GetSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "pick" +  m->getExtension(qualfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -471,7 +498,7 @@ int GetSeqsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -550,7 +577,7 @@ int GetSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" +  m->getExtension(namefile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -650,7 +677,7 @@ int GetSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -706,7 +733,7 @@ int GetSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -760,7 +787,7 @@ int GetSeqsCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -827,32 +854,6 @@ int GetSeqsCommand::readAlign(){
        }
 }
 //**********************************************************************************************************************
-
-int GetSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                                               
-                       names.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 //just looking at common mistakes. 
 int GetSeqsCommand::runSanityCheck(){
        try {
@@ -952,7 +953,7 @@ int GetSeqsCommand::compareAccnos(){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(accnosfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(accnosfile)) + "accnos.report";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(accnosfile)) + getOutputFileNameTag("accnosreport");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -1045,7 +1046,7 @@ int GetSeqsCommand::compareAccnos(){
                
        }
        catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readAccnos");
+               m->errorOut(e, "GetSeqsCommand", "compareAccnos");
                exit(1);
        }
 }
index 0f606ffb59ac884b46ac97d861aa3542786d1793..c71b5f2804a71190c6919f0dc80bf80d32f15508 100644 (file)
@@ -23,7 +23,8 @@ class GetSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "get.seqs";                            }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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"; }
 
@@ -44,7 +45,6 @@ class GetSeqsCommand : public Command {
                int readName();
                int readGroup();
                int readAlign();
-               int readAccnos();
                int readList();
                int readTax();
                int readQual();
index 02d8413675bade0cf79f8781987cc45078b74db2..9beca6aa96f75a58891b5326b5cbd94209701656 100644 (file)
@@ -58,6 +58,29 @@ string GetSharedOTUCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string GetSharedOTUCommand::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 =  "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);
+       }
+}
+
 //**********************************************************************************************************************
 GetSharedOTUCommand::GetSharedOTUCommand(){    
        try {
@@ -372,9 +395,9 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
                if (output != "accnos") {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".shared.seqs";
+                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("sharedseqs");
                }else {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".accnos";
+                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("accnos");
                }
                m->openOutputFile(outputFileNames, outNames);
                
@@ -481,7 +504,7 @@ 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 + ".shared.fasta";
+                       string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + "." + getOutputFileNameTag("fasta");
                        ofstream outFasta;
                        m->openOutputFile(outputFileFasta, outFasta);
                        outputNames.push_back(outputFileFasta); outputTypes["fasta"].push_back(outputFileFasta);
index ea6ed94ee687004d88a04e140f187392b05f5b42..e2026d71442b4a1c461ca1028c7dcd6fc4071986 100644 (file)
@@ -28,7 +28,8 @@ class GetSharedOTUCommand : public Command {
                string getCommandName()                 { return "get.sharedseqs";                      }
                string getCommandCategory()             { return "OTU-Based Approaches";        }
                string getRequiredCommand()             { return "none";                                        }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 47136938a19e6c5d4b8dd2b8110849249ac50b06..cf35cd9d6fa4c2a8fe1349b63399eb60007a4217 100644 (file)
@@ -52,6 +52,28 @@ string HClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string HClusterCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 HClusterCommand::HClusterCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -219,13 +241,17 @@ HClusterCommand::HClusterCommand(string option)  {
                                else if (method == "weighted")  { tag = "wn";  }
                                else                                                    { tag = "an";  }
                        
-                               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-                               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-                               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-                               
-                               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-                               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-                               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
+                               string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+                string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+                string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+                
+                m->openOutputFile(sabundFileName,      sabundFile);
+                m->openOutputFile(rabundFileName,      rabundFile);
+                m->openOutputFile(listFileName,        listFile);
+                
+                outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+                outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+                outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
                        }
                }
        }
index aeeb3bc9cb295d93bbec1c33f405dcab27e55673..6bf559ae6937f130679a5b601e939d7b79193acc 100644 (file)
@@ -38,6 +38,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "hcluster";    }
        string getCommandCategory()             { return "Clustering";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 7d9b482564287916f599b0f3148ee4d6a80861f2..d160525c70174131e8d32ac9803f5bcc756cb80f 100644 (file)
@@ -61,6 +61,28 @@ string HeatMapCommand::getHelpString(){
        }
 }
 
+//**********************************************************************************************************************
+
+string HeatMapCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 HeatMapCommand::HeatMapCommand(){      
        try {
index ccd5f4868e9061ed61e4a90ae042ae6bded4fa68..58eaa36b31b67bc1d453958f58336f559397b726 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "heatmap.bin";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 de35075e98ee938e67f1880cada0ebfb1e0ba26a..3de10e6a8cd9411d6829ac699ffd11991af81007 100644 (file)
@@ -72,6 +72,28 @@ string HeatMapSimCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+
+string HeatMapSimCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 HeatMapSimCommand::HeatMapSimCommand(){        
        try {
index 74e20bebb35863128f72c3d85a8398c87ad9a5b2..7b74880955594da0bb863c4b1755cf32c7b429e7 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "heatmap.sim";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 cba07087148b0a537a299746c808f4314ea05806..31dbd2b9014ab27a150663a6eff56c63f2f98f8f 100644 (file)
@@ -25,6 +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 getCitation() { return "no citation"; }
        string getDescription()         { return "help"; }
 
index 9b7ec9fb030becda2b3df217afedcdd40facd4cc..006f1e4d5ee0b046e3216b0f470ce5d5c6200aa0 100644 (file)
@@ -49,9 +49,27 @@ string HomovaCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
-
+string HomovaCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 HomovaCommand::HomovaCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -190,7 +208,7 @@ int HomovaCommand::execute(){
                
                //create a new filename
                ofstream HOMOVAFile;
-               string HOMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "homova";                               
+               string HOMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName)) + getOutputFileNameTag("homova");                          
                m->openOutputFile(HOMOVAFileName, HOMOVAFile);
                outputNames.push_back(HOMOVAFileName); outputTypes["homova"].push_back(HOMOVAFileName);
                
index 4afaeb8e3120b42558f5e555c9237474b27a510e..b6f21097b4fde750934526285f0ab5efe9849ca0 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "homova";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 8d1d7f7a6864b261a0a31611a1e02270730cfd32..f98620b2ee0bd4cc70bc10d1db908d8de40de995 100644 (file)
@@ -57,7 +57,27 @@ string IndicatorCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string IndicatorCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 IndicatorCommand::IndicatorCommand(){  
        try {
@@ -385,7 +405,7 @@ int IndicatorCommand::GetIndicatorSpecies(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary");
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -500,7 +520,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("summary");
                outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
                
                ofstream out;
@@ -520,7 +540,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
                
                string treeOutputDir = outputDir;
                if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + "indicator.tre";
+               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("tree");
                
                
                //create a map from tree node index to names of descendants, save time later to know which sharedRabund you need
index c5112e683dbf78a074aa1df6c1978d3b1fb0756d..2c36c35f6f3025bb3f07760055512b2e0e257914 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "indicator";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 1d1d41fadb4ca36994cefa4dc1c2d608126a93b1..7f8cd9b721fe50e82f4fdf2553e51a6d53b86a22 100644 (file)
@@ -65,6 +65,27 @@ string LibShuffCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string LibShuffCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 LibShuffCommand::LibShuffCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -341,7 +362,7 @@ int LibShuffCommand::printCoverageFile() {
        try {
 
                ofstream outCov;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "libshuff.coverage";
+               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("coverage");
                m->openOutputFile(summaryFile, outCov);
                outputNames.push_back(summaryFile); outputTypes["coverage"].push_back(summaryFile);
                outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
@@ -437,7 +458,7 @@ int LibShuffCommand::printSummaryFile() {
        try {
 
                ofstream outSum;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "libshuff.summary";
+               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("libshuffsummary");
                m->openOutputFile(summaryFile, outSum);
                outputNames.push_back(summaryFile); outputTypes["libshuffsummary"].push_back(summaryFile);
 
index 465a67f02d2858b86e8f79761c7f141813be185c..81ae17ab644287e75a2de30f88427a67937b549d 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "libshuff";                            }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 93b1510d22bc04cc19fec975df447381285b7788..4a12197b9f21534173c92f6d99c389a3aabb907f 100644 (file)
@@ -46,6 +46,27 @@ string ListOtuLabelsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ListOtuLabelsCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 ListOtuLabelsCommand::ListOtuLabelsCommand(){  
        try {
@@ -344,7 +365,7 @@ int ListOtuLabelsCommand::execute(){
 int ListOtuLabelsCommand::createList(vector<SharedRAbundVector*>& lookup){
        try {
         
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + ".otu.labels";
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels");
         outputNames.push_back(outputFileName);  outputTypes["otulabels"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -366,7 +387,7 @@ int ListOtuLabelsCommand::createList(vector<SharedRAbundVector*>& lookup){
 int ListOtuLabelsCommand::createList(vector<SharedRAbundFloatVector*>& lookup){
        try {
         
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + ".otu.labels";
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("otulabels");
         outputNames.push_back(outputFileName);  outputTypes["accnos"].push_back(outputFileName);
                ofstream out;
                m->openOutputFile(outputFileName, out);
index dbfd5d4f06cfc2c8453cfcc7cc2c556e17c882ee..1b10331925c1c91d32e42b06bedcb3f225e32c5a 100644 (file)
@@ -25,7 +25,8 @@ 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 getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     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 afbacc00aaaec2b92c5d81278d16b463c0f43ffe..bfbb0788c5092382f22bea643c5405674361dd67 100644 (file)
@@ -49,7 +49,26 @@ string ListSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string ListSeqsCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 ListSeqsCommand::ListSeqsCommand(){    
        try {
@@ -214,7 +233,7 @@ int ListSeqsCommand::execute(){
                
                if (outputDir == "") {  outputDir += m->hasPath(inputFileName);  }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + "accnos";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("accnos");
 
                ofstream out;
                m->openOutputFile(outputFileName, out);
index f814d8487d81fc98e98f2245ee13c5564ec5424b..1a31a6dd432e837159be8d916f7ce2a25e4d4dec 100644 (file)
@@ -23,7 +23,8 @@ class ListSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "list.seqs";                           }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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"; }
 
diff --git a/loadlogfilecommand.cpp b/loadlogfilecommand.cpp
new file mode 100644 (file)
index 0000000..66eb7b6
--- /dev/null
@@ -0,0 +1,251 @@
+//
+//  loadlogfilecommand.cpp
+//  Mothur
+//
+//  Created by Sarah Westcott on 6/13/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+#include "loadlogfilecommand.h"
+#include "commandoptionparser.hpp"
+#include "commandfactory.hpp"
+#include "setcurrentcommand.h"
+
+//**********************************************************************************************************************
+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);
+               
+               vector<string> myArray;
+               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LoadLogfileCommand", "setParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+string LoadLogfileCommand::getHelpString(){    
+       try {
+               string helpString = "";
+               helpString += "The load.logfile command extracts the current file names from a logfile.\n";
+               helpString += "The load.logfile parameter is logfile, and it is required.\n";
+               helpString += "The load.logfile command should be in the following format: \n";
+               helpString += "load.logfile(logfile=yourLogFile)\n";
+               return helpString;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LoadLogfileCommand", "getHelpString");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+LoadLogfileCommand::LoadLogfileCommand(){      
+       try {
+               abort = true; calledHelp = true;
+               setParameters();
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LoadLogfileCommand", "LoadLogfileCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+LoadLogfileCommand::LoadLogfileCommand(string option)  {
+       try {
+               abort = false; calledHelp = false;   
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
+               
+               else {
+                       //valid paramters for this command
+                       vector<string> myArray = setParameters();
+                       
+                       OptionParser parser(option);
+                       map<string,string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+                       map<string,string>::iterator it;
+                       //check to make sure all parameters are valid for command
+                       for (it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+            
+                       //if the user changes the input directory command factory will send this info to us in the output parameter 
+                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
+                       if (inputDir == "not found"){   inputDir = "";          }
+                       else {
+                
+                string path;
+                               it = parameters.find("logfile");
+                               //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["logfile"] = inputDir + it->second;          }
+                               }
+                               
+            }
+                        
+            //get shared file, it is required
+                       logfile = validParameter.validFile(parameters, "logfile", true);
+                       if (logfile == "not open") { logfile = ""; abort = true; }      
+                       else if (logfile == "not found") { m->mothurOut("The logfile parameter is required."); m->mothurOutEndLine();abort = true;  }
+            
+            //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(logfile); //if user entered a file with a path then preserve it  
+                       }
+        }
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NewCommand", "NewCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+int LoadLogfileCommand::execute(){
+       try {
+               
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
+        
+        m->mothurOutEndLine(); 
+        m->mothurOut("Extracting current files names..."); m->mothurOutEndLine(); 
+        m->mothurOutEndLine(); 
+        
+        CommandFactory* cFactory;
+        cFactory = CommandFactory::getInstance();
+        
+        ifstream in;
+        m->openInputFile(logfile, in);
+        
+        set<string> currentTypes = m->getCurrentTypes();
+        map<string, string> currentFiles;
+        string commandName = "";
+        bool skip = false;
+        string line = "";
+        
+        while (!in.eof()) {
+            if (m->control_pressed) { break; }
+
+            if (!skip) {  line = m->getline(in); m->gobble(in); }
+            m->gobble(in);
+             
+            //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("*****************"); 
+            
+            //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("*****************");
+                    if (posTemp != string::npos) { break; }
+                }
+            }
+            
+            if (pos != string::npos) { 
+                skip=false;
+                //extract command name and option string
+                string input = line.substr(pos+9);
+                CommandOptionParser parser(input);
+                commandName = parser.getCommandString();
+                string options = parser.getOptionString();
+                
+                //parse out parameters in option string
+                map<string,string> parameters;
+                OptionParser optionParser(options, parameters);
+                
+                for (map<string, string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
+                    if (currentTypes.count((it->first)) != 0) { //if this is a type we save
+                        if (it->second != "current") { currentFiles[it->first] = it->second; }//save the input file name as current
+                    }
+                }
+            }else if (pos2 != string::npos) { 
+                //read file output file names
+                vector<string> theseOutputNames;
+                while (!in.eof()) {
+                    if (m->control_pressed) { break; }
+                    line = m->getline(in); m->gobble(in); 
+                    int pos = line.find("mothur > ");
+                    if (pos != string::npos) { skip = true; break;  }
+                    else {  theseOutputNames.push_back(line);  }
+                }
+                //ask command for the output names for each type based on inputs
+                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
+                        map<string, string>::iterator itCurrentFiles = currentFiles.find(it->first);
+                        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;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        in.close();
+        
+        if (m->control_pressed) { return 0; }
+                
+        //output results
+        string inputString = "";
+        for (map<string, string>::iterator it = currentFiles.begin(); it != currentFiles.end(); it++) { inputString += it->first + "=" + it->second + ","; }
+        
+        if (inputString != "") { 
+            inputString = inputString.substr(0, inputString.length()-1); 
+            m->mothurOutEndLine(); 
+                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
+                       m->mothurOut("Running command: set.current(" + inputString + ")"); m->mothurOutEndLine(); 
+                       m->mothurCalling = true;
+            
+                       Command* currentCommand = new SetCurrentCommand(inputString);
+                       currentCommand->execute();
+                       
+            delete currentCommand;
+                       m->mothurCalling = false;
+                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
+                       
+
+        } 
+        
+        return 0;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "LoadLogfileCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+
diff --git a/loadlogfilecommand.h b/loadlogfilecommand.h
new file mode 100644 (file)
index 0000000..0fd82a8
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef Mothur_loadlogfilecommand_h
+#define Mothur_loadlogfilecommand_h
+
+//
+//  loadlogfilecommand.h
+//  Mothur
+//
+//  Created by Sarah Westcott on 6/13/12.
+//  Copyright (c) 2012 Schloss Lab. All rights reserved.
+//
+
+
+#include "command.hpp"
+
+/**************************************************************************************************/
+
+class LoadLogfileCommand : public Command {
+public:
+    LoadLogfileCommand(string);
+    LoadLogfileCommand();
+    ~LoadLogfileCommand(){}
+    
+    vector<string> setParameters();
+    string getCommandName()                    { return "load.logfile";                }
+    string getCommandCategory()                { return "General";             } 
+    string getOutputFileNameTag(string, string) { return ""; }
+       string getHelpString(); 
+    string getCitation() { return "http://www.mothur.org/wiki/Load.logfile"; }
+    string getDescription()            { return "extracts current files from a logfile"; }
+    
+    int execute(); 
+    void help() { m->mothurOut(getHelpString()); }     
+    
+private:
+    bool abort;
+    string outputDir, logfile;
+    vector<string> outputNames;
+};
+
+/**************************************************************************************************/
+
+
+
+
+#endif
index 03e7baf2b9888fc7f52cbe6076ea8fdfa472b584..9e8d3e39cb58e31e9f3dca2eeff35257eadd537a 100644 (file)
@@ -129,6 +129,27 @@ string MakeBiomCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string MakeBiomCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 MakeBiomCommand::MakeBiomCommand(){    
        try {
@@ -352,7 +373,7 @@ int MakeBiomCommand::execute(){
 int MakeBiomCommand::getBiom(vector<SharedRAbundVector*>& lookup){
        try {
         
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".biom";
+        string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("biom");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["biom"].push_back(outputFileName);
index 9f80c2e70215b130a9020a83ce2daebb9e63a089..8a458fe33a398de607ffe05e48a5950b9368353c 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.biom";   }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 523edd5e8ba1fd00f1bf5050a380b43e1549ee4f..ed2f05d5559584101fc77c55c09b2af3d078729d 100644 (file)
@@ -56,7 +56,28 @@ string MakeContigsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string MakeContigsCommand::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 =  "contigs.fasta";         }
+            else if (type == "qfile")        {   outputFileName =  "contigs.qual";          }
+            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);
+       }
+}
 //**********************************************************************************************************************
 MakeContigsCommand::MakeContigsCommand(){      
        try {
@@ -189,9 +210,9 @@ int MakeContigsCommand::execute(){
     
         if (m->control_pressed) { return 0; }
         
-        string outFastaFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "contigs.fasta";
-        string outQualFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "contigs.qual";
-        string outMisMatchFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + "contigs.mismatches";
+        string outFastaFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + getOutputFileNameTag("fasta");
+        string outQualFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + getOutputFileNameTag("qfile");
+        string outMisMatchFile = outputDir + m->getRootName(m->getSimpleName(ffastqfile)) + getOutputFileNameTag("mismatches");
         outputNames.push_back(outFastaFile); outputTypes["fasta"].push_back(outFastaFile);
         outputNames.push_back(outQualFile); outputTypes["qfile"].push_back(outQualFile);
         outputNames.push_back(outMisMatchFile); outputTypes["mismatch"].push_back(outMisMatchFile);
index cc088421bd7772cc6e6841abb178ab1ffd1e9a3f..dc094a2b3e951218447927d9ceeb639d8b833f53 100644 (file)
@@ -41,7 +41,8 @@ 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 getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     string getCitation() { return "http://www.mothur.org/wiki/Make.contigs"; }
     string getDescription()            { return "description"; }
     
index 0f6e030bb0d1fec3f7cf99614fa0827c66de2bb5..c6dcf2c83092303abdd685848efe9c875ca75976 100644 (file)
@@ -46,6 +46,26 @@ string MakeFastQCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MakeFastQCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MakeFastQCommand::MakeFastQCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -145,7 +165,7 @@ int MakeFastQCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "fastq";
+               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fastq");
                outputNames.push_back(outputFile); outputTypes["fastq"].push_back(outputFile);
                
                ofstream out;
index 1c209aab392f82a06ec5bce2d92811e20286df69..9119ebd50c4c9362e73a72902b888d4f1d06b887 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.fastq";                          }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Make.fastq"; }
        string getDescription()         { return "creates a fastq file from a fasta and quality file"; }
index 0add62e03a99270babfde920acca61a65dcdc2b3..77c2a2911468fe8c0cd123eddce3346b02a4c54c 100644 (file)
@@ -48,6 +48,26 @@ string MakeGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MakeGroupCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MakeGroupCommand::MakeGroupCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -165,8 +185,8 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                }
                                
                                //prevent giantic file name
-                               if (fastaFileNames.size() > 3) { filename = outputDir + "merge.groups"; }
-                               else {  filename += "groups";  }
+                               if (fastaFileNames.size() > 3) { filename = outputDir + "merge." + getOutputFileNameTag("group"); }
+                               else {  filename += getOutputFileNameTag("group");  }
                                
                                //make sure there is at least one valid file left
                                if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
index e0c709204a6be01c637bf3ada3fbdb73a8c7b3d8..b8521d76b1d398dd0cde7419e10750931a7b8fc4 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.group";  }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Make.group"; }
        string getDescription()         { return "creates a group file"; }
index 409eae414779acb412abec7aa295b61e82cd0e16..f3259e6096c3e0c1373e1c091078c9ceac377f82 100644 (file)
@@ -50,6 +50,26 @@ string MantelCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MantelCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MantelCommand::MantelCommand(){        
        try {
                abort = true; calledHelp = true;
@@ -206,7 +226,7 @@ int MantelCommand::execute(){
                
                if (m->control_pressed) { return 0; }
                
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(phylipfile1)) + "mantel";
+               string outputFile = outputDir + m->getRootName(m->getSimpleName(phylipfile1)) + getOutputFileNameTag("mantel");
                outputNames.push_back(outputFile); outputTypes["mantel"].push_back(outputFile);
                ofstream out;
                
index 0a2c4045960911c65c4ea43213c08add648663a6..644d9b21ded9302bc8be1eff6b011b17fec278ac 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "mantel";                                      }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 e1c8a984d7539dcc36379bc18df72e7f6002aeac..4b92c577fa3f5ef319fb8805eaef432e793c8d2e 100644 (file)
@@ -61,6 +61,26 @@ string MatrixOutputCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MatrixOutputCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MatrixOutputCommand::MatrixOutputCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -653,7 +673,7 @@ 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 + ".dist";
+                    string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + "." + getOutputFileNameTag("phylip");
                     outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                     ofstream outDist;
                     m->openOutputFile(distFileName, outDist);
@@ -757,7 +777,7 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                     stdmatrix[column][row] = stdDist;
                 }
             
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave.dist";
+                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave." + getOutputFileNameTag("phylip");
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outAve;
                 m->openOutputFile(distFileName, outAve);
@@ -767,7 +787,7 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                 
                 outAve.close();
                 
-                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std.dist";
+                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std." + getOutputFileNameTag("phylip");
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outSTD;
                 m->openOutputFile(distFileName, outSTD);
index 594fe30952a19921dd3e78b330661bc490442fdc..ff05ef70a30736f661379608ecd291e388cf9301 100644 (file)
@@ -73,6 +73,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "dist.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 04c92fae9a0d2189cb8f1ed69c9c53572fcfee2e..0501859e258f82410fa8360ae86092a0b1ea86f6 100644 (file)
@@ -41,7 +41,6 @@ string MergeFileCommand::getHelpString(){
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
 MergeFileCommand::MergeFileCommand(){  
        try {
@@ -130,29 +129,10 @@ int MergeFileCommand::execute(){
        try {
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
-               ofstream outputFile;
-               m->openOutputFile(outputFileName, outputFile);
-               
-               char c;
-               for(int i=0;i<numInputFiles;i++){
-                       ifstream inputFile; //declaration must be inside for loop of windows throws an error
-                       
-                       m->openInputFile(fileNames[i], inputFile);
-                       
-                       while(!inputFile.eof()){        
-                               if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); m->mothurRemove(outputFileName); return 0;  }
-                       
-                               c = inputFile.get(); 
-                               //-1 is eof char
-                               if (int(c) != -1) { outputFile << c; }   
-                       }
-                       
-                       inputFile.close();
-               }
-               
-               outputFile.close();
+               m->mothurRemove(outputFileName);
+               for(int i=0;i<numInputFiles;i++){  m->appendFiles(fileNames[i], outputFileName);  }
                
-               if (m->control_pressed) { outputTypes.clear();  m->mothurRemove(outputFileName); return 0;  }
+               if (m->control_pressed) {  m->mothurRemove(outputFileName); return 0;  }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
index 1c3c4d5a5ea12a6bcbc9cae3cd9eca54b3bd083d..9cb999bba52122480ae3a8f8d889281f9b5dd758 100644 (file)
@@ -22,6 +22,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "merge.files"; }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string) { return "";  }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Merge.files"; }
        string getDescription()         { return "appends files creating one file"; }
index e30558cbe69d3069135e0432f2eda7f9623095b5..5a672204973d252ce0fca2968c97acfdd112c5b5 100644 (file)
@@ -53,6 +53,27 @@ string MergeGroupsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MergeGroupsCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MergeGroupsCommand::MergeGroupsCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -284,8 +305,8 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "merge" +  m->getExtension(sharedfile);
-               outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("shared", sharedfile);
+        outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -387,7 +408,7 @@ int MergeGroupsCommand::processGroupFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "merge" +  m->getExtension(groupfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
index 7f216ebed7653a2647c4770e4ce17e5e6d881e95..4db344763950b4d53376b3d44e5afebef61db2f8 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "merge.groups";        }
        string getCommandCategory()             { return "General";                     }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 c5d349bc77b685b67a1e3251fa70f15602bb215d..b5b01e7f97166ed80143d349b9ae8c340d53e654 100644 (file)
@@ -60,6 +60,27 @@ string MetaStatsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string MetaStatsCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 MetaStatsCommand::MetaStatsCommand(){  
        try {
@@ -449,7 +470,7 @@ 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 + ".metastats";
+                       string outputFileName = outputDir +  m->getRootName(m->getSimpleName(sharedfile)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + "." + getOutputFileNameTag("metastats");
                        outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
                        //int nameLength = outputFileName.length();
                        //char * output = new char[nameLength];
index b4800b71d75bcda1bfa5a39db6f8191849d0b348..377adf18db177f145e1578d41e455fd7c70d6733 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "metastats";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 9c45afe95277b5c7106e3f87f64e60e53b9bf321..870536d4640e5a0de07d24d4fd8799e218359a34 100644 (file)
@@ -61,6 +61,28 @@ string MGClusterCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string MGClusterCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 MGClusterCommand::MGClusterCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -223,10 +245,13 @@ int MGClusterCommand::execute(){
                else if (method == "nearest")   { tag = "nn";  }
                else                                                    { tag = "an";  }
                
-               //open output files
-               m->openOutputFile(fileroot+ tag + ".list",  listFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",  rabundFile);
-               m->openOutputFile(fileroot+ tag + ".sabund",  sabundFile);
+        string sabundFileName = fileroot+ tag + "." + getOutputFileNameTag("sabund");
+        string rabundFileName = fileroot+ tag + "." + getOutputFileNameTag("rabund");
+        string listFileName = fileroot+ tag + "." + getOutputFileNameTag("list");
+        
+               m->openOutputFile(sabundFileName,       sabundFile);
+               m->openOutputFile(rabundFileName,       rabundFile);
+               m->openOutputFile(listFileName, listFile);
                
                if (m->control_pressed) { 
                        delete nameMap; delete read; delete list; delete rabund; 
@@ -493,9 +518,9 @@ int MGClusterCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(fileroot+ tag + ".list"); m->mothurOutEndLine();   outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
-               m->mothurOut(fileroot+ tag + ".rabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
+               m->mothurOut(listFileName); m->mothurOutEndLine();      outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
+               m->mothurOut(rabundFileName); m->mothurOutEndLine();    outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+               m->mothurOut(sabundFileName); m->mothurOutEndLine();    outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
                m->mothurOutEndLine();
                
                if (saveCutoff != cutoff) { 
index df0c526f2071636e87b0c2a403d2410324a8b89d..ea2c1de8603d746277017d8b557fcc5171c9af39 100644 (file)
@@ -31,6 +31,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "mgcluster";   }
        string getCommandCategory()             { return "Clustering";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 f98bea8ca92fbb387ad0d3727dbfbc858da49583..eacad376e1e91a519feff3c8e57727662042599b 100644 (file)
@@ -18,8 +18,45 @@ MothurOut* MothurOut::getInstance() {
        return _uniqueInstance;
 }
 /*********************************************************************************************/
+set<string> MothurOut::getCurrentTypes()  {
+       try {
+        
+        set<string> types;
+        types.insert("fasta");
+        types.insert("accnos");
+        types.insert("column");
+        types.insert("design");
+        types.insert("group");
+        types.insert("list");
+        types.insert("name");
+        types.insert("oligos");
+        types.insert("order");
+        types.insert("ordergroup");
+        types.insert("phylip");
+        types.insert("qfile");
+        types.insert("relabund");
+        types.insert("sabund");
+        types.insert("rabund");
+        types.insert("sff");
+        types.insert("shared");
+        types.insert("taxonomy");
+        types.insert("tree");
+        types.insert("flow");
+        types.insert("biom");
+        types.insert("processors");
+
+               return types;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "getCurrentTypes");
+               exit(1);
+       }
+}
+/*********************************************************************************************/
 void MothurOut::printCurrentFiles()  {
        try {
+        
+        
                if (accnosfile != "")           {  mothurOut("accnos=" + accnosfile); mothurOutEndLine();                       }
                if (columnfile != "")           {  mothurOut("column=" + columnfile); mothurOutEndLine();                       }
                if (designfile != "")           {  mothurOut("design=" + designfile); mothurOutEndLine();                       }
@@ -1477,7 +1514,163 @@ vector<string> MothurOut::splitWhiteSpace(string& rest, char buffer[], int size)
         return pieces;
        }
        catch(exception& e) {
-               errorOut(e, "MothurOut", "parsePieces");
+               errorOut(e, "MothurOut", "splitWhiteSpace");
+               exit(1);
+       }
+}
+/***********************************************************************/
+vector<string> MothurOut::splitWhiteSpace(string input){
+       try {
+        vector<string> pieces;
+        string rest = "";
+        
+        for (int i = 0; i < input.length(); i++) {
+            if (!isspace(input[i]))  { rest += input[i];  }
+            else {
+                pieces.push_back(rest);  rest = "";
+                while (i < input.length()) {  //gobble white space
+                    if (isspace(input[i])) { i++; }
+                    else { rest = input[i];  break; } //cout << "next piece buffer = " << nextPiece << endl;
+                } 
+            }
+        }
+        
+        if (rest != "") { pieces.push_back(rest); }
+        
+        return pieces;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "splitWhiteSpace");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int MothurOut::readTax(string namefile, map<string, string>& taxMap) {
+       try {
+               
+        //open input file
+               ifstream in;
+               openInputFile(namefile, in);
+        
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
+        string firstCol, secondCol;
+        
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+            in.read(buffer, 4096);
+            vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //are there confidence scores, if so remove them
+                    if (secondCol.find_first_of('(') != -1) {  removeConfidences(secondCol);   }
+                    taxMap[firstCol] = secondCol;
+                    if (debug) {  mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n");  }
+                    pairDone = false; 
+                }
+            }
+               }
+               in.close();
+               
+               return taxMap.size();
+
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readTax");
+               exit(1);
+       }
+}
+/**********************************************************************************************************************/
+int MothurOut::readNames(string namefile, map<string, string>& nameMap, bool redund) { 
+       try {
+               
+               //open input file
+               ifstream in;
+               openInputFile(namefile, in);
+        
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
+        string firstCol, secondCol;
+        
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+            in.read(buffer, 4096);
+            vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //parse names into vector
+                    vector<string> theseNames;
+                    splitAtComma(secondCol, theseNames);
+                    for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = firstCol;  }
+                    pairDone = false; 
+                }
+            }
+               }
+               in.close();
+               
+               return nameMap.size();
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readNames");
+               exit(1);
+       }
+}
+/**********************************************************************************************************************/
+int MothurOut::readNames(string namefile, map<string, string>& nameMap, map<string, int>& nameCount) { 
+       try {
+               nameMap.clear(); nameCount.clear();
+               //open input file
+               ifstream in;
+               openInputFile(namefile, in);
+        
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
+        string firstCol, secondCol;
+        
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+            in.read(buffer, 4096);
+            vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //parse names into vector
+                    vector<string> theseNames;
+                    splitAtComma(secondCol, theseNames);
+                    for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = firstCol;  }
+                    nameCount[firstCol] = theseNames.size();
+                    pairDone = false; 
+                }
+            }
+               }
+               in.close();
+               
+               return nameMap.size();
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readNames");
                exit(1);
        }
 }
@@ -1652,7 +1845,62 @@ int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, m
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+set<string> MothurOut::readAccnos(string accnosfile){
+       try {
+               set<string> names;
+               ifstream in;
+               openInputFile(accnosfile, in);
+               string name;
+               
+        string rest = "";
+        char buffer[4096];
+        
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+            in.read(buffer, 4096);
+            vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {  names.insert(pieces[i]);  }
+        }
+               in.close();     
+               
+               return names;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readAccnos");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int MothurOut::readAccnos(string accnosfile, vector<string>& names){
+       try {
+        names.clear();
+               ifstream in;
+               openInputFile(accnosfile, in);
+               string name;
+               
+        string rest = "";
+        char buffer[4096];
+        
+               while (!in.eof()) {
+                       if (control_pressed) { break; }
+                       
+            in.read(buffer, 4096);
+            vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {  names.push_back(pieces[i]);  }
+        }
+               in.close();     
+               
+               return 0;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "readAccnos");
+               exit(1);
+       }
+}
 /***********************************************************************/
 
 int MothurOut::getNumNames(string names){
index b19c05a68381c3ca96e19264e0eca931e22a0895..b2c638a167d1ebf507106cc300231f0f693471b0 100644 (file)
@@ -98,8 +98,14 @@ class MothurOut {
                void gobble(istream&);
                void gobble(istringstream&);
         vector<string> splitWhiteSpace(string& rest, char[], int);
-               map<string, int> readNames(string);
+        vector<string> splitWhiteSpace(string);
+        set<string> readAccnos(string);
+        int readAccnos(string, vector<string>&);
+        map<string, int> readNames(string);
+        int readTax(string, map<string, string>&);
+        int readNames(string, map<string, string>&, map<string, int>&);
                int readNames(string, map<string, string>&);
+        int readNames(string, map<string, string>&, bool);
                int readNames(string, map<string, vector<string> >&);
                int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
                int mothurRemove(string);
@@ -145,7 +151,7 @@ class MothurOut {
                int control_pressed;
                bool executing, runParse, jumble, gui, mothurCalling, debug;
                
-               //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles.
+               //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles/getCurrentTypes.
                string getPhylipFile()          { return phylipfile;            }
                string getColumnFile()          { return columnfile;            }
                string getListFile()            { return listfile;                      }
@@ -190,11 +196,12 @@ class MothurOut {
                void setTaxonomyFile(string f)          { taxonomyfile = getFullPathName(f);            }
                void setFlowFile(string f)                      { flowfile = getFullPathName(f);                        }
         void setBiomFile(string f)                     { biomfile = getFullPathName(f);                        }
-               void setProcessors(string p)            { processors = p;                                                       }
+        void setProcessors(string p)           { processors = p; mothurOut("\nUsing " + toString(p) + " processors.\n");       }
                
                void printCurrentFiles();
                bool hasCurrentFiles();
                void clearCurrentFiles();
+        set<string> getCurrentTypes(); 
                
        private:
                static MothurOut* _uniqueInstance;
index 92992061f29e2d01a65eb09445e6827caef2624f..085039eb1b9c3313acb5541744c5484abf49312a 100644 (file)
@@ -64,6 +64,28 @@ string NewCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string NewCommand::getOutputFileNameTag(string type, string inputName=""){     
+       try {
+        string tag = "";
+               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 == "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);
+       }
+}
+//**********************************************************************************************************************
 NewCommand::NewCommand(){      
        try {
                abort = true; calledHelp = true;
@@ -71,7 +93,7 @@ NewCommand::NewCommand(){
         vector<string> tempOutNames;
                outputTypes["fileType1"] = tempOutNames; //filetypes should be things like: shared, fasta, accnos...
                outputTypes["fileType2"] = tempOutNames;
-               outputTypes["FileType2"] = tempOutNames;
+               outputTypes["FileType3"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "NewCommand", "NewCommand");
index 5fd36b17af596785a2ff99d065ca02e3372d1e71..ae57bd81de4b78d5aff12757341dec0068139d0c 100644 (file)
@@ -35,8 +35,9 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "newCommandNameToBeSeenByUser";                        }
     string getCommandCategory()                { return "commandCategory";             } 
+    string getOutputFileNameTag(string, 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 e2a3712a410738b0396884accc41bdd555caa735..900f50bd43ffb2aaee98f279023e684bb8d7c00d 100644 (file)
@@ -55,6 +55,28 @@ string NMDSCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string NMDSCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 NMDSCommand::NMDSCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -186,8 +208,8 @@ int NMDSCommand::execute(){
                vector< vector<double> > axes;
                if (axesfile != "") {  axes = readAxes(names);          }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.iters";
-               string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.stress";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("iters");
+               string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("stress");
                outputNames.push_back(outputFileName); outputTypes["iters"].push_back(outputFileName);
                outputNames.push_back(stressFileName); outputTypes["stress"].push_back(stressFileName);
                
@@ -256,7 +278,7 @@ int NMDSCommand::execute(){
                out.close(); out2.close();
                
                //output best config
-               string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.axes";
+               string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + getOutputFileNameTag("nmds");
                outputNames.push_back(BestFileName); outputTypes["nmds"].push_back(BestFileName);
                
                m->mothurOut("\nNumber of dimensions:\t" + toString(bestDim) + "\n");
index c05c9fe36cfd1d2ecbf545451d753fe25b946968..90364adcdc03198320a12c86fc0ef4b7f970c650 100644 (file)
@@ -37,6 +37,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "nmds";                                        }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 5ed7e127d09ce645aa11cd43dd2192a1155b42dc..a5855dced6a50c8a808464421ceb34dd6cd5aa24 100644 (file)
@@ -21,12 +21,13 @@ public:
        NoCommand() {}
        ~NoCommand(){}
        
-       vector<string> setParameters()  { return outputNames;   } //dummy, doesn't really do anything   
-       string getCommandName()                 { return "NoCommand";   }
-       string getCommandCategory()             { return "Hidden";              }
-       string getHelpString() { return "No Command"; } 
-       string getCitation() { return "no citation"; }
-       string getDescription()         { return "no description"; }
+       vector<string> setParameters()      { return outputNames;       } //dummy, doesn't really do anything   
+       string getCommandName()             { return "NoCommand";       }
+       string getCommandCategory()         { return "Hidden";          }
+       string getHelpString()              { return "No Command";      }       
+    string getOutputFileNameTag(string, string) { return "";                }
+       string getCitation()                { return "no citation";     }
+       string getDescription()             { return "no description";  }
 
        
        int execute(); 
index bbf9a8335a3c2847f89b8cf136670c03a73e9725..e41cfd9355ce1e08157069e59880aa32066e1505 100644 (file)
@@ -54,7 +54,26 @@ string NormalizeSharedCommand::getHelpString(){
        }
 }
 
-
+//**********************************************************************************************************************
+string NormalizeSharedCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 NormalizeSharedCommand::NormalizeSharedCommand(){      
        try {
@@ -449,7 +468,7 @@ int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
                
                if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + ".norm.shared";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
@@ -540,7 +559,7 @@ 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() + ".norm.shared";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + "." + getOutputFileNameTag("shared");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
index 4b6f7fd9e93f4912bf648f2c826ab0a09b15910c..2feb40d1bcf105a485b5790ebc3be2484a94f0d5 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "normalize.shared";            }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Normalize.shared"; }
        string getDescription()         { return "normalize samples in a shared or relabund file"; }
index 0d6ed2d4d0bfa681a7aa30693bcb7ae30a9c77fb..2d13cd0cc5d2e1706d424c92440cd97c426b8fa8 100644 (file)
@@ -38,7 +38,37 @@ OptionParser::OptionParser(string option) {
                exit(1);
        }
 }
+/***********************************************************************/
 
+OptionParser::OptionParser(string option, map<string, string>& copy) {
+       try {
+               m = MothurOut::getInstance();
+               if (option != "") {
+                       
+                       string key, value;              
+                       //reads in parameters and values
+                       while((option.find_first_of(',') != -1)) {  //while there are parameters
+                               m->splitAtComma(value, option);
+                               m->splitAtEquals(key, value);
+                               if ((key == "candidate") || (key == "query")) { key = "fasta"; }
+                               if (key == "template") { key = "reference"; }
+                               parameters[key] = value;
+                       }
+                       
+                       //in case there is no comma and to get last parameter after comma
+                       m->splitAtEquals(key, option);
+                       if ((key == "candidate") || (key == "query")) { key = "fasta"; }
+                       if (key == "template") { key = "reference"; }
+                       parameters[key] = option;
+               }
+        
+        copy = parameters;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OptionParser", "OptionParser");
+               exit(1);
+       }
+}
 /***********************************************************************/
 
 map<string, string> OptionParser::getParameters() {    
@@ -47,65 +77,66 @@ map<string, string> OptionParser::getParameters() {
                //loop through parameters and look for "current" so you can return the appropriate file
                //doing it here to avoid code duplication in each of the commands
                
-               map<string, string>::iterator it;
-               for (it = parameters.begin(); it != parameters.end();) {
-                       
-                       if (it->second == "current") {
-                               
-                               //look for file types
-                               if (it->first == "fasta") {
-                                       it->second = m->getFastaFile();
-                               }else if (it->first == "qfile") {
-                                       it->second = m->getQualFile();
-                               }else if (it->first == "phylip") {
-                                       it->second = m->getPhylipFile();
-                               }else if (it->first == "column") {
-                                       it->second = m->getColumnFile();
-                               }else if (it->first == "list") {
-                                       it->second = m->getListFile();
-                               }else if (it->first == "rabund") {
-                                       it->second = m->getRabundFile();
-                               }else if (it->first == "sabund") {
-                                       it->second = m->getSabundFile();
-                               }else if (it->first == "name") {
-                                       it->second = m->getNameFile();
-                               }else if (it->first == "group") {
-                                       it->second = m->getGroupFile();
-                               }else if (it->first == "order") {
-                                       it->second = m->getOrderFile();
-                               }else if (it->first == "ordergroup") {
-                                       it->second = m->getOrderGroupFile();
-                               }else if (it->first == "tree") {
-                                       it->second = m->getTreeFile();
-                               }else if (it->first == "shared") {
-                                       it->second = m->getSharedFile();
-                               }else if (it->first == "relabund") {
-                                       it->second = m->getRelAbundFile();
-                               }else if (it->first == "design") {
-                                       it->second = m->getDesignFile();
-                               }else if (it->first == "sff") {
-                                       it->second = m->getSFFFile();
-                               }else if (it->first == "oligos") {
-                                       it->second = m->getOligosFile();
-                               }else if (it->first == "accnos") {
-                                       it->second = m->getAccnosFile();
-                               }else if (it->first == "taxonomy") {
-                                       it->second = m->getTaxonomyFile();
-                }else if (it->first == "biom") {
+       
+            map<string, string>::iterator it;
+            for (it = parameters.begin(); it != parameters.end();) {
+                
+                if (it->second == "current") {
+                    
+                    //look for file types
+                    if (it->first == "fasta") {
+                        it->second = m->getFastaFile();
+                    }else if (it->first == "qfile") {
+                        it->second = m->getQualFile();
+                    }else if (it->first == "phylip") {
+                        it->second = m->getPhylipFile();
+                    }else if (it->first == "column") {
+                        it->second = m->getColumnFile();
+                    }else if (it->first == "list") {
+                        it->second = m->getListFile();
+                    }else if (it->first == "rabund") {
+                        it->second = m->getRabundFile();
+                    }else if (it->first == "sabund") {
+                        it->second = m->getSabundFile();
+                    }else if (it->first == "name") {
+                        it->second = m->getNameFile();
+                    }else if (it->first == "group") {
+                        it->second = m->getGroupFile();
+                    }else if (it->first == "order") {
+                        it->second = m->getOrderFile();
+                    }else if (it->first == "ordergroup") {
+                        it->second = m->getOrderGroupFile();
+                    }else if (it->first == "tree") {
+                        it->second = m->getTreeFile();
+                    }else if (it->first == "shared") {
+                        it->second = m->getSharedFile();
+                    }else if (it->first == "relabund") {
+                        it->second = m->getRelAbundFile();
+                    }else if (it->first == "design") {
+                        it->second = m->getDesignFile();
+                    }else if (it->first == "sff") {
+                        it->second = m->getSFFFile();
+                    }else if (it->first == "oligos") {
+                        it->second = m->getOligosFile();
+                    }else if (it->first == "accnos") {
+                        it->second = m->getAccnosFile();
+                    }else if (it->first == "taxonomy") {
+                        it->second = m->getTaxonomyFile();
+                    }else if (it->first == "biom") {
                         it->second = m->getBiomFile();
-                               }else {
-                                       m->mothurOut("[ERROR]: mothur does not save a current file for " + it->first); m->mothurOutEndLine();
-                               }
-                               
-                               if (it->second == "") { //no file was saved for that type, warn and remove from parameters
-                                       m->mothurOut("[WARNING]: no file was saved for " + it->first + " parameter."); m->mothurOutEndLine();
-                                       parameters.erase(it++);
-                               }else {
-                                       m->mothurOut("Using " + it->second + " as input file for the " + it->first + " parameter."); m->mothurOutEndLine();
-                                       it++;
-                               }
-                       }else{ it++; }
-               }
+                    }else {
+                        m->mothurOut("[ERROR]: mothur does not save a current file for " + it->first); m->mothurOutEndLine();
+                    }
+                    
+                    if (it->second == "") { //no file was saved for that type, warn and remove from parameters
+                        m->mothurOut("[WARNING]: no file was saved for " + it->first + " parameter."); m->mothurOutEndLine();
+                        parameters.erase(it++);
+                    }else {
+                        m->mothurOut("Using " + it->second + " as input file for the " + it->first + " parameter."); m->mothurOutEndLine();
+                        it++;
+                    }
+                }else{ it++; }
+            }
                
                return parameters;      
        }
index facd1f85182cc526a6db01d85968d9231afcfc88..044299d43e51442aa673611003c00a80f557deaf 100644 (file)
@@ -21,6 +21,7 @@
 class OptionParser {
 public:
        OptionParser(string);
+    OptionParser(string, map<string, string>&);
        ~OptionParser() {}
        map<string, string> getParameters();
        bool getNameFile(vector<string>);
index 93f46ba1e716f80e321245832eb11eabb2bda733..06f83a4f1a390536a9952d10d413ec22613b89cd 100644 (file)
@@ -53,12 +53,32 @@ string OTUAssociationCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string OTUAssociationCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 OTUAssociationCommand::OTUAssociationCommand(){        
        try {
                abort = true; calledHelp = true; 
                setParameters();
                vector<string> tempOutNames;
-               outputTypes["otu.corr"] = tempOutNames;
+               outputTypes["otucorr"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "OTUAssociationCommand", "OTUAssociationCommand");
@@ -90,7 +110,7 @@ OTUAssociationCommand::OTUAssociationCommand(string option)  {
                        }
                        
                        vector<string> tempOutNames;
-                       outputTypes["otu.corr"] = tempOutNames;
+                       outputTypes["otucorr"] = 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);              
@@ -306,8 +326,8 @@ int OTUAssociationCommand::processShared(){
 int OTUAssociationCommand::process(vector<SharedRAbundVector*>& lookup){
        try {
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr";
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr");
+               outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -466,8 +486,8 @@ int OTUAssociationCommand::processRelabund(){
 int OTUAssociationCommand::process(vector<SharedRAbundFloatVector*>& lookup){
        try {
                
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr";
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + "." + getOutputFileNameTag("otucorr");
+               outputNames.push_back(outputFileName); outputTypes["otucorr"].push_back(outputFileName);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
index f1d047d97158c966bbeae80985b51c4725648885..64995ac38e146ff6994ab17f624e329fd848cd57 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "otu.association";                     }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 2f99aa6091452933f6796f21aa043449bfce1dd4..389879634e9ea1c003bde25604652187f8f460cb 100644 (file)
@@ -46,7 +46,26 @@ string OtuHierarchyCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string OtuHierarchyCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 OtuHierarchyCommand::OtuHierarchyCommand(){    
        try {
@@ -180,7 +199,7 @@ int OtuHierarchyCommand::execute(){
                }
                
                ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + ".otu.hierarchy";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + "." + getOutputFileNameTag("otuhierarchy");
                m->openOutputFile(outputFileName, out);
                
                //go through each bin in "big" otu and output the bins in "little" otu which created it
index 8a2c862cb66398ec1c00e964c627d158fc0d39c0..ad6da0cf529121202b3bfc5d1c1d6bdc166cba16 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "otu.hierarchy";                       }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Otu.hierarchy"; }
        string getDescription()         { return "relates OTUs at different distances"; }
index a4ccbf8f33b34b5dd8eccebf91242249cc465f28..1fa96e3e9d4c6cf8ce9a4e99af30d01c5562a009 100644 (file)
@@ -64,7 +64,27 @@ string PairwiseSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string PairwiseSeqsCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 PairwiseSeqsCommand::PairwiseSeqsCommand(){    
        try {
@@ -272,14 +292,14 @@ int PairwiseSeqsCommand::execute(){
                        string outputFile = "";
                                
                        if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "phylip.dist";
+                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "phylip." + getOutputFileNameTag("phylip");
                                m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile);
                        }else if (output == "column") { //user wants column format
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "dist";
+                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + getOutputFileNameTag("column");
                                outputTypes["column"].push_back(outputFile);
                                m->mothurRemove(outputFile);
                        }else { //assume square
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "square.dist";
+                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "square." + getOutputFileNameTag("phylip");
                                m->mothurRemove(outputFile);
                                outputTypes["phylip"].push_back(outputFile);
                        }
index e75f63c3fe80a4eaad7a2bccfae3ad266346b9e4..0e749d5c7e252ceb7c777de1e8878084f61b0a4d 100644 (file)
@@ -40,6 +40,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pairwise.seqs";               }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 06ea359e6740bd822691e9f8ab6e3e53454cc724..1331b7f47f4e131cb5a76913889d275b7ec93121 100644 (file)
@@ -46,6 +46,28 @@ string ParseFastaQCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ParseFastaQCommand::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 =  "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);
+       }
+}
+
 //**********************************************************************************************************************
 ParseFastaQCommand::ParseFastaQCommand(){      
        try {
@@ -132,8 +154,8 @@ int ParseFastaQCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //open Output Files
-               string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "fasta";
-               string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "qual";
+               string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("fasta");
+               string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + getOutputFileNameTag("qfile");
                ofstream outFasta, outQual;
                
                if (fasta) { m->openOutputFile(fastaFile, outFasta);  outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile);      }
index 6feabce848c09c21b2e276df8361ac4d78667f22..4481b98bb23bdbcd47a6059b2df0904c176ae9bf 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parse.fastq";         }
        string getCommandCategory()             { return "Sequence Processing"; }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 bb096d8646873f74c42bd8970b9eef9693a3252e..4e61a58d9e5cb4bc640c544797c87a363580575e 100644 (file)
@@ -45,6 +45,27 @@ string ParseListCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ParseListCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 ParseListCommand::ParseListCommand(){  
        try {
@@ -180,7 +201,7 @@ int ParseListCommand::execute(){
                        temp = new ofstream;
                        filehandles[gGroups[i]] = temp;
                        
-                       string filename = fileroot +  gGroups[i] + ".list";
+                       string filename = fileroot +  gGroups[i] + "." + getOutputFileNameTag("list");
                        outputNames.push_back(filename); outputTypes["list"].push_back(filename);
                        m->openOutputFile(filename, *temp);
                }
index 9356299b91c45c82b073c424a81b9a6bb28673e8..1faeaeb9f31f13ce0b3a5e4f1fbbe1f524ac6501 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parse.list";                          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Parse.list"; }
        string getDescription()         { return "parses a list file by group"; }
index 50e1bfa7e590d6e2fa47b4c184700b440cdb9621..f124b6002ee2c247db14716b4be81cb9ec10d8f2 100644 (file)
@@ -52,6 +52,27 @@ string ParsimonyCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ParsimonyCommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 ParsimonyCommand::ParsimonyCommand(){  
@@ -204,11 +225,11 @@ int ParsimonyCommand::execute() {
             delete reader;
        
                        if(outputDir == "") { outputDir += m->hasPath(treefile); }
-                       output = new ColumnFile(outputDir + m->getSimpleName(treefile)  +  ".parsimony", itersString);
-                       outputNames.push_back(outputDir + m->getSimpleName(treefile)  +  ".parsimony");
-                       outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(treefile)  +  ".parsimony");
+                       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"));
                                
-                       sumFile = outputDir + m->getSimpleName(treefile) + ".psummary";
+                       sumFile = outputDir + m->getSimpleName(treefile) + "." + getOutputFileNameTag("psummary");
                        m->openOutputFile(sumFile, outSum);
                        outputNames.push_back(sumFile);
                        outputTypes["psummary"].push_back(sumFile);
index 917255696166a505ae5734e20f0aaab47573876c..79613f560746e443697e4e92bfed755605a6fe4a 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "parsimony";                           }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 27e448bdfa1060a91c701c25fe301907e3529ec7..2cb37bda8896f8f2cb1f64521f1a73232507f24b 100644 (file)
@@ -48,6 +48,28 @@ string PCACommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string PCACommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 PCACommand::PCACommand(){      
        try {
@@ -403,17 +425,19 @@ void PCACommand::output(string fnameRoot, vector<string> name_list, vector<vecto
                        dsum += d[i];
                }
                
-               ofstream pcaData((fnameRoot+".pca.axes").c_str(), ios::trunc);
+               ofstream pcaData;
+        m->openOutputFile((fnameRoot+"."+getOutputFileNameTag("pca")), pcaData);
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
-               outputNames.push_back(fnameRoot+".pca.axes");
-               outputTypes["pca"].push_back(fnameRoot+".pca.axes");
+               outputNames.push_back(fnameRoot+"."+getOutputFileNameTag("pca"));
+               outputTypes["pca"].push_back(fnameRoot+"."+getOutputFileNameTag("pca"));
                
-               ofstream pcaLoadings((fnameRoot+".pca.loadings").c_str(), ios::trunc);
+               ofstream pcaLoadings;
+         m->openOutputFile((fnameRoot+"."+getOutputFileNameTag("loadings")), pcaLoadings);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+".pca.loadings");
-               outputTypes["loadings"].push_back(fnameRoot+".pca.loadings");   
+               outputNames.push_back(fnameRoot+"."+getOutputFileNameTag("loadings"));
+               outputTypes["loadings"].push_back(fnameRoot+"."+getOutputFileNameTag("loadings"));      
                
                pcaLoadings << "axis\tloading\n";
                for(int i=0;i<numEigenValues;i++){
index d16e896dac848552885bd9b9c33321f5be463c9b..64235841a9a29b651ea4f1fe2b64e2125876bc43 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pca";                                 }
        string getCommandCategory()             { return "Hypothesis Testing";  }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
index 02e165e978dc071ba19808139060866d7e41388c..354826f8c0b27a359b1eb1530e6a0d7a9fbaf32f 100644 (file)
@@ -46,6 +46,27 @@ string PCOACommand::getHelpString(){
        }
 }
 
+//**********************************************************************************************************************
+string PCOACommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 PCOACommand::PCOACommand(){    
@@ -229,17 +250,21 @@ void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vect
                        }
                }
                
-               ofstream pcaData((fnameRoot+"pcoa.axes").c_str(), ios::trunc);
+               ofstream pcaData;
+        string pcoaDataFile = fnameRoot+getOutputFileNameTag("pcoa");
+        m->openOutputFile(pcoaDataFile, pcaData);
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
-               outputNames.push_back(fnameRoot+"pcoa.axes");
-               outputTypes["pcoa"].push_back(fnameRoot+"pcoa.axes");
+               outputNames.push_back(pcoaDataFile);
+               outputTypes["pcoa"].push_back(pcoaDataFile);
                
-               ofstream pcaLoadings((fnameRoot+"pcoa.loadings").c_str(), ios::trunc);
+               ofstream pcaLoadings;
+        string loadingsFile = fnameRoot+getOutputFileNameTag("loadings");
+        m->openOutputFile(loadingsFile, pcaLoadings);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+"pcoa.loadings");
-               outputTypes["loadings"].push_back(fnameRoot+"pcoa.loadings");   
+               outputNames.push_back(loadingsFile);
+               outputTypes["loadings"].push_back(loadingsFile);        
                
                pcaLoadings << "axis\tloading\n";
                for(int i=0;i<rank;i++){
index 3d24f6a97f799f1c8627ef40d5dbec888da51dc6..93feefa3dec06bc6084055fc701a6cd8baf058de 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pcoa";                                        }
        string getCommandCategory()             { return "Hypothesis Testing";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 420a5ebc3e4b0cb527a3c2c692797c0b627c3b46..baeca4eedc66ac9aa38acaa4b7d65bfebca56410 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pcr.seqs";    }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Pcr.seqs"; }
        string getDescription()         { return "pcr.seqs"; }
index 29e2ef0ba39ba4fbe73bf88949bf7a4756d50578..9d68cb5debbbc65472577c4861391bb8ffbde3bc 100644 (file)
@@ -61,7 +61,28 @@ string PhyloDiversityCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string PhyloDiversityCommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 PhyloDiversityCommand::PhyloDiversityCommand(){        
@@ -237,9 +258,9 @@ int PhyloDiversityCommand::execute(){
                        if (m->control_pressed) { delete tmap; 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) + ".phylodiv.summary";
-                       string outRareFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + ".phylodiv.rarefaction";
-                       string outCollectFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + ".phylodiv";
+                       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");
                        
                        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);                   }
index 52cd3e27953ebac12619df1148e0e9bf932c8261..95276921149b5237a923928bc9f23a5e8e7aed1b 100644 (file)
@@ -25,7 +25,8 @@ class PhyloDiversityCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "phylo.diversity";                     }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 2f565150aabeec35cc8a3c03a459d8b85090550b..5f7bbc3c73a2161417a1841f567719a4bd1f8c4a 100644 (file)
@@ -73,24 +73,16 @@ PhyloSummary::PhyloSummary(string groupFile){
 
 int PhyloSummary::summarize(string userTfile){
        try {
-               
-               ifstream in;
-               m->openInputFile(userTfile, in);
-               
-               //read in users taxonomy file and add sequences to tree
-               string name, tax;
-               int numSeqs = 0;
-               while(!in.eof()){
-                       in >> name >> tax; m->gobble(in);
-                       
-                       addSeqToTree(name, tax);
+               map<string, string> temp;
+        m->readTax(userTfile, temp);
+        
+        for (map<string, string>::iterator itTemp = temp.begin(); itTemp != temp.end();) {
+            addSeqToTree(itTemp->first, itTemp->second);
                        numSeqs++;
-                       
-                       if (m->control_pressed) { break;  }
-               }
-               in.close();
-               
-               return numSeqs;
+            temp.erase(itTemp++);
+        }
+        
+        return numSeqs;
        }
        catch(exception& e) {
                m->errorOut(e, "PhyloSummary", "summarize");
index 4ed3d8c1c02e1c5a1ee93b9dd6143309f5606f5c..3dde18680c625eb816230a8d13774ccfc47032cf 100644 (file)
@@ -178,16 +178,13 @@ PhyloTree::PhyloTree(string tfile){
                        MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                
                #else
-                       ifstream in;
-                       m->openInputFile(tfile, in);
-                       
-                       //read in users taxonomy file and add sequences to tree
-                       while(!in.eof()){
-                               in >> name >> tax; m->gobble(in);
-                       
-                               addSeqToTree(name, tax);
-                       }
-                       in.close();
+            map<string, string> temp;
+            m->readTax(tfile, temp);
+        
+            for (map<string, string>::iterator itTemp = temp.begin(); itTemp != temp.end();) {
+                addSeqToTree(itTemp->first, itTemp->second);
+                temp.erase(itTemp++);
+            }
                #endif
        
                assignHeirarchyIDs(0);
index 2d2db08a40ea5e1aa8712902dcd419ddb1ad757a..38d3bdf929f4ffc110f76ab0a55b12d66ef4ad08 100644 (file)
@@ -53,7 +53,28 @@ string PhylotypeCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string PhylotypeCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 PhylotypeCommand::PhylotypeCommand(){  
        try {
@@ -198,13 +219,13 @@ int PhylotypeCommand::execute(){
                string fileroot = outputDir + m->getRootName(m->getSimpleName(taxonomyFileName));
                
                ofstream outList;
-               string outputListFile = fileroot + "tx.list";
+               string outputListFile = fileroot + "tx." + getOutputFileNameTag("list");
                m->openOutputFile(outputListFile, outList);
                ofstream outSabund;
-               string outputSabundFile = fileroot + "tx.sabund";
+               string outputSabundFile = fileroot + "tx." + getOutputFileNameTag("sabund");
                m->openOutputFile(outputSabundFile, outSabund);
                ofstream outRabund;
-               string outputRabundFile = fileroot + "tx.rabund";
+               string outputRabundFile = fileroot + "tx." + getOutputFileNameTag("rabund");
                m->openOutputFile(outputRabundFile, outRabund);
                
                outputNames.push_back(outputListFile); outputTypes["list"].push_back(outputListFile);
index ecc7376ecb7ea1a312af1e374ae76fb089e08add..0e315ec7c4ef4fcdabc34b4037d7f8bba53cfea2 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "phylotype";           }
        string getCommandCategory()             { return "Clustering";          }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Phylotype"; }
        string getDescription()         { return "cluster your sequences into OTUs based on their classifications"; }
index 8abe0ea7a439e99aae5be49dc5734516ce9bdab1..2c621bbe1da5b94bf9dd13f40d97bd27ef7b7c97 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pipeline.pds";        }
        string getCommandCategory()             { return "Hidden";                      }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Pipeline.pds"; }
        string getDescription()         { return "pat's pipeline"; }
index 725136bf56a2512355cf170634b625bfa5df1581..6b73d440778dce57e39cfdb1753277d9f512a94b 100644 (file)
@@ -58,7 +58,30 @@ string PcrSeqsCommand::getHelpString(){
        }
 }
 
-
+//**********************************************************************************************************************
+string PcrSeqsCommand::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 =  "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 == "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);
+       }
+}
 //**********************************************************************************************************************
 
 PcrSeqsCommand::PcrSeqsCommand(){      
@@ -265,10 +288,10 @@ int PcrSeqsCommand::execute(){
         
         string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string trimSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pcr.fasta";
+               string trimSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta");
                outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
         
-        string badSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pcr.scrap.fasta";
+        string badSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "scrap." + getOutputFileNameTag("fasta");
                
                
         length = 0;
@@ -857,7 +880,7 @@ int PcrSeqsCommand::writeAccnos(set<string> badNames){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
         outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
         
         ofstream out;
@@ -919,7 +942,7 @@ int PcrSeqsCommand::readName(set<string>& names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pcr" + m->getExtension(namefile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -977,7 +1000,7 @@ int PcrSeqsCommand::readGroup(set<string> names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pcr" + m->getExtension(groupfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -1024,7 +1047,7 @@ int PcrSeqsCommand::readTax(set<string> names){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pcr" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
         
index bcff0fcd820a497da04405bef0ddb42d7d60ded9..951b2008b062c26c5fabb54dfd8ef2d2a858da67 100644 (file)
@@ -51,7 +51,28 @@ string PreClusterCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string PreClusterCommand::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 =  "precluster" + m->getExtension(inputName); }
+            else if (type == "name") {  outputFileName =  "precluster.names"; }
+            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);
+       }
+}
 //**********************************************************************************************************************
 PreClusterCommand::PreClusterCommand(){        
        try {
@@ -184,9 +205,9 @@ int PreClusterCommand::execute(){
                int start = time(NULL);
                
                string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               string newFastaFile = fileroot + "precluster" + m->getExtension(fastafile);
-               string newNamesFile = fileroot + "precluster.names";
-               string newMapFile = fileroot + "precluster.map"; //add group name if by group
+               string newFastaFile = fileroot + getOutputFileNameTag("fasta", fastafile);
+               string newNamesFile = fileroot + getOutputFileNameTag("name");
+               string newMapFile = fileroot + getOutputFileNameTag("map"); //add group name if by group
                outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile);
                outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile);
                
index 64efc7fc1d43aca03d17497e28bee2fdb61cc74a..084bdc61ee464c665e2f37e200b38c09b85e8ef6 100644 (file)
@@ -41,6 +41,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "pre.cluster";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://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 64958008deae4165e4a9019ddf93a0f44fd09f25..63d6fd5c39576222d2b3b864cc8e50420de972bc 100644 (file)
@@ -27,6 +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 getCitation() { return "no citation"; }
        string getDescription()         { return "quit"; }
 
index 0fdd0798e2cdda014a6cc568d3a1c895362c3158..612e3b4d2a8d1632e1c0f44937be52ce84d28fec 100644 (file)
@@ -74,6 +74,39 @@ string RareFactCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string RareFactCommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 RareFactCommand::RareFactCommand(){    
@@ -305,52 +338,52 @@ int RareFactCommand::execute(){
                        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+"rarefaction")));
-                                               outputNames.push_back(fileNameRoot+"rarefaction"); outputTypes["rarefaction"].push_back(fileNameRoot+"rarefaction");
+                                               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"));
                                        }else if (Estimators[i] == "chao") { 
-                                               rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
-                                               outputNames.push_back(fileNameRoot+"r_chao"); outputTypes["r_chao"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "ace") { 
                                                if(abund < 5)
                                                        abund = 10;
-                                               rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
-                                               outputNames.push_back(fileNameRoot+"r_ace"); outputTypes["r_ace"].push_back(fileNameRoot+"r_ace");
+                                               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"));
                                        }else if (Estimators[i] == "jack") { 
-                                               rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
-                                               outputNames.push_back(fileNameRoot+"r_jack"); outputTypes["r_jack"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "shannon") { 
-                                               rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
-                                               outputNames.push_back(fileNameRoot+"r_shannon"); outputTypes["r_shannon"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "shannoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new ShannonEven(), new ThreeColumnFile(fileNameRoot+"r_shannoneven")));
-                                               outputNames.push_back(fileNameRoot+"r_shannoneven"); outputTypes["r_shannoneven"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "heip") { 
-                                               rDisplays.push_back(new RareDisplay(new Heip(), new ThreeColumnFile(fileNameRoot+"r_heip")));
-                                               outputNames.push_back(fileNameRoot+"r_heip"); outputTypes["r_heip"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "smithwilson") { 
-                                               rDisplays.push_back(new RareDisplay(new SmithWilson(), new ThreeColumnFile(fileNameRoot+"r_smithwilson")));
-                                               outputNames.push_back(fileNameRoot+"r_smithwilson"); outputTypes["r_smithwilson"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "npshannon") { 
-                                               rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
-                                               outputNames.push_back(fileNameRoot+"r_npshannon"); outputTypes["r_npshannon"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "simpson") { 
-                                               rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
-                                               outputNames.push_back(fileNameRoot+"r_simpson"); outputTypes["r_simpson"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "simpsoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new SimpsonEven(), new ThreeColumnFile(fileNameRoot+"r_simpsoneven")));
-                                               outputNames.push_back(fileNameRoot+"r_simpsoneven"); outputTypes["r_simpsoneven"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "invsimpson") { 
-                                               rDisplays.push_back(new RareDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"r_invsimpson")));
-                                               outputNames.push_back(fileNameRoot+"r_invsimpson"); outputTypes["r_invsimpson"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "bootstrap") { 
-                                               rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
-                                               outputNames.push_back(fileNameRoot+"r_bootstrap"); outputTypes["r_bootstrap"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "coverage") { 
-                                               rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
-                                               outputNames.push_back(fileNameRoot+"r_coverage"); outputTypes["r_coverage"].push_back(fileNameRoot+"r_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"));
                                        }else if (Estimators[i] == "nseqs") { 
-                                               rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
-                                               outputNames.push_back(fileNameRoot+"r_nseqs"); outputTypes["r_nseqs"].push_back(fileNameRoot+"r_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"));
                                        }
                     if (inputFileNames.size() > 1) { file2Group[outputNames.size()-1] = groups[p]; }
                                }
index 0e77a277e6ad7cda962a4c9476945f6b2aa6b557..9c7e1ed34fcffebaf73f4499bd6637d0d36c2b68 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "rarefaction.single";          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 fecf972c7ec99f80dda6f921706c6916a9d1679f..a312df07ec1508d1d257bc443ac895467be61525 100644 (file)
@@ -62,7 +62,27 @@ string RareFactSharedCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string RareFactSharedCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 RareFactSharedCommand::RareFactSharedCommand(){        
        try {
@@ -286,11 +306,11 @@ int RareFactSharedCommand::process(GroupMap& designMap, string thisSet){
                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+"shared.rarefaction", "")));
-                                       outputNames.push_back(fileNameRoot+"shared.rarefaction"); outputTypes["sharedrarefaction"].push_back(fileNameRoot+"shared.rarefaction");
+                                       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"));
                                }else if (Estimators[i] == "sharednseqs") { 
-                                       rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", "")));
-                                       outputNames.push_back(fileNameRoot+"shared.r_nseqs"); outputTypes["sharedr_nseqs"].push_back(fileNameRoot+"shared.r_nseqs");
+                                       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"));
                                }
                        }
             file2Group[outputNames.size()-1] = thisSet;
index a210574002969c411be4d9e9c705af9d88c980f0..a5b45468d7059ad2c9e8877376c0154102d05316 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "rarefaction.shared";          }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
diff --git a/readdistcommand.cpp b/readdistcommand.cpp
deleted file mode 100644 (file)
index 8bf6996..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- *  readdistcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readdistcommand.h"
-#include "readphylip.h"
-#include "readcolumn.h"
-#include "readmatrix.hpp"
-
-//**********************************************************************************************************************
-ReadDistCommand::ReadDistCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*//valid paramters for this command
-                       string Array[] =  {"phylip", "column", "name", "cutoff", "precision", "group","outputdir","inputdir","sim"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       //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 = ""; }
-
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  globaldata->setPhylipFile(phylipfile);  globaldata->setFormat("phylip");        }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { abort = true; } 
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  globaldata->setColumnFile(columnfile); globaldata->setFormat("column"); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else {  
-                               globaldata->setGroupFile(groupfile); 
-                               //groupMap = new GroupMap(groupfile);
-                               //groupMap->readMap();
-                       }
-
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else {  globaldata->setNameFile(namefile);      }
-                       
-                       //you are doing a list and group shared
-                       if ((phylipfile != "") && (groupfile != "")) { 
-                       globaldata->setFormat("matrix"); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a read.dist command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a read.dist command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-               
-                       if (columnfile != "") {
-                               if (namefile == "") {  cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       //get user cutoff and precision or use defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);                if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
-                       sim = m->isTrue(temp); 
-                       globaldata->sim = sim;
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "10"; }
-                       convert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0)); 
-                       
-                       if (abort == false) {
-                               distFileName = globaldata->inputFileName;
-                               format = globaldata->getFormat();       
-               
-                               if (format == "column") { read = new ReadColumnMatrix(distFileName); }  
-                               else if (format == "phylip") { read = new ReadPhylipMatrix(distFileName); }
-                               else if (format == "matrix") { 
-                                       groupMap = new GroupMap(groupfile);
-                                       int error = groupMap->readMap();
-                                       if (error == 1) { delete groupMap; abort = true; }
-                                       else {
-                                               if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap;  }
-                                               globaldata->gGroupmap = groupMap;
-                                       }
-                               }
-               
-                               if (format != "matrix" ) {
-                                       read->setCutoff(cutoff);
-       
-                                       if(namefile != ""){     
-                                               nameMap = new NameAssignment(namefile);
-                                               nameMap->readMap();
-                                       }else{
-                                               nameMap = NULL;
-                                       }
-                               }
-                       }
-*/
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadDistCommand", "ReadDistCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ReadDistCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-/*
-               time_t start = time(NULL);
-               size_t numDists = 0;
-               
-               if (format == "matrix") {
-                       ifstream in;
-                       m->openInputFile(distFileName, in);
-                       matrix = new FullMatrix(in); //reads the matrix file
-                       in.close();
-                       
-                       if (m->control_pressed) { delete groupMap; delete matrix; return 0; }
-                       
-                       //if files don't match...
-                       if (matrix->getNumSeqs() < groupMap->getNumSeqs()) {  
-                               m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences.");  m->mothurOutEndLine();                         
-                               //create new group file
-                               if(outputDir == "") { outputDir += m->hasPath(groupfile); }
-                               
-                               string newGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "editted.groups";
-                               outputNames.push_back(newGroupFile);
-                               ofstream outGroups;
-                               m->openOutputFile(newGroupFile, outGroups);
-                               
-                               for (int i = 0; i < matrix->getNumSeqs(); i++) {
-                                       if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; }
-                                       
-                                       Names temp = matrix->getRowInfo(i);
-                                       outGroups << temp.seqName << '\t' << temp.groupName << endl;
-                               }
-                               outGroups.close();
-                               
-                               m->mothurOut(newGroupFile + " is a new group file containing only the sequence that are in your distance file. I will read this file instead."); m->mothurOutEndLine();
-                               
-                               //read new groupfile
-                               delete groupMap; groupMap = NULL;
-                               groupfile = newGroupFile;
-                               globaldata->setGroupFile(groupfile); 
-                               
-                               groupMap = new GroupMap(groupfile);
-                               groupMap->readMap();
-                               
-                               if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; }
-       
-                               globaldata->gGroupmap = groupMap;
-                       }
-                       
-                       //memory leak prevention
-                       if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix;  }
-                       globaldata->gMatrix = matrix; //save matrix for coverage commands
-                       numDists = matrix->getSizes()[1];
-               } else {
-                       read->read(nameMap);
-                       //to prevent memory leak
-                       
-                       if (m->control_pressed) {  return 0; }
-               
-                       if (globaldata->gListVector != NULL) {  delete globaldata->gListVector;  }
-                       globaldata->gListVector = read->getListVector();
-
-                       if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix;  }
-                       globaldata->gSparseMatrix = read->getMatrix();
-                       numDists = globaldata->gSparseMatrix->getNNodes();
-               }
-               
-               if (m->control_pressed) {  return 0; }
-
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-               }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to read "); m->mothurOutEndLine();
- */
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadDistCommand", "execute");
-               exit(1);
-       }
-}
diff --git a/readdistcommand.h b/readdistcommand.h
deleted file mode 100644 (file)
index afe077d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef READDISTCOMMAND_H
-#define READDISTCOMMAND_H
-/*
- *  readdistcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readmatrix.hpp"
-#include "fullmatrix.h"
-#include "groupmap.h"
-
-/* The read.dist command is used to read a distance matrix file.  
-The read.dist command parameter options are phylipfile, columnfile, namefile, cutoff and precision. 
-The read.dist command should be in the following format: read.dist(phylipfile=yourDistFile, 
-namefile=yourNameFile, cutoff=yourCutoff, precision=yourPrecision). The phylipfile or columnfile are required and if you use a columnfile the namefile is required.  
-If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.  */
-
-class NameAssignment;
-
-class ReadDistCommand : public Command {
-public:
-       ReadDistCommand(string);
-       ReadDistCommand() { abort = true; calledHelp = true; }
-       ~ReadDistCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.dist";   }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your distance files directly to the downstream commands like cluster."; } 
-       string getCitation() { return "http://www.mothur.org/wiki/Read.dist"; }
-       string getDescription()         { return "read.dist"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       double cutoff;
-       int precision;
-       ReadMatrix* read;
-       FullMatrix* matrix;
-       GroupMap* groupMap;
-       string distFileName, format, method;
-       string phylipfile, columnfile, namefile, groupfile, outputDir;
-       NameAssignment* nameMap;
-       vector<string> outputNames;
-
-       bool abort, sim;
-
-};
-
-#endif
diff --git a/readotucommand.cpp b/readotucommand.cpp
deleted file mode 100644 (file)
index f39e8df..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- *  readotu.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-
-#include "readotucommand.h"
-
-
-//**********************************************************************************************************************
-ReadOtuCommand::ReadOtuCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ReadOtuCommand::ReadOtuCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*
-                       //valid paramters for this command
-                       string Array[] =  {"list","order","shared","relabund","label","group","sabund", "rabund","groups","ordergroup","outputdir","inputdir"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("order");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["order"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("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("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("ordergroup");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["ordergroup"] = inputDir + it->second;               }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       
-                       //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 = ""; }
-
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }    
-                       else {  globaldata->setListFile(listfile);  globaldata->setFormat("list");      }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { abort = true; } 
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
-
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { abort = true; } 
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  globaldata->setRabundFile(rabundfile);  globaldata->setFormat("rabund");}
-                       
-                       ordergroupfile = validParameter.validFile(parameters, "ordergroup", true);
-                       if (ordergroupfile == "not open") { abort = true; }     
-                       else if (ordergroupfile == "not found") { ordergroupfile = ""; }
-                       else {  globaldata->setOrderGroupFile(ordergroupfile);  }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; } 
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  globaldata->setSharedFile(sharedfile); globaldata->setFormat("sharedfile");     }
-                       
-                       relAbundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relAbundfile == "not open") { abort = true; }       
-                       else if (relAbundfile == "not found") { relAbundfile = ""; }
-                       else {  globaldata->setRelAbundFile(relAbundfile); globaldata->setFormat("relabund");   }
-
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else {  
-                               globaldata->setGroupFile(groupfile); 
-                               groupMap = new GroupMap(groupfile);
-                               
-                               int error = groupMap->readMap();
-                               if (error == 1) { abort = true; }
-                               
-                               globaldata->gGroupmap = groupMap;
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               globaldata->Groups = Groups;
-                       }
-
-                       //you are doing a list and group shared
-                       if ((listfile != "") && (groupfile != "")) { globaldata->setFormat("shared"); }
-                       
-                       //you have not given a file
-                       if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "") && (relAbundfile == "")) {
-                               m->mothurOut("You must enter either a listfile, rabundfile, sabundfile, relabund or a sharedfile with the read.otu command. "); m->mothurOutEndLine(); abort = true; 
-                       }
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                               globaldata->labels = labels;
-                       }
-                       
-                       globaldata->allLines = allLines;
-               
-                       orderfile = validParameter.validFile(parameters, "order", true);
-                       if (orderfile == "not open") { abort = true; }  
-                       else if (orderfile == "not found") { orderfile = ""; }
-                       else {  globaldata->setOrderFile(orderfile);    }
-                       
-                               
-                       if (abort == false) {
-                               //gets whichever one of the above is set
-                               filename = globaldata->inputFileName;
-                       }
-                        */
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
-               exit(1);
-       }
-}
-///**********************************************************************************************************************
-
-int ReadOtuCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-       
-               /*
-               if (globaldata->getFormat() == "shared") {
-                       
-                       shared = new SharedCommand(outputDir);
-                       int okay = shared->execute();
-                       
-                       //problem with shared
-                       if (okay == 1) {
-                               globaldata->setListFile("");
-                               globaldata->setGroupFile("");
-                               globaldata->setSharedFile("");
-                       }else { //shared command outputs the filenames
-                               //m->mothurOutEndLine();
-                               //m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-                               //m->mothurOut(globaldata->getSharedFile()); m->mothurOutEndLine();     
-                               //m->mothurOutEndLine();
-                       }
-                       
-                       outputTypes = shared->getOutputFiles();
-                       
-                       //set rabund file as new current rabundfile
-                       string current = "";
-                       itTypes = outputTypes.find("rabund");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("shared");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-                       }                       
-                       
-                       delete shared;
-               }
-               */
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/readotucommand.h b/readotucommand.h
deleted file mode 100644 (file)
index c6d6503..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef READOTUCOMMAND_H
-#define READOTUCOMMAND_H
-/*
- *  readotu.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "sharedcommand.h"
-
-class ReadOtuCommand : public Command {
-public:
-       ReadOtuCommand(string);
-       ReadOtuCommand();
-       ~ReadOtuCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.otu";    }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your files directly to the downstream commands like collect.shared."; }   
-       string getCitation() { return "http://www.mothur.org/wiki/Read.otu"; }
-       string getDescription()         { return "read.otu"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       InputData* input;
-       Command* shared;
-       GroupMap* groupMap;
-       string filename, listfile, orderfile, sharedfile, label, groupfile, sabundfile, rabundfile, format, groups, outputDir, ordergroupfile, relAbundfile;
-       vector<string> Groups, outputNames;
-       map<string, vector<string> > outputTypes;
-
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-
-};
-
-#endif
diff --git a/readtreecommand.cpp b/readtreecommand.cpp
deleted file mode 100644 (file)
index 7660643..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- *  readtreecommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readtreecommand.h"
-
-
-//**********************************************************************************************************************
-ReadTreeCommand::ReadTreeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*
-                       //valid paramters for this command
-                       string Array[] =  {"tree","group","name","outputdir","inputdir"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("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("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                       }
-
-                       
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { abort = true; }
-                       else if (treefile == "not found") { treefile = ""; m->mothurOut("tree is a required parameter for the read.tree command."); m->mothurOutEndLine(); abort = true;  }     
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { 
-                               groupfile = ""; 
-                               
-                               m->mothurOut("You have not provided a group file. I am assumming all sequence are from the same group."); m->mothurOutEndLine();        
-                               
-                               if (treefile != "") {  Tree* tree = new Tree(treefile); delete tree;  } //extracts names from tree to make faked out groupmap
-                               
-                               //read in group map info.
-                               treeMap = new TreeMap();
-                               for (int i = 0; i < m->Treenames.size(); i++) { treeMap->addSeq(m->Treenames[i], "Group1"); }
-                                       
-                       }else {  
-                               //read in group map info.
-                               treeMap = new TreeMap(groupfile);
-                               treeMap->readMap();
-                       }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { readNamesFile(); }       
-                       
-                       if (abort == false) {
-                               filename = treefile;
-                               read = new ReadNewickTree(filename);
-                       }
-                       */                      
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "ReadTreeCommand");           
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ReadTreeCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-               /*
-               int readOk;
-               
-               readOk = read->read(treeMap); 
-               
-               if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine(); globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
-               
-               vector<Tree*> T = read->gTree;
-
-               //assemble users trees
-               for (int i = 0; i < T.size(); i++) {
-                       if (m->control_pressed) {  
-                               for (int i = 0; i < T.size(); i++) {  delete T[i];  }
-                               globaldata->gTree.clear();
-                               delete globaldata->gTreemap;
-                               return 0;
-                       }
-       
-                       T[i]->assembleTree();
-               }
-
-               
-               //if you provide a namefile we will use the numNames in the namefile as long as the number of unique match the tree names size.
-               int numNamesInTree;
-               if (namefile != "")  {  
-                       if (numUniquesInName == globaldata->Treenames.size()) {  numNamesInTree = nameMap.size();  }
-                       else {   numNamesInTree = globaldata->Treenames.size();  }
-               }else {  numNamesInTree = globaldata->Treenames.size();  }
-               
-               
-               //output any names that are in group file but not in tree
-               if (numNamesInTree < treeMap->getNumSeqs()) {
-                       for (int i = 0; i < treeMap->namesOfSeqs.size(); i++) {
-                               //is that name in the tree?
-                               int count = 0;
-                               for (int j = 0; j < globaldata->Treenames.size(); j++) {
-                                       if (treeMap->namesOfSeqs[i] == globaldata->Treenames[j]) { break; } //found it
-                                       count++;
-                               }
-                               
-                               if (m->control_pressed) {  
-                                       for (int i = 0; i < T.size(); i++) {  delete T[i];  }
-                                       globaldata->gTree.clear();
-                                       delete globaldata->gTreemap;
-                                       return 0;
-                               }
-                               
-                               //then you did not find it so report it 
-                               if (count == globaldata->Treenames.size()) { 
-                                       //if it is in your namefile then don't remove
-                                       map<string, string>::iterator it = nameMap.find(treeMap->namesOfSeqs[i]);
-                                       
-                                       if (it == nameMap.end()) {
-                                               m->mothurOut(treeMap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); m->mothurOutEndLine();
-                                               treeMap->removeSeq(treeMap->namesOfSeqs[i]);
-                                               i--; //need this because removeSeq removes name from namesOfSeqs
-                                       }
-                               }
-                       }
-                       
-                       globaldata->gTreemap = treeMap;
-               }
-                */
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "execute");   
-               exit(1);
-       }
-}
-/*****************************************************************/
-int ReadTreeCommand::readNamesFile() {
-       try {
-               /*
-               m->names.clear();
-               numUniquesInName = 0;
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               string first, second;
-               map<string, string>::iterator itNames;
-               
-               while(!in.eof()) {
-                       in >> first >> second; m->gobble(in);
-                       
-                       numUniquesInName++;
-
-                       itNames = m->names.find(first);
-                       if (itNames == globaldata->names.end()) {  
-                               globaldata->names[first] = second; 
-                               
-                               //we need a list of names in your namefile to use above when removing extra seqs above so we don't remove them
-                               vector<string> dupNames;
-                               m->splitAtComma(second, dupNames);
-                               
-                               for (int i = 0; i < dupNames.size(); i++) {     nameMap[dupNames[i]] = dupNames[i];  if ((groupfile == "") && (i != 0)) { globaldata->gTreemap->addSeq(dupNames[i], "Group1"); }  }
-                       }else {  m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); globaldata->names.clear(); namefile = ""; return 1; }                 
-               }
-               in.close();
-               */
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/readtreecommand.h b/readtreecommand.h
deleted file mode 100644 (file)
index cbf3769..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef READTREECOMMAND_H
-#define READTREECOMMAND_H
-
-/*
- *  readtreecommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readtree.h"
-#include "treemap.h"
-
-
-class ReadTreeCommand : public Command {
-public:
-       ReadTreeCommand(string);
-       ReadTreeCommand() { abort = true; calledHelp = true; }
-       ~ReadTreeCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.tree";   }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your files directly to the downstream commands like unifrac.unweighted."; }       
-       string getCitation() { return "http://www.mothur.org/wiki/Read.tree"; }
-       string getDescription()         { return "read.tree"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       ReadTree* read;
-       TreeMap* treeMap;
-       string filename, treefile, groupfile, namefile;
-       bool abort;
-       map<string, string> nameMap;
-       vector<string> outputNames;
-       
-       int readNamesFile();
-       int numUniquesInName;
-
-};
-
-
-#endif
index 801029c06383e7811e5cfb14ea0c5cd629b66b67..05b1170bf4501ebd3131a616fdcd58a9b49e59f2 100644 (file)
@@ -57,7 +57,32 @@ string RemoveGroupsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string RemoveGroupsCommand::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 =  "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 == "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);
+       }
+}
 //**********************************************************************************************************************
 RemoveGroupsCommand::RemoveGroupsCommand(){    
        try {
@@ -295,7 +320,7 @@ int RemoveGroupsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
+               if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups);  }
                
                if (groupfile != "") {
                        groupMap = new GroupMap(groupfile);
@@ -385,7 +410,7 @@ int RemoveGroupsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -477,7 +502,7 @@ int RemoveGroupsCommand::readShared(){
                
                while(lookup[0] != NULL) {
                        
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
+                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + "." + getOutputFileNameTag("shared", sharedfile);
                        ofstream out;
                        m->openOutputFile(outputFileName, out);
                        outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -525,7 +550,7 @@ int RemoveGroupsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -615,8 +640,7 @@ int RemoveGroupsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);            
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -696,8 +720,7 @@ int RemoveGroupsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -743,7 +766,7 @@ int RemoveGroupsCommand::readDesign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + "pick" + m->getExtension(designfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + getOutputFileNameTag("design", designfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -791,7 +814,7 @@ int RemoveGroupsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -837,32 +860,6 @@ int RemoveGroupsCommand::readTax(){
        }
 }
 //**********************************************************************************************************************
-void RemoveGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 int RemoveGroupsCommand::fillNames(){
        try {
                vector<string> seqs = groupMap->getNamesSeqs();
index 24062bab3614fb3fc7ee803b3272c4242cdf68bd..c6db38057f8c206ecbba0806486078eccdcc7278 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.groups";                       }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
@@ -48,7 +49,6 @@ private:
        int readShared();
        int readName();
        int readGroup();
-       void readAccnos();
        int readList();
        int readTax();
        int fillNames();
index 9fec2496068950b4863448fe500b17cbc957670a..4cec90f567c764e8770987c150b67b5ececc0d35 100644 (file)
@@ -57,8 +57,31 @@ string RemoveLineageCommand::getHelpString(){
                exit(1);
        }
 }
-
-
+//**********************************************************************************************************************
+string RemoveLineageCommand::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 =  "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 == "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);
+       }
+}
 //**********************************************************************************************************************
 RemoveLineageCommand::RemoveLineageCommand(){  
        try {
@@ -302,8 +325,7 @@ int RemoveLineageCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -348,8 +370,7 @@ int RemoveLineageCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -419,8 +440,7 @@ int RemoveLineageCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -497,8 +517,7 @@ int RemoveLineageCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -540,7 +559,7 @@ int RemoveLineageCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -740,7 +759,7 @@ int RemoveLineageCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
index a4ffea9c529829da3c3f08cfbc41c5e3bdf5ddcf..a5caec8e4c3e0f04ec7744489c3f27c0a495e38d 100644 (file)
@@ -23,7 +23,8 @@ class RemoveLineageCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "remove.lineage";                      }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 77305fb49babaa2640d6a69db0a25e0816ac6785..01d8529dded5e9c7e17bd02724158156566dece7 100644 (file)
@@ -46,14 +46,36 @@ string RemoveOtuLabelsCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string RemoveOtuLabelsCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 RemoveOtuLabelsCommand::RemoveOtuLabelsCommand(){      
        try {
                abort = true; calledHelp = true;
                setParameters();
         vector<string> tempOutNames;
                outputTypes["contaxonomy"] = tempOutNames; 
-        outputTypes["otu.corr"] = tempOutNames;
-        outputTypes["corr.axes"] = tempOutNames;
+        outputTypes["otucorr"] = tempOutNames;
+        outputTypes["corraxes"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "RemoveOtuLabelsCommand", "RemoveOtuLabelsCommand");
@@ -127,8 +149,8 @@ RemoveOtuLabelsCommand::RemoveOtuLabelsCommand(string option)  {
             
             vector<string> tempOutNames;
             outputTypes["contaxonomy"] = tempOutNames; 
-            outputTypes["otu.corr"] = tempOutNames;
-            outputTypes["corr.axes"] = tempOutNames;
+            outputTypes["otucorr"] = tempOutNames;
+            outputTypes["corraxes"] = tempOutNames;
             
                        //check for parameters
             accnosfile = validParameter.validFile(parameters, "accnos", true);
@@ -175,7 +197,7 @@ int RemoveOtuLabelsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
         
         //get labels you want to keep
-               readAccnos();
+               labels = m->readAccnos(accnosfile);
                
                if (m->control_pressed) { return 0; }
                
@@ -204,7 +226,7 @@ int RemoveOtuLabelsCommand::readClassifyOtu(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(constaxonomyfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + "pick.taxonomy";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomyfile)) + getOutputFileNameTag("constaxonomy");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -253,7 +275,7 @@ int RemoveOtuLabelsCommand::readOtuAssociation(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(otucorrfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + "pick.corr";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(otucorrfile)) + getOutputFileNameTag("otucorr");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -286,7 +308,7 @@ int RemoveOtuLabelsCommand::readOtuAssociation(){
         out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file only contains labels from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["otu.corr"].push_back(outputFileName);
+               outputNames.push_back(outputFileName);  outputTypes["otucorr"].push_back(outputFileName);
                
                m->mothurOut("Removed " + toString(removedCount) + " lines from your otu.corr file."); m->mothurOutEndLine();
                
@@ -303,7 +325,7 @@ int RemoveOtuLabelsCommand::readCorrAxes(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(corraxesfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + "pick.axes";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(corraxesfile)) + getOutputFileNameTag("corraxes");
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -336,7 +358,7 @@ int RemoveOtuLabelsCommand::readCorrAxes(){
         out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file only contains labels from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["corr.axes"].push_back(outputFileName);
+               outputNames.push_back(outputFileName);  outputTypes["corraxes"].push_back(outputFileName);
                
                m->mothurOut("Removed " + toString(removedCount) + " lines from your corr.axes file."); m->mothurOutEndLine();
                
@@ -348,32 +370,6 @@ int RemoveOtuLabelsCommand::readCorrAxes(){
                exit(1);
        }
 }
-
-//**********************************************************************************************************************
-int RemoveOtuLabelsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-            
-                       labels.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtuLabelsCommand", "readAccnos");
-               exit(1);
-       }
-}
 //**********************************************************************************************************************
 
 
index da2441dd32039ee4574df10a8ed8c9493f168f4d..ea596624ddfab5111a2c95f8619e4a4681bd1d10 100644 (file)
@@ -23,7 +23,8 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "remove.otulabels";          }
     string getCommandCategory()                { return "OTU-Based Approaches";        } 
-    string getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     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."; }
     
@@ -39,8 +40,6 @@ private:
     int readClassifyOtu();
     int readOtuAssociation();
     int readCorrAxes();
-    int readAccnos();
-    
 };
 
 /**************************************************************************************************/
index 25ed99eacbbd3c6dcbcad18daf5fef44ec13b746..54adeb244693bb13e22884248e71deadeb5e2144 100644 (file)
@@ -52,7 +52,27 @@ string RemoveOtusCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string RemoveOtusCommand::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 == "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);
+       }
+}
 ///**********************************************************************************************************************
 RemoveOtusCommand::RemoveOtusCommand(){        
        try {
@@ -182,7 +202,7 @@ int RemoveOtusCommand::execute(){
                groupMap->readMap();
                
                //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
+               if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups);  }
                
                //make sure groups are valid
                //takes care of user setting groupNames that are invalid or setting groups=all
@@ -230,14 +250,14 @@ int RemoveOtusCommand::readListGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick." + label +  m->getExtension(listfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("list", listfile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
                string GroupOutputDir = outputDir;
                if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick." + label  + m->getExtension(groupfile);
+               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + label + "." + getOutputFileNameTag("group", groupfile);
                
                ofstream outGroup;
                m->openOutputFile(outputGroupFileName, outGroup);
@@ -407,30 +427,6 @@ int RemoveOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstr
        }
 }
 //**********************************************************************************************************************
-void RemoveOtusCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
 
 
 
index 6a7cf8a1e55fa1a5fe5915b4cb6da1c3150729ef..3a52a39f120a0d2af788478df3a590c64a7f9306 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.otus";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
@@ -38,7 +39,6 @@ private:
        vector<string> outputNames, Groups;
        GroupMap* groupMap;
        
-       void readAccnos();
        int readListGroup();
        int processList(ListVector*&, GroupMap*&, ofstream&, ofstream&, bool&);
        
index 24b616560de3bed794d423f4cb7a3544f0d48f5f..923ca72eccbd2f88bad0b36b0c15fba58f1b829c 100644 (file)
@@ -58,6 +58,31 @@ string RemoveRareCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string RemoveRareCommand::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 == "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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 RemoveRareCommand::RemoveRareCommand(){        
        try {
@@ -301,9 +326,8 @@ int RemoveRareCommand::processList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               string outputGroupFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" +  m->getExtension(groupfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);
+               string outputGroupFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);            
                ofstream out, outGroup;
                m->openOutputFile(outputFileName, out);
                
@@ -423,7 +447,7 @@ int RemoveRareCommand::processSabund(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + "pick" +  m->getExtension(sabundfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + getOutputFileNameTag("sabund", sabundfile);
                outputTypes["sabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
 
                ofstream out;
@@ -522,7 +546,7 @@ int RemoveRareCommand::processRabund(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + "pick" +  m->getExtension(rabundfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + getOutputFileNameTag("rabund", rabundfile);
                outputTypes["rabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
@@ -629,7 +653,7 @@ int RemoveRareCommand::processShared(){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "pick" +  m->getExtension(sharedfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("shared", sharedfile);
                outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
index 9e58c064f1c8e0c1bf5a4356c028ba9a60afed80..2d70ba784bdf9b413e8726f1cd160f62b85980d7 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "remove.rare";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 2abe9ef78a8c76354d377087fa7a23deb27b4d25..0d53c1a95ed5b968d0a8281f1f3d612d7d4c2047 100644 (file)
@@ -53,7 +53,32 @@ string RemoveSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string RemoveSeqsCommand::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 =  "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 { 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);
+       }
+}
 
 //**********************************************************************************************************************
 RemoveSeqsCommand::RemoveSeqsCommand(){        
@@ -257,7 +282,7 @@ int RemoveSeqsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //get names you want to keep
-               readAccnos();
+               names = m->readAccnos(accnosfile);
                
                if (m->control_pressed) { return 0; }
                
@@ -325,7 +350,7 @@ int RemoveSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -374,7 +399,7 @@ int RemoveSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "pick" +  m->getExtension(qualfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -442,8 +467,7 @@ int RemoveSeqsCommand::readList(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -521,8 +545,7 @@ int RemoveSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -604,8 +627,7 @@ int RemoveSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -651,7 +673,7 @@ int RemoveSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile);
                ofstream out;
                m->openOutputFile(outputFileName, out);
 
@@ -697,7 +719,7 @@ int RemoveSeqsCommand::readAlign(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + getOutputFileNameTag("alignreport");
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -764,29 +786,5 @@ int RemoveSeqsCommand::readAlign(){
        }
 }
 //**********************************************************************************************************************
-void RemoveSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                                               
-                       names.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
 
 
index df96e4514bc84787ad901e137bbc794588681705..474951a9feaee7d497417cf2a03f206367056241 100644 (file)
@@ -23,7 +23,8 @@ class RemoveSeqsCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "remove.seqs";                         }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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"; }
 
@@ -41,7 +42,6 @@ class RemoveSeqsCommand : public Command {
                int readName();
                int readGroup();
                int readAlign();
-               void readAccnos();
                int readList();
                int readTax();
                int readQual();
index c664ad7548b52f8966c799749f382d31169f564d..cde88b71203ac3c5fe364c2d7a7bd112bc8da8f8 100644 (file)
@@ -43,7 +43,27 @@ string ReverseSeqsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string ReverseSeqsCommand::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 =  "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);
+       }
+}
 //**********************************************************************************************************************
 ReverseSeqsCommand::ReverseSeqsCommand(){      
        try {
@@ -162,7 +182,7 @@ 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)) + "rc" + m->getExtension(fastaFileName);
+                       fastaReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName)) + getOutputFileNameTag("fasta", fastaFileName);
                        m->openOutputFile(fastaReverseFileName, outFASTA);
                        
                        while(!inFASTA.eof()){
@@ -190,8 +210,8 @@ 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)) + "rc" + m->getExtension(qualFileName);
-                       m->openOutputFile(qualReverseFileName, outQual);
+                       string qualReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName)) + getOutputFileNameTag("qfile", qualFileName);
+            m->openOutputFile(qualReverseFileName, outQual);
 
                        while(!inQual.eof()){
                                if (m->control_pressed) {  inQual.close();  outQual.close(); m->mothurRemove(qualReverseFileName); return 0; }
index f0fdfa887890607ea3efa2ccfdc44c7b95c1b7c7..2c7a9e4ee025e3ce8e94f328eb2cb1e676611cf6 100644 (file)
@@ -21,6 +21,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "reverse.seqs";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Reverse.seqs"; }
        string getDescription()         { return "outputs a fasta file containing the reverse-complements"; }
index 7ac910d4a74b9fc1bffeacb32f5893941f3eb60f..7f385d39c729e1acbc2d33325e9640c706f095e2 100644 (file)
@@ -70,6 +70,33 @@ string ScreenSeqsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ScreenSeqsCommand::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 =  "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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 ScreenSeqsCommand::ScreenSeqsCommand(){        
        try {
@@ -309,8 +336,8 @@ int ScreenSeqsCommand::execute(){
                        #endif
                }
                                        
-               string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "good" + m->getExtension(fastafile);
-               string badAccnosFile =  outputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
+               string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
+               string badAccnosFile =  outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("accnos");
                
                int numFastaSeqs = 0;
                set<string> badSeqNames;
@@ -514,7 +541,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                string seqName, seqList, group;
                set<string>::iterator it;
 
-               string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + "good" + m->getExtension(namefile);
+               string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                outputNames.push_back(goodNameFile);  outputTypes["name"].push_back(goodNameFile);
                
                ofstream goodNameOut;   m->openOutputFile(goodNameFile, goodNameOut);
@@ -560,7 +587,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                        ifstream inputGroups;
                        m->openInputFile(groupfile, inputGroups);
 
-                       string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
+                       string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                        outputNames.push_back(goodGroupFile);   outputTypes["group"].push_back(goodGroupFile);
                        
                        ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
@@ -893,8 +920,8 @@ int ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
                string seqName, group;
                set<string>::iterator it;
                
-               string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
-               outputNames.push_back(goodGroupFile);  outputTypes["group"].push_back(goodGroupFile);
+               string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
+        outputNames.push_back(goodGroupFile);  outputTypes["group"].push_back(goodGroupFile);
                ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
                
                while(!inputGroups.eof()){
@@ -945,7 +972,7 @@ int ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
                string seqName, group;
                set<string>::iterator it;
                
-               string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + "good" + m->getExtension(alignreport);
+               string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + getOutputFileNameTag("alignreport");
                outputNames.push_back(goodAlignReportFile);  outputTypes["alignreport"].push_back(goodAlignReportFile);
                ofstream goodAlignReportOut;    m->openOutputFile(goodAlignReportFile, goodAlignReportOut);
 
@@ -1009,7 +1036,7 @@ int ScreenSeqsCommand::screenTaxonomy(set<string> badSeqNames){
                string seqName, tax;
                set<string>::iterator it;
                
-               string goodTaxFile = outputDir + m->getRootName(m->getSimpleName(taxonomy)) + "good" + m->getExtension(taxonomy);
+               string goodTaxFile = outputDir + m->getRootName(m->getSimpleName(taxonomy)) + getOutputFileNameTag("taxonomy", taxonomy);
                outputNames.push_back(goodTaxFile);  outputTypes["taxonomy"].push_back(goodTaxFile);
                ofstream goodTaxOut;    m->openOutputFile(goodTaxFile, goodTaxOut);
                                
@@ -1058,7 +1085,7 @@ int ScreenSeqsCommand::screenQual(set<string> badSeqNames){
                m->openInputFile(qualfile, in);
                set<string>::iterator it;
                
-               string goodQualFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + "good" + m->getExtension(qualfile);
+               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 54c8fbb76a9f8db6d200b02feb2e28ce106682d0..771113da1bda0ee34859faaa39b2fe7be1bc2672 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "screen.seqs";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 24142e0cf4aa6174a8006f1e0a7a85c82f10ab24..ee50ab14e6183af4b2fe9979c97336ac1d9b75a5 100644 (file)
@@ -45,6 +45,26 @@ string AlignCheckCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string AlignCheckCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 AlignCheckCommand::AlignCheckCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -170,7 +190,7 @@ int AlignCheckCommand::execute(){
                m->openInputFile(fastafile, in);
                
                ofstream out;
-               string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "align.check";
+               string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("aligncheck");
                m->openOutputFile(outfile, out);
                
                                
index 4e7bdea09cac0d1bd86d780eb92e499bbe9bfc69..110f019f3beeafdd2a877c423b250232a488e62c 100644 (file)
@@ -39,7 +39,8 @@ class AlignCheckCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "align.check";                         }
                string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 55d90bdd2ce1debc857ddb33a47969e0c3f66933..cfa1f5b6dc0649925ff4762abdef070e93fd7688 100644 (file)
@@ -45,6 +45,26 @@ string SensSpecCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string SensSpecCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 SensSpecCommand::SensSpecCommand(){    
        try {
                abort = true; calledHelp = true; 
@@ -197,7 +217,7 @@ SensSpecCommand::SensSpecCommand(string option)  {
                                else { allLines = 1;  }
                        }
                        
-                       sensSpecFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + "sensspec";
+                       sensSpecFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + getOutputFileNameTag("sensspec");
                }
        }
        catch(exception& e) {
index 02e84c0c96e087b5acb6a664405a5427107a5d45..a5072e80c4bd908ed63d0f1ab34c83a5285b2e95 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sens.spec";                           }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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. \nhttp://www.mothur.org/wiki/Sens.spec"; }
        string getDescription()         { return "sens.spec"; }
index 0dc15f59ee98d0ee2d93659c4c3ad1f033f8a193..8fd6368154773bcc38e2b950d7b170c88be2186e 100644 (file)
@@ -63,20 +63,52 @@ string SeqErrorCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string SeqErrorCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 SeqErrorCommand::SeqErrorCommand(){    
        try {
                abort = true; calledHelp = true; 
                setParameters();
                vector<string> tempOutNames;
-               outputTypes["error.summary"] = tempOutNames;
-               outputTypes["error.seq"] = tempOutNames;
-               outputTypes["error.quality"] = tempOutNames;
-               outputTypes["error.qual.forward"] = tempOutNames;
-               outputTypes["error.qual.reverse"] = tempOutNames;
-               outputTypes["error.forward"] = tempOutNames;
-               outputTypes["error.reverse"] = tempOutNames;
-               outputTypes["error.count"] = tempOutNames;
-               outputTypes["error.matrix"] = tempOutNames;
+               outputTypes["errorsummary"] = tempOutNames;
+               outputTypes["errorseq"] = tempOutNames;
+               outputTypes["errorquality"] = tempOutNames;
+               outputTypes["errorqualforward"] = tempOutNames;
+               outputTypes["errorqualreverse"] = tempOutNames;
+               outputTypes["errorforward"] = tempOutNames;
+               outputTypes["errorreverse"] = tempOutNames;
+               outputTypes["errorcount"] = tempOutNames;
+               outputTypes["errormatrix"] = tempOutNames;
+        outputTypes["errorchimera"] = tempOutNames;
+        outputTypes["errorref-query"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "SeqErrorCommand", "SeqErrorCommand");
@@ -112,15 +144,17 @@ SeqErrorCommand::SeqErrorCommand(string option)  {
                        
                        //initialize outputTypes
                        vector<string> tempOutNames;
-                       outputTypes["error.summary"] = tempOutNames;
-                       outputTypes["error.seq"] = tempOutNames;
-                       outputTypes["error.quality"] = tempOutNames;
-                       outputTypes["error.qual.forward"] = tempOutNames;
-                       outputTypes["error.qual.reverse"] = tempOutNames;
-                       outputTypes["error.forward"] = tempOutNames;
-                       outputTypes["error.reverse"] = tempOutNames;
-                       outputTypes["error.count"] = tempOutNames;
-                       outputTypes["error.matrix"] = tempOutNames;
+                       outputTypes["errorsummary"] = tempOutNames;
+                       outputTypes["errorseq"] = tempOutNames;
+                       outputTypes["errorquality"] = tempOutNames;
+                       outputTypes["errorqualforward"] = tempOutNames;
+                       outputTypes["errorqualreverse"] = tempOutNames;
+                       outputTypes["errorforward"] = tempOutNames;
+                       outputTypes["errorreverse"] = tempOutNames;
+                       outputTypes["errorcount"] = tempOutNames;
+                       outputTypes["errormatrix"] = tempOutNames;
+            outputTypes["errorchimera"] = tempOutNames;
+            outputTypes["errorref-query"] = tempOutNames;
 
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -269,14 +303,15 @@ int SeqErrorCommand::execute(){
                totalBases = 0;
                totalMatches = 0;
                
-               string errorSummaryFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.summary";
-               outputNames.push_back(errorSummaryFileName); outputTypes["error.summary"].push_back(errorSummaryFileName);
+        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
+               string errorSummaryFileName = fileNameRoot + getOutputFileNameTag("errorsummary");
+               outputNames.push_back(errorSummaryFileName); outputTypes["errorsummary"].push_back(errorSummaryFileName);
                        
-               string errorSeqFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq";
-               outputNames.push_back(errorSeqFileName); outputTypes["error.seq"].push_back(errorSeqFileName);
+               string errorSeqFileName = fileNameRoot + getOutputFileNameTag("errorseq");
+               outputNames.push_back(errorSeqFileName); outputTypes["errorseq"].push_back(errorSeqFileName);
                
-               string errorChimeraFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.chimera";
-               outputNames.push_back(errorChimeraFileName); outputTypes["error.chimera"].push_back(errorChimeraFileName);
+               string errorChimeraFileName = fileNameRoot + getOutputFileNameTag("errorchimera");
+               outputNames.push_back(errorChimeraFileName); outputTypes["errorchimera"].push_back(errorChimeraFileName);
                
                getReferences();        //read in reference sequences - make sure there's no ambiguous bases
 
@@ -317,10 +352,10 @@ int SeqErrorCommand::execute(){
                
                if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
 
-               string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.count";
+               string errorCountFileName = fileNameRoot + getOutputFileNameTag("errorcount");
                ofstream errorCountFile;
                m->openOutputFile(errorCountFileName, errorCountFile);
-               outputNames.push_back(errorCountFileName);  outputTypes["error.count"].push_back(errorCountFileName);
+               outputNames.push_back(errorCountFileName);  outputTypes["errorcount"].push_back(errorCountFileName);
                m->mothurOut("Overall error rate:\t" + toString((double)(totalBases - totalMatches) / (double)totalBases) + "\n");
                m->mothurOut("Errors\tSequences\n");
                errorCountFile << "Errors\tSequences\n";                
@@ -334,10 +369,10 @@ int SeqErrorCommand::execute(){
 
                printSubMatrix();
                                
-               string megAlignmentFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.ref-query";
+               string megAlignmentFileName = fileNameRoot + getOutputFileNameTag("errorref-query");
                ofstream megAlignmentFile;
                m->openOutputFile(megAlignmentFileName, megAlignmentFile);
-               outputNames.push_back(megAlignmentFileName);  outputTypes["error.ref-query"].push_back(megAlignmentFileName);
+               outputNames.push_back(megAlignmentFileName);  outputTypes["errorref-query"].push_back(megAlignmentFileName);
                
                for(int i=0;i<numRefs;i++){
                        megAlignmentFile << referenceSeqs[i].getInlineSeq() << endl;
@@ -1046,10 +1081,11 @@ void SeqErrorCommand::printErrorData(Compare error, int numParentSeqs, ofstream&
 
 void SeqErrorCommand::printSubMatrix(){
        try {
-               string subMatrixFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.matrix";
+        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
+               string subMatrixFileName = fileNameRoot + getOutputFileNameTag("errormatrix");
                ofstream subMatrixFile;
                m->openOutputFile(subMatrixFileName, subMatrixFile);
-               outputNames.push_back(subMatrixFileName);  outputTypes["error.matrix"].push_back(subMatrixFileName);
+               outputNames.push_back(subMatrixFileName);  outputTypes["errormatrix"].push_back(subMatrixFileName);
                vector<string> bases(6);
                bases[0] = "A";
                bases[1] = "T";
@@ -1092,10 +1128,11 @@ void SeqErrorCommand::printSubMatrix(){
 
 void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map<char, vector<int> > errorReverse){
        try{
-               string errorForwardFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq.forward";
+        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
+               string errorForwardFileName = fileNameRoot + getOutputFileNameTag("errorforward");
                ofstream errorForwardFile;
                m->openOutputFile(errorForwardFileName, errorForwardFile);
-               outputNames.push_back(errorForwardFileName);  outputTypes["error.forward"].push_back(errorForwardFileName);
+               outputNames.push_back(errorForwardFileName);  outputTypes["errorforward"].push_back(errorForwardFileName);
 
                errorForwardFile << "position\ttotalseqs\tmatch\tsubstitution\tinsertion\tdeletion\tambiguous" << endl;
                for(int i=0;i<maxLength;i++){
@@ -1110,10 +1147,10 @@ void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map
                }
                errorForwardFile.close();
 
-               string errorReverseFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq.reverse";
+               string errorReverseFileName = fileNameRoot + getOutputFileNameTag("errorreverse");
                ofstream errorReverseFile;
                m->openOutputFile(errorReverseFileName, errorReverseFile);
-               outputNames.push_back(errorReverseFileName);  outputTypes["error.reverse"].push_back(errorReverseFileName);
+               outputNames.push_back(errorReverseFileName);  outputTypes["errorreverse"].push_back(errorReverseFileName);
 
                errorReverseFile << "position\ttotalseqs\tmatch\tsubstitution\tinsertion\tdeletion\tambiguous" << endl;
                for(int i=0;i<maxLength;i++){
@@ -1138,11 +1175,11 @@ void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map
 
 void SeqErrorCommand::printErrorQuality(map<char, vector<int> > qScoreErrorMap){
        try{
-
-               string errorQualityFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.quality";
+        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
+               string errorQualityFileName = fileNameRoot + getOutputFileNameTag("errorquality");
                ofstream errorQualityFile;
                m->openOutputFile(errorQualityFileName, errorQualityFile);
-               outputNames.push_back(errorQualityFileName);  outputTypes["error.quality"].push_back(errorQualityFileName);
+               outputNames.push_back(errorQualityFileName);  outputTypes["errorquality"].push_back(errorQualityFileName);
 
                errorQualityFile << "qscore\tmatches\tsubstitutions\tinsertions\tambiguous" << endl;
                for(int i=0;i<41;i++){
@@ -1172,11 +1209,11 @@ void SeqErrorCommand::printQualityFR(vector<vector<int> > qualForwardMap, vector
                                }
                        }
                }
-
-               string qualityForwardFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.qual.forward";
+        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(queryFileName));
+               string qualityForwardFileName = fileNameRoot + getOutputFileNameTag("errorqualforward");
                ofstream qualityForwardFile;
                m->openOutputFile(qualityForwardFileName, qualityForwardFile);
-               outputNames.push_back(qualityForwardFileName);  outputTypes["error.qual.forward"].push_back(qualityForwardFileName);
+               outputNames.push_back(qualityForwardFileName);  outputTypes["errorqualforward"].push_back(qualityForwardFileName);
 
                for(int i=0;i<numColumns;i++){  qualityForwardFile << '\t' << i;        }       qualityForwardFile << endl;
 
@@ -1191,10 +1228,10 @@ void SeqErrorCommand::printQualityFR(vector<vector<int> > qualForwardMap, vector
                qualityForwardFile.close();
 
                
-               string qualityReverseFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.qual.reverse";
+               string qualityReverseFileName = fileNameRoot + getOutputFileNameTag("errorqualreverse");
                ofstream qualityReverseFile;
                m->openOutputFile(qualityReverseFileName, qualityReverseFile);
-               outputNames.push_back(qualityReverseFileName);  outputTypes["error.qual.reverse"].push_back(qualityReverseFileName);
+               outputNames.push_back(qualityReverseFileName);  outputTypes["errorqualreverse"].push_back(qualityReverseFileName);
                
                for(int i=0;i<numColumns;i++){  qualityReverseFile << '\t' << i;        }       qualityReverseFile << endl;
                for(int i=0;i<numRows;i++){
index e7c97e152d718b8944b0e004b32398dd1f210e99..660544fff2982a325c325932b3972d9b3451f3c4 100644 (file)
@@ -24,6 +24,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "seq.error";                           }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Seq.error"; }
        string getDescription()         { return "seq.error"; }
index 1ea58c584054b9b4b5944db18d198fd49e78cc51..c328a041267d01e21ed2e99780f18de486571685 100644 (file)
@@ -45,6 +45,26 @@ string SeqSummaryCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string SeqSummaryCommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 SeqSummaryCommand::SeqSummaryCommand(){        
@@ -155,7 +175,7 @@ int SeqSummaryCommand::execute(){
                //set current fasta to fastafile
                m->setFastaFile(fastafile);
                
-               string summaryFile = outputDir + m->getSimpleName(fastafile) + ".summary";
+               string summaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("summary");
                                
                int numSeqs = 0;
                
index d8837a374d070298ceb9d224aaf8c621680bf249..79e8be96974141da315d1038a51096695212ad5c 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.seqs";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 3eb508dd737e15d4f06cb04c202608b5d5e1fe7c..c45602e4bf5c6083ae61a5943370f58a94042260 100644 (file)
@@ -68,71 +68,84 @@ SequenceParser::SequenceParser(string groupFile, string fastaFile, string nameFi
                int countName = 0;
                set<string> thisnames1;
                
-               while(!inName.eof()) {
-                       
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
+        string firstCol, secondCol;
+        
+               while (!inName.eof()) {
                        if (m->control_pressed) { break; }
                        
-                       inName >> first; m->gobble(inName);
-                       inName >> second; m->gobble(inName);
-                       
-                       vector<string> names;
-                       m->splitAtChar(second, names, ',');
-                       
-                       //get aligned string for these seqs from the fasta file
-                       string alignedString = "";
-                       map<string, string>::iterator itAligned = seqName.find(names[0]);
-                       if (itAligned == seqName.end()) {
-                               error = 1; m->mothurOut("[ERROR]: " + names[0] + " is in your name file and not in your fasta file, please correct."); m->mothurOutEndLine();
-                       }else {
-                               alignedString = itAligned->second;
-                       }
-                       
-                       //separate by group - parse one line in name file
-                       map<string, string> splitMap; //group -> name1,name2,...
-                       map<string, string>::iterator it;
-                       for (int i = 0; i < names.size(); i++) {
-                               
-                               string group = groupMap->getGroup(names[i]);
-                               if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + names[i] + " is in your name file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
-                               else {  
-                                       
-                                       it = splitMap.find(group);
-                                       if (it != splitMap.end()) { //adding seqs to this group
-                                               (it->second) += "," + names[i];
-                                               thisnames1.insert(names[i]);
-                                               countName++;
-                                       }else { //first sighting of this group
-                                               splitMap[group] = names[i];
-                                               countName++;
-                                               thisnames1.insert(names[i]);
-                                               
-                                               //is this seq in the fasta file?
-                                               if (i != 0) { //if not then we need to add a duplicate sequence to the seqs for this group so the new "fasta" and "name" files will match
-                                                       Sequence tempSeq(names[i], alignedString); //get the first guys sequence string since he's in the fasta file.
-                                                       seqs[group].push_back(tempSeq);
-                                               }
-                                       }
-                               }
-                               
-                               allSeqsMap[names[i]] = names[0];
-                       }
-                       
-                       
-                       //fill nameMapPerGroup - holds all lines in namefile separated by group
-                       for (it = splitMap.begin(); it != splitMap.end(); it++) {
-                               //grab first name
-                               string firstName = "";
-                               for(int i = 0; i < (it->second).length(); i++) {
-                                       if (((it->second)[i]) != ',') {
-                                               firstName += ((it->second)[i]);
-                                       }else { break; }
-                               }
-                               
-                               //group1 -> seq1 -> seq1,seq2,seq3
-                               nameMapPerGroup[it->first][firstName] = it->second;
-                       }
+            inName.read(buffer, 4096);
+            vector<string> pieces = m->splitWhiteSpace(rest, buffer, inName.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { //save one line
+                    vector<string> names;
+                    m->splitAtChar(second, names, ',');
+                    
+                    //get aligned string for these seqs from the fasta file
+                    string alignedString = "";
+                    map<string, string>::iterator itAligned = seqName.find(names[0]);
+                    if (itAligned == seqName.end()) {
+                        error = 1; m->mothurOut("[ERROR]: " + names[0] + " is in your name file and not in your fasta file, please correct."); m->mothurOutEndLine();
+                    }else {
+                        alignedString = itAligned->second;
+                    }
+                    
+                    //separate by group - parse one line in name file
+                    map<string, string> splitMap; //group -> name1,name2,...
+                    map<string, string>::iterator it;
+                    for (int i = 0; i < names.size(); i++) {
+                        
+                        string group = groupMap->getGroup(names[i]);
+                        if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + names[i] + " is in your name file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
+                        else { 
+                            
+                            it = splitMap.find(group);
+                            if (it != splitMap.end()) { //adding seqs to this group
+                                (it->second) += "," + names[i];
+                                thisnames1.insert(names[i]);
+                                countName++;
+                            }else { //first sighting of this group
+                                splitMap[group] = names[i];
+                                countName++;
+                                thisnames1.insert(names[i]);
+                                
+                                //is this seq in the fasta file?
+                                if (i != 0) { //if not then we need to add a duplicate sequence to the seqs for this group so the new "fasta" and "name" files will match
+                                    Sequence tempSeq(names[i], alignedString); //get the first guys sequence string since he's in the fasta file.
+                                    seqs[group].push_back(tempSeq);
+                                }
+                            }
+                        }
+                        
+                        allSeqsMap[names[i]] = names[0];
+                    }
+                    
+                    
+                    //fill nameMapPerGroup - holds all lines in namefile separated by group
+                    for (it = splitMap.begin(); it != splitMap.end(); it++) {
+                        //grab first name
+                        string firstName = "";
+                        for(int i = 0; i < (it->second).length(); i++) {
+                            if (((it->second)[i]) != ',') {
+                                firstName += ((it->second)[i]);
+                            }else { break; }
+                        }
+                        
+                        //group1 -> seq1 -> seq1,seq2,seq3
+                        nameMapPerGroup[it->first][firstName] = it->second;
+                    }
+
+                    pairDone = false; 
+                }
+            }
                }
-               
                inName.close();
                
                if (error == 1) { m->control_pressed = true; }
index 3949519e9ec3f04392d555539fd5409dcab59dea..becc4d4712bba2257018378424e4f555e1a6f42a 100644 (file)
@@ -23,6 +23,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.current"; }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Set.current"; }
        string getDescription()         { return "set current files for mothur"; }
index 9afc4ea6579d68019dfe04c56aab7119b78d656a..837a8b58053cc7b2f5491d8fb59ba00c7c758328 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.dir";             }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Set.dir"; }
        string getDescription()         { return "set input, output and default directories"; }
index 8d3bfcdc15d3c75253a78abe12b3277c1f9b6c8b..a97c7910ad6ccc2ad63544c0f2f6b9b875af1da8 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "set.logfile";         }
        string getCommandCategory()             { return "General";                     }
+       string getOutputFileNameTag(string, string) { return ""; }
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Set.logfile"; }
        string getDescription()         { return "set logfile name"; }
index f267ba4b7859ed091f749456cb5495799ffc9ec0..08cf21e5d6b543684cfebe56c0cdaf8697139125 100644 (file)
@@ -55,6 +55,29 @@ string SffInfoCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string SffInfoCommand::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 =  "fasta";   }
+            else if (type == "flow")    {   outputFileName =  "flow";   }
+            else if (type == "sfftxt")        {   outputFileName =  "sff.txt";   }
+            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);
+       }
+}
 
 
 //**********************************************************************************************************************
@@ -365,14 +388,14 @@ int SffInfoCommand::extractSffInfo(string input, string accnos){
         string rootName = outputDir + m->getRootName(m->getSimpleName(input));
         if(rootName.find_last_of(".") == rootName.npos){ rootName += "."; }
         
-               string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "sff.txt";
-               string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "flow";
+               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)) + "fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "qual";
+                       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.fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.qual";
+                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("fasta");
+                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("qfile");
                }
                
                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); }
@@ -940,17 +963,17 @@ int SffInfoCommand::parseSffTxt() {
                        fileRoot = m->getRootName(fileRoot);
                }
                
-               string outFlowFileName = outputDir + fileRoot + "flow";
+               string outFlowFileName = outputDir + fileRoot + getOutputFileNameTag("flow");
                if (trim) {
-                       outFastaFileName = outputDir + fileRoot + "fasta";
-                       outQualFileName = outputDir + fileRoot + "qual";
+                       outFastaFileName = outputDir + fileRoot + getOutputFileNameTag("fasta");
+                       outQualFileName = outputDir + fileRoot + getOutputFileNameTag("qfile");
                }else{
-                       outFastaFileName = outputDir + fileRoot + "raw.fasta";
-                       outQualFileName = outputDir + fileRoot + "raw.qual";
+                       outFastaFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("fasta");
+                       outQualFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("qfile");
                }
                
                if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
-               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName);  }
+               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName);  }
                if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  outFlow.setf(ios::fixed, ios::floatfield); outFlow.setf(ios::showpoint); outputTypes["flow"].push_back(outFlowFileName);  }
                
                //read common header
index 837435b3a6ca4c4c7f2e7e7579141b8fbece342b..4e72a960a7bb07d4e94df795bea462519f6d777a 100644 (file)
@@ -69,6 +69,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sffinfo";                                     }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; }
        string getDescription()         { return "extract sequences reads from a .sff file"; }
index 8f05cfcc567a8f0e5d9cbdc867bf15bebd887f11..f3330f7672e1fbaef8300f70b88c625ac9857b1c 100644 (file)
@@ -52,6 +52,29 @@ string SharedCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string SharedCommand::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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 SharedCommand::SharedCommand(){        
        try {
@@ -131,6 +154,10 @@ SharedCommand::SharedCommand(string option)  {
                                 }
                         }
                         
+             vector<string> tempOutNames;
+             outputTypes["rabund"] = tempOutNames;
+             outputTypes["shared"] = tempOutNames;
+             outputTypes["group"] = tempOutNames;
                         
                         //if the user changes the output directory command factory will send this info to us in the output parameter 
                         outputDir = validParameter.validFile(parameters, "outputdir", false);          if (outputDir == "not found"){  outputDir = ""; }
@@ -221,7 +248,7 @@ int SharedCommand::execute(){
                if (outputDir == "") { outputDir += m->hasPath(filename); }
                
                filename = outputDir + m->getRootName(m->getSimpleName(filename));
-               filename = filename + "shared";
+               filename = filename + getOutputFileNameTag("shared");
                outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
                
         if (listfile != "") {  createSharedFromListGroup(filename);  }
@@ -762,9 +789,9 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         
         //clears file before we start to write to it below
         for (int i=0; i<Groups.size(); i++) {
-            m->mothurRemove((fileroot + Groups[i] + ".rabund"));
-            outputNames.push_back((fileroot + Groups[i] + ".rabund"));
-            outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
+            m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
+            outputNames.push_back((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
+            outputTypes["rabund"].push_back((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));
         }
         
         string errorOff = "no error";
@@ -781,7 +808,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
             delete SharedList; delete groupMap; 
             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] + ".rabund"));                }
+            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
             return 0; 
         }
         
@@ -818,7 +845,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 }
             }else { groups = "merge"; }
             
-            string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + "groups";
+            string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + getOutputFileNameTag("group");
             outputTypes["group"].push_back(newGroupFile); 
             outputNames.push_back(newGroupFile);
             ofstream outGroups;
@@ -844,7 +871,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 delete SharedList; delete groupMap;
                 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] + ".rabund"));            }
+                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));         }
                 return 0; 
             }
             
@@ -862,7 +889,7 @@ 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] + ".rabund"));                }
+                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
                     return 0; 
                 }
                 
@@ -892,7 +919,7 @@ 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] + ".rabund"));                }
+                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
                     return 0; 
                 }
                 
@@ -938,7 +965,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
                 delete groupMap;
                 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] + ".rabund"));            }
+                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));         }
                 return 0; 
             }
             
@@ -958,7 +985,7 @@ 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] + ".rabund"));                }
+            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + "." + getOutputFileNameTag("rabund")));             }
             return 0; 
         }
 
@@ -987,7 +1014,7 @@ void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup, ofst
                                Groups.push_back(thislookup[i]->getGroup());
                                
                                RAbundVector rav = thislookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
+                               m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + "." + getOutputFileNameTag("rabund"), *(filehandles[thislookup[i]->getGroup()]));
                                rav.print(*(filehandles[thislookup[i]->getGroup()]));
                                (*(filehandles[thislookup[i]->getGroup()])).close();
                        }
@@ -1015,7 +1042,7 @@ void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup, ofst
                                        Groups.push_back((myIt->second)->getGroup());
                                
                                        RAbundVector rav = (myIt->second)->getRAbundVector();
-                                       m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
+                                       m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + "." + getOutputFileNameTag("rabund"), *(filehandles[(myIt->second)->getGroup()]));
                                        rav.print(*(filehandles[(myIt->second)->getGroup()]));
                                        (*(filehandles[(myIt->second)->getGroup()])).close();
                                }else{
index 5d0daa2fdc484f55b78613541e1e82ef547a7d09..1100c3d30afc344119538e89e7c40a8dfa839578 100644 (file)
@@ -30,6 +30,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "make.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Make.shared"; }
        string getDescription()         { return "make a shared file from a list and group file"; }
index 8ae76d9836c31b0d3a37ac41d58a6aa54db6e859..97629b600031c06c063f405175dd9fa369ae7c93 100644 (file)
@@ -47,6 +47,30 @@ 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);
+       }
+}
+//**********************************************************************************************************************
 
 ShhherCommand::ShhherCommand(){        
        try {
@@ -54,8 +78,12 @@ ShhherCommand::ShhherCommand(){
                setParameters();
                
                //initialize outputTypes
-//             vector<string> tempOutNames;
-//             outputTypes["pn.dist"] = tempOutNames;
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+        outputTypes["name"] = tempOutNames;
+        outputTypes["group"] = tempOutNames;
+        outputTypes["counts"] = tempOutNames;
+        outputTypes["qfile"] = tempOutNames;
 
        }
        catch(exception& e) {
@@ -96,9 +124,13 @@ ShhherCommand::ShhherCommand(string option) {
                        }
                        
                        //initialize outputTypes
-                       vector<string> tempOutNames;
-//                     outputTypes["pn.dist"] = tempOutNames;
-                       //                      outputTypes["fasta"] = tempOutNames;
+            vector<string> tempOutNames;
+            outputTypes["fasta"] = tempOutNames;
+            outputTypes["name"] = tempOutNames;
+            outputTypes["group"] = tempOutNames;
+            outputTypes["counts"] = tempOutNames;
+            outputTypes["qfile"] = tempOutNames;
+
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
@@ -770,7 +802,7 @@ string ShhherCommand::createNamesFile(){
                        duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
                }
                
-               string nameFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.names";
+               string nameFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName) + getOutputFileNameTag("name");
                
                ofstream nameFile;
                m->openOutputFile(nameFileName, nameFile);
@@ -1614,7 +1646,7 @@ void ShhherCommand::writeQualities(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.qual";
+        string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("qfile");
         
         ofstream qualityFile;
         m->openOutputFile(qualityFileName, qualityFile);
@@ -1721,7 +1753,7 @@ void ShhherCommand::writeSequences(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.fasta";
+        string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("fasta");
         ofstream fastaFile;
         m->openOutputFile(fastaFileName, fastaFile);
         
@@ -1769,7 +1801,7 @@ void ShhherCommand::writeNames(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.names";
+        string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("name");
         ofstream nameFile;
         m->openOutputFile(nameFileName, nameFile);
         
@@ -1808,7 +1840,7 @@ void ShhherCommand::writeGroups(){
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
         string fileRoot = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
-        string groupFileName = fileRoot + "shhh.groups";
+        string groupFileName = fileRoot + getOutputFileNameTag("group");
         ofstream groupFile;
         m->openOutputFile(groupFileName, groupFile);
         
@@ -1832,7 +1864,7 @@ void ShhherCommand::writeClusters(vector<int> otuCounts){
     try {
         string thisOutputDir = outputDir;
         if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.counts";
+        string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) +getOutputFileNameTag("counts");
         ofstream otuCountsFile;
         m->openOutputFile(otuCountsFileName, otuCountsFile);
         
@@ -2283,12 +2315,12 @@ 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)) + "shhh.qual";
-                string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.fasta";
-                string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.names";
-                string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.counts";
+                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");
                 string fileRoot = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
-                string groupFileName = fileRoot + "shhh.groups";
+                string groupFileName = fileRoot + getOutputFileNameTag("group");
 
                 
                 writeQualities(numOTUs, numFlowCells, qualityFileName, otuCounts, nSeqsPerOTU, seqNumber, singleTau, flowDataIntI, uniqueFlowgrams, cumNumSeqs, mapUniqueToSeq, seqNameVector, centroids, aaI); if (m->control_pressed) { break; }
@@ -2299,15 +2331,15 @@ int ShhherCommand::driver(vector<string> filenames, string thisCompositeFASTAFil
                 
                 if (large) {
                     if (g > 0) {
-                        m->appendFiles(qualityFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + "shhh.qual"));
+                        m->appendFiles(qualityFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("qfile")));
                         m->mothurRemove(qualityFileName);
-                        m->appendFiles(fastaFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + "shhh.fasta"));
+                        m->appendFiles(fastaFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("fasta")));
                         m->mothurRemove(fastaFileName);
-                        m->appendFiles(nameFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + "shhh.names"));
+                        m->appendFiles(nameFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("name")));
                         m->mothurRemove(nameFileName);
-                        m->appendFiles(otuCountsFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + "shhh.counts"));
+                        m->appendFiles(otuCountsFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("counts")));
                         m->mothurRemove(otuCountsFileName);
-                        m->appendFiles(groupFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + "shhh.groups"));
+                        m->appendFiles(groupFileName, (thisOutputDir + m->getRootName(m->getSimpleName(theseFlowFileNames[0])) + getOutputFileNameTag("group")));
                         m->mothurRemove(groupFileName);
                     }
                     m->mothurRemove(theseFlowFileNames[g]);
index 5ef43df17099c0b269c73c60dd6cf02e355b6176..03f171e8a85cf0ebe363381793fbaea7e69950ab 100644 (file)
@@ -41,6 +41,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "shhh.flows";  }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Shhh.flows"; }
        string getDescription()         { return "shhh.flows"; }
index 5c6359ec58bb776ce9a050a132e8409e60cf197b..63de2bb5541ddbd653b90eced12b4d59a9084629 100644 (file)
@@ -54,6 +54,29 @@ string ShhhSeqsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string ShhhSeqsCommand::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_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);
+       }
+}
+
 //**********************************************************************************************************************
 
 ShhhSeqsCommand::ShhhSeqsCommand(){    
@@ -185,9 +208,9 @@ 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)) + "shhh.fasta";
-               string nameFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + "shhh.names";
-               string mapFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + "shhh.map";
+               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 (groupfile != "") {
                        //Parse sequences by group
index 7174ac70caf3f55e146d1cdf09e2b15e5b0cfaf4..a4695be5934eddf0fab5da392fe587b1a8199432 100644 (file)
@@ -29,6 +29,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "shhh.seqs";   }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Shhh.seqs"; }
        string getDescription()         { return "shhh.seqs"; }
index 0236a505d7dafb683ebe188bbad768a88ca5a5c3..ee7bf7304c0a952fb29064aa87e0cf3892b98808 100644 (file)
@@ -52,6 +52,31 @@ string SortSeqsCommand::getHelpString(){
        }
 }
 
+//**********************************************************************************************************************
+string SortSeqsCommand::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 =  "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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 SortSeqsCommand::SortSeqsCommand(){    
@@ -230,7 +255,13 @@ int SortSeqsCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //read through the correct file and output lines you want to keep
-        if (accnosfile != "")          {               readAccnos();   }
+        if (accnosfile != "")          {               
+            vector<string> temp;
+            m->readAccnos(accnosfile, temp);
+            for (int i = 0; i < temp.size(); i++) {  names[temp[i]] = i;  }
+            m->mothurOut("\nUsing " + accnosfile + " to determine the order. It contains " + toString(temp.size()) + " representative sequences.\n");  
+        }
+        
                if (fastafile != "")            {               readFasta();    }
         if (flowfile != "")         {          readFlow();     }
         if (qualfile != "")                    {               readQual();             }
@@ -294,7 +325,7 @@ int SortSeqsCommand::readFasta(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "sorted" + m->getExtension(fastafile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);
                outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -467,7 +498,7 @@ int SortSeqsCommand::readFlow(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(flowfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowfile)) + "sorted" + m->getExtension(flowfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowfile)) + getOutputFileNameTag("flow", flowfile);
                outputTypes["flow"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -645,7 +676,7 @@ int SortSeqsCommand::readQual(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "sorted" +  m->getExtension(qualfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("qfile", qualfile);
         outputTypes["qfile"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -825,7 +856,7 @@ int SortSeqsCommand::readName(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "sorted" + m->getExtension(namefile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile); 
         outputTypes["name"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -902,8 +933,8 @@ int SortSeqsCommand::readGroup(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               outputTypes["group"].push_back(outputFileName);  outputNames.push_back(outputFileName);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile); 
+        outputTypes["group"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -978,7 +1009,7 @@ int SortSeqsCommand::readTax(){
        try {
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("taxonomy", taxfile); 
         outputTypes["taxonomy"].push_back(outputFileName);  outputNames.push_back(outputFileName);
         
                ofstream out;
@@ -1051,38 +1082,6 @@ int SortSeqsCommand::readTax(){
        }
 }
 //**********************************************************************************************************************
-int SortSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-        int count = 0;
-               
-               while(!in.eof()){
-            
-            if (m->control_pressed) { break; }
-            
-                       in >> name; m->gobble(in);
-            
-            if (name != "") {
-                names[name] = count;
-                count++;
-            }
-               }
-               in.close();             
-        
-        m->mothurOut("\nUsing " + accnosfile + " to determine the order. It contains " + toString(count) + " representative sequences.\n");
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
 
 
 
index 0685d3bad74dde206fce4872fd165186f15df355..6d9c5ed8f2c6183ffdce14f52bff60da3f2316a8 100644 (file)
@@ -25,7 +25,8 @@ public:
     vector<string> setParameters();
     string getCommandName()                    { return "sort.seqs";                           }
     string getCommandCategory()                { return "Sequence Processing";         }
-    string getHelpString();    
+    string getOutputFileNameTag(string, string);
+       string getHelpString(); 
     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"; }
     
@@ -43,7 +44,6 @@ private:
     int readFlow();
     int readName();
     int readGroup();
-    int readAccnos();
     int readTax();
     int readQual();
     
index 8131fa9195f6b8d939b27891605dd862d618964b..bc1cdb3ecfaa8ca528b88c2534e40c61263aacef 100644 (file)
@@ -56,7 +56,30 @@ string SplitAbundCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string SplitAbundCommand::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 =  "fasta";   }
+            else if (type == "list")    {   outputFileName =  "list";   }
+            else if (type == "name")        {   outputFileName =  "names";   }
+            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);
+       }
+}
 //**********************************************************************************************************************
 SplitAbundCommand::SplitAbundCommand(){        
        try {
@@ -434,11 +457,11 @@ int SplitAbundCommand::writeList(ListVector* thisList, string tag) {
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare.list";
+                       string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare." + getOutputFileNameTag("list");
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["list"].push_back(rare);
                        
-                       string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund.list";
+                       string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund." + getOutputFileNameTag("list");
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["list"].push_back(abund);
 
@@ -476,10 +499,12 @@ int SplitAbundCommand::writeList(ListVector* thisList, string tag) {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + Groups[i] + tag + ".rare.list", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + Groups[i] + tag + ".abund.list", *(filehandles[Groups[i]+".abund"]));
-                               outputNames.push_back(fileroot + Groups[i] + tag + ".rare.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".rare.list");
-                               outputNames.push_back(fileroot + Groups[i] + tag + ".abund.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".abund.list");
+                string rareGroupFileName = fileroot + Groups[i] + tag + ".rare." + getOutputFileNameTag("list");
+                string abundGroupFileName = fileroot + Groups[i] + tag + ".abund." + getOutputFileNameTag("list");
+                               m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
+                               outputNames.push_back(rareGroupFileName); outputTypes["list"].push_back(rareGroupFileName);
+                               outputNames.push_back(abundGroupFileName); outputTypes["list"].push_back(abundGroupFileName);
                        }
                        
                        map<string, string> groupVector;
@@ -642,11 +667,11 @@ int SplitAbundCommand::writeNames() { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare.names";
+                       string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare." + getOutputFileNameTag("name");
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["name"].push_back(rare);
                        
-                       string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund.names";
+                       string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund." + getOutputFileNameTag("name");
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["name"].push_back(abund);
                        
@@ -677,8 +702,10 @@ int SplitAbundCommand::writeNames() { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
+                string rareGroupFileName = fileroot + Groups[i] + ".rare." + getOutputFileNameTag("name");
+                string abundGroupFileName = fileroot + Groups[i] + ".abund." + getOutputFileNameTag("name");
+                               m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
@@ -714,7 +741,7 @@ int SplitAbundCommand::writeNames() { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + it3->first + ".names");  outputTypes["name"].push_back(fileroot + it3->first + ".names");
+                               outputNames.push_back(fileroot + it3->first + "." + getOutputFileNameTag("name"));  outputTypes["name"].push_back(fileroot + it3->first + "." + getOutputFileNameTag("name"));
                                delete it3->second;
                        }
                }
@@ -739,7 +766,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        ofstream rout;
                        
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare.accnos";
+                       string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare." + getOutputFileNameTag("accnos");
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["accnos"].push_back(rare); 
                        
@@ -748,7 +775,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        }
                        rout.close();
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund.accnos";
+                       string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund." + getOutputFileNameTag("accnos");
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
                        
@@ -770,8 +797,8 @@ int SplitAbundCommand::writeAccnos(string tag) {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
+                               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"]));
                        }
                        
                        //write rare
@@ -795,7 +822,7 @@ 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 + ".accnos");  outputTypes["accnos"].push_back(fileroot + tag + it3->first + ".accnos");
+                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos"));  outputTypes["accnos"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos"));
                                delete it3->second;
                        }
                }
@@ -818,11 +845,12 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare.groups";
+                       string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare." + getOutputFileNameTag("group");
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["group"].push_back(rare);
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund.groups";
+                       string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund." + getOutputFileNameTag("group");
+;
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["group"].push_back(abund);
                        
@@ -862,8 +890,8 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
+                               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"]));
                        }
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
@@ -889,7 +917,7 @@ 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 + ".groups");  outputTypes["group"].push_back(fileroot + tag + it3->first + ".groups");
+                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group"));  outputTypes["group"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group"));
                                delete it3->second;
                        }
                }
@@ -912,11 +940,11 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare.fasta";
+                       string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare." + getOutputFileNameTag("fasta");
                        m->openOutputFile(rare, rout);
                        outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
                
-                       string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund.fasta";
+                       string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund." + getOutputFileNameTag("fasta");
                        m->openOutputFile(abund, aout);
                        outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
                
@@ -963,8 +991,8 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
+                               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"]));
                        }
                        
                        //open input file
@@ -1009,7 +1037,7 @@ 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 + ".fasta");  outputTypes["fasta"].push_back(fileroot + tag + it3->first + ".fasta");
+                               outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta"));  outputTypes["fasta"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta"));
                                delete it3->second;
                        }
                }
index df925f34cc70bc405ac35e2302ecc49a8fd97872..232c36ba36763dcdb325fb9f8404d537e92450a6 100644 (file)
@@ -35,6 +35,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "split.abund";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 26716554decad148623563d4b120148325b7477a..af3ca665b5791d0001141f27192b78aab171d71a 100644 (file)
@@ -51,6 +51,27 @@ string SplitGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string SplitGroupCommand::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 =  "fasta";   }
+            else if (type == "name")        {   outputFileName =  "names";   }
+            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);
+       }
+}
+//**********************************************************************************************************************
 SplitGroupCommand::SplitGroupCommand(){        
        try {
                abort = true; calledHelp = true; 
@@ -188,8 +209,8 @@ int SplitGroupCommand::execute(){
                        
                        m->mothurOut("Processing group: " + Groups[i]); m->mothurOutEndLine();
                        
-                       string newFasta = fastafileRoot + Groups[i] + ".fasta";
-                       string newName = namefileRoot + Groups[i] + ".names";
+                       string newFasta = fastafileRoot + Groups[i] + "." + getOutputFileNameTag("fasta");
+                       string newName = namefileRoot + Groups[i] + "." + getOutputFileNameTag("name");
                        
                        parser->getSeqs(Groups[i], newFasta, false);
                        outputNames.push_back(newFasta); outputTypes["fasta"].push_back(newFasta);
index a6b8854752f406a2bcaf82d5094c9abe023c2a46..a8dc9a19e656651be58416c99e802e1b98b72a56 100644 (file)
@@ -30,6 +30,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "split.group";                         }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Split.group"; }
        string getDescription()         { return "split a name or fasta file by group"; }
index 59e49a79e9e702cfcf70c47ffee3a42da8a0b537..384b09af1bb94be09c5607c8b863b28b16215731 100644 (file)
@@ -91,16 +91,13 @@ int SplitMatrix::splitClassify(){
                //build tree from users taxonomy file
                PhyloTree* phylo = new PhyloTree();
                
-               ifstream in;
-               m->openInputFile(taxFile, in);
-                       
-               //read in users taxonomy file and add sequences to tree
-               string seqname, tax;
-               while(!in.eof()){
-                       in >> seqname >> tax; m->gobble(in);
-                       phylo->addSeqToTree(seqname, tax);
-               }
-               in.close();
+        map<string, string> temp;
+        m->readTax(taxFile, temp);
+        
+        for (map<string, string>::iterator itTemp = temp.begin(); itTemp != temp.end();) {
+            phylo->addSeqToTree(itTemp->first, itTemp->second);
+            temp.erase(itTemp++);
+        }
                
                phylo->assignHeirarchyIDs(0);
 
index aebba6bbc430a6608d5fe8bb0a31ef9ebd58c4f4..35441013919fbfe55452532e735b5bd1d7673f2f 100644 (file)
@@ -63,6 +63,33 @@ string SubSampleCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string SubSampleCommand::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 =  "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 == "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);
+       }
+}
+
 //**********************************************************************************************************************
 SubSampleCommand::SubSampleCommand(){  
        try {
@@ -479,8 +506,7 @@ int SubSampleCommand::getSubSampleFasta() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "subsample" + m->getExtension(fastafile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + getOutputFileNameTag("fasta", fastafile);         
                ofstream out;
                m->openOutputFile(outputFileName, out);
                
@@ -528,6 +554,7 @@ int SubSampleCommand::getSubSampleFasta() {
                if (namefile != "") {
                        m->mothurOut("Deconvoluting subsampled fasta file... "); m->mothurOutEndLine();
                        
+            string outputNameFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + getOutputFileNameTag("name", namefile);
                        //use unique.seqs to create new name and fastafile
                        string inputString = "fasta=" + outputFileName;
                        m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
@@ -542,10 +569,11 @@ int SubSampleCommand::getSubSampleFasta() {
                        delete uniqueCommand;
                        m->mothurCalling = false;
             
-                       outputTypes["name"].push_back(filenames["name"][0]);  outputNames.push_back(filenames["name"][0]);
-                       m->mothurRemove(outputFileName);
-                       outputFileName = filenames["fasta"][0];
-                       
+            m->renameFile(filenames["name"][0], outputNameFileName);
+            m->renameFile(filenames["fasta"][0], outputFileName);
+            
+                       outputTypes["name"].push_back(outputNameFileName);  outputNames.push_back(outputNameFileName);
+
                        m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
                        
                        m->mothurOut("Done."); m->mothurOutEndLine();
@@ -558,7 +586,7 @@ int SubSampleCommand::getSubSampleFasta() {
                        
                        string groupOutputDir = outputDir;
                        if (outputDir == "") {  groupOutputDir += m->hasPath(groupfile);  }
-                       string groupOutputFileName = groupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "subsample" + m->getExtension(groupfile);
+                       string groupOutputFileName = groupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + getOutputFileNameTag("group", groupfile);
                        
                        ofstream outGroup;
                        m->openOutputFile(groupOutputFileName, outGroup);
@@ -780,8 +808,7 @@ 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() + ".subsample" + m->getExtension(sharedfile);
-        
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + thislookup[0]->getLabel() + getOutputFileNameTag("shared", sharedfile);        
         SubSample sample;
         vector<string> subsampledLabels = sample.getSample(thislookup, size);
         
@@ -819,8 +846,7 @@ int SubSampleCommand::getSubSampleList() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "subsample" + m->getExtension(listfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + getOutputFileNameTag("list", listfile);            
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -1164,8 +1190,7 @@ int SubSampleCommand::getSubSampleRabund() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + "subsample" + m->getExtension(rabundfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + getOutputFileNameTag("rabund", rabundfile);              
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["rabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
@@ -1319,8 +1344,7 @@ int SubSampleCommand::getSubSampleSabund() {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + "subsample" + m->getExtension(sabundfile);
-               
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + getOutputFileNameTag("sabund", sabundfile);              
                ofstream out;
                m->openOutputFile(outputFileName, out);
                outputTypes["sabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
index 7235a7b68ec569412bb97d1b98f076ff3b439bdb..c746e144119dc4d4c0d45ef10872b1f7c9951129 100644 (file)
@@ -28,6 +28,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "sub.sample";  }
        string getCommandCategory()             { return "General";             }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 85f0970f25930f563616c5fba9bc27fecda9cf98..9a6aac883c7d13af87d735df4a7d484dd379479b 100644 (file)
@@ -84,7 +84,26 @@ string SummaryCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string SummaryCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 SummaryCommand::SummaryCommand(){      
        try {
@@ -288,13 +307,10 @@ int SummaryCommand::execute(){
                        numLines = 0;
                        numCols = 0;
                        
-                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "summary";
-            string fileNameAve = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "ave";
-            string fileNameSTD = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "std";
-                       outputNames.push_back(fileNameRoot); outputTypes["summary"].push_back(fileNameRoot);
+                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + getOutputFileNameTag("summary");
+            string fileNameAve = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "ave-std." + getOutputFileNameTag("summary");
+            outputNames.push_back(fileNameRoot); outputTypes["summary"].push_back(fileNameRoot);
             
-            
-                       
                        if (inputFileNames.size() > 1) {
                                m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
                 groupIndex[fileNameRoot] = groups[p];
@@ -369,18 +385,14 @@ int SummaryCommand::execute(){
                        m->openOutputFile(fileNameRoot, outputFileHandle);
                        outputFileHandle << "label";
             
-            ofstream outAve, outSTD;
+            ofstream outAve;
             if (subsample) {
                 m->openOutputFile(fileNameAve, outAve);
-                m->openOutputFile(fileNameSTD, outSTD);
-                outputNames.push_back(fileNameAve); outputTypes["ave"].push_back(fileNameAve);
-                outputNames.push_back(fileNameSTD); outputTypes["std"].push_back(fileNameSTD);
-                outAve << "label"; outSTD << "label";
+                outputNames.push_back(fileNameAve); outputTypes["summary"].push_back(fileNameAve);
+                outAve << "label\tmethod"; 
                 outAve.setf(ios::fixed, ios::floatfield); outAve.setf(ios::showpoint);
-                outSTD.setf(ios::fixed, ios::floatfield); outSTD.setf(ios::showpoint);
                 if (inputFileNames.size() > 1) {
                     groupIndex[fileNameAve] = groups[p];
-                    groupIndex[fileNameSTD] = groups[p];
                 }
             }
                
@@ -391,17 +403,17 @@ int SummaryCommand::execute(){
                        for(int i=0;i<sumCalculators.size();i++){
                                if(sumCalculators[i]->getCols() == 1){
                                        outputFileHandle << '\t' << sumCalculators[i]->getName();
-                    if (subsample) { outAve << '\t' << sumCalculators[i]->getName(); outSTD << '\t' << sumCalculators[i]->getName(); }
+                    if (subsample) { outAve << '\t' << sumCalculators[i]->getName();  }
                                        numCols++;
                                }
                                else{
                                        outputFileHandle << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";
-                    if (subsample) { outAve << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci"; outSTD << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci"; }
+                    if (subsample) { outAve << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";  }
                                        numCols += 3;
                                }
                        }
                        outputFileHandle << endl;
-            if (subsample) { outSTD << endl; outAve << endl; }
+            if (subsample) {  outAve << endl; }
                        
                        //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                        set<string> processedLabels;
@@ -409,11 +421,11 @@ int SummaryCommand::execute(){
                        
             
             
-                       if (m->control_pressed) {  outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                       if (m->control_pressed) {  outputFileHandle.close(); outAve.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                        
                        while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                
-                               if (m->control_pressed) { outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                               if (m->control_pressed) { outputFileHandle.close(); outAve.close();  for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                                
                                if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
                                        
@@ -421,9 +433,9 @@ int SummaryCommand::execute(){
                                        processedLabels.insert(sabund->getLabel());
                                        userLabels.erase(sabund->getLabel());
                                        
-                    process(sabund, outputFileHandle, outAve, outSTD);
+                    process(sabund, outputFileHandle, outAve);
                     
-                    if (m->control_pressed) { outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                    if (m->control_pressed) { outputFileHandle.close(); outAve.close();  for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                                        numLines++;
                                }
                                
@@ -437,9 +449,9 @@ int SummaryCommand::execute(){
                                        processedLabels.insert(sabund->getLabel());
                                        userLabels.erase(sabund->getLabel());
                                        
-                    process(sabund, outputFileHandle, outAve, outSTD);
+                    process(sabund, outputFileHandle, outAve);
                     
-                    if (m->control_pressed) { outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                    if (m->control_pressed) { outputFileHandle.close(); outAve.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                                        numLines++;
                                        
                                        //restore real lastlabel to save below
@@ -452,7 +464,7 @@ int SummaryCommand::execute(){
                                sabund = input->getSAbundVector();
                        }
                        
-                       if (m->control_pressed) {  outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
+                       if (m->control_pressed) {  outputFileHandle.close(); outAve.close();  for (int i = 0; i < outputNames.size(); i++) {    m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
 
                        //output error messages about any remaining user labels
                        set<string>::iterator it;
@@ -473,15 +485,15 @@ int SummaryCommand::execute(){
                                sabund = input->getSAbundVector(lastLabel);
                                
                                m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                process(sabund, outputFileHandle, outAve, outSTD);
+                process(sabund, outputFileHandle, outAve);
                 
-                if (m->control_pressed) { outputFileHandle.close(); outAve.close(); outSTD.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
+                if (m->control_pressed) { outputFileHandle.close(); outAve.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
                                numLines++;
                                delete sabund;
                        }
                        
                        outputFileHandle.close();
-            if (subsample) { outAve.close(); outSTD.close(); }
+            if (subsample) { outAve.close(); }
                        
                        if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
 
@@ -510,7 +522,7 @@ int SummaryCommand::execute(){
        }
 }
 //**********************************************************************************************************************
-int SummaryCommand::process(SAbundVector*& sabund, ofstream& outputFileHandle, ofstream& outAve, ofstream& outStd) {
+int SummaryCommand::process(SAbundVector*& sabund, ofstream& outputFileHandle, ofstream& outAve) {
     try {
         
         //calculator -> data -> values
@@ -559,7 +571,7 @@ int SummaryCommand::process(SAbundVector*& sabund, ofstream& outputFileHandle, o
         outputFileHandle << endl;
      
         if (subsample) {
-            outAve << sabund->getLabel() << '\t'; outStd << sabund->getLabel() << '\t';
+            outAve << sabund->getLabel() << '\t' << "ave\t"; 
             //find ave and std for this label and output
             //will need to modify the createGroupSummary to combine results and not mess with the .summary file.
             
@@ -594,14 +606,15 @@ int SummaryCommand::process(SAbundVector*& sabund, ofstream& outputFileHandle, o
                 }
             }
             
+            outAve << endl << sabund->getLabel() << '\t' << "std\t"; 
             for (int i = 0; i < stdDev.size(); i++) {  //finds average.
                 for (int j = 0; j < stdDev[i].size(); j++) {
                     stdDev[i][j] /= (float) iters;
                     stdDev[i][j] = sqrt(stdDev[i][j]);
-                    outStd << stdDev[i][j] << '\t';
+                    outAve << stdDev[i][j] << '\t';
                 }
             }
-            outAve << endl;  outStd << endl; 
+            outAve << endl;  
         }
         
         return 0;
@@ -702,38 +715,37 @@ vector<string> SummaryCommand::createGroupSummaryFile(int numLines, int numCols,
                                
                //open each groups summary file
         vector<string> newComboNames;
-               string newLabel = "";
+               
                map<string, map<string, vector<string> > > files;
+        map<string, string> filesTypesLabels;
+        map<string, int> filesTypesNumLines;
                for (int i=0; i<outputNames.size(); i++) {
-            string extension = m->getExtension(outputNames[i]);
-            string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + extension;
-                       m->mothurRemove(combineFileName); //remove old file
-             
                        vector<string> thisFilesLines;
             
                        ifstream temp;
                        m->openInputFile(outputNames[i], temp);
                        
                        //read through first line - labels
-                       string tempLabel;
-                       if (i == 0) { //we want to save the labels to output below
-                               for (int j = 0; j < numCols+1; j++) {  
-                                       temp >> tempLabel; 
-                                       
-                                       if (j == 1) {  newLabel += "group\t" + tempLabel + '\t';
-                                       }else{  newLabel += tempLabel + '\t';   }
-                               }
-                       }else{  for (int j = 0; j < numCols+1; j++) {  temp >> tempLabel;  }  }
+            string labelsLine = m->getline(temp);
+            vector<string> theseLabels = m->splitWhiteSpace(labelsLine);
+            
+            string newLabel = "";
+            for (int j = 0; j < theseLabels.size(); j++) { 
+                 if (j == 1) {  newLabel += "group\t" + theseLabels[j] + '\t';
+                }else{  newLabel += theseLabels[j] + '\t';     }
+            }
                        
                        m->gobble(temp);
                        
+            int stop = numLines;
+            if (theseLabels.size() != numCols+1) {  stop = numLines*2; }
                        //for each label
-                       for (int k = 0; k < numLines; k++) {
+                       for (int k = 0; k < stop; k++) {
                                
                                string thisLine = "";
                                string tempLabel;
                                        
-                               for (int j = 0; j < numCols+1; j++) {  
+                               for (int j = 0; j < theseLabels.size(); j++) {  
                                        temp >> tempLabel; 
                                                
                                        //save for later
@@ -748,6 +760,13 @@ vector<string> SummaryCommand::createGroupSummaryFile(int numLines, int numCols,
                                m->gobble(temp);
                        }
             
+            string extension = m->getExtension(outputNames[i]);
+            if (theseLabels.size() != numCols+1) { extension = ".ave-std" + extension;  }
+            string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + extension;
+                       m->mothurRemove(combineFileName); //remove old file
+            filesTypesLabels[extension] = newLabel;
+            filesTypesNumLines[extension] = stop;
+            
             map<string, map<string, vector<string> > >::iterator itFiles = files.find(extension);
             if (itFiles != files.end()) { //add new files info to existing type
                 files[extension][outputNames[i]] = thisFilesLines;
@@ -758,7 +777,7 @@ vector<string> SummaryCommand::createGroupSummaryFile(int numLines, int numCols,
             }
                        
                        temp.close();
-                       m->mothurRemove(outputNames[i]);
+                       //m->mothurRemove(outputNames[i]);
                }
                
         
@@ -775,10 +794,10 @@ vector<string> SummaryCommand::createGroupSummaryFile(int numLines, int numCols,
             m->openOutputFile(combineFileName, out);
             
             //output label line to new file
-            out << newLabel << endl;
+            out <<  filesTypesLabels[extension] << endl;
                
             //for each label
-            for (int k = 0; k < numLines; k++) {
+            for (int k = 0; k < filesTypesNumLines[extension]; k++) {
                
                 //grab summary data for each group
                 for (map<string, vector<string> >::iterator itType = thisType.begin(); itType != thisType.end(); itType++) {
index 1d93a333a8c971458ced6ca8803cb0b2027a48b2..4936dd8e9ad004bbf18352bb36659463c62be746 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.single";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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"; }
@@ -48,7 +49,7 @@ private:
        
        vector<string> parseSharedFile(string);
        vector<string> createGroupSummaryFile(int, int, vector<string>&, map<string, string>);
-    int process(SAbundVector*&, ofstream&, ofstream&, ofstream&);
+    int process(SAbundVector*&, ofstream&, ofstream&);
 
 
 };
index 5c175106ecb2584d07ca15a06c71f27284a3571c..5d7971349656d4400e5d41a24c15e576ccdf57f7 100644 (file)
@@ -45,7 +45,26 @@ string SummaryQualCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string SummaryQualCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 SummaryQualCommand::SummaryQualCommand(){      
        try {
@@ -189,7 +208,7 @@ int SummaryQualCommand::execute(){
                if (m->control_pressed) {  return 0; }
                
                //print summary file
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + "qual.summary";
+               string summaryFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + getOutputFileNameTag("summary");
                printQual(summaryFile, position, averageQ, scores);
                
                if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
index bbd103c1d14f7b40badd9654152aec0fd2b47a10..31390b4296ff7659fdfb2946d3f37ff33b2877b7 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.qual";                        }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Summary.qual"; }
        string getDescription()         { return "summarize the quality of a set of sequences"; }
index 6792f19f219ad99f0bb13d0eec3b84ae20e67c88..50fbd32c3bcfa39e6b3b9c1014338eceeb7d8a8d 100644 (file)
@@ -64,12 +64,34 @@ string SummarySharedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string SummarySharedCommand::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 == "summary")            {   outputFileName =  "shared.summary";   }
+            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);
+       }
+}
+//**********************************************************************************************************************
 SummarySharedCommand::SummarySharedCommand(){  
        try {
                abort = true; calledHelp = true; 
                setParameters();
                vector<string> tempOutNames;
                outputTypes["summary"] = tempOutNames;
+        outputTypes["phylip"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
@@ -104,6 +126,7 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                        //initialize outputTypes
                        vector<string> tempOutNames;
                        outputTypes["summary"] = tempOutNames;
+            outputTypes["phylip"] = 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);              
@@ -294,7 +317,7 @@ int SummarySharedCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                ofstream outputFileHandle, outAll;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "shared.summary";
+               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary");
                
                //if the users entered no valid calculators don't execute command
                if (sumCalculators.size() == 0) { return 0; }
@@ -325,7 +348,7 @@ int SummarySharedCommand::execute(){
                outputFileHandle.close();
                
                //create file and put column headers for multiple groups file
-               string outAllFileName = ((m->getRootName(sharedfile)) + "sharedmultiple.summary");
+               string outAllFileName = ((m->getRootName(sharedfile)) + "multiple." + getOutputFileNameTag("summary"));
                if (mult == true) {
                        m->openOutputFile(outAllFileName, outAll);
                        outputNames.push_back(outAllFileName);
@@ -763,7 +786,7 @@ 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 + ".dist";
+                        string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + "." + getOutputFileNameTag("phylip");
                         outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                         ofstream outDist;
                         m->openOutputFile(distFileName, outDist);
@@ -856,7 +879,7 @@ 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.dist";
+                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave." + getOutputFileNameTag("phylip");;
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outAve;
                 m->openOutputFile(distFileName, outAve);
@@ -866,7 +889,7 @@ int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string
                 
                 outAve.close();
                 
-                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std.dist";
+                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std." + getOutputFileNameTag("phylip");
                 outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
                 ofstream outSTD;
                 m->openOutputFile(distFileName, outSTD);
index 99ed5d039c9e95e6404731d092b81c2f824a0309..7c6a4b2965783a8145d311cfae05a150d82c2ce7 100644 (file)
@@ -67,6 +67,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "summary.shared";                      }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        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 ffa304102b95570669e4e977a9f4859b18c24c71..3e16e74005c5f0b7cfc62d32df7c172be805e511 100644 (file)
@@ -48,7 +48,26 @@ string SummaryTaxCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string SummaryTaxCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 SummaryTaxCommand::SummaryTaxCommand(){        
        try {
@@ -225,7 +244,7 @@ int SummaryTaxCommand::execute(){
                
                //print summary file
                ofstream outTaxTree;
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "tax.summary";
+               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("summary");
                m->openOutputFile(summaryFile, outTaxTree);
                taxaSum->print(outTaxTree);
                outTaxTree.close();
index b5bdab15ab977b97b1d1a813869ff0dbe38d8deb..5f0630f66a03ba9f08a2dd4d2098808a513f0a3c 100644 (file)
@@ -23,7 +23,8 @@ class SummaryTaxCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "summary.tax";                 }
                string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                string getCitation() { return "http://www.mothur.org/wiki/Summary.tax"; }
                string getDescription()         { return "summarize the taxonomies of a set of sequences"; }
                
index 6a4b884cba8ee21629219593cf43eae7b4c02447..6dc09ef75690b43eb0e5045788308c1a4d26d93b 100644 (file)
@@ -24,7 +24,8 @@ class SystemCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "system";              }
                string getCommandCategory()             { return "General";             }
-               string getHelpString(); 
+        string getOutputFileNameTag(string, string) { return ""; }
+        string getHelpString();        
                string getCitation() { return "http://www.mothur.org/wiki/System"; }
                string getDescription()         { return "execute system commands from within mothur"; }
 
index c26199d673088b5b64872b672ab8e64ca780e616..888f50202e3443855a99d82d71b126cf715ee380 100644 (file)
@@ -70,6 +70,26 @@ string TreeGroupCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string TreeGroupCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 TreeGroupCommand::TreeGroupCommand(){  
        try {
                abort = true; calledHelp = true;
@@ -442,7 +462,7 @@ int TreeGroupCommand::execute(){
                        if (m->control_pressed) { return 0; }
 
                        //create a new filename
-                       string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "tre";    
+                       string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("tree");     
                        outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                                
                        Tree* newTree = createTree(matrix);
@@ -896,7 +916,7 @@ 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.tre";                            
+                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".ave." + getOutputFileNameTag("tree");                                
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 //creates tree from similarity matrix and write out file
@@ -909,7 +929,7 @@ 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.tre";                            
+                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".all." + getOutputFileNameTag("tree");                                
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 ofstream outAll;
@@ -950,7 +970,7 @@ 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.tre";                              
+                string conFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".cons." + getOutputFileNameTag("tree");                          
                 outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
                 ofstream outTree;
                 m->openOutputFile(conFile, outTree);
@@ -978,7 +998,7 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                 }
                 
                 //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";                                
+                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + getOutputFileNameTag("tree");                            
                 outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                 
                 //creates tree from similarity matrix and write out file
index d3c1b3e47615fb6d3b342c8d41758aa7b9d9178a..a0e0d420163cabdfe46518873cc3a42d98bc14a6 100644 (file)
@@ -81,6 +81,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "tree.shared";                         }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Tree.shared"; }
        string getDescription()         { return "generate a tree file that describes the dissimilarity among groups"; }
index c228162aab1d511af3fc5318aaf3e5eb5b39610c..42ec336dd53d9da3c0ac44b997cdc7509a89c9cf 100644 (file)
  TreeMap::~TreeMap(){}
 /************************************************************/
 int TreeMap::readMap(string gf) {
-    
-    groupFileName = gf;
-       m->openInputFile(gf, fileHandle);
-    
-    string seqName, seqGroup;
-    int error = 0;
-    
-    while(fileHandle){
-        fileHandle >> seqName;       m->gobble(fileHandle);    //read from first column
-        fileHandle >> seqGroup;                        //read from second column
+    try {
+        groupFileName = gf;
+        m->openInputFile(gf, fileHandle);
         
-        if (m->control_pressed) {  fileHandle.close();  return 1; }
-        
-        setNamesOfGroups(seqGroup);
+        string seqName, seqGroup;
+        int error = 0;
+
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
         
-        map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
-        if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-        else {
-            namesOfSeqs.push_back(seqName);
-            treemap[seqName].groupname = seqGroup;     //store data in map
+        while (!fileHandle.eof()) {
+            if (m->control_pressed) { fileHandle.close();  return 1; }
             
-            it2 = seqsPerGroup.find(seqGroup);
-            if (it2 == seqsPerGroup.end()) { //if it's a new group
-                seqsPerGroup[seqGroup] = 1;
-            }else {//it's a group we already have
-                seqsPerGroup[seqGroup]++;
-            }                          
+            fileHandle.read(buffer, 4096);
+            vector<string> pieces = m->splitWhiteSpace(rest, buffer, fileHandle.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
+                    if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        namesOfSeqs.push_back(seqName);
+                        treemap[seqName].groupname = seqGroup; //store data in map
+                        
+                        it2 = seqsPerGroup.find(seqGroup);
+                        if (it2 == seqsPerGroup.end()) { //if it's a new group
+                            seqsPerGroup[seqGroup] = 1;
+                        }else {//it's a group we already have
+                            seqsPerGroup[seqGroup]++;
+                        }                              
+                    }
+                    pairDone = false; 
+                } 
+            }
         }
+        fileHandle.close();
         
-        m->gobble(fileHandle);
+        return error;
     }
-    fileHandle.close();
-    
-    return error;
+       catch(exception& e) {
+               m->errorOut(e, "TreeMap", "readMap");
+               exit(1);
+       }
 }
 
 /************************************************************/
 int TreeMap::readMap() {
-               string seqName, seqGroup;
-               int error = 0;
-               
-               while(fileHandle){
-                       fileHandle >> seqName;           m->gobble(fileHandle); //read from first column
-                       fileHandle >> seqGroup;                 //read from second column
-                       
-                       if (m->control_pressed) {  fileHandle.close();  return 1; }
-                       
-                       setNamesOfGroups(seqGroup);
-                                       
-                       map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
-                       if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-                       else {
-                               namesOfSeqs.push_back(seqName);
-                               treemap[seqName].groupname = seqGroup;  //store data in map
-                               
-                               it2 = seqsPerGroup.find(seqGroup);
-                               if (it2 == seqsPerGroup.end()) { //if it's a new group
-                                       seqsPerGroup[seqGroup] = 1;
-                               }else {//it's a group we already have
-                                       seqsPerGroup[seqGroup]++;
-                               }                               
-                       }
-                       
-                       m->gobble(fileHandle);
-               }
-               fileHandle.close();
-       
-
-               return error;
+    try {
+        string seqName, seqGroup;
+        int error = 0;
+        
+        string rest = "";
+        char buffer[4096];
+        bool pairDone = false;
+        bool columnOne = true;
+        
+        while (!fileHandle.eof()) {
+            if (m->control_pressed) { fileHandle.close();  return 1; }
+            
+            fileHandle.read(buffer, 4096);
+            vector<string> pieces = m->splitWhiteSpace(rest, buffer, fileHandle.gcount());
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
+                    if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        namesOfSeqs.push_back(seqName);
+                        treemap[seqName].groupname = seqGroup; //store data in map
+                        
+                        it2 = seqsPerGroup.find(seqGroup);
+                        if (it2 == seqsPerGroup.end()) { //if it's a new group
+                            seqsPerGroup[seqGroup] = 1;
+                        }else {//it's a group we already have
+                            seqsPerGroup[seqGroup]++;
+                        }                              
+                    }
+                    pairDone = false; 
+                } 
+            }
+        }
+        fileHandle.close();
+        
+        return error;
+    }
+       catch(exception& e) {
+               m->errorOut(e, "TreeMap", "readMap");
+               exit(1);
+       }
 }
 /************************************************************/
 void TreeMap::addSeq(string seqName, string seqGroup) {
index 0557c71bda3453068175fe3d405ff87972df80e1..d45f20cae1f0516c014d42cf7e6afaef57d2a1a2 100644 (file)
@@ -56,7 +56,28 @@ string TrimFlowsCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string TrimFlowsCommand::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 == "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);
+       }
+}
 //**********************************************************************************************************************
 
 TrimFlowsCommand::TrimFlowsCommand(){  
@@ -66,6 +87,7 @@ TrimFlowsCommand::TrimFlowsCommand(){
                vector<string> tempOutNames;
                outputTypes["flow"] = tempOutNames;
                outputTypes["fasta"] = tempOutNames;
+        outputTypes["file"] = tempOutNames;
        }
        catch(exception& e) {
                m->errorOut(e, "TrimFlowsCommand", "TrimFlowsCommand");
@@ -103,6 +125,7 @@ TrimFlowsCommand::TrimFlowsCommand(string option)  {
                        vector<string> tempOutNames;
                        outputTypes["flow"] = tempOutNames;
                        outputTypes["fasta"] = tempOutNames;
+            outputTypes["file"] = 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);              
@@ -225,13 +248,13 @@ int TrimFlowsCommand::execute(){
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
 
-               string trimFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "trim.flow";
+               string trimFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "trim." + getOutputFileNameTag("flow");
                outputNames.push_back(trimFlowFileName); outputTypes["flow"].push_back(trimFlowFileName);
                
-               string scrapFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "scrap.flow";
+               string scrapFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "scrap." + getOutputFileNameTag("flow");;
                outputNames.push_back(scrapFlowFileName); outputTypes["flow"].push_back(scrapFlowFileName);
 
-               string fastaFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.fasta";
+               string fastaFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("fasta");
                if(fasta){
                        outputNames.push_back(fastaFileName); outputTypes["fasta"].push_back(fastaFileName);
                }
@@ -284,7 +307,7 @@ int TrimFlowsCommand::execute(){
                
                if(allFiles){
                        set<string> namesAlreadyProcessed;
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.files";
+                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("file");
                        m->openOutputFile(flowFilesFileName, output);
 
                        for(int i=0;i<barcodePrimerComboFileNames.size();i++){
@@ -317,7 +340,7 @@ int TrimFlowsCommand::execute(){
                        output.close();
                }
                else{
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.files";
+                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + getOutputFileNameTag("file");
                        m->openOutputFile(flowFilesFileName, output);
                        
                        output << m->getFullPathName(trimFlowFileName) << endl;
index 414c73cd1d2e6740b89d5200a5c7e7c704097ed6..b7fbf4342b821d1f6eb6dbb7094d94c3e85d19a3 100644 (file)
@@ -26,6 +26,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "trim.flows";  }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Trim.flows"; }
        string getDescription()         { return "trim.flows"; }
index 6f5bb979a4d45b9fc3d8201848aa9f6b2d2dddb7..6a8afd017c1e88ff1bdbde883608b5eff00b235f 100644 (file)
@@ -97,6 +97,29 @@ string TrimSeqsCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+string TrimSeqsCommand::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 == "qfile")            {   outputFileName =  "qual";   }
+            else if (type == "fasta")            {   outputFileName =  "fasta";   }
+            else if (type == "group")            {   outputFileName =  "groups";   }
+            else if (type == "name")            {   outputFileName =  "names";   }
+            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);
+       }
+}
 
 
 //**********************************************************************************************************************
@@ -336,14 +359,14 @@ int TrimSeqsCommand::execute(){
                vector<vector<string> > qualFileNames;
                vector<vector<string> > nameFileNames;
                
-               string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
+               string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim." + getOutputFileNameTag("fasta");
                outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
                
-               string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.fasta";
+               string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap." + getOutputFileNameTag("fasta");
                outputNames.push_back(scrapSeqFile); outputTypes["fasta"].push_back(scrapSeqFile);
                
-               string trimQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual";
-               string scrapQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.qual";
+               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);
@@ -352,8 +375,8 @@ int TrimSeqsCommand::execute(){
                        outputTypes["qfile"].push_back(scrapQualFile); 
                }
                
-               string trimNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "trim.names";
-               string scrapNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "scrap.names";
+               string trimNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "trim." + getOutputFileNameTag("name");
+               string scrapNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "scrap." + getOutputFileNameTag("name");
                
                if (nameFile != "") {
                        m->readNames(nameFile, nameMap);
@@ -369,7 +392,7 @@ int TrimSeqsCommand::execute(){
                if(oligoFile != ""){
                        createGroup = getOligos(fastaFileNames, qualFileNames, nameFileNames);
                        if (createGroup) {
-                               outputGroupFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "groups";
+                               outputGroupFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + getOutputFileNameTag("group");
                                outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName);
                        }
                }
@@ -428,7 +451,7 @@ int TrimSeqsCommand::execute(){
                                m->openInputFile(it->first, in);
                                
                                ofstream out;
-                               string thisGroupName = outputDir + m->getRootName(m->getSimpleName(it->first)) + "groups";
+                               string thisGroupName = outputDir + m->getRootName(m->getSimpleName(it->first)) + getOutputFileNameTag("group");
                                outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName);
                                m->openOutputFile(thisGroupName, out);
                                
index e280c8a1d4b50336f125dda5788d91d2af76c09a..957f37a65bfb1c177f000c9c6d031ddfc3784c81 100644 (file)
@@ -27,6 +27,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "trim.seqs";   }
        string getCommandCategory()             { return "Sequence Processing";         }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Trim.seqs"; }
        string getDescription()         { return "provides the preprocessing features needed to screen and sort pyrosequences"; }
index 318409fa8845f91fcaae0765a6f930626299e82d..0650ea0e8e42e564213d285183e48594f54fc722 100644 (file)
@@ -63,6 +63,31 @@ string UnifracUnweightedCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+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);
+       }
+}
+
 //**********************************************************************************************************************
 UnifracUnweightedCommand::UnifracUnweightedCommand(){  
        try {
@@ -248,7 +273,7 @@ int UnifracUnweightedCommand::execute() {
         map<string, string> unique2Dup = reader->getNameMap();
         delete reader; 
         
-               sumFile = outputDir + m->getSimpleName(treefile) + ".uwsummary";
+               sumFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("uwsummary");
                outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile);
                m->openOutputFile(sumFile, outSum);
                
@@ -309,9 +334,9 @@ int UnifracUnweightedCommand::execute() {
             counter = 0;
                        
                        if (random)  {  
-                               output = new ColumnFile(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted", itersString);
-                               outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted");
-                               outputTypes["unweighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted");
+                               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"));
                        }
                        
                        
@@ -480,15 +505,15 @@ int UnifracUnweightedCommand::getAverageSTDMatrices(vector< vector<double> >& di
             }
         }
         
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.ave.dist";
-        outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName); 
-        
+        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.ave." + getOutputFileNameTag("phylip");
+        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.dist";
-        outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); 
-        
+        string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.std." + getOutputFileNameTag("phylip");
+        if (outputForm != "column") { outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); }
+        else { outputNames.push_back(stdFileName); outputTypes["column"].push_back(stdFileName); }
         ofstream outStd;
         m->openOutputFile(stdFileName, outStd);
         
@@ -569,7 +594,7 @@ 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.tre";                                
+        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.cons." + getOutputFileNameTag("tree");                            
         outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
         ofstream outTree;
         m->openOutputFile(conFile, outTree);
@@ -593,7 +618,7 @@ 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.tre";                              
+        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.all." + getOutputFileNameTag("tree");                          
         outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
         
         ofstream outAll;
@@ -761,10 +786,10 @@ void UnifracUnweightedCommand::createPhylipFile(int i) {
        try {
                string phylipFileName;
                if ((outputForm == "lt") || (outputForm == "square")) {
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.phylip.dist";
+                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.phylip." + getOutputFileNameTag("phylip");
                        outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
                }else { //column
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.column.dist";
+                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.column." + getOutputFileNameTag("column");
                        outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
                }
                
index fd39ae43852bee7ad970d77035fa839c50f62422..15c3b9684b01fa58403276b80864684f99e8d189 100644 (file)
@@ -27,7 +27,8 @@ class UnifracUnweightedCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "unifrac.unweighted";          }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 1df79888eb8bdacb442b9dc2c89c51a7d4fa75ff..13d10fd5f4d6c690777fcc4730f06fea8832341f 100644 (file)
@@ -64,6 +64,30 @@ string UnifracWeightedCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string UnifracWeightedCommand::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 == "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);
+       }
+}
+//**********************************************************************************************************************
 UnifracWeightedCommand::UnifracWeightedCommand(){      
        try {
                abort = true; calledHelp = true; 
@@ -242,7 +266,7 @@ int UnifracWeightedCommand::execute() {
     
         if (m->control_pressed) {  delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } return 0; }
                                
-               sumFile = outputDir + m->getSimpleName(treefile) + ".wsummary";
+               sumFile = outputDir + m->getSimpleName(treefile) + getOutputFileNameTag("wsummary");
                m->openOutputFile(sumFile, outSum);
                outputNames.push_back(sumFile);  outputTypes["wsummary"].push_back(sumFile);
                
@@ -306,9 +330,9 @@ 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) + ".weighted", itersString);  
-                outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted");
-                outputTypes["weighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted");
+                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"));
             } 
             
             userData = weighted.getValues(T[i], processors, outputDir); //userData[0] = weightedscore
@@ -461,15 +485,15 @@ int UnifracWeightedCommand::getAverageSTDMatrices(vector< vector<double> >& dist
             }
         }
         
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.ave.dist";
-        outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName); 
-        
+        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.ave." + getOutputFileNameTag("phylip");
+        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.dist";
-       outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); 
-        
+        string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.std." + getOutputFileNameTag("phylip");
+        if (outputForm != "column") { outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); }
+        else { outputNames.push_back(stdFileName); outputTypes["column"].push_back(stdFileName); }        
         ofstream outStd;
         m->openOutputFile(stdFileName, outStd);
         
@@ -550,7 +574,7 @@ 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.tre";                          
+        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.cons." + getOutputFileNameTag("tree");                              
         outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
         ofstream outTree;
         m->openOutputFile(conFile, outTree);
@@ -574,7 +598,7 @@ 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.tre";                                
+        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.all." + getOutputFileNameTag("tree");                            
         outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
         
         ofstream outAll;
@@ -885,10 +909,10 @@ void UnifracWeightedCommand::createPhylipFile() {
                
                        string phylipFileName;
                        if ((outputForm == "lt") || (outputForm == "square")) {
-                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.phylip.dist";
+                               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.dist";
+                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.column." + getOutputFileNameTag("column");
                                outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
                        }
                        
index 9deb065b21da66b0bd83ef50d6d7d457e750025a..06354ce5cbeed8dc7c1629a482c65d9381b40e04 100644 (file)
@@ -28,7 +28,8 @@ class UnifracWeightedCommand : public Command {
                vector<string> setParameters();
                string getCommandName()                 { return "unifrac.weighted";            }
                string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
+               string getOutputFileNameTag(string, string);
+       string getHelpString(); 
                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 1b4e3bc70848d7511c1dcd136fb4c320e4265b11..18bb635010bc07a1787e2847ae84c4eaf923e8cf 100644 (file)
@@ -66,6 +66,27 @@ string VennCommand::getHelpString(){
                exit(1);
        }
 }
+//**********************************************************************************************************************
+
+string VennCommand::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 == "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);
+       }
+}
 
 //**********************************************************************************************************************
 VennCommand::VennCommand(){    
index ae3c12167080508fbb8785751970c0836ef0a941..9f369280fc66e53754da98a4b6252568a7960d90 100644 (file)
@@ -25,6 +25,7 @@ public:
        vector<string> setParameters();
        string getCommandName()                 { return "venn";                                        }
        string getCommandCategory()             { return "OTU-Based Approaches";        }
+       string getOutputFileNameTag(string, string);
        string getHelpString(); 
        string getCitation() { return "http://www.mothur.org/wiki/Venn"; }
        string getDescription()         { return "generates a Venn diagram from data provided in a shared file"; }