]> git.donarmstrong.com Git - mothur.git/commitdiff
added pipeline commands which involved change to command factory and command class...
authorwestcott <westcott>
Fri, 15 Oct 2010 16:46:19 +0000 (16:46 +0000)
committerwestcott <westcott>
Fri, 15 Oct 2010 16:46:19 +0000 (16:46 +0000)
186 files changed:
Mothur.xcodeproj/project.pbxproj
aligncommand.cpp
aligncommand.h
bayesian.cpp
binsequencecommand.cpp
binsequencecommand.h
bootstrapsharedcommand.cpp
bootstrapsharedcommand.h
catchallcommand.cpp
catchallcommand.h
chimerabellerophoncommand.cpp
chimerabellerophoncommand.h
chimeraccodecommand.cpp
chimeraccodecommand.h
chimeracheckcommand.cpp
chimeracheckcommand.h
chimerapintailcommand.cpp
chimerapintailcommand.h
chimeraseqscommand.cpp
chimeraseqscommand.h
chimeraslayercommand.cpp
chimeraslayercommand.h
chopseqscommand.cpp
chopseqscommand.h
classifyotucommand.cpp
classifyotucommand.h
classifyseqscommand.cpp
classifyseqscommand.h
clearcutcommand.cpp
clearcutcommand.h
clustercommand.cpp
clustercommand.h
clusterfragmentscommand.cpp
clusterfragmentscommand.h
clustersplitcommand.cpp
clustersplitcommand.h
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
collectsharedcommand.h
command.hpp
commandfactory.cpp
commandfactory.hpp
consensuscommand.cpp
consensuscommand.h
deconvolutecommand.cpp
deconvolutecommand.h
degapseqscommand.cpp
degapseqscommand.h
distancecommand.cpp
distancecommand.h
eachgapignore.h
fastamap.cpp
filterseqscommand.cpp
filterseqscommand.h
getgroupcommand.cpp
getgroupcommand.h
getlabelcommand.cpp
getlabelcommand.h
getlineagecommand.cpp
getlineagecommand.h
getlistcountcommand.cpp
getlistcountcommand.h
getoturepcommand.cpp
getoturepcommand.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.cpp
helpcommand.h
ignoregaps.h
libshuffcommand.cpp
libshuffcommand.h
listseqscommand.cpp
listseqscommand.h
makegroupcommand.cpp
makegroupcommand.h
matrixoutputcommand.cpp
matrixoutputcommand.h
mergefilecommand.cpp
mergefilecommand.h
metastatscommand.cpp
metastatscommand.h
mgclustercommand.cpp
mgclustercommand.h
mothur
mothurout.cpp
mothurout.h
nocommands.cpp
nocommands.h
normalizesharedcommand.cpp
normalizesharedcommand.h
onegapignore.h
otuhierarchycommand.cpp
otuhierarchycommand.h
parsefastaqcommand.cpp
parsefastaqcommand.h
parselistscommand.cpp
parselistscommand.h
parsesffcommand.cpp
parsesffcommand.h
parsimonycommand.cpp
parsimonycommand.h
pcacommand.cpp
pcacommand.h
phylodiversitycommand.cpp
phylodiversitycommand.h
phylotypecommand.cpp
phylotypecommand.h
pipelinepdscommand.cpp [new file with mode: 0644]
pipelinepdscommand.h [new file with mode: 0644]
preclustercommand.cpp
preclustercommand.h
quitcommand.cpp
quitcommand.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h
readdistcommand.cpp
readdistcommand.h
readotucommand.cpp
readotucommand.h
readtreecommand.cpp
readtreecommand.h
removelineagecommand.cpp
removelineagecommand.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
setdircommand.cpp
setdircommand.h
setlogfilecommand.cpp
setlogfilecommand.h
sffinfocommand.cpp
sffinfocommand.h
sharedcommand.cpp
sharedcommand.h
splitabundcommand.cpp
splitabundcommand.h
splitgroupscommand.cpp
splitgroupscommand.h
splitmatrix.cpp
splitmatrix.h
summarycommand.cpp
summarycommand.h
summarysharedcommand.cpp
summarysharedcommand.h
systemcommand.cpp
systemcommand.h
treegroupscommand.cpp
treegroupscommand.h
trimseqscommand.cpp
trimseqscommand.h
unifracunweightedcommand.cpp
unifracunweightedcommand.h
unifracweightedcommand.cpp
unifracweightedcommand.h
unweighted.cpp
validparameter.cpp
venncommand.cpp
venncommand.h

index e2673fc9331524944d0b8b3553e00c42a1f34766..5e84c7eabc213ba337255d55f61034df9e7384fa 100644 (file)
@@ -43,6 +43,8 @@
                A72B3A63118B37FD004B9F8D /* phylodiversitycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylodiversitycommand.cpp; sourceTree = "<group>"; };
                A72B3A7B118B4D1B004B9F8D /* phylodiversity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylodiversity.h; sourceTree = "<group>"; };
                A72B3A7C118B4D1B004B9F8D /* phylodiversity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylodiversity.cpp; sourceTree = "<group>"; };
+               A72C66A1125B356F0058C2F9 /* pipelinepdscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pipelinepdscommand.h; sourceTree = "<group>"; };
+               A72C66A2125B356F0058C2F9 /* pipelinepdscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pipelinepdscommand.cpp; sourceTree = "<group>"; };
                A732505E11E49EF100484B90 /* sffinfocommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sffinfocommand.h; sourceTree = "<group>"; };
                A732505F11E49EF100484B90 /* sffinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sffinfocommand.cpp; sourceTree = "<group>"; };
                A73953DA11987ED100B0B160 /* chopseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chopseqscommand.h; sourceTree = "<group>"; };
                                A7DA1FEE113FECD400BF472F /* aligncommand.cpp */,
                                A7DA1FFE113FECD400BF472F /* binsequencecommand.h */,
                                A7DA1FFD113FECD400BF472F /* binsequencecommand.cpp */,
-                               A7DA2007113FECD400BF472F /* bootstrapsharedcommand.cpp */,
                                A7DA2008113FECD400BF472F /* bootstrapsharedcommand.h */,
+                               A7DA2007113FECD400BF472F /* bootstrapsharedcommand.cpp */,
                                A7D216061199C47F00F13F13 /* catchallcommand.h */,
                                A7D216071199C47F00F13F13 /* catchallcommand.cpp */,
-                               A7DA2017113FECD400BF472F /* chimeraseqscommand.cpp */,
                                A7DA2018113FECD400BF472F /* chimeraseqscommand.h */,
+                               A7DA2017113FECD400BF472F /* chimeraseqscommand.cpp */,
                                A7825502116519F70002E2DD /* chimerabellerophoncommand.h */,
                                A7825503116519F70002E2DD /* chimerabellerophoncommand.cpp */,
                                A747E79B1163442A00FB9042 /* chimeracheckcommand.h */,
                                A7BBDA7C11B5694E006E6551 /* classifyotucommand.cpp */,
                                A7D215C811996C6E00F13F13 /* clearcutcommand.h */,
                                A7D215C911996C6E00F13F13 /* clearcutcommand.cpp */,
-                               A7DA2021113FECD400BF472F /* clustercommand.cpp */,
                                A7DA2022113FECD400BF472F /* clustercommand.h */,
+                               A7DA2021113FECD400BF472F /* clustercommand.cpp */,
                                A74A9C03124B72DB000D5D25 /* clusterfragmentscommand.h */,
                                A74A9C04124B72DB000D5D25 /* clusterfragmentscommand.cpp */,
                                A71D924311AEB42400D00CBC /* clustersplitcommand.h */,
                                A71D924211AEB42400D00CBC /* clustersplitcommand.cpp */,
                                A7DA2026113FECD400BF472F /* collectcommand.h */,
                                A7DA2025113FECD400BF472F /* collectcommand.cpp */,
-                               A7DA2029113FECD400BF472F /* collectsharedcommand.cpp */,
                                A7DA202A113FECD400BF472F /* collectsharedcommand.h */,
-                               A7DA2031113FECD400BF472F /* consensuscommand.cpp */,
+                               A7DA2029113FECD400BF472F /* collectsharedcommand.cpp */,
                                A7DA2032113FECD400BF472F /* consensuscommand.h */,
+                               A7DA2031113FECD400BF472F /* consensuscommand.cpp */,
                                A7118EE511CFCAC000CFDE03 /* degapseqscommand.h */,
                                A7118EE611CFCAC000CFDE03 /* degapseqscommand.cpp */,
-                               A7DA203A113FECD400BF472F /* deconvolutecommand.cpp */,
                                A7DA203B113FECD400BF472F /* deconvolutecommand.h */,
-                               A7DA203E113FECD400BF472F /* distancecommand.cpp */,
+                               A7DA203A113FECD400BF472F /* deconvolutecommand.cpp */,
                                A7DA203F113FECD400BF472F /* distancecommand.h */,
-                               A7DA204F113FECD400BF472F /* filterseqscommand.cpp */,
+                               A7DA203E113FECD400BF472F /* distancecommand.cpp */,
                                A7DA2050113FECD400BF472F /* filterseqscommand.h */,
-                               A7DA205A113FECD400BF472F /* getgroupcommand.cpp */,
+                               A7DA204F113FECD400BF472F /* filterseqscommand.cpp */,
                                A7DA205B113FECD400BF472F /* getgroupcommand.h */,
-                               A7DA205C113FECD400BF472F /* getlabelcommand.cpp */,
+                               A7DA205A113FECD400BF472F /* getgroupcommand.cpp */,
                                A7DA205D113FECD400BF472F /* getlabelcommand.h */,
+                               A7DA205C113FECD400BF472F /* getlabelcommand.cpp */,
                                A787A24F124CB46C0076EB84 /* getlineagecommand.h */,
                                A787A250124CB46C0076EB84 /* getlineagecommand.cpp */,
                                A7DA205F113FECD400BF472F /* getlistcountcommand.h */,
                                A7DA205E113FECD400BF472F /* getlistcountcommand.cpp */,
                                A7DA2061113FECD400BF472F /* getoturepcommand.h */,
                                A7DA2060113FECD400BF472F /* getoturepcommand.cpp */,
-                               A7DA2062113FECD400BF472F /* getrabundcommand.cpp */,
                                A7DA2063113FECD400BF472F /* getrabundcommand.h */,
+                               A7DA2062113FECD400BF472F /* getrabundcommand.cpp */,
                                A7118F0F11CFD5DC00CFDE03 /* getrelabundcommand.h */,
                                A7118F1011CFD5DC00CFDE03 /* getrelabundcommand.cpp */,
-                               A7DA2064113FECD400BF472F /* getsabundcommand.cpp */,
                                A7DA2065113FECD400BF472F /* getsabundcommand.h */,
+                               A7DA2064113FECD400BF472F /* getsabundcommand.cpp */,
                                A7DA2067113FECD400BF472F /* getseqscommand.h */,
                                A7DA2066113FECD400BF472F /* getseqscommand.cpp */,
-                               A7DA2068113FECD400BF472F /* getsharedotucommand.cpp */,
                                A7DA2069113FECD400BF472F /* getsharedotucommand.h */,
-                               A7DA2074113FECD400BF472F /* hclustercommand.cpp */,
+                               A7DA2068113FECD400BF472F /* getsharedotucommand.cpp */,
                                A7DA2075113FECD400BF472F /* hclustercommand.h */,
-                               A7DA2078113FECD400BF472F /* heatmapcommand.cpp */,
+                               A7DA2074113FECD400BF472F /* hclustercommand.cpp */,
                                A7DA2079113FECD400BF472F /* heatmapcommand.h */,
-                               A7DA207C113FECD400BF472F /* heatmapsimcommand.cpp */,
+                               A7DA2078113FECD400BF472F /* heatmapcommand.cpp */,
                                A7DA207D113FECD400BF472F /* heatmapsimcommand.h */,
-                               A7DA207E113FECD400BF472F /* helpcommand.cpp */,
+                               A7DA207C113FECD400BF472F /* heatmapsimcommand.cpp */,
                                A7DA207F113FECD400BF472F /* helpcommand.h */,
+                               A7DA207E113FECD400BF472F /* helpcommand.cpp */,
                                A7DA208E113FECD400BF472F /* libshuffcommand.h */,
                                A7DA208D113FECD400BF472F /* libshuffcommand.cpp */,
                                A7DA2090113FECD400BF472F /* listseqscommand.h */,
                                A7DA208F113FECD400BF472F /* listseqscommand.cpp */,
                                A703FE931194645F002C397E /* makegroupcommand.h */,
                                A703FE941194645F002C397E /* makegroupcommand.cpp */,
-                               A7DA2098113FECD400BF472F /* matrixoutputcommand.cpp */,
                                A7DA2099113FECD400BF472F /* matrixoutputcommand.h */,
-                               A7DA209A113FECD400BF472F /* mergefilecommand.cpp */,
+                               A7DA2098113FECD400BF472F /* matrixoutputcommand.cpp */,
                                A7DA209B113FECD400BF472F /* mergefilecommand.h */,
+                               A7DA209A113FECD400BF472F /* mergefilecommand.cpp */,
                                A7F6C8EA12423C0300299875 /* metastatscommand.h */,
                                A7F6C8EB12423C0300299875 /* metastatscommand.cpp */,
-                               A7DA209C113FECD400BF472F /* mgclustercommand.cpp */,
                                A7DA209D113FECD400BF472F /* mgclustercommand.h */,
-                               A7DA20AC113FECD400BF472F /* nocommands.cpp */,
+                               A7DA209C113FECD400BF472F /* mgclustercommand.cpp */,
                                A7DA20AD113FECD400BF472F /* nocommands.h */,
+                               A7DA20AC113FECD400BF472F /* nocommands.cpp */,
                                A798626D1240D91B005FC847 /* normalizesharedcommand.h */,
                                A798626E1240D91B005FC847 /* normalizesharedcommand.cpp */,
-                               A7DA20B8113FECD400BF472F /* otuhierarchycommand.cpp */,
                                A7DA20B9113FECD400BF472F /* otuhierarchycommand.h */,
+                               A7DA20B8113FECD400BF472F /* otuhierarchycommand.cpp */,
                                A724C2B61254961E006BB1C7 /* parsefastaqcommand.h */,
                                A724C2B71254961E006BB1C7 /* parsefastaqcommand.cpp */,
-                               A7DA20BC113FECD400BF472F /* parselistscommand.cpp */,
                                A7DA20BD113FECD400BF472F /* parselistscommand.h */,
+                               A7DA20BC113FECD400BF472F /* parselistscommand.cpp */,
                                A7E8338C115BBDAA00739EC4 /* parsesffcommand.h */,
                                A7E8338B115BBDAA00739EC4 /* parsesffcommand.cpp */,
-                               A7DA20C0113FECD400BF472F /* parsimonycommand.cpp */,
                                A7DA20C1113FECD400BF472F /* parsimonycommand.h */,
+                               A7DA20C0113FECD400BF472F /* parsimonycommand.cpp */,
                                A7DA20C3113FECD400BF472F /* pcacommand.h */,
                                A7DA20C2113FECD400BF472F /* pcacommand.cpp */,
                                A72B3A62118B37FD004B9F8D /* phylodiversitycommand.h */,
                                A72B3A63118B37FD004B9F8D /* phylodiversitycommand.cpp */,
                                A7DA20C7113FECD400BF472F /* phylotypecommand.h */,
                                A7DA20C6113FECD400BF472F /* phylotypecommand.cpp */,
+                               A72C66A1125B356F0058C2F9 /* pipelinepdscommand.h */,
+                               A72C66A2125B356F0058C2F9 /* pipelinepdscommand.cpp */,
                                A7DA20CB113FECD400BF472F /* preclustercommand.h */,
                                A7DA20CA113FECD400BF472F /* preclustercommand.cpp */,
                                A7DA20D1113FECD400BF472F /* quitcommand.h */,
index ccf5eebe68f42426f16f2465b68832beb413d2eb..b4af28a2990a44d69527d4c5cb7e5984d8b73033 100644 (file)
 
 
 //**********************************************************************************************************************
-
+vector<string> AlignCommand::getValidParameters(){     
+       try {
+               string AlignArray[] =  {"template","candidate","search","ksize","align","match","mismatch","gapopen","gapextend", "processors","flip","threshold","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> AlignCommand::getRequiredParameters(){  
+       try {
+               string AlignArray[] =  {"template","candidate"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> AlignCommand::getRequiredFiles(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+AlignCommand::AlignCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCommand", "AlignCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 AlignCommand::AlignCommand(string option)  {
        try {
-               
                abort = false;
        
                //allow user to run help
@@ -52,7 +99,13 @@ AlignCommand::AlignCommand(string option)  {
                        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["fasta"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["accnos"] = 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 = "";         }
                        
@@ -112,6 +165,17 @@ AlignCommand::AlignCommand(string option)  {
                                                        candidateFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]);
+                                                       m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       candidateFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();                                     
 
                                        if (ableToOpen == 1) { 
@@ -165,7 +229,6 @@ AlignCommand::AlignCommand(string option)  {
                exit(1);
        }
 }
-
 //**********************************************************************************************************************
 
 AlignCommand::~AlignCommand(){ 
@@ -225,10 +288,9 @@ int AlignCommand::execute(){
                        m->mothurOutEndLine();
                        alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
                }
-               vector<string> outputNames;
                
                for (int s = 0; s < candidateFileNames.size(); s++) {
-                       if (m->control_pressed) { return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); return 0; }
                        
                        m->mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); m->mothurOutEndLine();
                        
@@ -277,7 +339,7 @@ int AlignCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, outReportFilename, outMode, MPI_INFO_NULL, &outMPIReport);
                                MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
                                
-                               if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); return 0; }
+                               if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
                                
                                if (pid == 0) { //you are the root process 
                                        
@@ -297,7 +359,7 @@ int AlignCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIAlign, outMPIReport, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); return 0; }
+                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
 
                                        for (int i = 1; i < processors; i++) {
                                                bool tempResult;
@@ -319,7 +381,7 @@ int AlignCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIAlign, outMPIReport, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); return 0; }
+                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
 
                                        MPI_Send(&MPIWroteAccnos, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); 
                                }
@@ -357,7 +419,7 @@ int AlignCommand::execute(){
                        if(processors == 1){
                                numFastaSeqs = driver(lines[0], alignFileName, reportFileName, accnosFileName, candidateFileNames[s]);
                                
-                               if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); return 0; }
+                               if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); outputTypes.clear(); return 0; }
                                
                                //delete accnos file if its blank else report to user
                                if (m->isBlank(accnosFileName)) {  remove(accnosFileName.c_str());  hasAccnos = false; }
@@ -408,12 +470,12 @@ int AlignCommand::execute(){
                                        m->mothurOutEndLine();
                                }else{ hasAccnos = false;  }
                                
-                               if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); return 0; }
+                               if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); outputTypes.clear(); return 0; }
                        }
        #else
                        numFastaSeqs = driver(lines[0], alignFileName, reportFileName, accnosFileName, candidateFileNames[s]);
                        
-                       if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); return 0; }
+                       if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); outputTypes.clear();  return 0; }
                        
                        //delete accnos file if its blank else report to user
                        if (m->isBlank(accnosFileName)) {  remove(accnosFileName.c_str());  hasAccnos = false; }
@@ -436,9 +498,9 @@ int AlignCommand::execute(){
                        if (pid == 0) { //only one process should output to screen
                #endif
 
-                       outputNames.push_back(alignFileName);
-                       outputNames.push_back(reportFileName);
-                       if (hasAccnos)  {       outputNames.push_back(accnosFileName);          }
+                       outputNames.push_back(alignFileName); outputTypes["fasta"].push_back(alignFileName);
+                       outputNames.push_back(reportFileName); outputTypes["alignreport"].push_back(reportFileName);
+                       if (hasAccnos)  {       outputNames.push_back(accnosFileName);  outputTypes["accnos"].push_back(accnosFileName);  }
                        
                #ifdef USE_MPI
                        }
index 1167c938708bcce7bb54755229bfceef00379822..1410626a42e3a407289f18565dd0e64a3d4d3cd4 100644 (file)
@@ -20,7 +20,12 @@ class AlignCommand : public Command {
        
 public:
        AlignCommand(string);   
+       AlignCommand();
        ~AlignCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute(); 
        void help();    
        
@@ -33,6 +38,7 @@ private:
        vector<int> processIDS;   //processid
        vector<linePair*> lines;
        bool MPIWroteAccnos;
+       map<string, vector<string> > outputTypes;
        
        AlignmentDB* templateDB;
        Alignment* alignment;
@@ -50,6 +56,7 @@ private:
        float match, misMatch, gapOpen, gapExtend, threshold;
        int processors, kmerSize;
        vector<string> candidateFileNames;
+       vector<string> outputNames;
        
        bool abort, flip;
 };
index 531abc52561db977aa58fc274c7d7e91ee1d4a8d..80518666cfe5436280f58117fe506dc132bd2754 100644 (file)
@@ -76,9 +76,9 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i)  {
                        
                                //initialze probabilities
                                wordGenusProb.resize(numKmers);
-                       
+                       cout << numKmers << '\t' << genusNodes.size() << endl;
                                for (int j = 0; j < wordGenusProb.size(); j++) {        wordGenusProb[j].resize(genusNodes.size());             }
-                               
+                       cout << numKmers << '\t' << genusNodes.size() << endl;  
                                ofstream out;
                                ofstream out2;
                                
index a761d5a6eed759f3fd4f93d0d3500c20a4e87676..a1c965bb8052bab0d2ad086e8f57622ae5abfbc0 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "binsequencecommand.h"
 
+//**********************************************************************************************************************
+vector<string> BinSeqCommand::getValidParameters(){    
+       try {
+               string AlignArray[] =  {"fasta","label","name", "group","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BinSeqCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> BinSeqCommand::getRequiredParameters(){ 
+       try {
+               string AlignArray[] =  {"fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BinSeqCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> BinSeqCommand::getRequiredFiles(){      
+       try {
+               string AlignArray[] =  {"list"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BinSeqCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+BinSeqCommand::BinSeqCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BinSeqCommand", "BinSeqCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 BinSeqCommand::BinSeqCommand(string option) {
        try {
@@ -36,6 +84,10 @@ BinSeqCommand::BinSeqCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = 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 = ""; 
@@ -316,7 +368,7 @@ int BinSeqCommand::process(ListVector* list) {
                                m->openOutputFile(outputFileName, out);
                                
                                //save to output list of output file names
-                               outputNames.push_back(outputFileName);
+                               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
 
                                m->mothurOut(list->getLabel()); m->mothurOutEndLine();
                                
index 6ea7305265a6725a6a6290f6de028b307c5e8a0b..df7ea7593dd266c71a3a1b7a49c03c70596a368f 100644 (file)
@@ -25,7 +25,12 @@ class BinSeqCommand : public Command {
        
 public:
        BinSeqCommand(string);  
+       BinSeqCommand();
        ~BinSeqCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -42,6 +47,7 @@ private:
        ofstream out;
        ifstream in, inNames;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        void readNamesFile();
        int process(ListVector*);
index 9424347180c7713c6b498fd16cada4e7e86accd4..2b7232db4dd050a663c3a5b9514b59ae058e5c4c 100644 (file)
 #include "sharedmorisitahorn.h"
 #include "sharedbraycurtis.h"
 
-
 //**********************************************************************************************************************
-
+vector<string> BootSharedCommand::getValidParameters(){        
+       try {
+               string AlignArray[] =  {"label","calc","groups","iters","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BootSharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+BootSharedCommand::BootSharedCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BootSharedCommand", "BootSharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> BootSharedCommand::getRequiredParameters(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BootSharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> BootSharedCommand::getRequiredFiles(){  
+       try {
+               string AlignArray[] =  {"shared"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "BootSharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 BootSharedCommand::BootSharedCommand(string option) {
        try {
                globaldata = GlobalData::getInstance();
@@ -49,6 +94,10 @@ BootSharedCommand::BootSharedCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["tree"] = 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 = ""; 
@@ -410,7 +459,7 @@ int BootSharedCommand::process(SharedOrderVector* order) {
                                        //create a new filename
                                        outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
                                        m->openOutputFile(outputFile, *(out[z]));
-                                       outputNames.push_back(outputFile);
+                                       outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                                }
                                
                                m->mothurOut("Generating bootstrap trees..."); cout.flush();
index be4a7648825ba541a253daa74817b120ed087f57..53f6a26fd471d395a19d414af75640dc9bb0d62c 100644 (file)
@@ -27,7 +27,12 @@ class BootSharedCommand : public Command {
        
 public:
        BootSharedCommand(string);      
+       BootSharedCommand();
        ~BootSharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -59,6 +64,7 @@ private:
        string outputFile, calc, groups, label, outputDir;
        int numGroups, iters;
        vector<string>  Estimators, Groups, outputNames; //holds estimators to be used
+       map< string, vector<string> > outputTypes;
 
 };
        
index b185b9f49baf98e96a78fc836c4668a5d0a14972..d6264db3309bd867696ee0b89041b9e34d3b6556 100644 (file)
 #include "catchallcommand.h"
 #include "globaldata.hpp"
 
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getValidParameters(){  
+       try {
+               string AlignArray[] =  {"sabund","label","inputdir","outputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+CatchAllCommand::CatchAllCommand(){    
+       try {
+               //initialize outputTypes
+               
+               //need to determine outputFIles and types
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getRequiredParameters(){       
+       try {
+               string AlignArray[] =  {"sabund"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**************************************************************************************/
 CatchAllCommand::CatchAllCommand(string option)  {     
        try {
@@ -36,6 +83,11 @@ CatchAllCommand::CatchAllCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       
+                       //initialize outputTypes
+                       //need to determine outputFIles and types
+                       
+                       
                        //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 = "";          }
@@ -53,7 +105,7 @@ CatchAllCommand::CatchAllCommand(string option)  {
                        //check for required parameters
                        sabundfile = validParameter.validFile(parameters, "sabund", true);
                        if (sabundfile == "not open") { sabundfile = ""; abort = true; }
-                       else if (sabundfile == "not found") { sabundfile = "";  m->mothurOut("You must provide either a sabund file for the catchall command."); m->mothurOutEndLine(); abort=true; }
+                       else if (sabundfile == "not found") { sabundfile = "";  m->mothurOut("You must provide a sabund file for the catchall command."); m->mothurOutEndLine(); abort=true; }
                        else { globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
                        
                        string label = validParameter.validFile(parameters, "label", false);                    
@@ -99,8 +151,6 @@ int CatchAllCommand::execute() {
                
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                //prepare full output directory
                outputDir = m->getFullPathName(outputDir);
                
index ac9f115a6a3205cd95d94000a4a88555a14e821e..186185d5ea68b08b969b6a99ef090ff75d5af72a 100644 (file)
@@ -26,7 +26,12 @@ class CatchAllCommand : public Command {
 public:
 
        CatchAllCommand(string);
-       ~CatchAllCommand() {};
+       CatchAllCommand();
+       ~CatchAllCommand() {}
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map< string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -39,6 +44,8 @@ private:
        string outputDir, sabundfile, rabundfile, listfile, format;
        bool abort, allLines;
        set<string> labels;
+       vector<string> outputNames;
+       map< string, vector<string> > outputTypes;
        
        string process(SAbundVector*);
 };
index 5972c62f028100b71b9007785af7c9d4600aaeb4..6d0a116ac4d0d5d1bb2b8cf97f1ea5a1b5126fef 100644 (file)
 #include "chimerabellerophoncommand.h"
 #include "bellerophon.h"
 
+//**********************************************************************************************************************
+vector<string> ChimeraBellerophonCommand::getValidParameters(){        
+       try {
+               string AlignArray[] =  {"fasta","filter","correction","processors","window","increment","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraBellerophonCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraBellerophonCommand::getRequiredParameters(){     
+       try {
+               string AlignArray[] =  {"fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraBellerophonCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraBellerophonCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraBellerophonCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChimeraBellerophonCommand::ChimeraBellerophonCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["chimera"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
        try {
                abort = false;
@@ -35,6 +82,11 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["chimera"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -66,6 +118,17 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
 
                                        if (ableToOpen == 1) { 
@@ -156,7 +219,7 @@ int ChimeraBellerophonCommand::execute(){
                        
                        chimera->getChimeras();
                        
-                       if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0;     }
+                       if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } outputTypes.clear(); return 0;        }
                        
                #ifdef USE_MPI
                        MPI_File outMPI;
@@ -192,12 +255,12 @@ int ChimeraBellerophonCommand::execute(){
                        
                #endif
                        
-                       if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } delete chimera;       return 0;       }
+                       if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } outputTypes.clear(); delete chimera;  return 0;       }
                        
                        m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
                        
-                       outputNames.push_back(outputFileName);
-                       outputNames.push_back(accnosFileName);
+                       outputNames.push_back(outputFileName);  outputTypes["chimera"].push_back(outputFileName);
+                       outputNames.push_back(accnosFileName);  outputTypes["accnos"].push_back(accnosFileName);
                        
                        delete chimera;
                }
index 4ff7f799202f9403b8793a625ee0a551354a69a2..6e1ae50794f23d92c75d0224011251e385ae8f43 100644 (file)
 class ChimeraBellerophonCommand : public Command {
 public:
        ChimeraBellerophonCommand(string);
+       ChimeraBellerophonCommand();
        ~ChimeraBellerophonCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map< string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
                
@@ -31,6 +36,7 @@ private:
        int processors, window, increment, numSeqs;
        Chimera* chimera;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        vector<string> fastaFileNames;
 };
 
index ab10eb8f56bb04dffceb9f4a309ff59157c708d2..1f6a5a56a8ee7398a8f1b0b454986c28c1483fe7 100644 (file)
 #include "chimeraccodecommand.h"
 #include "ccode.h"
 
+//**********************************************************************************************************************
+vector<string> ChimeraCcodeCommand::getValidParameters(){      
+       try {
+               string AlignArray[] =  {"fasta", "filter", "processors", "window", "template", "mask", "numwanted", "outputdir","inputdir" };
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCcodeCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChimeraCcodeCommand::ChimeraCcodeCommand(){    
+       try {
+               vector<string> tempOutNames;
+               outputTypes["chimera"] = tempOutNames;
+               outputTypes["mapinfo"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCcodeCommand", "ChimeraCcodeCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraCcodeCommand::getRequiredParameters(){   
+       try {
+               string AlignArray[] =  {"template","fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCcodeCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraCcodeCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCcodeCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
        try {
                abort = false;
@@ -21,7 +68,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
                
                else {
                        //valid paramters for this command
-                       string Array[] =  {"fasta", "filter", "processors", "window", "template", "mask", "numwanted", "outputdir","inputdir", };
+                       string Array[] =  {"fasta", "filter", "processors", "window", "template", "mask", "numwanted", "outputdir","inputdir" };
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -35,6 +82,11 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       vector<string> tempOutNames;
+                       outputTypes["chimera"] = tempOutNames;
+                       outputTypes["mapinfo"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -77,6 +129,17 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -201,7 +264,7 @@ int ChimeraCcodeCommand::execute(){
 
                        string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "mapinfo";
                        
-                       if (m->control_pressed) { delete chimera;  for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); }  return 0;    }
+                       if (m->control_pressed) { delete chimera;  for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); } outputTypes.clear(); return 0;        }
                        
                #ifdef USE_MPI
                
@@ -233,7 +296,7 @@ int ChimeraCcodeCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
                                MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
 
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); } outputTypes.clear();  delete chimera; return 0;  }
                        
                                if (pid == 0) { //you are the root process 
                                        string outTemp = "For full window mapping info refer to " + mapInfo + "\n\n";
@@ -263,7 +326,7 @@ int ChimeraCcodeCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } outputTypes.clear();  delete chimera; return 0;  }
 
                                }else{ //you are a child process
                                        MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
@@ -279,7 +342,7 @@ int ChimeraCcodeCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  outputTypes.clear(); delete chimera; return 0;  }
                                }
                                
                                //close files 
@@ -310,7 +373,7 @@ int ChimeraCcodeCommand::execute(){
                                                                                
                                        numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                        
-                                       if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                                       if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
                                        
                                }else{
                                        processIDS.resize(0);
@@ -335,7 +398,7 @@ int ChimeraCcodeCommand::execute(){
                                        if (m->control_pressed) { 
                                                remove(outputFileName.c_str()); 
                                                remove(accnosFileName.c_str());
-                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } 
+                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } outputTypes.clear();
                                                for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                                                delete chimera;
                                                return 0;
@@ -346,7 +409,7 @@ int ChimeraCcodeCommand::execute(){
                        #else
                                numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                
-                               if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                               if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
                                
                        #endif
        
@@ -358,10 +421,10 @@ int ChimeraCcodeCommand::execute(){
                
                        delete chimera;
                        
-                       outputNames.push_back(outputFileName);
-                       outputNames.push_back(mapInfo);
-                       outputNames.push_back(accnosFileName); 
-                       
+                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
+                       outputNames.push_back(mapInfo); outputTypes["mapinfo"].push_back(mapInfo);
+                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
+                        
                        for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                        
                        m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
index d980288ac3585916321edec15114d0c47303e120..a9ed223b112cdb50876024c893257549e159481f 100644 (file)
 class ChimeraCcodeCommand : public Command {
 public:
        ChimeraCcodeCommand(string);
+       ChimeraCcodeCommand();
        ~ChimeraCcodeCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -47,6 +52,7 @@ private:
        Chimera* chimera;
        vector<string> fastaFileNames;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        
 };
index ac092083a53944207b926a6bb9d725a2249b571a..2591460a5ddd0bdcbe958bddc5ccf5ce9e644c7e 100644 (file)
@@ -9,8 +9,53 @@
 
 #include "chimeracheckcommand.h"
 
+//**********************************************************************************************************************
+vector<string> ChimeraCheckCommand::getValidParameters(){      
+       try {
+               string AlignArray[] =  {"fasta","processors","increment","template","ksize","svg", "name","outputdir","inputdir" };
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCheckCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraCheckCommand::getRequiredParameters(){   
+       try {
+               string AlignArray[] =  {"template","fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCheckCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraCheckCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCheckCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChimeraCheckCommand::ChimeraCheckCommand(){    
+       try {
+               vector<string> tempOutNames;
+               outputTypes["chimera"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraCheckCommand", "ChimeraCheckCommand");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
        try {
                abort = false;
@@ -34,6 +79,9 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       vector<string> tempOutNames;
+                       outputTypes["chimera"] = 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 = "";          }
@@ -75,6 +123,17 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -123,6 +182,17 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                                                        nameFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]);
+                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       nameFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -219,7 +289,7 @@ int ChimeraCheckCommand::execute(){
                        
                        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";
-                       outputNames.push_back(outputFileName);
+                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
                        
                #ifdef USE_MPI
                
@@ -246,7 +316,7 @@ int ChimeraCheckCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
                                MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
                                
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } delete chimera; return 0;  }
+                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0;  }
                                
                                if (pid == 0) { //you are the root process 
                                        MPIPos = m->setFilePosFasta(fastaFileNames[i], numSeqs); //fills MPIPos, returns numSeqs
@@ -266,7 +336,7 @@ int ChimeraCheckCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); }   delete chimera; return 0;  }
+                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); }   outputTypes.clear(); delete chimera; return 0;  }
                                        
                                        //wait on chidren
                                        for(int j = 1; j < processors; j++) { 
@@ -286,7 +356,7 @@ int ChimeraCheckCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  outputTypes.clear(); delete chimera; return 0;  }
                                        
                                        //tell parent you are done.
                                        char buf[5];
@@ -311,7 +381,7 @@ int ChimeraCheckCommand::execute(){
                                if(processors == 1){
                                        numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]);
                                        
-                                       if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear(); delete chimera; return 0; }
+                                       if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } for (int j = 0; j < lines.size(); j++) {  delete lines[j];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
                                                                        
                                }else{
                                        processIDS.resize(0);
@@ -327,7 +397,7 @@ int ChimeraCheckCommand::execute(){
                                        }
                                        
                                        if (m->control_pressed) { 
-                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } 
+                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } outputTypes.clear();
                                                for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear();
                                                delete chimera;
                                                return 0;
@@ -337,7 +407,7 @@ int ChimeraCheckCommand::execute(){
                        #else
                                numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]);
                                
-                               if (m->control_pressed) { for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear(); for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } delete chimera; return 0; }
+                               if (m->control_pressed) { for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear(); for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } outputTypes.clear(); delete chimera; return 0; }
                        #endif
                #endif          
                        delete chimera;
index 71e1f0cdad86dc4610a65711c57c355eb9ee2aaf..6e81812e469772b18a737930354f1bdf943a9ef9 100644 (file)
 class ChimeraCheckCommand : public Command {
 public:
        ChimeraCheckCommand(string);
+       ChimeraCheckCommand();
        ~ChimeraCheckCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -51,6 +56,7 @@ private:
        vector<string> fastaFileNames;
        vector<string> nameFileNames;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
                
 };
 
index 30136505f2a2136028c392c8e3e346ce878e045d..2dccd498f6dd2e5fdf82a9b12665aaf7a523ad90 100644 (file)
 #include "chimerapintailcommand.h"
 #include "pintail.h"
 
+//**********************************************************************************************************************
+vector<string> ChimeraPintailCommand::getValidParameters(){    
+       try {
+               string AlignArray[] =  {"fasta","filter","processors","window" ,"increment","template","conservation","quantile","mask","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraPintailCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChimeraPintailCommand::ChimeraPintailCommand(){        
+       try {
+               vector<string> tempOutNames;
+               outputTypes["chimera"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraPintailCommand", "ChimeraPintailCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraPintailCommand::getRequiredParameters(){ 
+       try {
+               string AlignArray[] =  {"template","fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraPintailCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraPintailCommand::getRequiredFiles(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraPintailCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
        try {
                abort = false;
@@ -35,6 +81,10 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       vector<string> tempOutNames;
+                       outputTypes["chimera"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        inputDir = validParameter.validFile(parameters, "inputdir", false);             
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -94,6 +144,16 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -140,7 +200,17 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                                                        maskfile = tryPath;
                                        }
                                }
-                                       in.close();
+                               
+                               if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(maskfile);
+                                                       m->mothurOut("Unable to open " + maskfile + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       maskfile = tryPath;
+                                               }
+                               }
+                               
+                               in.close();
                                        
                                if (ableToOpen == 1) { 
                                                m->mothurOut("Unable to open " + maskfile + "."); m->mothurOutEndLine(); 
@@ -332,7 +402,7 @@ int ChimeraPintailCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
                                MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
                                
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
 
                                if (pid == 0) { //you are the root process 
                                                                
@@ -352,7 +422,7 @@ int ChimeraPintailCommand::execute(){
                                        //do your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
                                        
                                }else{ //you are a child process
                                        MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
@@ -367,7 +437,7 @@ int ChimeraPintailCommand::execute(){
                                        //do your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
                                }
                                
                                //close files 
@@ -388,7 +458,7 @@ int ChimeraPintailCommand::execute(){
                
                                        numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                        
-                                       if (m->control_pressed) { remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                                       if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
                                        
                                }else{
                                        processIDS.resize(0);
@@ -413,7 +483,7 @@ int ChimeraPintailCommand::execute(){
                                        if (m->control_pressed) { 
                                                remove(outputFileName.c_str()); 
                                                remove(accnosFileName.c_str());
-                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } 
+                                               for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } outputTypes.clear();
                                                for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                                                delete chimera;
                                                return 0;
@@ -423,7 +493,7 @@ int ChimeraPintailCommand::execute(){
                        #else
                                numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                
-                               if (m->control_pressed) { remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
                        #endif
                        
                #endif  
@@ -431,8 +501,8 @@ int ChimeraPintailCommand::execute(){
                        delete chimera;
                        for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                        
-                       outputNames.push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); 
+                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
+                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
                        
                        m->mothurOutEndLine();
                        m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
index 9082204bf80af5ccb83cba072078ef8b276f6e3a..d2b2e03a3196d61cf7036ff879f1a18bec741ae6 100644 (file)
@@ -22,7 +22,12 @@ class ChimeraPintailCommand : public Command {
 public:
 
        ChimeraPintailCommand(string);
+       ChimeraPintailCommand();
        ~ChimeraPintailCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -49,6 +54,7 @@ private:
        int processors, window, increment, numSeqs, templateSeqsLength;
        Chimera* chimera;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        vector<string> fastaFileNames;
        
        
index 663b8940592f1f4ecfc8dce5ae81beadef8bef45..9013e7d33f66f38b7ce1283ee92a45be3d4ab76c 100644 (file)
@@ -9,6 +9,39 @@
 
 #include "chimeraseqscommand.h"
 
+//**********************************************************************************************************************
+vector<string> ChimeraSeqsCommand::getValidParameters(){       
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraSeqsCommand::getRequiredParameters(){    
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraSeqsCommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 ChimeraSeqsCommand::ChimeraSeqsCommand(string option)  {}
index afbc2592a389f2faa971452d2fa12e3be4fa9680..7e51748b3b7c8b16bf983e44f0771275f7cd532f 100644 (file)
 class ChimeraSeqsCommand : public Command {
 public:
        ChimeraSeqsCommand(string);
+       ChimeraSeqsCommand() {}
        ~ChimeraSeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map< string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
                
 private:
+       vector<string> outputNames;
+       map< string, vector<string> > outputTypes;
 
 };
 
index d2f3067a3beb153242cfd5c945156e0e11f42b9b..2172369e70d38915ab6a3831f0ab53e4a34f759d 100644 (file)
 #include "chimeraslayercommand.h"
 #include "chimeraslayer.h"
 
-
+//**********************************************************************************************************************
+vector<string> ChimeraSlayerCommand::getValidParameters(){     
+       try {
+               string AlignArray[] =  {"fasta", "processors", "window", "template","numwanted", "ksize", "match","mismatch", 
+                       "divergence", "minsim","mincov","minbs", "minsnp","parents", "iters","outputdir","inputdir", "search","realign" };
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSlayerCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChimeraSlayerCommand::ChimeraSlayerCommand(){  
+       try {
+               vector<string> tempOutNames;
+               outputTypes["chimera"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSlayerCommand", "ChimeraSlayerCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraSlayerCommand::getRequiredParameters(){  
+       try {
+               string AlignArray[] =  {"template","fasta"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSlayerCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChimeraSlayerCommand::getRequiredFiles(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChimeraSlayerCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
        try {
                abort = false;
@@ -37,6 +83,10 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       vector<string> tempOutNames;
+                       outputTypes["chimera"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -80,6 +130,16 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -258,7 +318,7 @@ int ChimeraSlayerCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
                                MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
 
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); }   delete chimera; return 0;  }
+                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos); for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); }   delete chimera; return 0;  }
                        
                                if (pid == 0) { //you are the root process 
                                        m->mothurOutEndLine();
@@ -291,7 +351,7 @@ int ChimeraSlayerCommand::execute(){
                                        //do your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  delete chimera; return 0;  }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      remove(outputNames[j].c_str()); }  remove(outputFileName.c_str());  remove(accnosFileName.c_str());  delete chimera; return 0;  }
 
                                }else{ //you are a child process
                                        MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
@@ -306,7 +366,7 @@ int ChimeraSlayerCommand::execute(){
                                        //do your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      remove(outputNames[j].c_str()); }  delete chimera; return 0;  }
                                }
                                
                                //close files 
@@ -334,7 +394,7 @@ int ChimeraSlayerCommand::execute(){
                                if(processors == 1){
                                        numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                        
-                                       if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                                       if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
                                        
                                }else{
                                        processIDS.resize(0);
@@ -356,13 +416,13 @@ int ChimeraSlayerCommand::execute(){
                                                remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str());
                                        }
                                        
-                                       if (m->control_pressed) { remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                                       if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {   remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
                                }
 
                        #else
                                numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
                                
-                               if (m->control_pressed) { remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
+                               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); remove(tempHeader.c_str()); remove(accnosFileName.c_str()); for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
                                
                        #endif
                        
@@ -377,8 +437,8 @@ int ChimeraSlayerCommand::execute(){
                        
                        for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
                        
-                       outputNames.push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); 
+                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
+                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
                        
                        m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
                }
index c5ef88885d9b4c1e7275c998e8a2b35bbbbba99b..aa9b5e7102a324bce97095c2fce7d78f470ab3fc 100644 (file)
 class ChimeraSlayerCommand : public Command {
 public:
        ChimeraSlayerCommand(string);
+       ChimeraSlayerCommand();
        ~ChimeraSlayerCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -50,6 +55,7 @@ private:
        Chimera* chimera;
        
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        vector<string> fastaFileNames;
        
 };
index b2810741ae7b2b6591a7f0aa8e3b52b143dcfe3d..fc2d9a7faf24c7cfa433482e6897ac7b224844a6 100644 (file)
 #include "sequence.hpp"
 
 //**********************************************************************************************************************
-
+vector<string> ChopSeqsCommand::getValidParameters(){  
+       try {
+               string AlignArray[] =  {"fasta","numbases","countgaps","keep","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ChopSeqsCommand::ChopSeqsCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "ChopSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChopSeqsCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta","numbases"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ChopSeqsCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 ChopSeqsCommand::ChopSeqsCommand(string option)  {
        try {
                abort = false;
@@ -35,6 +82,11 @@ ChopSeqsCommand::ChopSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -118,7 +170,7 @@ int ChopSeqsCommand::execute(){
                        
                        Sequence seq(in);
                        
-                       if (m->control_pressed) { in.close(); out.close(); outAcc.close(); remove(outputFileName.c_str()); remove(outputFileNameAccnos.c_str()); return 0;  }
+                       if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); remove(outputFileName.c_str()); remove(outputFileNameAccnos.c_str()); return 0;  }
                        
                        if (seq.getName() != "") {
                                string newSeqString = getChopped(seq);
@@ -138,9 +190,9 @@ int ChopSeqsCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
                
-               if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine();  }
+               if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine(); outputNames.push_back(outputFileNameAccnos); outputTypes["accnos"].push_back(outputFileNameAccnos); }
                else {  remove(outputFileNameAccnos.c_str());  }
                
                m->mothurOutEndLine();
index 604906425997010d3cfcde2b41b9cdeb6b5a1ae7..8e007ff7513e62df1dd32e7fe192628c02e48425 100644 (file)
@@ -18,8 +18,13 @@ class ChopSeqsCommand : public Command {
        
        public:
        
-               ChopSeqsCommand(string);        
+               ChopSeqsCommand(string);
+               ChopSeqsCommand();      
                ~ChopSeqsCommand(){};
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -27,9 +32,12 @@ class ChopSeqsCommand : public Command {
                string fastafile, outputDir, keep;
                bool abort, countGaps;
                int numbases;
+               vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                
                string getChopped(Sequence);
                
+               
 };
 
 #endif
index d27a88141534c7bf9b8115eaccb55d7966096753..cedc1f2c71c450f80ad5bcfefffe8713effab6fb 100644 (file)
 #include "classifyotucommand.h"
 #include "phylotree.h"
 
-
+//**********************************************************************************************************************
+vector<string> ClassifyOtuCommand::getValidParameters(){       
+       try {
+               string AlignArray[] =  {"list","label","name","taxonomy","cutoff","probs","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifyOtuCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClassifyOtuCommand::ClassifyOtuCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["constaxonomy"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifyOtuCommand", "ClassifyOtuCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClassifyOtuCommand::getRequiredParameters(){    
+       try {
+               string Array[] =  {"list","taxonomy"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifyOtuCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClassifyOtuCommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifyOtuCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
        try{
@@ -37,6 +83,10 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["constaxonomy"] = 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 = "";          }
@@ -157,7 +207,7 @@ int ClassifyOtuCommand::execute(){
                set<string> processedLabels;
                set<string> userLabels = labels;
                
-               if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     remove(outputNames[i].c_str());  }  return 0; }
+               if (m->control_pressed) { outputTypes.clear(); delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  }  return 0; }
        
                while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
@@ -165,7 +215,7 @@ int ClassifyOtuCommand::execute(){
                        
                                        m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
                                        process(list);
-                                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
+                                       if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
                                                                                
                                        processedLabels.insert(list->getLabel());
                                        userLabels.erase(list->getLabel());
@@ -180,7 +230,7 @@ int ClassifyOtuCommand::execute(){
                                        process(list);
                                
                                        
-                                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
+                                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
                                                                                
                                        processedLabels.insert(list->getLabel());
                                        userLabels.erase(list->getLabel());
@@ -216,12 +266,12 @@ int ClassifyOtuCommand::execute(){
                        process(list);
                        delete list;
                        
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
+                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } delete input; delete list; return 0; }
                }
                
                delete input;  
                                
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());  } return 0; }
+               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str());  } return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -424,7 +474,9 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                ofstream out;
                string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".cons.taxonomy";
                m->openOutputFile(outputFile, out);
-               outputNames.push_back(outputFile);
+               outputNames.push_back(outputFile); outputTypes["constaxonomy"].push_back(outputFile);
+               
+               out << "OTU\tSize\tTaxonomy" << endl;
                
                //for each bin in the list vector
                for (int i = 0; i < processList->getNumBins(); i++) {
index 1077781e59b998892d699bf09b34c897a0a15375..60bfb29a900dbabedcb49a23523b4b704e98352e 100644 (file)
@@ -19,7 +19,12 @@ class ClassifyOtuCommand : public Command {
 
 public:
        ClassifyOtuCommand(string);
+       ClassifyOtuCommand();
        ~ClassifyOtuCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
 
@@ -34,6 +39,7 @@ private:
        vector<string> outputNames;
        map<string, string> nameMap;
        map<string, string> taxMap;
+       map<string, vector<string> > outputTypes;
 
        int readNamesFile();
        int readTaxonomyFile();
index 33f49e5fc4b322301c4620cf4c9263fe751ab259..9f05eda2704c179ca3eb4f120d83862aeb4eb6e4 100644 (file)
 #include "phylosummary.h"
 #include "knn.h"
 
-//**********************************************************************************************************************
 
+//**********************************************************************************************************************
+vector<string> ClassifySeqsCommand::getValidParameters(){      
+       try {
+               string AlignArray[] =  {"template","fasta","name","group","search","ksize","method","processors","taxonomy","match","mismatch","gapopen","gapextend","numwanted","cutoff","probs","iters", "outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifySeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClassifySeqsCommand::ClassifySeqsCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["taxonomy"] = tempOutNames;
+               outputTypes["taxsummary"] = tempOutNames;
+               outputTypes["matchdist"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClassifySeqsCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"fasta","template","taxonomy"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifySeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClassifySeqsCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClassifySeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
        try {
                abort = false;
@@ -40,6 +89,12 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["taxonomy"] = tempOutNames;
+                       outputTypes["taxsummary"] = tempOutNames;
+                       outputTypes["matchdist"] = 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 = "";         }
                        
@@ -110,6 +165,16 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -162,6 +227,15 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                                        namefileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(namefileNames[i]);
+                                                       m->mothurOut("Unable to open " + namefileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       namefileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -204,6 +278,16 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                                                        groupfileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(groupfileNames[i]);
+                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       groupfileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -336,7 +420,6 @@ int ClassifySeqsCommand::execute(){
                
                if (m->control_pressed) { delete classify; return 0; }
                
-               vector<string> outputNames;
                                
                for (int s = 0; s < fastaFileNames.size(); s++) {
                
@@ -354,11 +437,11 @@ int ClassifySeqsCommand::execute(){
                        
                        if ((method == "knn") && (search == "distance")) { 
                                string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "match.dist";
-                               classify->setDistName(DistName);  outputNames.push_back(DistName);
+                               classify->setDistName(DistName);  outputNames.push_back(DistName); outputTypes["matchdist"].push_back(DistName);
                        }
                        
-                       outputNames.push_back(newTaxonomyFile);
-                       outputNames.push_back(taxSummary);
+                       outputNames.push_back(newTaxonomyFile); outputTypes["taxonomy"].push_back(newTaxonomyFile);
+                       outputNames.push_back(taxSummary);      outputTypes["taxsummary"].push_back(taxSummary);
                        
                        int start = time(NULL);
                        int numFastaSeqs = 0;
@@ -380,20 +463,11 @@ int ClassifySeqsCommand::execute(){
                                int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
                                int inMode=MPI_MODE_RDONLY; 
                                
-                               //char* outNewTax = new char[newTaxonomyFile.length()];
-                               //memcpy(outNewTax, newTaxonomyFile.c_str(), newTaxonomyFile.length());
-                               
                                char outNewTax[1024];
                                strcpy(outNewTax, newTaxonomyFile.c_str());
-
-                               //char* outTempTax = new char[tempTaxonomyFile.length()];
-                               //memcpy(outTempTax, tempTaxonomyFile.c_str(), tempTaxonomyFile.length());
                                
                                char outTempTax[1024];
                                strcpy(outTempTax, tempTaxonomyFile.c_str());
-
-                               //char* inFileName = new char[fastaFileNames[s].length()];
-                               //memcpy(inFileName, fastaFileNames[s].c_str(), fastaFileNames[s].length());
                                
                                char inFileName[1024];
                                strcpy(inFileName, fastaFileNames[s].c_str());
@@ -402,11 +476,7 @@ int ClassifySeqsCommand::execute(){
                                MPI_File_open(MPI_COMM_WORLD, outNewTax, outMode, MPI_INFO_NULL, &outMPINewTax);
                                MPI_File_open(MPI_COMM_WORLD, outTempTax, outMode, MPI_INFO_NULL, &outMPITempTax);
                                
-                               //delete outNewTax;
-                               //delete outTempTax;
-                               //delete inFileName;
-
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
+                               if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
                                
                                if (pid == 0) { //you are the root process 
                                        
@@ -427,7 +497,7 @@ int ClassifySeqsCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPINewTax, outMPITempTax, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  for (int i = 0; i < outputNames.size(); i++) {    remove(outputNames[i].c_str()); } delete classify; return 0;  }
+                                       if (m->control_pressed) {  outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } delete classify; return 0;  }
                                        
                                        for (int i = 1; i < processors; i++) {
                                                int done;
@@ -447,7 +517,7 @@ int ClassifySeqsCommand::execute(){
                                        //align your part
                                        driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPINewTax, outMPITempTax, MPIPos);
                                        
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
+                                       if (m->control_pressed) {  outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);   MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
 
                                        int done = 0;
                                        MPI_Send(&done, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); 
@@ -532,7 +602,7 @@ int ClassifySeqsCommand::execute(){
                        
                        PhyloSummary taxaSum(taxonomyFileName, group);
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } delete classify; return 0; }
+                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } delete classify; return 0; }
                
                        if (namefile == "") {  taxaSum.summarize(tempTaxonomyFile);  }
                        else {
@@ -561,7 +631,7 @@ int ClassifySeqsCommand::execute(){
                        }
                        remove(tempTaxonomyFile.c_str());
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } delete classify; return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } delete classify; return 0; }
                        
                        //print summary file
                        ofstream outTaxTree;
@@ -583,7 +653,7 @@ int ClassifySeqsCommand::execute(){
                        //read taxfile - this reading and rewriting is done to preserve the confidence scores.
                        string name, taxon;
                        while (!inTax.eof()) {
-                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } remove(unclass.c_str()); delete classify; return 0; }
+                               if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } remove(unclass.c_str()); delete classify; return 0; }
 
                                inTax >> name >> taxon; m->gobble(inTax);
                                
index 84f5f9f04d6752728c5f3bf72d5688cafd73b723..16549135aacbe25e36d89f21c503f1baae2fe659 100644 (file)
@@ -29,7 +29,12 @@ class ClassifySeqsCommand : public Command {
        
 public:
        ClassifySeqsCommand(string);
+       ClassifySeqsCommand();
        ~ClassifySeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute(); 
        void help();    
        
@@ -45,8 +50,10 @@ private:
        vector<string> fastaFileNames;
        vector<string> namefileNames;
        vector<string> groupfileNames;
+       vector<string> outputNames;
        map<string, vector<string> > nameMap;
        map<string,  vector<string> >::iterator itNames;
+       map<string, vector<string> > outputTypes;
        
        Classify* classify;
        
index c76de383fce839d31dd95e56bb7288a6df617d3c..0d2da75284049cd377d9cf209de5d0eb44b4034c 100644 (file)
 #include "clearcutcommand.h"
 #include "clearcut.h"
 
-
+//**********************************************************************************************************************
+vector<string> ClearcutCommand::getValidParameters(){  
+       try {
+               string AlignArray[] =  {"fasta","phylip","version","verbose","quiet","seed","norandom","shuffle","neighbor","expblen",
+                                                               "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClearcutCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClearcutCommand::ClearcutCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["matrixout"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClearcutCommand", "ClearcutCommand");
+               exit(1);
+       }
+}//**********************************************************************************************************************
+vector<string> ClearcutCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta","phylip","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClearcutCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClearcutCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClearcutCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**************************************************************************************/
 ClearcutCommand::ClearcutCommand(string option)  {     
        try {
@@ -36,6 +83,11 @@ ClearcutCommand::ClearcutCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["tree"] = tempOutNames;
+                       outputTypes["matrixout"] = 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 = "";          }
@@ -177,6 +229,7 @@ int ClearcutCommand::execute() {
                
                //prepare filename
                string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
+               outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
                
                vector<char*> cPara;
                
@@ -226,6 +279,8 @@ int ClearcutCommand::execute() {
                        char* temp = new char[tempMatrix.length()];
                        strcpy(temp, tempMatrix.c_str());
                        cPara.push_back(temp);
+                       outputNames.push_back((outputDir + matrixout));
+                       outputTypes["matrixout"].push_back((outputDir + matrixout));
                }
 
                if (ntrees != "1")              {  
@@ -252,8 +307,7 @@ int ClearcutCommand::execute() {
                if (!stdoutWanted) {    
                        m->mothurOutEndLine();
                        m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       m->mothurOut(outputName); m->mothurOutEndLine();
-                       if (matrixout != "")    {  m->mothurOut(outputDir+matrixout); m->mothurOutEndLine();  }
+                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
                        m->mothurOutEndLine();
                }
 
index 980431b216ec67c67c3a8bd221055b24f1c98624..ea6e279b88ca0f6d59312936b2c1652ff5b1a9b6 100644 (file)
@@ -25,7 +25,12 @@ class ClearcutCommand : public Command {
 
 public:
        ClearcutCommand(string);
+       ClearcutCommand();
        ~ClearcutCommand() {};
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -33,6 +38,8 @@ private:
        string outputDir, phylipfile, fastafile, matrixout, inputFile, seed, ntrees;
        bool version, verbose, quiet, norandom, shuffle, neighbor, expblen, expdist, stdoutWanted, kimura, jukes, protein, DNA;
        bool abort;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 };
 
 /****************************************************************************/
index 2f9c36e0ff84c4b67af8f9e4d50e77edd62d414a..8a1d120934717524c2670699c8c487c8b6c8c6bc 100644 (file)
@@ -9,6 +9,55 @@
 
 #include "clustercommand.h"
 
+//**********************************************************************************************************************
+vector<string> ClusterCommand::getValidParameters(){   
+       try {
+               string AlignArray[] =  {"cutoff","precision","method","showabund","timing","hard","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClusterCommand::ClusterCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterCommand", "ClusterCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterCommand::getRequiredFiles(){     
+       try {
+               string Array[] =  {"phylip","column","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
 ClusterCommand::ClusterCommand(string option)  {
@@ -37,6 +86,12 @@ ClusterCommand::ClusterCommand(string option)  {
                                }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["rabund"] = tempOutNames;
+                       outputTypes["sabund"] = 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 = "";         }
                        
@@ -101,9 +156,9 @@ ClusterCommand::ClusterCommand(string option)  {
                                m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
                                m->openOutputFile(fileroot+ tag + ".list",              listFile);
                                
-                               outputNames.push_back(fileroot+ tag + ".sabund");
-                               outputNames.push_back(fileroot+ tag + ".rabund");
-                               outputNames.push_back(fileroot+ tag + ".list");
+                               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");
                        }
                }
        }
@@ -158,14 +213,14 @@ int ClusterCommand::execute(){
                double saveCutoff = cutoff;
                
                while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){
-       cout << matrix->getSmallDist() << '\t' << cutoff << '\t' << matrix->getNNodes() << endl;        
+               
                        if (m->control_pressed) { //clean up
                                delete globaldata->gSparseMatrix;  globaldata->gSparseMatrix = NULL;
                                delete globaldata->gListVector;  globaldata->gListVector = NULL;
                                if (globaldata->getFormat() == "phylip") { globaldata->setPhylipFile(""); }
                                else if (globaldata->getFormat() == "column") { globaldata->setColumnFile(""); }
                                sabundFile.close();rabundFile.close();listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         } outputTypes.clear();
                                return 0;
                        }
                
index c8e01749de20baac9fe523e9cbf0b5f158b35941..787f835a0f33d1d157aeab41568286c28a752520 100644 (file)
@@ -30,7 +30,12 @@ class ClusterCommand : public Command {
        
 public:
        ClusterCommand(string);
+       ClusterCommand();
        ~ClusterCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -57,6 +62,7 @@ private:
        
        void printData(string label);
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 };
 
 #endif
index 0c4dec353a97d3e02bccd69f5af5126e051da617..b5681db57833ae10e9bf665b53e77bea363473c2 100644 (file)
@@ -25,6 +25,54 @@ inline bool comparePriority(seqRNode first, seqRNode second) {
        return better; 
 }
 //**********************************************************************************************************************
+vector<string> ClusterFragmentsCommand::getValidParameters(){  
+       try {
+               string AlignArray[] =  {"fasta","name","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterFragmentsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClusterFragmentsCommand::ClusterFragmentsCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterFragmentsCommand", "ClusterFragmentsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterFragmentsCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterFragmentsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterFragmentsCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterFragmentsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 ClusterFragmentsCommand::ClusterFragmentsCommand(string option) {
        try {
                abort = false;
@@ -48,6 +96,11 @@ ClusterFragmentsCommand::ClusterFragmentsCommand(string option) {
                                if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["name"] = 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 = "";          }
@@ -193,6 +246,7 @@ int ClusterFragmentsCommand::execute(){
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                m->mothurOut(newFastaFile); m->mothurOutEndLine();      
                m->mothurOut(newNamesFile); m->mothurOutEndLine();      
+               outputNames.push_back(newFastaFile);  outputNames.push_back(newNamesFile); outputTypes["fasta"].push_back(newFastaFile); outputTypes["name"].push_back(newNamesFile);
                m->mothurOutEndLine();
 
                return 0;
index 9bdbc4479f19bd7e1aa8297ed4e1f278e0de912f..842485e15c1c9679cf6cd8b1cb16f987454a27c5 100644 (file)
@@ -31,7 +31,12 @@ class ClusterFragmentsCommand : public Command {
        
 public:
        ClusterFragmentsCommand(string);
+       ClusterFragmentsCommand();
        ~ClusterFragmentsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -42,6 +47,8 @@ private:
        map<string, string> names; //represents the names file first column maps to second column
        map<string, int> sizes;  //this map a seq name to the number of identical seqs in the names file
        map<string, int>::iterator itSize; 
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        int readFASTA();
        void readNameFile();
index 10579a3b209c3f5b15b1590d44d2ab99f90326b1..3c957a6ce84b5e5a489faaccf18a1dc40f99a02b 100644 (file)
 #include "readmatrix.hpp"
 #include "inputdata.h"
 
+
+//**********************************************************************************************************************
+vector<string> ClusterSplitCommand::getValidParameters(){      
+       try {
+               string AlignArray[] =  {"fasta","phylip","column","name","cutoff","precision","method","splitmethod","taxonomy","taxlevel","large","showabund","timing","hard","processors","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterSplitCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ClusterSplitCommand::ClusterSplitCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterSplitCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"fasta","phylip","column","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterSplitCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ClusterSplitCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ClusterSplitCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
 ClusterSplitCommand::ClusterSplitCommand(string option)  {
@@ -44,6 +94,12 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                                }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["rabund"] = tempOutNames;
+                       outputTypes["sabund"] = tempOutNames;
+                       
                        globaldata->newRead();
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
@@ -292,7 +348,7 @@ int ClusterSplitCommand::execute(){
                SplitMatrix* split;
                if (splitmethod == "distance")                  {       split = new SplitMatrix(distfile, namefile, taxFile, cutoff, splitmethod, large);                                                       }
                else if (splitmethod == "classify")             {       split = new SplitMatrix(distfile, namefile, taxFile, taxLevelCutoff, splitmethod, large);                                       }
-               else if (splitmethod == "fasta")                {       split = new SplitMatrix(fastafile, namefile, taxFile, taxLevelCutoff, splitmethod, processors, outputDir);      }
+               else if (splitmethod == "fasta")                {       split = new SplitMatrix(fastafile, namefile, taxFile, taxLevelCutoff, cutoff, splitmethod, processors, outputDir);      }
                else { m->mothurOut("Not a valid splitting method.  Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); return 0;             }
                
                split->split();
@@ -696,9 +752,9 @@ int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> us
                m->openOutputFile(fileroot+ tag + ".rabund",    outRabund);
                m->openOutputFile(fileroot+ tag + ".list",              outList);
                                
-               outputNames.push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list");
+               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");
                
                map<float, int>::iterator itLabel;
 
index dc46f9904a594919d3789c4c98f06ec7a7c159d7..07ddaf95e72f9f0e8c51baa5e8d55a87fb9a9967 100644 (file)
@@ -23,7 +23,12 @@ class ClusterSplitCommand : public Command {
        
 public:
        ClusterSplitCommand(string);
+       ClusterSplitCommand();
        ~ClusterSplitCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -31,6 +36,7 @@ private:
        GlobalData* globaldata;
        vector<int> processIDS;   //processid
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        string method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, distfile, format, showabund, timing, splitmethod, taxFile, fastafile;
        double cutoff, splitcutoff;
index 2d952fa9b9a60ea762a83f967dc7e6c125fff61d..3dd2436a8a88cf21b8cd7705a799ed9ab6450ebf 100644 (file)
 #include "shen.h"
 #include "coverage.h"
 
-
+//**********************************************************************************************************************
+vector<string> CollectCommand::getValidParameters(){   
+       try {
+               string AlignArray[] =  {"freq","label","calc","abund","size","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CollectCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CollectCommand::getRequiredFiles(){     
+       try {
+               string AlignArray[] =  {"shared","list","rabund","sabund","or"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+CollectCommand::CollectCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["sobs"] = tempOutNames;
+               outputTypes["chao"] = tempOutNames;
+               outputTypes["nseqs"] = tempOutNames;
+               outputTypes["coverage"] = tempOutNames;
+               outputTypes["ace"] = tempOutNames;
+               outputTypes["jack"] = tempOutNames;
+               outputTypes["shannon"] = tempOutNames;
+               outputTypes["shannoneven"] = tempOutNames;
+               outputTypes["np_shannon"] = tempOutNames;
+               outputTypes["heip"] = tempOutNames;
+               outputTypes["smithwilson"] = tempOutNames;
+               outputTypes["simpson"] = tempOutNames;
+               outputTypes["simpsoneven"] = tempOutNames;
+               outputTypes["invsimpson"] = tempOutNames;
+               outputTypes["bootstrap"] = tempOutNames;
+               outputTypes["geometric"] = tempOutNames;
+               outputTypes["qstat"] = tempOutNames;
+               outputTypes["logseries"] = tempOutNames;
+               outputTypes["bergerparker"] = tempOutNames;
+               outputTypes["bstick"] = tempOutNames;
+               outputTypes["goodscoverage"] = tempOutNames;
+               outputTypes["efron"] = tempOutNames;
+               outputTypes["boneh"] = tempOutNames;
+               outputTypes["solow"] = tempOutNames;
+               outputTypes["shen"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectCommand", "CollectCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 CollectCommand::CollectCommand(string option)  {
        try {
@@ -62,6 +132,34 @@ CollectCommand::CollectCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sobs"] = tempOutNames;
+                       outputTypes["chao"] = tempOutNames;
+                       outputTypes["nseqs"] = tempOutNames;
+                       outputTypes["coverage"] = tempOutNames;
+                       outputTypes["ace"] = tempOutNames;
+                       outputTypes["jack"] = tempOutNames;
+                       outputTypes["shannon"] = tempOutNames;
+                       outputTypes["shannoneven"] = tempOutNames;
+                       outputTypes["np_shannon"] = tempOutNames;
+                       outputTypes["heip"] = tempOutNames;
+                       outputTypes["smithwilson"] = tempOutNames;
+                       outputTypes["simpson"] = tempOutNames;
+                       outputTypes["simpsoneven"] = tempOutNames;
+                       outputTypes["invsimpson"] = tempOutNames;
+                       outputTypes["bootstrap"] = tempOutNames;
+                       outputTypes["geometric"] = tempOutNames;
+                       outputTypes["qstat"] = tempOutNames;
+                       outputTypes["logseries"] = tempOutNames;
+                       outputTypes["bergerparker"] = tempOutNames;
+                       outputTypes["bstick"] = tempOutNames;
+                       outputTypes["goodscoverage"] = tempOutNames;
+                       outputTypes["efron"] = tempOutNames;
+                       outputTypes["boneh"] = tempOutNames;
+                       outputTypes["solow"] = tempOutNames;
+                       outputTypes["shen"] = 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 = "";         }
                        
@@ -140,15 +238,13 @@ int CollectCommand::execute(){
                
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
                else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
        
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); }
                        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
@@ -164,79 +260,79 @@ int CollectCommand::execute(){
                                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");
+                                               outputNames.push_back(fileNameRoot+"sobs"); outputTypes["sobs"].push_back(fileNameRoot+"sobs");
                                        }else if (Estimators[i] == "chao") { 
                                                cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
-                                               outputNames.push_back(fileNameRoot+"chao");
+                                               outputNames.push_back(fileNameRoot+"chao"); outputTypes["chao"].push_back(fileNameRoot+"chao");
                                        }else if (Estimators[i] == "nseqs") { 
                                                cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
-                                               outputNames.push_back(fileNameRoot+"nseqs");
+                                               outputNames.push_back(fileNameRoot+"nseqs"); outputTypes["nseqs"].push_back(fileNameRoot+"nseqs");
                                        }else if (Estimators[i] == "coverage") { 
                                                cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+"coverage")));
-                                               outputNames.push_back(fileNameRoot+"coverage");
+                                               outputNames.push_back(fileNameRoot+"coverage"); outputTypes["coverage"].push_back(fileNameRoot+"coverage");
                                        }else if (Estimators[i] == "ace") { 
                                                cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
-                                               outputNames.push_back(fileNameRoot+"ace");
+                                               outputNames.push_back(fileNameRoot+"ace"); outputTypes["ace"].push_back(fileNameRoot+"ace");
                                        }else if (Estimators[i] == "jack") { 
                                                cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
-                                               outputNames.push_back(fileNameRoot+"jack");
+                                               outputNames.push_back(fileNameRoot+"jack"); outputTypes["jack"].push_back(fileNameRoot+"jack");
                                        }else if (Estimators[i] == "shannon") { 
                                                cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
-                                               outputNames.push_back(fileNameRoot+"shannon");
+                                               outputNames.push_back(fileNameRoot+"shannon"); outputTypes["shannon"].push_back(fileNameRoot+"shannon");
                                        }else if (Estimators[i] == "shannoneven") { 
                                                cDisplays.push_back(new CollectDisplay(new ShannonEven(), new OneColumnFile(fileNameRoot+"shannoneven")));
-                                               outputNames.push_back(fileNameRoot+"shannoneven");
+                                               outputNames.push_back(fileNameRoot+"shannoneven"); outputTypes["shannoneven"].push_back(fileNameRoot+"shannoneven");
                                        }else if (Estimators[i] == "npshannon") { 
                                                cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
-                                               outputNames.push_back(fileNameRoot+"np_shannon");
+                                               outputNames.push_back(fileNameRoot+"np_shannon"); outputTypes["np_shannon"].push_back(fileNameRoot+"np_shannon");
                                        }else if (Estimators[i] == "heip") { 
                                                cDisplays.push_back(new CollectDisplay(new Heip(), new OneColumnFile(fileNameRoot+"heip")));
-                                               outputNames.push_back(fileNameRoot+"heip");
+                                               outputNames.push_back(fileNameRoot+"heip"); outputTypes["heip"].push_back(fileNameRoot+"heip");
                                        }else if (Estimators[i] == "smithwilson") { 
                                                cDisplays.push_back(new CollectDisplay(new SmithWilson(), new OneColumnFile(fileNameRoot+"smithwilson")));
-                                               outputNames.push_back(fileNameRoot+"smithwilson");
+                                               outputNames.push_back(fileNameRoot+"smithwilson"); outputTypes["smithwilson"].push_back(fileNameRoot+"smithwilson");
                                        }else if (Estimators[i] == "simpson") { 
                                                cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
-                                               outputNames.push_back(fileNameRoot+"simpson");
+                                               outputNames.push_back(fileNameRoot+"simpson"); outputTypes["simpson"].push_back(fileNameRoot+"simpson");
                                        }else if (Estimators[i] == "simpsoneven") { 
                                                cDisplays.push_back(new CollectDisplay(new SimpsonEven(), new OneColumnFile(fileNameRoot+"simpsoneven")));
-                                               outputNames.push_back(fileNameRoot+"simpsoneven");
+                                               outputNames.push_back(fileNameRoot+"simpsoneven"); outputTypes["simpsoneven"].push_back(fileNameRoot+"simpsoneven");
                                        }else if (Estimators[i] == "invsimpson") { 
                                                cDisplays.push_back(new CollectDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"invsimpson")));
-                                               outputNames.push_back(fileNameRoot+"invsimpson");
+                                               outputNames.push_back(fileNameRoot+"invsimpson"); outputTypes["invsimpson"].push_back(fileNameRoot+"invsimpson");
                                        }else if (Estimators[i] == "bootstrap") { 
                                                cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
-                                               outputNames.push_back(fileNameRoot+"bootstrap");
+                                               outputNames.push_back(fileNameRoot+"bootstrap"); outputTypes["bootstrap"].push_back(fileNameRoot+"bootstrap");
                                        }else if (Estimators[i] == "geometric") { 
                                                cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geometric")));
-                                               outputNames.push_back(fileNameRoot+"geometric");
+                                               outputNames.push_back(fileNameRoot+"geometric"); outputTypes["geometric"].push_back(fileNameRoot+"geometric");
                                        }else if (Estimators[i] == "qstat") { 
                                                cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat")));
-                                               outputNames.push_back(fileNameRoot+"qstat");
+                                               outputNames.push_back(fileNameRoot+"qstat"); outputTypes["qstat"].push_back(fileNameRoot+"qstat");
                                        }else if (Estimators[i] == "logseries") { 
                                                cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logseries")));
-                                               outputNames.push_back(fileNameRoot+"logseries");
+                                               outputNames.push_back(fileNameRoot+"logseries"); outputTypes["logseries"].push_back(fileNameRoot+"logseries");
                                        }else if (Estimators[i] == "bergerparker") { 
                                                cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker")));
-                                               outputNames.push_back(fileNameRoot+"bergerparker");
+                                               outputNames.push_back(fileNameRoot+"bergerparker"); outputTypes["bergerparker"].push_back(fileNameRoot+"bergerparker");
                                        }else if (Estimators[i] == "bstick") { 
                                                cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick")));
-                                               outputNames.push_back(fileNameRoot+"bstick");
+                                               outputNames.push_back(fileNameRoot+"bstick"); outputTypes["bstick"].push_back(fileNameRoot+"bstick");
                                        }else if (Estimators[i] == "goodscoverage") { 
                                                cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage")));
-                                               outputNames.push_back(fileNameRoot+"goodscoverage");
+                                               outputNames.push_back(fileNameRoot+"goodscoverage"); outputTypes["goodscoverage"].push_back(fileNameRoot+"goodscoverage");
                                        }else if (Estimators[i] == "efron") {
                                                cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron")));
-                                               outputNames.push_back(fileNameRoot+"efron");
+                                               outputNames.push_back(fileNameRoot+"efron"); outputTypes["efron"].push_back(fileNameRoot+"efron");
                                        }else if (Estimators[i] == "boneh") {
                                                cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh")));
-                                               outputNames.push_back(fileNameRoot+"boneh");
+                                               outputNames.push_back(fileNameRoot+"boneh"); outputTypes["boneh"].push_back(fileNameRoot+"boneh");
                                        }else if (Estimators[i] == "solow") {
                                                cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
-                                               outputNames.push_back(fileNameRoot+"solow");
+                                               outputNames.push_back(fileNameRoot+"solow"); outputTypes["solow"].push_back(fileNameRoot+"solow");
                                        }else if (Estimators[i] == "shen") {
                                                cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(fileNameRoot+"shen")));
-                                               outputNames.push_back(fileNameRoot+"shen");
+                                               outputNames.push_back(fileNameRoot+"shen"); outputTypes["shen"].push_back(fileNameRoot+"shen");
                                        }
                                }
                        }
@@ -257,7 +353,7 @@ int CollectCommand::execute(){
                        
                        if (m->control_pressed) {  
                                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         } outputTypes.clear(); 
                                delete input;  globaldata->ginput = NULL;
                                delete read;
                                delete order; globaldata->gorder = NULL;
@@ -272,7 +368,7 @@ int CollectCommand::execute(){
                        
                                if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         } outputTypes.clear(); 
                                        delete input;  globaldata->ginput = NULL;
                                        delete read;
                                        delete order; globaldata->gorder = NULL;
@@ -324,7 +420,7 @@ int CollectCommand::execute(){
                        
                        if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         } outputTypes.clear(); 
                                        delete input;  globaldata->ginput = NULL;
                                        delete read;
                                        delete validCalculator;
@@ -359,7 +455,7 @@ int CollectCommand::execute(){
                                
                                if (m->control_pressed) { 
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         } outputTypes.clear(); 
                                        delete input;  globaldata->ginput = NULL;
                                        delete read;
                                        delete order; globaldata->gorder = NULL;
index 773bdae5c1d0b71bdad01e4403d3af3702274e70..20c863b81dfd79fad597cd6e1e83571256873969 100644 (file)
@@ -38,7 +38,12 @@ class CollectCommand : public Command {
        
 public:
        CollectCommand(string); 
+       CollectCommand();
        ~CollectCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -52,6 +57,8 @@ private:
        vector<Display*> cDisplays;
        int abund, size;
        float freq;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used
index c0b8248e58981473b1f7bf70709863c36c68992b..87194893f3a1cc5a027646766c36f9b7db9557cb 100644 (file)
 #include "whittaker.h"
 
 
-
 //**********************************************************************************************************************
-
+vector<string> CollectSharedCommand::getValidParameters(){     
+       try {
+               string AlignArray[] =  {"freq","label","calc","groups","all","outputdir","inputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectSharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CollectSharedCommand::getRequiredParameters(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectSharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CollectSharedCommand::getRequiredFiles(){       
+       try {
+               string AlignArray[] =  {"shared"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectSharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+CollectSharedCommand::CollectSharedCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["sharedchao"] = tempOutNames;
+               outputTypes["sharedsobs"] = tempOutNames;
+               outputTypes["sharedace"] = tempOutNames;
+               outputTypes["jabund"] = tempOutNames;
+               outputTypes["sorabund"] = tempOutNames;
+               outputTypes["jclass"] = tempOutNames;
+               outputTypes["sorclass"] = tempOutNames;
+               outputTypes["jest"] = tempOutNames;
+               outputTypes["sorest"] = tempOutNames;
+               outputTypes["thetayc"] = tempOutNames;
+               outputTypes["thetan"] = tempOutNames;
+               outputTypes["kstest"] = tempOutNames;
+               outputTypes["whittaker"] = tempOutNames;
+               outputTypes["sharednseqs"] = tempOutNames;
+               outputTypes["ochiai"] = tempOutNames;
+               outputTypes["anderberg"] = tempOutNames;
+               outputTypes["skulczynski"] = tempOutNames;
+               outputTypes["kulczynskicody"] = tempOutNames;
+               outputTypes["lennon"] = tempOutNames;
+               outputTypes["morisitahorn"] = tempOutNames;
+               outputTypes["braycurtis"] = tempOutNames;
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 CollectSharedCommand::CollectSharedCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
@@ -63,6 +129,31 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sharedchao"] = tempOutNames;
+                       outputTypes["sharedsobs"] = tempOutNames;
+                       outputTypes["sharedace"] = tempOutNames;
+                       outputTypes["jabund"] = tempOutNames;
+                       outputTypes["sorabund"] = tempOutNames;
+                       outputTypes["jclass"] = tempOutNames;
+                       outputTypes["sorclass"] = tempOutNames;
+                       outputTypes["jest"] = tempOutNames;
+                       outputTypes["sorest"] = tempOutNames;
+                       outputTypes["thetayc"] = tempOutNames;
+                       outputTypes["thetan"] = tempOutNames;
+                       outputTypes["kstest"] = tempOutNames;
+                       outputTypes["whittaker"] = tempOutNames;
+                       outputTypes["sharednseqs"] = tempOutNames;
+                       outputTypes["ochiai"] = tempOutNames;
+                       outputTypes["anderberg"] = tempOutNames;
+                       outputTypes["skulczynski"] = tempOutNames;
+                       outputTypes["kulczynskicody"] = tempOutNames;
+                       outputTypes["lennon"] = tempOutNames;
+                       outputTypes["morisitahorn"] = tempOutNames;
+                       outputTypes["braycurtis"] = 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 = "";         }
                        
@@ -124,67 +215,67 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                        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");
+                                                       outputNames.push_back(fileNameRoot+"shared.chao"); outputTypes["sharedchao"].push_back(fileNameRoot+"shared.chao");
                                                }else if (Estimators[i] == "sharedsobs") { 
                                                        cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.sobs");
+                                                       outputNames.push_back(fileNameRoot+"shared.sobs"); outputTypes["sharedsobs"].push_back(fileNameRoot+"shared.sobs");
                                                }else if (Estimators[i] == "sharedace") { 
                                                        cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
-                                                       outputNames.push_back(fileNameRoot+"shared.ace");
+                                                       outputNames.push_back(fileNameRoot+"shared.ace"); outputTypes["sharedace"].push_back(fileNameRoot+"shared.ace");
                                                }else if (Estimators[i] == "jabund") {  
                                                        cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(fileNameRoot+"jabund")));
-                                                       outputNames.push_back(fileNameRoot+"jabund");
+                                                       outputNames.push_back(fileNameRoot+"jabund"); outputTypes["jabund"].push_back(fileNameRoot+"jabund");
                                                }else if (Estimators[i] == "sorabund") { 
                                                        cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(fileNameRoot+"sorabund")));
-                                                       outputNames.push_back(fileNameRoot+"sorabund");
+                                                       outputNames.push_back(fileNameRoot+"sorabund"); outputTypes["sorabund"].push_back(fileNameRoot+"sorabund");
                                                }else if (Estimators[i] == "jclass") { 
                                                        cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(fileNameRoot+"jclass")));
-                                                       outputNames.push_back(fileNameRoot+"jclass");
+                                                       outputNames.push_back(fileNameRoot+"jclass"); outputTypes["jclass"].push_back(fileNameRoot+"jclass");
                                                }else if (Estimators[i] == "sorclass") { 
                                                        cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(fileNameRoot+"sorclass")));
-                                                       outputNames.push_back(fileNameRoot+"sorclass");
+                                                       outputNames.push_back(fileNameRoot+"sorclass"); outputTypes["sorclass"].push_back(fileNameRoot+"sorclass");
                                                }else if (Estimators[i] == "jest") { 
                                                        cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(fileNameRoot+"jest")));
-                                                       outputNames.push_back(fileNameRoot+"jest");
+                                                       outputNames.push_back(fileNameRoot+"jest"); outputTypes["jest"].push_back(fileNameRoot+"jest");
                                                }else if (Estimators[i] == "sorest") { 
                                                        cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(fileNameRoot+"sorest")));
-                                                       outputNames.push_back(fileNameRoot+"sorest");
+                                                       outputNames.push_back(fileNameRoot+"sorest"); outputTypes["sorest"].push_back(fileNameRoot+"sorest");
                                                }else if (Estimators[i] == "thetayc") { 
                                                        cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(fileNameRoot+"thetayc")));
-                                                       outputNames.push_back(fileNameRoot+"thetayc");
+                                                       outputNames.push_back(fileNameRoot+"thetayc"); outputTypes["thetayc"].push_back(fileNameRoot+"thetayc");
                                                }else if (Estimators[i] == "thetan") { 
                                                        cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(fileNameRoot+"thetan")));
-                                                       outputNames.push_back(fileNameRoot+"thetan");
+                                                       outputNames.push_back(fileNameRoot+"thetan"); outputTypes["thetan"].push_back(fileNameRoot+"thetan");
                                                }else if (Estimators[i] == "kstest") { 
                                                        cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(fileNameRoot+"kstest")));
-                                                       outputNames.push_back(fileNameRoot+"kstest");
+                                                       outputNames.push_back(fileNameRoot+"kstest"); outputTypes["kstest"].push_back(fileNameRoot+"kstest");
                                                }else if (Estimators[i] == "whittaker") { 
                                                        cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(fileNameRoot+"whittaker")));
-                                                       outputNames.push_back(fileNameRoot+"whittaker");
+                                                       outputNames.push_back(fileNameRoot+"whittaker"); outputTypes["whittaker"].push_back(fileNameRoot+"whittaker");
                                                }else if (Estimators[i] == "sharednseqs") { 
                                                        cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+"shared.nseqs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.nseqs");
+                                                       outputNames.push_back(fileNameRoot+"shared.nseqs"); outputTypes["shared.nseqs"].push_back(fileNameRoot+"shared.nseqs");
                                                }else if (Estimators[i] == "ochiai") { 
                                                        cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(fileNameRoot+"ochiai")));
-                                                       outputNames.push_back(fileNameRoot+"ochiai");
+                                                       outputNames.push_back(fileNameRoot+"ochiai"); outputTypes["ochiai"].push_back(fileNameRoot+"ochiai");
                                                }else if (Estimators[i] == "anderberg") { 
                                                        cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+"anderberg")));
-                                                       outputNames.push_back(fileNameRoot+"anderberg");
+                                                       outputNames.push_back(fileNameRoot+"anderberg"); outputTypes["anderberg"].push_back(fileNameRoot+"anderberg");
                                                }else if (Estimators[i] == "skulczynski") { 
                                                        cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+"kulczynski")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynski");
+                                                       outputNames.push_back(fileNameRoot+"kulczynski"); outputTypes["kulczynski"].push_back(fileNameRoot+"kulczynski");
                                                }else if (Estimators[i] == "kulczynskicody") { 
                                                        cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(fileNameRoot+"kulczynskicody")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynskicody");
+                                                       outputNames.push_back(fileNameRoot+"kulczynskicody"); outputTypes["kulczynskicody"].push_back(fileNameRoot+"kulczynskicody");
                                                }else if (Estimators[i] == "lennon") { 
                                                        cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(fileNameRoot+"lennon")));
-                                                       outputNames.push_back(fileNameRoot+"lennon");
+                                                       outputNames.push_back(fileNameRoot+"lennon"); outputTypes["lennon"].push_back(fileNameRoot+"lennon");
                                                }else if (Estimators[i] == "morisitahorn") { 
                                                        cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(fileNameRoot+"morisitahorn")));
-                                                       outputNames.push_back(fileNameRoot+"morisitahorn");
+                                                       outputNames.push_back(fileNameRoot+"morisitahorn"); outputTypes["morisitahorn"].push_back(fileNameRoot+"morisitahorn");
                                                }else if (Estimators[i] == "braycurtis") { 
                                                        cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
-                                                       outputNames.push_back(fileNameRoot+"braycurtis");
+                                                       outputNames.push_back(fileNameRoot+"braycurtis"); outputTypes["braycurtis"].push_back(fileNameRoot+"braycurtis");
                                                }
                                        }
                                }       
@@ -263,7 +354,7 @@ int CollectSharedCommand::execute(){
 
                while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  outputTypes.clear();
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        delete order; 
                                        globaldata->Groups.clear();
@@ -311,7 +402,7 @@ int CollectSharedCommand::execute(){
                }
                
                if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }   outputTypes.clear();
                                        for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                        globaldata->Groups.clear();
                                        return 0;
@@ -341,7 +432,7 @@ int CollectSharedCommand::execute(){
                        delete cCurve;
                        
                        if (m->control_pressed) { 
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());         }  outputTypes.clear();
                                for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
                                delete order; 
                                globaldata->Groups.clear();
index b7a494149249af486c2a8cb812b00316a42b241f..327ce5d28832dbe7f25d69f6c0755f6e931c747d 100644 (file)
@@ -27,7 +27,12 @@ class CollectSharedCommand : public Command {
        
 public:
        CollectSharedCommand(string);   
+       CollectSharedCommand(); 
        ~CollectSharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -49,6 +54,7 @@ private:
        set<string> labels; //holds labels to be used
        string label, calc, groups, outputDir;
        vector<string>  Estimators, Groups, outputNames;
+       map<string, vector<string> > outputTypes;
 
 
 };
index b6bf5cd397644ad215a8a88f269f461d04add112..97701aa0017ccaf821546f06e40df41cad6233e5 100644 (file)
@@ -22,6 +22,10 @@ class Command {
        
        public:
                Command() {  m = MothurOut::getInstance();  }
+               virtual vector<string> getValidParameters() = 0;
+               virtual vector<string> getRequiredParameters() = 0; //adding "or" as the last element indicates one of the previous is needed
+               virtual vector<string> getRequiredFiles() = 0; //adding "or" as the last element indicates one of the previous is needed
+               virtual map<string, vector<string> > getOutputFiles() = 0; //file type to names
                virtual int execute() = 0;
                virtual void help() = 0;
                virtual ~Command() { }
index 6912bbb2c79eb03e4a3d899d85369c660e7a0e42..917ab96e69afa7cf7ad76d2cf85bbb79401e8db4 100644 (file)
@@ -92,6 +92,7 @@
 #include "getlineagecommand.h"
 #include "removelineagecommand.h"
 #include "parsefastaqcommand.h"
+#include "pipelinepdscommand.h"
 
 /*******************************************************/
 
@@ -116,6 +117,8 @@ CommandFactory::CommandFactory(){
        m = MothurOut::getInstance();
        
        command = new NoCommand(s);
+       shellcommand = new NoCommand(s);
+       pipecommand = new NoCommand(s);
        
        outputDir = ""; inputDir = "";
        logFileName = "";
@@ -188,6 +191,7 @@ CommandFactory::CommandFactory(){
        commands["get.lineage"]                 = "get.lineage";
        commands["remove.lineage"]              = "remove.lineage";
        commands["fastq.info"]                  = "fastq.info";
+       commands["pipeline.pds"]                = "MPIEnabled";
        commands["classify.seqs"]               = "MPIEnabled"; 
        commands["dist.seqs"]                   = "MPIEnabled";
        commands["filter.seqs"]                 = "MPIEnabled";
@@ -223,6 +227,8 @@ bool CommandFactory::MPIEnabled(string commandName) {
 CommandFactory::~CommandFactory(){
        _uniqueInstance = 0;
        delete command;
+       delete shellcommand;
+       delete pipecommand;
 }
 
 /***********************************************************/
@@ -327,6 +333,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                else if(commandName == "get.lineage")                   {       command = new GetLineageCommand(optionString);                          }
                else if(commandName == "remove.lineage")                {       command = new RemoveLineageCommand(optionString);                       }
                else if(commandName == "fastq.info")                    {       command = new ParseFastaQCommand(optionString);                         }
+               else if(commandName == "pipeline.pds")                  {       command = new PipelineCommand(optionString);                            }
                else                                                                                    {       command = new NoCommand(optionString);                                          }
 
                return command;
@@ -337,6 +344,216 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
        }
 }
 /***********************************************************/
+
+/***********************************************************/
+//This function calls the appropriate command fucntions based on user input.
+Command* CommandFactory::getCommand(string commandName, string optionString, string mode){
+       try {
+               delete pipecommand;   //delete the old command
+               
+               //user has opted to redirect output from dir where input files are located to some other place
+               if (outputDir != "") { 
+                       if (optionString != "") { optionString += ", outputdir=" + outputDir; }
+                       else { optionString += "outputdir=" + outputDir; }
+               }
+               
+               //user has opted to redirect input from dir where mothur.exe is located to some other place
+               if (inputDir != "") { 
+                       if (optionString != "") { optionString += ", inputdir=" + inputDir; }
+                       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);                                 }
+               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);                                    }
+               else if(commandName == "quit")                                  {       pipecommand = new QuitCommand(optionString);                                    }
+               else if(commandName == "collect.single")                {       pipecommand = new CollectCommand(optionString);                                 }
+               else if(commandName == "collect.shared")                {       pipecommand = new CollectSharedCommand(optionString);                   }
+               else if(commandName == "rarefaction.single")    {       pipecommand = new RareFactCommand(optionString);                                }
+               else if(commandName == "rarefaction.shared")    {       pipecommand = new RareFactSharedCommand(optionString);                  }
+               else if(commandName == "summary.single")                {       pipecommand = new SummaryCommand(optionString);                                 }
+               else if(commandName == "summary.shared")                {       pipecommand = new SummarySharedCommand(optionString);                   }
+               else if(commandName == "unifrac.weighted")              {       pipecommand = new UnifracWeightedCommand(optionString);                 }
+               else if(commandName == "unifrac.unweighted")    {       pipecommand = new UnifracUnweightedCommand(optionString);               }
+               else if(commandName == "get.group")             {   pipecommand = new GetgroupCommand(optionString);                            }
+               else if(commandName == "get.label")             {   pipecommand = new GetlabelCommand(optionString);                            }
+               else if(commandName == "get.sabund")            {   pipecommand = new GetSAbundCommand(optionString);                           }
+               else if(commandName == "get.rabund")            {   pipecommand = new GetRAbundCommand(optionString);                           }
+               else if(commandName == "libshuff")              {   pipecommand = new LibShuffCommand(optionString);                            }
+               else if(commandName == "heatmap.bin")                   {   pipecommand = new HeatMapCommand(optionString);                                     }
+               else if(commandName == "heatmap.sim")                   {   pipecommand = new HeatMapSimCommand(optionString);                          }
+               else if(commandName == "filter.seqs")                   {   pipecommand = new FilterSeqsCommand(optionString);                          }
+               else if(commandName == "venn")                                  {   pipecommand = new VennCommand(optionString);                                        }
+               else if(commandName == "bin.seqs")                              {   pipecommand = new BinSeqCommand(optionString);                                      }
+               else if(commandName == "get.oturep")                    {   pipecommand = new GetOTURepCommand(optionString);                           }
+               else if(commandName == "tree.shared")                   {   pipecommand = new TreeGroupCommand(optionString);                           }
+               else if(commandName == "dist.shared")                   {   pipecommand = new MatrixOutputCommand(optionString);                        }
+               else if(commandName == "bootstrap.shared")              {   pipecommand = new BootSharedCommand(optionString);                          }
+               else if(commandName == "consensus")                             {   pipecommand = new ConcensusCommand(optionString);                           }
+               else if(commandName == "dist.seqs")                             {   pipecommand = new DistanceCommand(optionString);                            }
+               else if(commandName == "align.seqs")                    {   pipecommand = new AlignCommand(optionString);                                       }
+               else if(commandName == "summary.seqs")                  {       pipecommand = new SeqSummaryCommand(optionString);                              }
+               else if(commandName == "screen.seqs")                   {       pipecommand = new ScreenSeqsCommand(optionString);                              }
+               else if(commandName == "reverse.seqs")                  {       pipecommand = new ReverseSeqsCommand(optionString);                             }
+               else if(commandName == "trim.seqs")                             {       pipecommand = new TrimSeqsCommand(optionString);                                }
+               else if(commandName == "chimera.seqs")                  {       pipecommand = new ChimeraSeqsCommand(optionString);                             }
+               else if(commandName == "list.seqs")                             {       pipecommand = new ListSeqsCommand(optionString);                                }
+               else if(commandName == "get.seqs")                              {       pipecommand = new GetSeqsCommand(optionString);                                 }
+               else if(commandName == "remove.seqs")                   {       pipecommand = new RemoveSeqsCommand(optionString);                              }
+               else if(commandName == "merge.files")                   {       pipecommand = new MergeFileCommand(optionString);                               }
+               else if(commandName == "system")                                {       pipecommand = new SystemCommand(optionString);                                  }
+               else if(commandName == "align.check")                   {       pipecommand = new AlignCheckCommand(optionString);                              }
+               else if(commandName == "get.sharedseqs")                {       pipecommand = new GetSharedOTUCommand(optionString);                    }
+               else if(commandName == "get.otulist")                   {       pipecommand = new GetListCountCommand(optionString);                    }
+               else if(commandName == "hcluster")                              {       pipecommand = new HClusterCommand(optionString);                                }
+               else if(commandName == "classify.seqs")                 {       pipecommand = new ClassifySeqsCommand(optionString);                    }
+               else if(commandName == "chimera.ccode")                 {       pipecommand = new ChimeraCcodeCommand(optionString);                    }
+               else if(commandName == "chimera.check")                 {       pipecommand = new ChimeraCheckCommand(optionString);                    }
+               else if(commandName == "chimera.slayer")                {       pipecommand = new ChimeraSlayerCommand(optionString);                   }
+               else if(commandName == "chimera.pintail")               {       pipecommand = new ChimeraPintailCommand(optionString);                  }
+               else if(commandName == "chimera.bellerophon")   {       pipecommand = new ChimeraBellerophonCommand(optionString);              }
+               else if(commandName == "phylotype")                             {       pipecommand = new PhylotypeCommand(optionString);                               }
+               else if(commandName == "mgcluster")                             {       pipecommand = new MGClusterCommand(optionString);                               }
+               else if(commandName == "pre.cluster")                   {       pipecommand = new PreClusterCommand(optionString);                              }
+               else if(commandName == "pcoa")                                  {       pipecommand = new PCACommand(optionString);                                             }
+               else if(commandName == "otu.hierarchy")                 {       pipecommand = new OtuHierarchyCommand(optionString);                    }
+               else if(commandName == "set.dir")                               {       pipecommand = new SetDirectoryCommand(optionString);                    }
+               else if(commandName == "set.logfile")                   {       pipecommand = new SetLogFileCommand(optionString);                              }
+               else if(commandName == "parse.list")                    {       pipecommand = new ParseListCommand(optionString);                               }
+               else if(commandName == "parse.sff")                             {       pipecommand = new ParseSFFCommand(optionString);                                }
+               else if(commandName == "phylo.diversity")               {       pipecommand = new PhyloDiversityCommand(optionString);                  }
+               else if(commandName == "make.group")                    {       pipecommand = new MakeGroupCommand(optionString);                               }
+               else if(commandName == "chop.seqs")                             {       pipecommand = new ChopSeqsCommand(optionString);                                }
+               else if(commandName == "clearcut")                              {       pipecommand = new ClearcutCommand(optionString);                                }
+               else if(commandName == "catchall")                              {       pipecommand = new CatchAllCommand(optionString);                                }
+               else if(commandName == "split.abund")                   {       pipecommand = new SplitAbundCommand(optionString);                              }
+               else if(commandName == "cluster.split")                 {       pipecommand = new ClusterSplitCommand(optionString);                    }
+               else if(commandName == "classify.otu")                  {       pipecommand = new ClassifyOtuCommand(optionString);                             }
+               else if(commandName == "degap.seqs")                    {       pipecommand = new DegapSeqsCommand(optionString);                               }
+               else if(commandName == "get.relabund")                  {       pipecommand = new GetRelAbundCommand(optionString);                             }
+               else if(commandName == "sens.spec")                             {       pipecommand = new SensSpecCommand(optionString);                                }
+               else if(commandName == "seq.error")                             {       pipecommand = new SeqErrorCommand(optionString);                                }
+               else if(commandName == "sffinfo")                               {       pipecommand = new SffInfoCommand(optionString);                                 }
+               else if(commandName == "normalize.shared")              {       pipecommand = new NormalizeSharedCommand(optionString);                 }
+               else if(commandName == "metastats")                             {       pipecommand = new MetaStatsCommand(optionString);                               }
+               else if(commandName == "split.groups")                  {       pipecommand = new SplitGroupCommand(optionString);                              }
+               else if(commandName == "cluster.fragments")             {       pipecommand = new ClusterFragmentsCommand(optionString);                }
+               else if(commandName == "get.lineage")                   {       pipecommand = new GetLineageCommand(optionString);                              }
+               else if(commandName == "remove.lineage")                {       pipecommand = new RemoveLineageCommand(optionString);                   }
+               else if(commandName == "fastq.info")                    {       pipecommand = new ParseFastaQCommand(optionString);                             }
+               else                                                                                    {       pipecommand = new NoCommand(optionString);                                              }
+
+               return pipecommand;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CommandFactory", "getCommand");
+               exit(1);
+       }
+}
+/***********************************************************/
+
+/***********************************************************/
+//This function calls the appropriate command fucntions based on user input, this is used by the pipeline command to check a users piepline for errors before running
+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();                            }
+               else if(commandName == "unique.seqs")                   {       shellcommand = new DeconvoluteCommand();                        }
+               else if(commandName == "parsimony")                             {       shellcommand = new ParsimonyCommand();                          }
+               else if(commandName == "help")                                  {       shellcommand = new HelpCommand();                                       }
+               else if(commandName == "quit")                                  {       shellcommand = new QuitCommand();                                       }
+               else if(commandName == "collect.single")                {       shellcommand = new CollectCommand();                            }
+               else if(commandName == "collect.shared")                {       shellcommand = new CollectSharedCommand();                      }
+               else if(commandName == "rarefaction.single")    {       shellcommand = new RareFactCommand();                           }
+               else if(commandName == "rarefaction.shared")    {       shellcommand = new RareFactSharedCommand();                     }
+               else if(commandName == "summary.single")                {       shellcommand = new SummaryCommand();                            }
+               else if(commandName == "summary.shared")                {       shellcommand = new SummarySharedCommand();                      }
+               else if(commandName == "unifrac.weighted")              {       shellcommand = new UnifracWeightedCommand();            }
+               else if(commandName == "unifrac.unweighted")    {       shellcommand = new UnifracUnweightedCommand();          }
+               else if(commandName == "get.group")             {   shellcommand = new GetgroupCommand();                               }
+               else if(commandName == "get.label")             {   shellcommand = new GetlabelCommand();                               }
+               else if(commandName == "get.sabund")            {   shellcommand = new GetSAbundCommand();                              }
+               else if(commandName == "get.rabund")            {   shellcommand = new GetRAbundCommand();                              }
+               else if(commandName == "libshuff")              {   shellcommand = new LibShuffCommand();                               }
+               else if(commandName == "heatmap.bin")                   {   shellcommand = new HeatMapCommand();                                }
+               else if(commandName == "heatmap.sim")                   {   shellcommand = new HeatMapSimCommand();                             }
+               else if(commandName == "filter.seqs")                   {   shellcommand = new FilterSeqsCommand();                             }
+               else if(commandName == "venn")                                  {   shellcommand = new VennCommand();                                   }
+               else if(commandName == "bin.seqs")                              {   shellcommand = new BinSeqCommand();                                 }
+               else if(commandName == "get.oturep")                    {   shellcommand = new GetOTURepCommand();                              }
+               else if(commandName == "tree.shared")                   {   shellcommand = new TreeGroupCommand();                              }
+               else if(commandName == "dist.shared")                   {   shellcommand = new MatrixOutputCommand();                   }
+               else if(commandName == "bootstrap.shared")              {   shellcommand = new BootSharedCommand();                             }
+               else if(commandName == "consensus")                             {   shellcommand = new ConcensusCommand();                              }
+               else if(commandName == "dist.seqs")                             {   shellcommand = new DistanceCommand();                               }
+               else if(commandName == "align.seqs")                    {   shellcommand = new AlignCommand();                                  }
+               else if(commandName == "summary.seqs")                  {       shellcommand = new SeqSummaryCommand();                         }
+               else if(commandName == "screen.seqs")                   {       shellcommand = new ScreenSeqsCommand();                         }
+               else if(commandName == "reverse.seqs")                  {       shellcommand = new ReverseSeqsCommand();                        }
+               else if(commandName == "trim.seqs")                             {       shellcommand = new TrimSeqsCommand();                           }
+               else if(commandName == "chimera.seqs")                  {       shellcommand = new ChimeraSeqsCommand();                        }
+               else if(commandName == "list.seqs")                             {       shellcommand = new ListSeqsCommand();                           }
+               else if(commandName == "get.seqs")                              {       shellcommand = new GetSeqsCommand();                            }
+               else if(commandName == "remove.seqs")                   {       shellcommand = new RemoveSeqsCommand();                         }
+               else if(commandName == "merge.files")                   {       shellcommand = new MergeFileCommand();                          }
+               else if(commandName == "system")                                {       shellcommand = new SystemCommand();                                     }
+               else if(commandName == "align.check")                   {       shellcommand = new AlignCheckCommand();                         }
+               else if(commandName == "get.sharedseqs")                {       shellcommand = new GetSharedOTUCommand();                       }
+               else if(commandName == "get.otulist")                   {       shellcommand = new GetListCountCommand();                       }
+               else if(commandName == "hcluster")                              {       shellcommand = new HClusterCommand();                           }
+               else if(commandName == "classify.seqs")                 {       shellcommand = new ClassifySeqsCommand();                       }
+               else if(commandName == "chimera.ccode")                 {       shellcommand = new ChimeraCcodeCommand();                       }
+               else if(commandName == "chimera.check")                 {       shellcommand = new ChimeraCheckCommand();                       }
+               else if(commandName == "chimera.slayer")                {       shellcommand = new ChimeraSlayerCommand();                      }
+               else if(commandName == "chimera.pintail")               {       shellcommand = new ChimeraPintailCommand();                     }
+               else if(commandName == "chimera.bellerophon")   {       shellcommand = new ChimeraBellerophonCommand();         }
+               else if(commandName == "phylotype")                             {       shellcommand = new PhylotypeCommand();                          }
+               else if(commandName == "mgcluster")                             {       shellcommand = new MGClusterCommand();                          }
+               else if(commandName == "pre.cluster")                   {       shellcommand = new PreClusterCommand();                         }
+               else if(commandName == "pcoa")                                  {       shellcommand = new PCACommand();                                        }
+               else if(commandName == "otu.hierarchy")                 {       shellcommand = new OtuHierarchyCommand();                       }
+               else if(commandName == "set.dir")                               {       shellcommand = new SetDirectoryCommand();                       }
+               else if(commandName == "set.logfile")                   {       shellcommand = new SetLogFileCommand();                         }
+               else if(commandName == "parse.list")                    {       shellcommand = new ParseListCommand();                          }
+               else if(commandName == "parse.sff")                             {       shellcommand = new ParseSFFCommand();                           }
+               else if(commandName == "phylo.diversity")               {       shellcommand = new PhyloDiversityCommand();                     }
+               else if(commandName == "make.group")                    {       shellcommand = new MakeGroupCommand();                          }
+               else if(commandName == "chop.seqs")                             {       shellcommand = new ChopSeqsCommand();                           }
+               else if(commandName == "clearcut")                              {       shellcommand = new ClearcutCommand();                           }
+               else if(commandName == "catchall")                              {       shellcommand = new CatchAllCommand();                           }
+               else if(commandName == "split.abund")                   {       shellcommand = new SplitAbundCommand();                         }
+               else if(commandName == "cluster.split")                 {       shellcommand = new ClusterSplitCommand();                       }
+               else if(commandName == "classify.otu")                  {       shellcommand = new ClassifyOtuCommand();                        }
+               else if(commandName == "degap.seqs")                    {       shellcommand = new DegapSeqsCommand();                          }
+               else if(commandName == "get.relabund")                  {       shellcommand = new GetRelAbundCommand();                        }
+               else if(commandName == "sens.spec")                             {       shellcommand = new SensSpecCommand();                           }
+               else if(commandName == "seq.error")                             {       shellcommand = new SeqErrorCommand();                           }
+               else if(commandName == "sffinfo")                               {       shellcommand = new SffInfoCommand();                            }
+               else if(commandName == "normalize.shared")              {       shellcommand = new NormalizeSharedCommand();            }
+               else if(commandName == "metastats")                             {       shellcommand = new MetaStatsCommand();                          }
+               else if(commandName == "split.groups")                  {       shellcommand = new SplitGroupCommand();                         }
+               else if(commandName == "cluster.fragments")             {       shellcommand = new ClusterFragmentsCommand();           }
+               else if(commandName == "get.lineage")                   {       shellcommand = new GetLineageCommand();                         }
+               else if(commandName == "remove.lineage")                {       shellcommand = new RemoveLineageCommand();                      }
+               else if(commandName == "fastq.info")                    {       shellcommand = new ParseFastaQCommand();                        }
+               else                                                                                    {       shellcommand = new NoCommand();                                         }
+
+               return shellcommand;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CommandFactory", "getCommand");
+               exit(1);
+       }
+}
+/***********************************************************
 //This function is used to interrupt a command
 Command* CommandFactory::getCommand(){
        try {
@@ -374,7 +591,23 @@ bool CommandFactory::isValidCommand(string command) {
                exit(1);
        }
 }
-
+/***********************************************************************/
+bool CommandFactory::isValidCommand(string command, string noError) {
+       try {   
+       
+               //is the command in the map
+               if ((commands.find(command)) != (commands.end())) {
+                       return true;
+               }else{
+                       return false;
+               }
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CommandFactory", "isValidCommand");
+               exit(1);
+       }
+}
 /***********************************************************************/
 void CommandFactory::printCommands(ostream& out) {
        try {   
index 44e78fd66fa290d9664d773f470249f0600a2836..a6dc5b72e0b403df37dd77b7ee593ca5ff19de73 100644 (file)
@@ -18,11 +18,14 @@ class Command;
 class CommandFactory {\r
 public:\r
        static CommandFactory* getInstance();\r
+       Command* getCommand(string, string, string);\r
        Command* getCommand(string, string);\r
-       Command* getCommand();\r
+       Command* getCommand(string);\r
+       //Command* getCommand();\r
        bool isValidCommand(string);\r
+       bool isValidCommand(string, string);\r
        void printCommands(ostream&);\r
-       void setOutputDirectory(string o)               {       outputDir = o;          }\r
+       void setOutputDirectory(string o)               {       outputDir = o;  m->setOutputDir(o);     }\r
        void setInputDirectory(string i)                {       inputDir = i;           }\r
        void setLogfileName(string n, bool a)   {       logFileName = n;  append = a;           }\r
        string getLogfileName()                                 {       return logFileName;     }\r
@@ -32,6 +35,8 @@ public:
 \r
 private:\r
        Command* command;\r
+       Command* shellcommand;\r
+       Command* pipecommand;\r
        MothurOut* m;\r
        map<string, string> commands;\r
        map<string, string>::iterator it;\r
index a65d56fb86c2a8a91ac2915def73d05c7e53b6d6..a7469902d44cb9f16b4a109f8e0bc7a0182f7f86 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "consensuscommand.h"
 
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getValidParameters(){ 
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getRequiredFiles(){   
+       try {
+               string AlignArray[] =  {"tree","group"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ConcensusCommand::ConcensusCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "ConcensusCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ConcensusCommand::ConcensusCommand(string fileroot)  {
@@ -16,6 +63,11 @@ ConcensusCommand::ConcensusCommand(string fileroot)  {
                globaldata = GlobalData::getInstance();
                abort = false;
                
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
+               
                filename = fileroot;
                
                t = globaldata->gTree;
@@ -67,7 +119,7 @@ int ConcensusCommand::execute(){
                if (m->control_pressed) { return 0; }
                
                //open file for pairing not included in the tree
-               notIncluded = filename + ".cons.pairs";
+               notIncluded = filename + ".cons.pairs"; outputNames.push_back(notIncluded);  outputTypes["nodepairs"].push_back(notIncluded);
                m->openOutputFile(notIncluded, out2);
                
                consensusTree = new Tree();
@@ -150,7 +202,7 @@ int ConcensusCommand::execute(){
                        out2 << '\t' << it2->second << endl;
                }
                
-               outputFile = filename + ".cons.tre";
+               outputFile = filename + ".cons.tre";  outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                m->openOutputFile(outputFile, out);
                
                consensusTree->printForBoot(out);
index 7a7960708c9b5d17d69355caaf8cfd8be089e76d..d5072da082cd020d1836e39c06228fa4689eafbe 100644 (file)
@@ -20,7 +20,12 @@ class ConcensusCommand : public Command {
        
 public:
        ConcensusCommand(string);       
+       ConcensusCommand();
        ~ConcensusCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -43,6 +48,8 @@ private:
        string outputFile, notIncluded, filename;
        ofstream out, out2;
        int numNodes, numLeaves, count;  //count is the next available spot in the tree vector
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
                                                                                
        int getSets();
        int getSubgroupRating(vector<string>);
index b3fa7ddd397e973b7ac3895acfb8c0ebf0505f1f..3129ea0ad368cb8c08a5ca2e9f036c38e4b1a441 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "deconvolutecommand.h"
 
+//**********************************************************************************************************************
+vector<string> DeconvoluteCommand::getValidParameters(){       
+       try {
+               string Array[] =  {"fasta", "name","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DeconvoluteCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+DeconvoluteCommand::DeconvoluteCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DeconvoluteCommand::getRequiredParameters(){    
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DeconvoluteCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DeconvoluteCommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DeconvoluteCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**************************************************************************************/
 DeconvoluteCommand::DeconvoluteCommand(string option)  {       
        try {
@@ -33,6 +81,11 @@ DeconvoluteCommand::DeconvoluteCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["name"] = 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 = "";          }
@@ -115,12 +168,13 @@ int DeconvoluteCommand::execute() {
                fastamap.printCondensedFasta(outFastaFile);
                fastamap.printNamesFile(outNameFile);
                
-               if (m->control_pressed) { remove(outFastaFile.c_str()); remove(outNameFile.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear(); remove(outFastaFile.c_str()); remove(outNameFile.c_str()); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                m->mothurOut(outFastaFile); m->mothurOutEndLine();      
                m->mothurOut(outNameFile); m->mothurOutEndLine();
+               outputNames.push_back(outFastaFile);  outputNames.push_back(outNameFile); outputTypes["fasta"].push_back(outFastaFile);  outputTypes["name"].push_back(outNameFile); 
                m->mothurOutEndLine();
 
 
index 9c8fd22d702f8a8b98ee12d682d6f880e5c1fb0e..88b7a382d4c175a14c243d21e97a7580cba9c32d 100644 (file)
@@ -20,12 +20,19 @@ class DeconvoluteCommand : public Command {
 
 public:
        DeconvoluteCommand(string);
-       ~DeconvoluteCommand() { };
+       DeconvoluteCommand();
+       ~DeconvoluteCommand() {}
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
 private:
        string inFastaName, oldNameMapFName, outputDir;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort;
 };
index e475727cb68dd0a28c27ffb64f699a9e633229f8..290d5dc0996a62783ab3365513f7441b1aafd717 100644 (file)
 #include "degapseqscommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> DegapSeqsCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"fasta", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DegapSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+DegapSeqsCommand::DegapSeqsCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DegapSeqsCommand", "DegapSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DegapSeqsCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DegapSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DegapSeqsCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DegapSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
-
 DegapSeqsCommand::DegapSeqsCommand(string option)  {
        try {
                abort = false;
@@ -35,6 +81,11 @@ DegapSeqsCommand::DegapSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -65,6 +116,17 @@ DegapSeqsCommand::DegapSeqsCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -137,7 +199,7 @@ int DegapSeqsCommand::execute(){
                        m->openOutputFile(degapFile, outFASTA);
                        
                        while(!inFASTA.eof()){
-                               if (m->control_pressed) {  inFASTA.close();  outFASTA.close(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) {        remove(outputNames[j].c_str()); } return 0; }
+                               if (m->control_pressed) {   outputTypes.clear(); inFASTA.close();  outFASTA.close(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) {  remove(outputNames[j].c_str()); } return 0; }
                                 
                                Sequence currSeq(inFASTA);  m->gobble(inFASTA);
                                if (currSeq.getName() != "") {
@@ -148,9 +210,9 @@ int DegapSeqsCommand::execute(){
                        inFASTA.close();
                        outFASTA.close();
                        
-                       outputNames.push_back(degapFile);
+                       outputNames.push_back(degapFile); outputTypes["fasta"].push_back(degapFile);
                        
-                       if (m->control_pressed) {  remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) {    remove(outputNames[j].c_str()); } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) {       remove(outputNames[j].c_str()); } return 0; }
                }
                
                m->mothurOutEndLine();
index 192d6eb7397e143e5ff91389ca37a5be98857a6e..5501d49b6affcdfe7e24fb8b444f837800d08ff5 100644 (file)
 class DegapSeqsCommand : public Command {
 public:
        DegapSeqsCommand(string);
+       DegapSeqsCommand();
        ~DegapSeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -26,7 +31,7 @@ private:
        string fastafile, outputDir;
        vector<string> outputNames;
        vector<string> fastaFileNames;
-       
+       map<string, vector<string> > outputTypes;
 };
 
 #endif
index 60e90500866673aa8e643e024c3c60b840140dce..ce8aeb74dcd8a83b9a48b9923be219eb06edfa97 100644 (file)
 #include "onegapignore.h"
 
 //**********************************************************************************************************************
-
+vector<string> DistanceCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"fasta","oldfasta","column", "output", "calc", "countends", "cutoff", "processors", "outputdir","inputdir","compress"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DistanceCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+DistanceCommand::DistanceCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["phylip"] = tempOutNames;
+               outputTypes["column"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DistanceCommand", "DistanceCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DistanceCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> DistanceCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "DistanceCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 DistanceCommand::DistanceCommand(string option) {
        try {
                abort = false;
@@ -41,6 +88,11 @@ DistanceCommand::DistanceCommand(string option) {
                                if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["phylip"] = tempOutNames;
+                       outputTypes["column"] = 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 = "";          }
@@ -213,11 +265,12 @@ int DistanceCommand::execute(){
                                
                if (output == "lt") { //does the user want lower triangle phylip formatted file 
                        outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip.dist";
-                       remove(outputFile.c_str());
+                       remove(outputFile.c_str()); 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";
+                       outputTypes["column"].push_back(outputFile);
                        
                        //so we don't accidentally overwrite
                        if (outputFile == column) { 
@@ -229,6 +282,7 @@ int DistanceCommand::execute(){
                }else { //assume square
                        outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist";
                        remove(outputFile.c_str());
+                       outputTypes["phylip"].push_back(outputFile);
                }
                
 
@@ -270,11 +324,11 @@ int DistanceCommand::execute(){
                                
                                driverMPI(start, end, outMPI, cutoff); 
                                
-                               if (m->control_pressed) { MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
+                               if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
                        
                                //wait on chidren
                                for(int i = 1; i < processors; i++) { 
-                                       if (m->control_pressed) { MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
                                        
                                        char buf[5];
                                        MPI_Recv(buf, 5, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
@@ -283,7 +337,7 @@ int DistanceCommand::execute(){
                                //do your part
                                driverMPI(start, end, outMPI, cutoff); 
                                
-                               if (m->control_pressed) { MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
+                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
                        
                                char buf[5];
                                strcpy(buf, "done"); 
@@ -303,7 +357,7 @@ int DistanceCommand::execute(){
                                if (output != "square"){ driverMPI(start, end, outputFile, mySize); }
                                else { driverMPI(start, end, outputFile, mySize, output); }
        
-                               if (m->control_pressed) {  delete distCalculator;  return 0; }
+                               if (m->control_pressed) {  outputTypes.clear();  delete distCalculator;  return 0; }
                                
                                int amode=MPI_MODE_APPEND|MPI_MODE_WRONLY|MPI_MODE_CREATE; //
                                MPI_File outMPI;
@@ -322,7 +376,7 @@ int DistanceCommand::execute(){
                                for(int b = 1; b < processors; b++) { 
                                        unsigned long int fileSize;
                                        
-                                       if (m->control_pressed) { MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
+                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);  delete distCalculator;  return 0; }
                                        
                                        MPI_Recv(&fileSize, 1, MPI_LONG, b, tag, MPI_COMM_WORLD, &status); 
                                        
@@ -398,7 +452,7 @@ int DistanceCommand::execute(){
        #endif
        
 #endif
-               if (m->control_pressed) { delete distCalculator; remove(outputFile.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear();  delete distCalculator; remove(outputFile.c_str()); return 0; }
                
                #ifdef USE_MPI
                        MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
@@ -441,7 +495,7 @@ int DistanceCommand::execute(){
                        }
                #endif
                
-               if (m->control_pressed) { delete distCalculator; remove(outputFile.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear();  delete distCalculator; remove(outputFile.c_str()); return 0; }
                
                delete distCalculator;
                
@@ -456,7 +510,8 @@ int DistanceCommand::execute(){
                        m->mothurOut("Compressing..."); m->mothurOutEndLine();
                        m->mothurOut("(Replacing " + outputFile + " with " + outputFile + ".gz)"); m->mothurOutEndLine();
                        system(("gzip -v " + outputFile).c_str());
-               }
+                       outputNames.push_back(outputFile + ".gz");
+               }else { outputNames.push_back(outputFile); }
 
                return 0;
                
index bf463a00d238cd6da3b21213f0d393ee6ff895c9..3b2d345d73fc46244446cd136366869f92a6e6d6 100644 (file)
@@ -21,7 +21,12 @@ class DistanceCommand : public Command {
 
 public:
        DistanceCommand(string);
+       DistanceCommand();
        ~DistanceCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -42,7 +47,8 @@ private:
        vector<linePair*> lines;
        
        bool abort;
-       vector<string>  Estimators; //holds estimators to be used
+       vector<string>  Estimators, outputNames; //holds estimators to be used
+       map<string, vector<string> > outputTypes;
        
        //void m->appendFiles(string, string);
        void createProcesses(string);
index f6824cf8d3e407dce231f3fc18194cb5f7b8bc0e..824a8b87b936c75dbfe21fdaf6a1b9a54c1440b0 100644 (file)
@@ -23,6 +23,7 @@ public:
                int length = 0;
                int start = 0;
                int end = 0;
+               bool overlap = false;
                
                string seqA = A.getAligned();
                string seqB = B.getAligned();
@@ -32,6 +33,7 @@ public:
                        if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
                                start = i;
 //                             cout << "start: " << start << endl;
+                               overlap = true;
                                break;
                        }
                }
@@ -39,6 +41,7 @@ public:
                        if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
                                end = i;
 //                             cout << "end: " << end << endl;
+                               overlap = true;
                                break;
                        }
                }
@@ -55,6 +58,9 @@ public:
                        }
                }
                
+               //non-overlapping sequences
+               if (!overlap) { length = 0; }
+               
                if(length == 0) {       dist = 1.0000;                                                          }
                else                    {       dist = ((double)diff  / (double)length);        }
                
index 95d3f3cfe34397f603aecca3dc62bd65dc38c634..25860e1a7b22bb9f20fca7ff9aa77a884a09827a 100644 (file)
@@ -19,7 +19,9 @@ void FastaMap::readFastaFile(string inFileName) {
                string name, sequence, line;
                sequence = "";
                string temp;
-
+               map<string, string>::iterator itName;
+               
+               
                while(!in.eof()){
                        if (m->control_pressed) { break; }
                        
@@ -30,7 +32,10 @@ void FastaMap::readFastaFile(string inFileName) {
                                if(currSeq.getIsAligned())      {       sequence = currSeq.getAligned();        }
                                else                                            {       sequence = currSeq.getUnaligned();      }
                                
-                               seqmap[name] = sequence;  
+                               itName = seqmap.find(name);
+                               if (itName == seqmap.end()) { seqmap[name] = sequence;  }
+                               else { m->mothurOut("You already have a sequence named " + name + ", sequence names must be unique, please correct."); m->mothurOutEndLine(); }
+                               
                                map<string,group>::iterator it = data.find(sequence);
                                if (it == data.end()) {         //it's unique.
                                        data[sequence].groupname = name;  //group name will be the name of the first duplicate sequence found.
index a12058e4785d00e1c21b84ea453ce82c4f62797d..c463cd294d04dcdc31e1a6891db1659db45dc05e 100644 (file)
 #include "filterseqscommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> FilterSeqsCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta", "trump", "soft", "hard", "vertical", "outputdir","inputdir", "processors"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "FilterSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+FilterSeqsCommand::FilterSeqsCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["filter"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> FilterSeqsCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "FilterSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> FilterSeqsCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "FilterSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**************************************************************************************/
-
 FilterSeqsCommand::FilterSeqsCommand(string option)  {
        try {
                abort = false;
@@ -36,6 +83,11 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["filter"] = 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 = "";          }
@@ -84,6 +136,17 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                                                        fastafileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastafileNames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -188,7 +251,7 @@ int FilterSeqsCommand::execute() {
                
                m->mothurOutEndLine();  m->mothurOutEndLine();
                
-               if (m->control_pressed) { return 0; }
+               if (m->control_pressed) { outputTypes.clear(); return 0; }
                
                #ifdef USE_MPI
                        int pid;
@@ -207,7 +270,7 @@ int FilterSeqsCommand::execute() {
                m->openOutputFile(filterFile, outFilter);
                outFilter << filter << endl;
                outFilter.close();
-               outputNames.push_back(filterFile);
+               outputNames.push_back(filterFile); outputTypes["filter"].push_back(filterFile);
                
                #ifdef USE_MPI
                        }
@@ -226,7 +289,7 @@ int FilterSeqsCommand::execute() {
                        if(filter[i] == '1'){   filteredLength++;       }
                }
                
-               if (m->control_pressed) {  for(int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }  return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); for(int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); }  return 0; }
 
                
                m->mothurOutEndLine();
@@ -373,7 +436,7 @@ int FilterSeqsCommand::filterSequences() {
                                if (m->control_pressed) {  return 1; }
                #endif
 #endif
-                       outputNames.push_back(filteredFasta);
+                       outputNames.push_back(filteredFasta); outputTypes["fasta"].push_back(filteredFasta);
                }
 
                return 0;
index cb02732d1ede7c7a70ec5a518426bca18a0019bf..c670f37919e7da8ce3e3f3ee5d294cd4d23acd94 100644 (file)
@@ -18,7 +18,12 @@ class FilterSeqsCommand : public Command {
 \r
 public:\r
        FilterSeqsCommand(string);\r
+       FilterSeqsCommand();\r
        ~FilterSeqsCommand() {};\r
+       vector<string> getRequiredParameters();\r
+       vector<string> getValidParameters();\r
+       vector<string> getRequiredFiles();\r
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }\r
        int execute();  \r
        void help();\r
        \r
@@ -37,6 +42,7 @@ private:
        int alignmentLength, processors;\r
        vector<int> bufferSizes;\r
        vector<string> outputNames;\r
+       map<string, vector<string> > outputTypes;\r
 \r
        char trump;\r
        bool abort;\r
index cf47661bb6a8084740262d8a6b4b157181a2b0ab..40bfb26c6a21cfd29368720ef91782e8cd638ac6 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "getgroupcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetgroupCommand::GetgroupCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["bootgroup"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetgroupCommand::getRequiredFiles(){    
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetgroupCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetgroupCommand::GetgroupCommand(string option)  {
        try {
@@ -32,6 +79,10 @@ 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 output directory command factory will send this info to us in the output parameter 
                        string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found"){  outputDir = "";         }
                        
@@ -102,13 +153,13 @@ int GetgroupCommand::execute(){
                        in >> inputData;
                }
                
-               if (m->control_pressed) { in.close();  out.close(); remove(outputFile.c_str());   return 0; }
+               if (m->control_pressed) { outputTypes.clear(); in.close();  out.close(); remove(outputFile.c_str());   return 0; }
 
                if (in.eof() != true) { in >> nextLabel; }
                
                //read the rest of the groups info in
                while ((nextLabel == holdLabel) && (in.eof() != true)) {
-                       if (m->control_pressed) { in.close();  out.close(); remove(outputFile.c_str());   return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); in.close();  out.close(); remove(outputFile.c_str());   return 0; }
                        
                        in >> groupN >> num;
                        count++;
@@ -132,7 +183,7 @@ int GetgroupCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFile); m->mothurOutEndLine();        
+               m->mothurOut(outputFile); m->mothurOutEndLine();        outputNames.push_back(outputFile); outputTypes["bootgroup"].push_back(outputFile);
                m->mothurOutEndLine();
                
                return 0;       
index bc805bdc7ef5363b3c300b4bc980f535704ee0f7..fb3e810666320ea2cd1c32d4b14b0c2cac08c995 100644 (file)
 class GetgroupCommand : public Command {
 public:
        GetgroupCommand(string);
+       GetgroupCommand();
        ~GetgroupCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -24,6 +29,8 @@ private:
        GlobalData* globaldata;
        GroupMap* groupMap;
        string outputFile, sharedfile;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        ofstream out;
        ifstream in;
        bool abort;
index 971feb4b33f70f44bcfbabdf6de55caf17bda3cd..fe4387aa118487b5e60e120246b746222f93a5da 100644 (file)
@@ -9,6 +9,41 @@
 
 #include "getlabelcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getRequiredFiles(){    
+       try {
+               string Array[] =  {"list","rabund","sabund", "or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 GetlabelCommand::GetlabelCommand(string option)  {
index 3e18026f327d1836a8f2d623c10ad1c966a21525..00945e1b362e6e19cf705cf77ee16a15e5a3ccf0 100644 (file)
@@ -18,7 +18,12 @@ class GlobalData;
 class GetlabelCommand : public Command {
 public:
        GetlabelCommand(string);
+       GetlabelCommand(){}
        ~GetlabelCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -26,6 +31,8 @@ private:
        GlobalData* globaldata;
        string filename;
        bool abort;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 };
 
 #endif
index 5ace2a1077b4fe6984c470218c2aaee80113a041..a1d44857531ddea86b025ac1b6d0d888f21df702 100644 (file)
 #include "sequence.hpp"
 #include "listvector.hpp"
 
-//**********************************************************************************************************************
 
+//**********************************************************************************************************************
+vector<string> GetLineageCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport", "taxon", "dups", "list","taxonomy","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetLineageCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetLineageCommand::GetLineageCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["taxonomy"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["list"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetLineageCommand", "GetLineageCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetLineageCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"taxonomy"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetLineageCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetLineageCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetLineageCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetLineageCommand::GetLineageCommand(string option)  {
        try {
                abort = false;
@@ -36,6 +88,15 @@ GetLineageCommand::GetLineageCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["taxonomy"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["list"] = 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 = "";         }
                        
@@ -183,7 +244,7 @@ int GetLineageCommand::execute(){
                if (listfile != "")                     {               readList();             }
                
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
+               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str());  } return 0; }
                
                if (outputNames.size() != 0) {
                        m->mothurOutEndLine();
@@ -238,7 +299,7 @@ int GetLineageCommand::readFasta(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
                
                return 0;
 
@@ -310,7 +371,7 @@ int GetLineageCommand::readList(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
                
                return 0;
 
@@ -403,7 +464,7 @@ int GetLineageCommand::readName(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["name"].push_back(outputFileName);
                
                return 0;
                
@@ -451,7 +512,7 @@ int GetLineageCommand::readGroup(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["group"].push_back(outputFileName);
                
                return 0;
 
@@ -504,7 +565,7 @@ int GetLineageCommand::readTax(){
                out.close();
                
                if (names.size() == 0) { m->mothurOut("Your taxonomy file does not contain any sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
                        
                return 0;
 
@@ -595,7 +656,7 @@ int GetLineageCommand::readAlign(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
                
                return 0;
                
index 0d07ac6193f37807a25247df864f762e67369d58..84f773d92c57c124fc1c748131e3cdce4f43fad4 100644 (file)
@@ -17,7 +17,12 @@ class GetLineageCommand : public Command {
        public:
        
                GetLineageCommand(string);
+               GetLineageCommand();
                ~GetLineageCommand(){};
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -26,6 +31,7 @@ class GetLineageCommand : public Command {
                vector<string> outputNames;
                string fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir, taxons;
                bool abort, dups;
+               map<string, vector<string> > outputTypes;
                
                int readFasta();
                int readName();
index 23c0eaf0dd1852e9406fc600ce09ae8e80042431..31b174861c4c577659e478defcb7d0fa1d5e6c7a 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "getlistcountcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"list","label","sort","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetListCountCommand::GetListCountCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["otu"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetListCountCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetListCountCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetListCountCommand::GetListCountCommand(string option)  {
        try {
@@ -36,6 +83,10 @@ GetListCountCommand::GetListCountCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["otu"] = tempOutNames;
+               
                        string ranRead = globaldata->getListFile();
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -152,7 +203,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                        
@@ -173,7 +224,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                                }
                                                                                                        
@@ -216,7 +267,7 @@ int GetListCountCommand::execute(){
                                        delete input;
                                        delete list;
                                        globaldata->gListVector = NULL;  
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        return 0; 
                        }
                        
@@ -248,7 +299,7 @@ void GetListCountCommand::process(ListVector* list) {
                if (outputDir == "") { outputDir += m->hasPath(listfile); }
                string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
                m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName);
+               outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
                
                m->mothurOut(list->getLabel()); m->mothurOutEndLine();
                
index e238cf5fc8086f5ec29e6f419f6be0ec2c711e18..60d28cc6a351011fdc34af98189025af5d26f487 100644 (file)
@@ -21,8 +21,13 @@ class GlobalData;
 class GetListCountCommand : public Command {
        
 public:
-       GetListCountCommand(string);    
+       GetListCountCommand(string);
+       GetListCountCommand();  
        ~GetListCountCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -37,6 +42,7 @@ private:
        string label, listfile, outputDir, sort;
        ofstream out;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        void process(ListVector*);
 };
index 6b2570c9808ab9083a06c4fc41439c6fd99b22e2..1e09dba67dc7f1d9b0b10c5a5dfa79023b04a3a6 100644 (file)
@@ -36,6 +36,54 @@ inline bool compareGroup(repStruct left, repStruct right){
        return (left.group < right.group);      
 }
 //**********************************************************************************************************************
+GetOTURepCommand::GetOTURepCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetOTURepCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"fasta","list","label","name", "group", "sorted", "phylip","column","large","cutoff","precision","groups","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetOTURepCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetOTURepCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"fasta","list"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetOTURepCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetOTURepCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetOTURepCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetOTURepCommand::GetOTURepCommand(string option)  {
        try{
                globaldata = GlobalData::getInstance();
@@ -62,6 +110,11 @@ GetOTURepCommand::GetOTURepCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["name"] = 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 = "";          }
@@ -378,7 +431,7 @@ int GetOTURepCommand::execute(){
                                        
                                        if (m->control_pressed) { 
                                                if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                                delete read; delete input; delete list; globaldata->gListVector = NULL; return 0; 
                                        }
                                        
@@ -397,7 +450,7 @@ int GetOTURepCommand::execute(){
                                        
                                        if (m->control_pressed) { 
                                                if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                                delete read; delete input; delete list; globaldata->gListVector = NULL; return 0; 
                                        }
                                        
@@ -437,7 +490,7 @@ int GetOTURepCommand::execute(){
                        
                        if (m->control_pressed) { 
                                        if (large) {  inRow.close(); remove(distFile.c_str());  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                        delete read; delete input; delete list; globaldata->gListVector = NULL; return 0; 
                        }
                }
@@ -607,7 +660,7 @@ int GetOTURepCommand::process(ListVector* processList) {
                if (Groups.size() == 0) { //you don't want to use groups
                        outputNamesFile  = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
                        m->openOutputFile(outputNamesFile, newNamesOutput);
-                       outputNames.push_back(outputNamesFile);
+                       outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile); 
                        outputNameFiles[outputNamesFile] = processList->getLabel();
                }else{ //you want to use groups
                        ofstream* temp;
@@ -617,7 +670,7 @@ int GetOTURepCommand::process(ListVector* processList) {
                                outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".rep.names";
                                
                                m->openOutputFile(outputNamesFile, *(temp));
-                               outputNames.push_back(outputNamesFile);
+                               outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile);
                                outputNameFiles[outputNamesFile] = processList->getLabel() + "." + Groups[i];
                        }
                }
@@ -705,7 +758,7 @@ int GetOTURepCommand::processNames(string filename, string label) {
                string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + label + ".rep.fasta";
                m->openOutputFile(outputFileName, out);
                vector<repStruct> reps;
-               outputNames.push_back(outputFileName);
+               outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
                
                ofstream out2;
                string tempNameFile = filename + ".temp";
index 8099a3998c1a63de92d9c72b2c5419c08e2f96ff..874e43ce5a8f45178a073b9d8e8e00fa8852deb0 100644 (file)
@@ -39,7 +39,12 @@ class GetOTURepCommand : public Command {
 
 public:
        GetOTURepCommand(string);
+       GetOTURepCommand();
        ~GetOTURepCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
 
@@ -66,6 +71,7 @@ private:
        vector<SeqMap> seqVec;                  // contains maps with sequence index and distance
                                                                        // for all distances related to a certain sequence
        vector<int> rowPositions;
+       map<string, vector<string> > outputTypes;
 
        void readNamesFile();
        int process(ListVector*);
index b7dd7153609ada80c297d5d51cab70d3cae5ebc4..a38aeb30dea60a2fe67984fa05dc83b6fb9130e1 100644 (file)
 #include "getrabundcommand.h"
 
 //**********************************************************************************************************************
-
+vector<string> GetRAbundCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"label","sorted","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRAbundCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetRAbundCommand::GetRAbundCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetRAbundCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRAbundCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetRAbundCommand::getRequiredFiles(){   
+       try {
+               string Array[] =  {"list"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRAbundCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetRAbundCommand::GetRAbundCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
@@ -42,6 +89,10 @@ GetRAbundCommand::GetRAbundCommand(string option)  {
                                outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it       
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["rabund"] = tempOutNames;
+                       
                        //make sure the user has already run the read.otu command
                        if (globaldata->getListFile() == "") { m->mothurOut("You must read a listfile before you can use the get.rabund command."); m->mothurOutEndLine(); abort = true; }
                        
@@ -120,7 +171,7 @@ int GetRAbundCommand::execute(){
                set<string> processedLabels;
                set<string> userLabels = labels;
                
-               if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; globaldata->gListVector = NULL;  return 0; }
+               if (m->control_pressed) {  outputTypes.clear();  out.close(); remove(filename.c_str());  delete list; globaldata->gListVector = NULL;  return 0; }
                
                while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
@@ -129,7 +180,7 @@ int GetRAbundCommand::execute(){
                                        rabund = new RAbundVector();                            
                                        *rabund = (list->getRAbundVector());
                                        
-                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+                                       if (m->control_pressed) {   outputTypes.clear(); out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
 
                                        
                                        if(sorted)      {   rabund->print(out);                         }
@@ -151,7 +202,7 @@ int GetRAbundCommand::execute(){
                                        rabund = new RAbundVector();
                                        *rabund = (list->getRAbundVector());
                                        
-                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+                                       if (m->control_pressed) {   outputTypes.clear(); out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
                                        
                                        if(sorted)      {   rabund->print(out);                         }
                                        else            {       rabund->nonSortedPrint(out);    }
@@ -193,7 +244,7 @@ int GetRAbundCommand::execute(){
                        rabund = new RAbundVector();
                        *rabund = (list->getRAbundVector());
                        
-                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete list; delete rabund; globaldata->gListVector = NULL;  return 0; }
                        
                        if(sorted)      {   rabund->print(out);                         }
                        else            {       rabund->nonSortedPrint(out);    }
@@ -204,7 +255,7 @@ int GetRAbundCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(filename); m->mothurOutEndLine();  
+               m->mothurOut(filename); m->mothurOutEndLine();  outputNames.push_back(filename); outputTypes["rabund"].push_back(filename);
                m->mothurOutEndLine();
                
                out.close(); 
index ed51be12ca9e9c0a41b9c03a5089cd9fce7b3893..e853ac5f913a1d758e7a633510478ad30449feec 100644 (file)
@@ -21,7 +21,12 @@ class GlobalData;
 class GetRAbundCommand : public Command {
 public:
        GetRAbundCommand(string);
+       GetRAbundCommand();
        ~GetRAbundCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -33,6 +38,8 @@ private:
        InputData* input;
        ListVector* list;
        RAbundVector* rabund;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort, allLines, sorted;
        set<string> labels; //holds labels to be used
index 4c79b21ab53e903fec94fa17296a7da30a9569bf..5b9327b57bd928a5e456a7251a83be1a0664cd6c 100644 (file)
 #include "getrelabundcommand.h"
 
 //**********************************************************************************************************************
-
+vector<string> GetRelAbundCommand::getValidParameters(){       
+       try {
+               string Array[] =  {"groups","label","scale","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRelAbundCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetRelAbundCommand::GetRelAbundCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["relabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRelAbundCommand", "GetRelAbundCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetRelAbundCommand::getRequiredParameters(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRelAbundCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetRelAbundCommand::getRequiredFiles(){ 
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetRelAbundCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetRelAbundCommand::GetRelAbundCommand(string option) {
        try {
                globaldata = GlobalData::getInstance();
@@ -36,6 +82,10 @@ GetRelAbundCommand::GetRelAbundCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["relabund"] = 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 = ""; 
@@ -136,7 +186,7 @@ int GetRelAbundCommand::execute(){
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) {  outputTypes.clear();  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
        
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
@@ -167,13 +217,13 @@ int GetRelAbundCommand::execute(){
                        //prevent memory leak
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
                        
-                       if (m->control_pressed) {  globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) {  outputTypes.clear();  globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
 
                        //get next line to process
                        lookup = input->getSharedRAbundVectors();                               
                }
                
-               if (m->control_pressed) { globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str());  return 0; }
+               if (m->control_pressed) { outputTypes.clear(); globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str());  return 0; }
 
                //output error messages about any remaining user labels
                set<string>::iterator it;
@@ -206,11 +256,11 @@ int GetRelAbundCommand::execute(){
                delete read;
                out.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0;}
+               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0;}
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();
+               m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["relabund"].push_back(outputFileName);
                m->mothurOutEndLine();
                
                return 0;
index 9725a31ab546f0829ec4ca0bf370e6792fdfeadf..3a5f6ad094a16bf2e43c4521c2f1d35436352e60 100644 (file)
@@ -21,7 +21,12 @@ class GetRelAbundCommand : public Command {
 
 public:
        GetRelAbundCommand(string);
+       GetRelAbundCommand();
        ~GetRelAbundCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -34,7 +39,8 @@ private:
        bool abort, allLines, pickedGroups;
        set<string> labels; //holds labels to be used
        string groups, label, outputDir, scale;
-       vector<string> Groups;
+       vector<string> Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        
        int getRelAbundance(vector<SharedRAbundVector*>&, ofstream&);
        int eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup);
index ba05ea1e11d3e5e603ec84babe81ee172c68a440..8ad8b4b710f0c2bba003d12f355be1dff3d5f636 100644 (file)
 #include "getsabundcommand.h"
 
 //**********************************************************************************************************************
-
+vector<string> GetSAbundCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"label","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSAbundCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetSAbundCommand::GetSAbundCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSAbundCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSAbundCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSAbundCommand::getRequiredFiles(){   
+       try {
+               string Array[] =  {"list","rabund"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSAbundCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetSAbundCommand::GetSAbundCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
@@ -36,6 +82,10 @@ GetSAbundCommand::GetSAbundCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sabund"] = tempOutNames;
+               
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
                        string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found"){  
                                outputDir = ""; 
@@ -115,7 +165,7 @@ int GetSAbundCommand::execute(){
                set<string> processedLabels;
                set<string> userLabels = labels;
                
-               if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
 
                
                while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
@@ -127,7 +177,7 @@ int GetSAbundCommand::execute(){
                                        sabund->print(out);
                                        delete sabund;
                                        
-                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
+                                       if (m->control_pressed) { outputTypes.clear();  out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
 
                                        processedLabels.insert(order->getLabel());
                                        userLabels.erase(order->getLabel());
@@ -145,7 +195,7 @@ int GetSAbundCommand::execute(){
                                        sabund->print(out);
                                        delete sabund;
                                        
-                                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
+                                       if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
 
                                        processedLabels.insert(order->getLabel());
                                        userLabels.erase(order->getLabel());
@@ -185,7 +235,7 @@ int GetSAbundCommand::execute(){
                        sabund->print(out);
                        delete sabund;
                        
-                       if (m->control_pressed) {  out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete order; globaldata->gorder = NULL;  return 0; }
                        
                        delete order;
                }
@@ -195,7 +245,7 @@ int GetSAbundCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(filename); m->mothurOutEndLine();  
+               m->mothurOut(filename); m->mothurOutEndLine();  outputNames.push_back(filename); outputTypes["sabund"].push_back(filename);
                m->mothurOutEndLine();
                
                return 0;               
index e2ea5d292fdf7bbd4e9a1d1fb58ab62a80549c6c..b5363e1bce548af4af74408593d855cac4da973c 100644 (file)
@@ -21,7 +21,12 @@ class GlobalData;
 class GetSAbundCommand : public Command {
 public:
        GetSAbundCommand(string);
+       GetSAbundCommand();
        ~GetSAbundCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -33,6 +38,8 @@ private:
        OrderVector* order;
        InputData* input;
        SAbundVector* sabund;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used
index 1926ae0b017abc926c2256e2c3b0396de1dbae40..34788b8897cca88fa06ba46a5b37f88b70df70c0 100644 (file)
 #include "listvector.hpp"
 
 //**********************************************************************************************************************
-
+vector<string> GetSeqsCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport", "accnos", "dups", "list","taxonomy","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetSeqsCommand::GetSeqsCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["taxonomy"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["list"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSeqsCommand", "GetSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSeqsCommand::getRequiredParameters(){        
+       try {
+               string Array[] =  {"accnos"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSeqsCommand::getRequiredFiles(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetSeqsCommand::GetSeqsCommand(string option)  {
        try {
                abort = false;
@@ -36,6 +87,15 @@ GetSeqsCommand::GetSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["taxonomy"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["list"] = 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 = "";         }
                        
@@ -185,7 +245,7 @@ int GetSeqsCommand::execute(){
                if (listfile != "")                     {               readList();             }
                if (taxfile != "")                      {               readTax();              }
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
+               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str());  } return 0; }
                
                if (outputNames.size() != 0) {
                        m->mothurOutEndLine();
@@ -240,7 +300,7 @@ int GetSeqsCommand::readFasta(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName); 
                
                return 0;
 
@@ -312,7 +372,7 @@ int GetSeqsCommand::readList(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
                
                return 0;
 
@@ -405,7 +465,7 @@ int GetSeqsCommand::readName(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
                
                return 0;
                
@@ -453,7 +513,7 @@ int GetSeqsCommand::readGroup(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["group"].push_back(outputFileName);
                
                return 0;
 
@@ -498,7 +558,7 @@ int GetSeqsCommand::readTax(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["taxonomy"].push_back(outputFileName);
                        
                return 0;
 
@@ -566,7 +626,7 @@ int GetSeqsCommand::readAlign(){
                out.close();
                
                if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputNames.push_back(outputFileName);  outputTypes["alignreport"].push_back(outputFileName);
                
                return 0;
                
index 4f4c809e51e7f9308ae4f372bdd2195eb964f6c3..ea93b5a1c4e0427cc43157a5d77f995bb3f2308b 100644 (file)
@@ -17,7 +17,12 @@ class GetSeqsCommand : public Command {
        public:
        
                GetSeqsCommand(string);
+               GetSeqsCommand();
                ~GetSeqsCommand(){};
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -26,6 +31,7 @@ class GetSeqsCommand : public Command {
                vector<string> outputNames;
                string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir;
                bool abort, dups;
+               map<string, vector<string> > outputTypes;
                
                int readFasta();
                int readName();
index 492195d702286af6cc82d919311aae7a59260596..f8c245f95f8e159b61db3acda6cfa42dee9417d3 100644 (file)
@@ -9,8 +9,57 @@
 
 #include "getsharedotucommand.h"
 
-//**********************************************************************************************************************
 
+//**********************************************************************************************************************
+vector<string> GetSharedOTUCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"label","unique","shared","fasta","list","group","output","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSharedOTUCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+GetSharedOTUCommand::GetSharedOTUCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+               outputTypes["sharedseqs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSharedOTUCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSharedOTUCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetSharedOTUCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetSharedOTUCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 GetSharedOTUCommand::GetSharedOTUCommand(string option)  {
        try {
        
@@ -39,6 +88,12 @@ GetSharedOTUCommand::GetSharedOTUCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+                       outputTypes["sharedseqs"] = 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 = "";         }
                        
@@ -191,7 +246,7 @@ int GetSharedOTUCommand::execute(){
                        m->openInputFile(fastafile, inFasta);
                        
                        while(!inFasta.eof()) {
-                               if (m->control_pressed) { inFasta.close(); delete groupMap; return 0; }
+                               if (m->control_pressed) { outputTypes.clear(); inFasta.close(); delete groupMap; return 0; }
                                
                                Sequence seq(inFasta); m->gobble(inFasta);
                                if (seq.getName() != "") {  seqs.push_back(seq);   }
@@ -214,7 +269,7 @@ int GetSharedOTUCommand::execute(){
                        
                        if (m->control_pressed) { 
                                if (lastlist != NULL) {         delete lastlist;        }
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }  
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }  outputTypes.clear();
                                delete groupMap; return 0;
                        }
                        
@@ -277,7 +332,7 @@ int GetSharedOTUCommand::execute(){
                
                if (lastlist != NULL) {         delete lastlist;        }
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); }  delete groupMap; return 0; } 
+               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str()); }  delete groupMap; return 0; } 
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -406,6 +461,8 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                }else { 
                        m->mothurOut("\t" + toString(num)); m->mothurOutEndLine(); 
                        outputNames.push_back(outputFileNames);
+                       if (output != "accnos") { outputTypes["sharedseqs"].push_back(outputFileNames); }
+                       else { outputTypes["accnos"].push_back(outputFileNames); }
                }
                
                //if fasta file provided output new fasta file
@@ -414,7 +471,7 @@ int GetSharedOTUCommand::process(ListVector* shared) {
                        string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta";
                        ofstream outFasta;
                        m->openOutputFile(outputFileFasta, outFasta);
-                       outputNames.push_back(outputFileFasta);
+                       outputNames.push_back(outputFileFasta); outputTypes["fasta"].push_back(outputFileFasta);
                        
                        for (int k = 0; k < seqs.size(); k++) {
                                if (m->control_pressed) { outFasta.close(); return 0; }
index 30a5cd2468ab7ec8bb741729f4cb390e8a8f7c1d..0e25721b6ca2bcd53967261e7fab18bb0dbead54 100644 (file)
@@ -22,7 +22,12 @@ class GetSharedOTUCommand : public Command {
        public:
        
                GetSharedOTUCommand(string);    
+               GetSharedOTUCommand();  
                ~GetSharedOTUCommand();
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -40,6 +45,7 @@ class GetSharedOTUCommand : public Command {
                map<string, string>::iterator it;
                vector<Sequence> seqs;
                vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                
                int process(ListVector*);
                
index fd95323e745bd0ce499368c5ea4cb7bd0ce21bf8..e236d86cf2934a349500bbd2aacf2737d3f351b7 100644 (file)
@@ -9,6 +9,55 @@
 
 #include "hclustercommand.h"
 
+//**********************************************************************************************************************
+vector<string> HClusterCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"cutoff","hard","precision","method","phylip","column","name","sorted","showabund","timing","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HClusterCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+HClusterCommand::HClusterCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HClusterCommand", "HClusterCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HClusterCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"phylip","column","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HClusterCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HClusterCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HClusterCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
 HClusterCommand::HClusterCommand(string option)  {
@@ -37,6 +86,12 @@ HClusterCommand::HClusterCommand(string option)  {
                                }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["rabund"] = tempOutNames;
+                       outputTypes["sabund"] = tempOutNames;
+               
                        globaldata->newRead();
                        
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
@@ -142,9 +197,9 @@ HClusterCommand::HClusterCommand(string option)  {
                                m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
                                m->openOutputFile(fileroot+ tag + ".list",              listFile);
                                
-                               outputNames.push_back(fileroot+ tag + ".sabund");
-                               outputNames.push_back(fileroot+ tag + ".rabund");
-                               outputNames.push_back(fileroot+ tag + ".list");
+                               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");
                        }
                }
        }
@@ -201,7 +256,7 @@ int HClusterCommand::execute(){
                                sabundFile.close();
                                rabundFile.close();
                                listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                return 0;  
                        }
                        
@@ -217,7 +272,7 @@ int HClusterCommand::execute(){
                        sabundFile.close();
                        rabundFile.close();
                        listFile.close();
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                        return 0;  
                }
 
@@ -247,7 +302,7 @@ int HClusterCommand::execute(){
                                sabundFile.close();
                                rabundFile.close();
                                listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                return 0;  
                }
 
@@ -261,7 +316,7 @@ int HClusterCommand::execute(){
                                sabundFile.close();
                                rabundFile.close();
                                listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                return 0;  
                        }
 
@@ -275,7 +330,7 @@ int HClusterCommand::execute(){
                                                sabundFile.close();
                                                rabundFile.close();
                                                listFile.close();
-                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                                                return 0;  
                                        }
 
@@ -308,7 +363,7 @@ int HClusterCommand::execute(){
                        sabundFile.close();
                        rabundFile.close();
                        listFile.close();
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                        return 0;  
                }
                                        
@@ -336,7 +391,7 @@ int HClusterCommand::execute(){
                delete cluster;
                
                if (m->control_pressed) {  
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } outputTypes.clear();
                        return 0;  
                }
 
index 1aae49d9b341a6ce2652ed4bd3e340bf2a0a9040..fc0333174a87b111a0cda756dc24ff4669202cc9 100644 (file)
 class HClusterCommand : public Command {
        
 public:
-       HClusterCommand(string);        
+       HClusterCommand(string);
+       HClusterCommand();      
        ~HClusterCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -54,6 +59,7 @@ private:
        time_t start;
        unsigned long loops;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        void printData(string label);
 };
index bb82702e9089b04f73571be314956567fb88f40e..dc4fec28a2c6edeb799dac61a90c5ecbff247a51 100644 (file)
@@ -9,7 +9,53 @@
 
 #include "heatmapcommand.h"
 
-
+//**********************************************************************************************************************
+vector<string> HeatMapCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"groups","label","sorted","scale","fontsize","numotu","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+HeatMapCommand::HeatMapCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["svg"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapCommand::getRequiredFiles(){     
+       try {
+               string Array[] =  {"list","sabund","rabund","shared","relabund","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 HeatMapCommand::HeatMapCommand(string option) {
@@ -37,6 +83,10 @@ HeatMapCommand::HeatMapCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["svg"] = 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 = ""; 
@@ -168,7 +218,7 @@ int HeatMapCommand::execute(){
                        while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                if (m->control_pressed) {
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                        globaldata->Groups.clear(); 
                                        delete read; delete heatmap; return 0;
                                }
@@ -176,7 +226,8 @@ int HeatMapCommand::execute(){
                                if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
        
                                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       outputNames.push_back(heatmap->getPic(lookup));
+                                       string outputFileName = heatmap->getPic(lookup);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
@@ -190,7 +241,8 @@ int HeatMapCommand::execute(){
                                        lookup = input->getSharedRAbundVectors(lastLabel);
                                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                        
-                                       outputNames.push_back(heatmap->getPic(lookup));
+                                       string outputFileName = heatmap->getPic(lookup);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(lookup[0]->getLabel());
                                        userLabels.erase(lookup[0]->getLabel());
@@ -209,7 +261,7 @@ int HeatMapCommand::execute(){
                        
                        
                        if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                globaldata->Groups.clear(); 
                                delete read; delete heatmap; return 0;
                        }
@@ -233,7 +285,8 @@ int HeatMapCommand::execute(){
                                lookup = input->getSharedRAbundVectors(lastLabel);
                                
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               outputNames.push_back(heatmap->getPic(lookup));
+                               string outputFileName = heatmap->getPic(lookup);
+                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
                        }
                
@@ -244,14 +297,15 @@ int HeatMapCommand::execute(){
        
                        while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                if (m->control_pressed) {   
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                        delete rabund;  delete read; delete heatmap; return 0;  
                                }
 
                                if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
        
                                        m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       outputNames.push_back(heatmap->getPic(rabund));
+                                       string outputFileName = heatmap->getPic(rabund);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(rabund->getLabel());
                                        userLabels.erase(rabund->getLabel());
@@ -264,7 +318,8 @@ int HeatMapCommand::execute(){
                                        rabund = input->getRAbundVector(lastLabel);
                                        m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
                                        
-                                       outputNames.push_back(heatmap->getPic(rabund));
+                                       string outputFileName = heatmap->getPic(rabund);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(rabund->getLabel());
                                        userLabels.erase(rabund->getLabel());
@@ -281,7 +336,7 @@ int HeatMapCommand::execute(){
                        }
                        
                        if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                delete read; delete heatmap; return 0;
                        }
 
@@ -305,7 +360,8 @@ int HeatMapCommand::execute(){
                                rabund = input->getRAbundVector(lastLabel);
                                m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
                                        
-                               outputNames.push_back(heatmap->getPic(rabund));
+                               string outputFileName = heatmap->getPic(rabund);
+                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                delete rabund; globaldata->rabund = NULL;
                        }
                
@@ -315,7 +371,7 @@ int HeatMapCommand::execute(){
                        while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                if (m->control_pressed) {
                                        for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                        globaldata->Groups.clear(); 
                                        delete read; delete heatmap; return 0;
                                }
@@ -323,7 +379,8 @@ int HeatMapCommand::execute(){
                                if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){                     
        
                                        m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                                       outputNames.push_back(heatmap->getPic(lookupFloat));
+                                       string outputFileName = heatmap->getPic(lookupFloat);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(lookupFloat[0]->getLabel());
                                        userLabels.erase(lookupFloat[0]->getLabel());
@@ -336,7 +393,8 @@ int HeatMapCommand::execute(){
                                        lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
                                        m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
                                        
-                                       outputNames.push_back(heatmap->getPic(lookupFloat));
+                                       string outputFileName = heatmap->getPic(lookupFloat);
+                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                        
                                        processedLabels.insert(lookupFloat[0]->getLabel());
                                        userLabels.erase(lookupFloat[0]->getLabel());
@@ -355,7 +413,7 @@ int HeatMapCommand::execute(){
                        
                        
                        if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                                globaldata->Groups.clear(); 
                                delete read; delete heatmap; return 0;
                        }
@@ -379,7 +437,8 @@ int HeatMapCommand::execute(){
                                lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
                                
                                m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                               outputNames.push_back(heatmap->getPic(lookupFloat));
+                               string outputFileName = heatmap->getPic(lookupFloat);
+                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
                                for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
                        }
                
@@ -392,7 +451,7 @@ int HeatMapCommand::execute(){
                delete input; globaldata->ginput = NULL;
                
                if (m->control_pressed) {
-                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } }
+                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  remove(outputNames[i].c_str());  } } outputTypes.clear();
                        delete read; delete heatmap; return 0;
                }
                
index f3ae012fb7e5c161fc222e487d9d272acd8d0ff8..a85d510074c55a73adc25b07f16a8a81bdd4a30c 100644 (file)
@@ -24,7 +24,12 @@ class HeatMapCommand : public Command {
 
 public:
        HeatMapCommand(string);
+       HeatMapCommand();
        ~HeatMapCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -42,6 +47,7 @@ private:
        set<string> labels; //holds labels to be used
        string format, groups, sorted, scale, label, outputDir;
        vector<string> Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        int numOTU, fontSize;
 
 
index 7e77980659681cd6aa4bbafbc6d502e4e0064bc7..1eb3ceedb228220f8e8d86231866c1606a50b196 100644 (file)
 #include "sharedmorisitahorn.h"
 #include "sharedbraycurtis.h"
 
-
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"groups","label", "calc","phylip","column","name","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+HeatMapSimCommand::HeatMapSimCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["svg"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getRequiredParameters(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HeatMapSimCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HeatMapSimCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 HeatMapSimCommand::HeatMapSimCommand(string option)  {
@@ -50,6 +95,10 @@ HeatMapSimCommand::HeatMapSimCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["svg"] = tempOutNames;
+                       
                        format = "";
                        //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 = "";         }
@@ -240,7 +289,7 @@ int HeatMapSimCommand::execute(){
                delete heatmap;
                delete validCalculator;
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } outputTypes.clear(); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -286,7 +335,7 @@ int HeatMapSimCommand::runCommandShared() {
        
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }
                                        
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
@@ -300,7 +349,7 @@ int HeatMapSimCommand::runCommandShared() {
 
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
                                        
                                processedLabels.insert(lookup[0]->getLabel());
                                userLabels.erase(lookup[0]->getLabel());
@@ -344,7 +393,7 @@ int HeatMapSimCommand::runCommandShared() {
 
                        m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
                        vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                       for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); }
+                       for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
                        
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
@@ -482,8 +531,10 @@ int HeatMapSimCommand::runCommandDist() {
                        delete nameMap;
                }
                
-
-               outputNames.push_back(heatmap->getPic(matrix, names)); //vector<vector<double>>, vector<string>
+               
+               string outputFileName = heatmap->getPic(matrix, names);
+               outputNames.push_back(outputFileName); //vector<vector<double>>, vector<string>
+               outputTypes["svg"].push_back(outputFileName);
                
                return 0;
        }
index a26018062f28c4406dd83a518f67ee78b388d227..cd12c176f44994e4ea1da4128737dabe2931b6ac 100644 (file)
@@ -22,7 +22,12 @@ class HeatMapSimCommand : public Command {
 
 public:
        HeatMapSimCommand(string);
+       HeatMapSimCommand();
        ~HeatMapSimCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -41,6 +46,7 @@ private:
        set<string> labels; //holds labels to be used
        string format, groups, label, calc, phylipfile, columnfile, namefile, outputDir;
        vector<string> Estimators, Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        
        int runCommandShared();
        int runCommandDist();
index 36ce2b760e266a790bba56e9b4d5adf5f5b493a5..24d587b60ab7115b06379a98e9076ad3c6999c0f 100644 (file)
@@ -9,6 +9,40 @@
 
 #include "helpcommand.h"
 
+//**********************************************************************************************************************
+vector<string> HelpCommand::getValidParameters(){      
+       try {
+               
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HelpCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HelpCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HelpCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> HelpCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "HelpCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 HelpCommand::HelpCommand(string option)  {
index 7a19ee66f1f747295e7b299c281f85e121edc26e..d4e7b1fda16a88f8e88a30a46ba70e50fe1ce290 100644 (file)
@@ -18,12 +18,19 @@ class HelpCommand : public Command {
        
 public:
        HelpCommand(string);
+       HelpCommand() {}
        ~HelpCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help() {};
        
 private:
        CommandFactory* validCommands;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        
 private:
index e81ab92e2aaaced862fad7ae0e2f14cdf1d9f386..d4e5ee507219bcfd943b371b0f19b86aea132da5 100644 (file)
@@ -24,6 +24,7 @@ public:
                int diff = 0;
                int length = 0;
                int start = 0;
+               bool overlap = false;
                
                string seqA = A.getAligned();
                string seqB = B.getAligned();
@@ -32,6 +33,7 @@ public:
                for(int i=0;i<alignLength;i++){
                        if(seqA[i] != '.' && seqB[i] != '.'){
                                start = i;
+                               overlap = true;
                                break;
                        }
                }
@@ -47,6 +49,9 @@ public:
                                length++;
                        }
                }
+               
+               //non-overlapping sequences
+               if (!overlap) { length = 0; }
 
                if(length == 0)         {       dist = 1.0000;                                                          }
                else                            {       dist = ((double)diff  / (double)length);        }
index 773d8d351211f3ab9794770e72aad77235754b53..e48cf33d7dd4a60405841e124a35c5250f76bd86 100644 (file)
 #include "slibshuff.h"
 #include "dlibshuff.h"
 
+//**********************************************************************************************************************
+vector<string> LibShuffCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"iters","groups","step","form","cutoff","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LibShuffCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+LibShuffCommand::LibShuffCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["coverage"] = tempOutNames;
+               outputTypes["libshuffsummary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LibShuffCommand", "LibShuffCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> LibShuffCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LibShuffCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> LibShuffCommand::getRequiredFiles(){    
+       try {
+               string Array[] =  {"phylip","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "LibShuffCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 LibShuffCommand::LibShuffCommand(string option)  {
@@ -44,6 +92,11 @@ LibShuffCommand::LibShuffCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["coverage"] = tempOutNames;
+                       outputTypes["libshuffsummary"] = 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 = ""; 
@@ -147,14 +200,14 @@ int LibShuffCommand::execute(){
                        pValueCounts[i].assign(numGroups, 0);
                }
        
-               if (m->control_pressed) {  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; return 0; }
                                
                Progress* reading = new Progress();
                
                for(int i=0;i<numGroups-1;i++) {
                        for(int j=i+1;j<numGroups;j++) {
                                
-                               if (m->control_pressed) {  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
+                               if (m->control_pressed) {  outputTypes.clear();  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
 
                                reading->newLine(groupNames[i]+'-'+groupNames[j], iters);
                                int spoti = globaldata->gGroupmap->groupIndex[groupNames[i]]; //neccessary in case user selects groups so you know where they are in the matrix
@@ -162,13 +215,13 @@ int LibShuffCommand::execute(){
        
                                for(int p=0;p<iters;p++) {      
                                        
-                                       if (m->control_pressed) {  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
+                                       if (m->control_pressed) {  outputTypes.clear(); delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
                                        
                                        form->randomizeGroups(spoti,spotj); 
                                        if(form->evaluatePair(spoti,spotj) >= savedDXYValues[spoti][spotj])     {       pValueCounts[i][j]++;   }
                                        if(form->evaluatePair(spotj,spoti) >= savedDXYValues[spotj][spoti])     {       pValueCounts[j][i]++;   }
                                        
-                                       if (m->control_pressed) {  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
+                                       if (m->control_pressed) {  outputTypes.clear(); delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
                                        
                                        reading->update(p);                     
                                }
@@ -177,7 +230,7 @@ int LibShuffCommand::execute(){
                        }
                }
                
-               if (m->control_pressed) {  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
+               if (m->control_pressed) { outputTypes.clear();  delete form; globaldata->Groups.clear(); delete globaldata->gMatrix;  globaldata->gMatrix = NULL; delete reading; return 0; }
        
                reading->finish();
                delete reading;
@@ -193,7 +246,7 @@ int LibShuffCommand::execute(){
                //delete globaldata's copy of the gmatrix to free up memory
                delete globaldata->gMatrix;  globaldata->gMatrix = NULL;
                
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } return 0; }
 
                
                m->mothurOutEndLine();
@@ -217,7 +270,7 @@ int LibShuffCommand::printCoverageFile() {
                ofstream outCov;
                summaryFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getPhylipFile())) + "libshuff.coverage";
                m->openOutputFile(summaryFile, outCov);
-               outputNames.push_back(summaryFile);
+               outputNames.push_back(summaryFile); outputTypes["coverage"].push_back(summaryFile);
                outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
                //cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
                
@@ -313,7 +366,7 @@ int LibShuffCommand::printSummaryFile() {
                ofstream outSum;
                summaryFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getPhylipFile())) + "libshuff.summary";
                m->openOutputFile(summaryFile, outSum);
-               outputNames.push_back(summaryFile);
+               outputNames.push_back(summaryFile); outputTypes["libshuffsummary"].push_back(summaryFile);
 
                outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
                cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
index 1c8fbc4da656bf5c4240c1be8cb4a7843b3ac72c..3240860fc329bed3b9551359a6ff1b23a16b8019 100644 (file)
@@ -20,8 +20,13 @@ class GlobalData;
 class LibShuffCommand : public Command {
        
 public:
-       LibShuffCommand(string);        
+       LibShuffCommand(string);
+       LibShuffCommand();      
        ~LibShuffCommand(){};
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
 
@@ -45,6 +50,7 @@ private:
        bool abort;
        string outputFile, groups, userform, savegroups, outputDir;
        vector<string> Groups, outputNames; //holds groups to be used
+       map<string, vector<string> > outputTypes;
 };
 
 #endif
index d85d5be2909aa153d8e4331a80ff6d91fc6ea9c2..c8c82971a1cf53d0eb2ba4834c281cc310d8984b 100644 (file)
 #include "sequence.hpp"
 #include "listvector.hpp"
 
+//**********************************************************************************************************************
+vector<string> ListSeqsCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport","list","taxonomy","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ListSeqsCommand::ListSeqsCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListSeqsCommand", "ListSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ListSeqsCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport","list","taxonomy","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ListSeqsCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ListSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ListSeqsCommand::ListSeqsCommand(string option)  {
@@ -36,6 +83,10 @@ ListSeqsCommand::ListSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["accnos"] = 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 = "";         }
                        
@@ -164,7 +215,7 @@ int ListSeqsCommand::execute(){
                else if (listfile != "")        {       inputFileName = listfile;       readList();             }
                else if (taxfile != "")         {       inputFileName = taxfile;        readTax();              }
                
-               if (m->control_pressed) { return 0; }
+               if (m->control_pressed) { outputTypes.clear();  return 0; }
                
                //sort in alphabetical order
                sort(names.begin(), names.end());
@@ -179,17 +230,17 @@ int ListSeqsCommand::execute(){
                //output to .accnos file
                for (int i = 0; i < names.size(); i++) {
                        
-                       if (m->control_pressed) { out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); out.close(); remove(outputFileName.c_str()); return 0; }
                        
                        out << names[i] << endl;
                }
                out.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear();  remove(outputFileName.c_str()); return 0; }
 
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
                m->mothurOutEndLine();
                
                return 0;               
index 6a210a180e5bc9453005c7aefb8613fa45d52c03..889b3733df47f346be5a3fd9dd327a0660913c61 100644 (file)
@@ -16,13 +16,19 @@ class ListSeqsCommand : public Command {
        
        public:
        
-               ListSeqsCommand(string);        
-               ~ListSeqsCommand(){};
+               ListSeqsCommand(string);
+               ListSeqsCommand();      
+               ~ListSeqsCommand(){}
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
        private:
-               vector<string> names;
+               vector<string> names, outputNames;
+               map<string, vector<string> > outputTypes;
                string fastafile, namefile, groupfile, alignfile, inputFileName, outputDir, listfile, taxfile;
                bool abort;
                
index 8dd1d67b294517437648f314321324ca8f1baf11..fd68b8022c610557402d03a1ab970901939c9126 100644 (file)
 #include "makegroupcommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> MakeGroupCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"fasta", "groups","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MakeGroupCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+MakeGroupCommand::MakeGroupCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["group"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MakeGroupCommand", "MakeGroupCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MakeGroupCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"fasta","groups"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MakeGroupCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MakeGroupCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MakeGroupCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 MakeGroupCommand::MakeGroupCommand(string option)  {
@@ -36,7 +83,11 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                        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["group"] = 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 = "";          }
@@ -68,6 +119,16 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                                        fastaFileNames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
+                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       fastaFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -140,7 +201,7 @@ int MakeGroupCommand::execute(){
                
                for (int i = 0; i < fastaFileNames.size(); i++) {
                
-                       if (m->control_pressed) {  out.close(); remove(filename.c_str()); return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); return 0; }
                        
                        ifstream in;
                        m->openInputFile(fastaFileNames[i], in);
@@ -149,7 +210,7 @@ int MakeGroupCommand::execute(){
                                
                                Sequence seq(in, "no align"); m->gobble(in);
                                
-                               if (m->control_pressed) {  in.close(); out.close(); remove(filename.c_str()); return 0; }
+                               if (m->control_pressed) { outputTypes.clear();  in.close(); out.close(); remove(filename.c_str()); return 0; }
                                
                                if (seq.getName() != "") {      out << seq.getName() << '\t' << groupsNames[i] << endl;         }
                        }
@@ -159,7 +220,7 @@ int MakeGroupCommand::execute(){
                out.close();
                
                m->mothurOutEndLine();
-               m->mothurOut("Output File Name: " + filename); m->mothurOutEndLine();
+               m->mothurOut("Output File Name: " + filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["group"].push_back(filename); 
                m->mothurOutEndLine();
 
                return 0;
index 23d4598122bd99bdbc0a5869b590034159361ba1..260deaa5637a580c24d6be89b1c8b822ba262591 100644 (file)
 class MakeGroupCommand : public Command {
        
 public:
-       MakeGroupCommand(string);       
+       MakeGroupCommand(string);
+       MakeGroupCommand();     
        ~MakeGroupCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute(); 
        void help();    
        
@@ -24,7 +29,8 @@ private:
                
        string fastaFileName, groups, outputDir, filename;
        vector<string> fastaFileNames;
-       vector<string> groupsNames;
+       vector<string> groupsNames, outputNames;
+       map<string, vector<string> > outputTypes;
        
        bool abort;
 };
index a55edd04e1db2f2acd24f57862b4dffb51e0ab8e..020ccff57c813168625132e83c9c198eb113a121 100644 (file)
 #include "sharedmorisitahorn.h"
 #include "sharedbraycurtis.h"
 
-
+//**********************************************************************************************************************
+vector<string> MatrixOutputCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"label","calc","groups","outputdir","inputdir", "output"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MatrixOutputCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+MatrixOutputCommand::MatrixOutputCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["phylip"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MatrixOutputCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MatrixOutputCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MatrixOutputCommand::getRequiredFiles(){        
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MatrixOutputCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 MatrixOutputCommand::MatrixOutputCommand(string option)  {
@@ -49,6 +95,10 @@ MatrixOutputCommand::MatrixOutputCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["phylip"] = 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 = ""; 
@@ -199,7 +249,7 @@ int MatrixOutputCommand::execute(){
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                
-                       if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
+                       if (m->control_pressed) { outputTypes.clear(); delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } for (int i = 0; i < outputNames.size(); i++) {     remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
                
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
                                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
@@ -232,7 +282,7 @@ int MatrixOutputCommand::execute(){
                        lookup = input->getSharedRAbundVectors();
                }
                
-               if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
+               if (m->control_pressed) { outputTypes.clear(); delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) {     remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
 
                //output error messages about any remaining user labels
                set<string>::iterator it;
@@ -247,7 +297,7 @@ int MatrixOutputCommand::execute(){
                        }
                }
                
-               if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
+               if (m->control_pressed) { outputTypes.clear(); delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) {    remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
 
                //run last label if you need to
                if (needToRun == true)  {
@@ -259,7 +309,7 @@ int MatrixOutputCommand::execute(){
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
                }
                
-               if (m->control_pressed) { delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
+               if (m->control_pressed) { outputTypes.clear();  delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str()); } globaldata->Groups.clear(); return 0;  }
                
                //reset groups parameter
                globaldata->Groups.clear();  
@@ -349,7 +399,7 @@ int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
                                        
                                        exportFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist";
                                        m->openOutputFile(exportFileName, out);
-                                       outputNames.push_back(exportFileName);
+                                       outputNames.push_back(exportFileName); outputTypes["phylip"].push_back(exportFileName);
                                        
                                        printSims(out);
                                        out.close();
index 537f7916299d36c7f628a9e7e6974821746f3b12..2a7908167ac1ede1d402fa26c2f9c30978b31469 100644 (file)
@@ -26,8 +26,13 @@ class GlobalData;
 class MatrixOutputCommand : public Command {
        
 public:
-       MatrixOutputCommand(string);    
+       MatrixOutputCommand(string);
+       MatrixOutputCommand();  
        ~MatrixOutputCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -50,6 +55,7 @@ private:
        set<string> labels; //holds labels to be used
        string outputFile, calc, groups, label, outputDir;
        vector<string>  Estimators, Groups, outputNames; //holds estimators to be used
+       map<string, vector<string> > outputTypes;
        
 
 };
index 098da009eaeacfab076c9ad0f800f626158f4a15..d431dd32ff17dcef5e267b1e93a47c8fc93b324b 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "mergefilecommand.h"
 
+//**********************************************************************************************************************
+vector<string> MergeFileCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"input", "output","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MergeFileCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+MergeFileCommand::MergeFileCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["merge"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MergeFileCommand", "MergeFileCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MergeFileCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"input","output"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MergeFileCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MergeFileCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MergeFileCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 MergeFileCommand::MergeFileCommand(string option)  {
@@ -34,6 +81,10 @@ MergeFileCommand::MergeFileCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["merge"] = 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 = "";          }
@@ -67,7 +118,7 @@ MergeFileCommand::MergeFileCommand(string option)  {
                        
                        outputFileName = validParameter.validFile(parameters, "output", false);                 
                        if (outputFileName == "not found") { m->mothurOut("you must enter an output file name"); m->mothurOutEndLine();  abort=true;  }
-                       else if (outputDir != "") { outputFileName = outputDir + m->getSimpleName(outputFileName); }
+                       else if (outputDir != "") { outputFileName = outputDir + m->getSimpleName(outputFileName);  }
                }
                        
        }
@@ -97,7 +148,7 @@ int MergeFileCommand::execute(){
                        m->openInputFile(fileNames[i], inputFile);
                        
                        while(!inputFile.eof()){        
-                               if (m->control_pressed) { inputFile.close(); outputFile.close(); remove(outputFileName.c_str()); return 0;  }
+                               if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); remove(outputFileName.c_str()); return 0;  }
                        
                                c = inputFile.get(); 
                                //-1 is eof char
@@ -109,11 +160,11 @@ int MergeFileCommand::execute(){
                
                outputFile.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0;  }
+               if (m->control_pressed) { outputTypes.clear();  remove(outputFileName.c_str()); return 0;  }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["merge"].push_back(outputFileName);
                m->mothurOutEndLine();
 
                return 0;
index bd94d77aa6cd8990545953b718c9f6254f44231c..56da3152309ec3c422cccb3aa0c6abce9f92be46 100644 (file)
 class MergeFileCommand : public Command {
 public:
        MergeFileCommand(string);
+       MergeFileCommand();
        ~MergeFileCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
 
 private:
-       vector<string> fileNames;
+       vector<string> fileNames, outputNames;
+       map<string, vector<string> > outputTypes;
        string outputFileName;
        int numInputFiles;
        bool abort;
index 7d1f4df1e95fa10241225ca20dba35c1f069d6ff..08c94ba3261c47c33d13368d9fbd84718cb5f3a2 100644 (file)
 #include "metastats.h"
 #include "sharedutilities.h"
 
+//**********************************************************************************************************************
+vector<string> MetaStatsCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"groups","label","outputdir","iters","threshold","g","design","sets","processors","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MetaStatsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+MetaStatsCommand::MetaStatsCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["metastats"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MetaStatsCommand", "MetaStatsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MetaStatsCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"design"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MetaStatsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MetaStatsCommand::getRequiredFiles(){   
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MetaStatsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 MetaStatsCommand::MetaStatsCommand(string option) {
@@ -39,6 +87,10 @@ MetaStatsCommand::MetaStatsCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["metastats"] = 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 = ""; 
@@ -206,7 +258,7 @@ int MetaStatsCommand::execute(){
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {     remove(outputNames[i].c_str()); } return 0; }
        
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
@@ -237,13 +289,13 @@ int MetaStatsCommand::execute(){
                        //prevent memory leak
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
                        
-                       if (m->control_pressed) {  globaldata->Groups.clear(); delete read;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); globaldata->Groups.clear(); delete read;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {     remove(outputNames[i].c_str()); } return 0; }
 
                        //get next line to process
                        lookup = input->getSharedRAbundVectors();                               
                }
                
-               if (m->control_pressed) { globaldata->Groups.clear(); delete read; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {    remove(outputNames[i].c_str()); }  return 0; }
+               if (m->control_pressed) { outputTypes.clear(); globaldata->Groups.clear(); delete read; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); }  return 0; }
 
                //output error messages about any remaining user labels
                set<string>::iterator it;
@@ -276,7 +328,7 @@ int MetaStatsCommand::execute(){
                delete read;
                delete designMap;
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); } return 0;}
+               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   remove(outputNames[i].c_str()); } return 0;}
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
@@ -350,7 +402,7 @@ int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& th
                        
                        //get filename
                        string outputFileName = outputDir +  m->getRootName(m->getSimpleName(globaldata->inputFileName)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + ".metastats";
-                       outputNames.push_back(outputFileName);
+                       outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
                        int nameLength = outputFileName.length();
                        char * output = new char[nameLength];
                        strcpy(output, outputFileName.c_str());
index 1c3f10cf49d915cb243e102ec0a7170f3ba90985..a38f3a7951c9629b680b4799c4a9ea00ea8d0270 100644 (file)
@@ -21,7 +21,12 @@ class MetaStatsCommand : public Command {
 
 public:
        MetaStatsCommand(string);
+       MetaStatsCommand();
        ~MetaStatsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -38,6 +43,7 @@ private:
        ReadOTUFile* read;
        InputData* input;
        vector<SharedRAbundVector*> lookup;
+       map<string, vector<string> > outputTypes;
        
        bool abort, allLines, pickedGroups;
        set<string> labels; //holds labels to be used
index eef54ef23b290a930d5560e8dbf444a20da46073..e5dd1a30141af8a7573f7117f5883399a3a409e4 100644 (file)
@@ -9,6 +9,56 @@
 
 #include "mgclustercommand.h"
 
+
+//**********************************************************************************************************************
+vector<string> MGClusterCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"blast", "method", "name", "hard", "cutoff", "precision", "length", "min", "penalty", "hcluster","merge","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MGClusterCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+MGClusterCommand::MGClusterCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MGClusterCommand", "MGClusterCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MGClusterCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"blast"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MGClusterCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> MGClusterCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "MGClusterCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 MGClusterCommand::MGClusterCommand(string option) {
        try {
@@ -34,6 +84,12 @@ MGClusterCommand::MGClusterCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["rabund"] = tempOutNames;
+                       outputTypes["sabund"] = 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 = "";          }
@@ -167,7 +223,7 @@ int MGClusterCommand::execute(){
                list = new ListVector(nameMap->getListVector());
                RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
                
-               if (m->control_pressed) { delete nameMap; delete read; delete list; delete rabund; return 0; }
+               if (m->control_pressed) { outputTypes.clear(); delete nameMap; delete read; delete list; delete rabund; return 0; }
                
                start = time(NULL);
                oldList = *list;
@@ -186,6 +242,7 @@ int MGClusterCommand::execute(){
                if (m->control_pressed) { 
                        delete nameMap; delete read; delete list; delete rabund; 
                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                       outputTypes.clear();
                        return 0; 
                }
                
@@ -206,6 +263,7 @@ int MGClusterCommand::execute(){
                        if (m->control_pressed) { 
                                delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
                                listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                               outputTypes.clear();
                                return 0; 
                        }
                
@@ -217,6 +275,7 @@ int MGClusterCommand::execute(){
                                if (m->control_pressed) { 
                                        delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                                       outputTypes.clear();
                                        return 0; 
                                }
                                
@@ -239,6 +298,7 @@ int MGClusterCommand::execute(){
                                                if (m->control_pressed) { 
                                                        delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
                                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                                                       outputTypes.clear();
                                                        return 0; 
                                                }
                                                
@@ -269,6 +329,7 @@ int MGClusterCommand::execute(){
                                        if (m->control_pressed) { 
                                                        delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
                                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                                                       outputTypes.clear();
                                                        return 0; 
                                        }
                                        
@@ -298,6 +359,7 @@ int MGClusterCommand::execute(){
                        if (m->control_pressed) { 
                                delete nameMap;  delete list; delete rabund; 
                                listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                               outputTypes.clear();
                                return 0; 
                        }
                
@@ -314,6 +376,7 @@ int MGClusterCommand::execute(){
                        if (m->control_pressed) { 
                                delete nameMap;  delete list; delete rabund; delete hcluster;
                                listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+                               outputTypes.clear();
                                return 0; 
                        }
 
@@ -326,6 +389,7 @@ int MGClusterCommand::execute(){
                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                        remove(distFile.c_str());
                                        remove(overlapFile.c_str());
+                                       outputTypes.clear();
                                        return 0; 
                                }
                                
@@ -340,6 +404,7 @@ int MGClusterCommand::execute(){
                                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                                        remove(distFile.c_str());
                                                        remove(overlapFile.c_str());
+                                                       outputTypes.clear();
                                                        return 0; 
                                                }
        
@@ -363,6 +428,7 @@ int MGClusterCommand::execute(){
                                                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                                                        remove(distFile.c_str());
                                                                        remove(overlapFile.c_str());
+                                                                       outputTypes.clear();
                                                                        return 0; 
                                                                }
 
@@ -398,6 +464,7 @@ int MGClusterCommand::execute(){
                                                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                                        remove(distFile.c_str());
                                                        remove(overlapFile.c_str());
+                                                       outputTypes.clear();
                                                        return 0; 
                                        }
                                        
@@ -429,14 +496,15 @@ int MGClusterCommand::execute(){
                        listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                        globaldata->setListFile("");
                        globaldata->setFormat("");
+                       outputTypes.clear();
                        return 0; 
                }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(fileroot+ tag + ".list"); m->mothurOutEndLine();   
-               m->mothurOut(fileroot+ tag + ".rabund"); m->mothurOutEndLine(); 
-               m->mothurOut(fileroot+ tag + ".sabund"); 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->mothurOutEndLine();
                
                m->mothurOut("It took " + toString(time(NULL) - start) + " seconds to cluster."); m->mothurOutEndLine();
index 4ef0bd90de3de904e51556e87e31163f4d08d0c7..f16a8f0c5ebc75bf07039a54d910d266e418b94e 100644 (file)
@@ -24,7 +24,12 @@ class MGClusterCommand : public Command {
 
 public:
        MGClusterCommand(string);
+       MGClusterCommand();
        ~MGClusterCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -37,6 +42,8 @@ private:
        ListVector* list;
        ListVector oldList;
        vector<seqDist> overlapMatrix;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        string blastfile, method, namefile, overlapFile, distFile, outputDir;
        ofstream sabundFile, rabundFile, listFile;
diff --git a/mothur b/mothur
index 405237b5d8c315b0ed18f87f32d2b5cb7b748a9a..f090f30ee6aa770553f0c67148e1d3915f91c298 100755 (executable)
Binary files a/mothur and b/mothur differ
index 67c62c1bed469a387462f5decac8252971dda43e..cd9e3212bfb3e4759ed798895fcfb004784e31c5 100644 (file)
@@ -60,6 +60,16 @@ void MothurOut::setDefaultPath(string pathname)  {
        }
 }
 /*********************************************************************************************/
+void MothurOut::setOutputDir(string pathname)  {
+       try {
+               outputDir = pathname;
+       }
+       catch(exception& e) {
+               errorOut(e, "MothurOut", "setOutputDir");
+               exit(1);
+       }
+}
+/*********************************************************************************************/
 void MothurOut::closeLog()  {
        try {
                
index 2244eeef21b571ed94bcd8a12820e76416e5b7b8..9921a40dccec386ad1266e9954ed72686f7be130 100644 (file)
@@ -27,6 +27,8 @@ class MothurOut {
                void closeLog();
                string getDefaultPath() { return defaultPath; }
                void setDefaultPath(string);
+               string getOutputDir() { return outputDir; }
+               void setOutputDir(string);
                
                string getReleaseDate() { return releaseDate; }
                void setReleaseDate(string r) { releaseDate = r; }
@@ -95,7 +97,7 @@ class MothurOut {
                ~MothurOut();
 
                string logFileName;
-               string defaultPath;
+               string defaultPath, outputDir;
                string releaseDate, version;
                
                ofstream out;
index 1a01d3718f33fa02ee7f475323d704e135130fea..eab873ba1eec6bc6a01b748f4ce6b441c9e1f4f1 100644 (file)
@@ -9,6 +9,39 @@
 
 #include "nocommands.h"
 
+//**********************************************************************************************************************
+vector<string> NoCommand::getValidParameters(){        
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NoCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> NoCommand::getRequiredParameters(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NoCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> NoCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NoCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 NoCommand::NoCommand(string option)  {}
index 5b84b65d5a518e77ea754d580e46fe9681db9ae1..f11673f98ce4e7c5c01f8c2aa624e85911f01fc7 100644 (file)
@@ -18,11 +18,18 @@ class NoCommand : public Command {
 
 public:
        NoCommand(string);
+       NoCommand() {}
        ~NoCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help() {}
        
 private:
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
                
 };
 
index 4a333322d5ff7893dd349e11eb3cc624d8c2b6f5..dc5ed196b4df8eff111954dbab106b1439f7a20c 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "normalizesharedcommand.h"
 
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"groups","label","scale","outputdir","inputdir","norm"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NormalizeSharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+NormalizeSharedCommand::NormalizeSharedCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["shared"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NormalizeSharedCommand", "NormalizeSharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NormalizeSharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> NormalizeSharedCommand::getRequiredFiles(){     
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "NormalizeSharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 NormalizeSharedCommand::NormalizeSharedCommand(string option) {
@@ -36,6 +83,10 @@ NormalizeSharedCommand::NormalizeSharedCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["shared"] = 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 = ""; 
@@ -150,7 +201,7 @@ int NormalizeSharedCommand::execute(){
                //as long as you are not at the end of the file or done wih the lines you want
                while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
        
                        if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
 
@@ -181,13 +232,13 @@ int NormalizeSharedCommand::execute(){
                        //prevent memory leak
                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
                        
-                       if (m->control_pressed) {  globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str()); return 0; }
 
                        //get next line to process
                        lookup = input->getSharedRAbundVectors();                               
                }
                
-               if (m->control_pressed) { globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str());  return 0; }
+               if (m->control_pressed) { outputTypes.clear(); globaldata->Groups.clear(); delete read;  out.close(); remove(outputFileName.c_str());  return 0; }
 
                //output error messages about any remaining user labels
                set<string>::iterator it;
@@ -220,11 +271,11 @@ int NormalizeSharedCommand::execute(){
                delete read;
                out.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0;}
+               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0;}
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();
+               m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
                m->mothurOutEndLine();
                
                return 0;
index fcfc727b23ba0e4aae0fc1d1406c6799fde81689..22158bd6d5ff136d0df81d0304b476ec580b8b7a 100644 (file)
@@ -21,7 +21,12 @@ class NormalizeSharedCommand : public Command {
 
 public:
        NormalizeSharedCommand(string);
+       NormalizeSharedCommand();
        ~NormalizeSharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -35,7 +40,8 @@ private:
        set<string> labels; //holds labels to be used
        string groups, label, outputDir, method;
        int norm;
-       vector<string> Groups;
+       vector<string> Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        
        int normalize(vector<SharedRAbundVector*>&, ofstream&);
        int eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup);
index 785272e08c69a3e1491d5d1d2792bbc9ba3eda5d..32818e3df6fce4bc5ab8a4ddda975572146a2a53 100644 (file)
@@ -25,6 +25,7 @@ public:
                int minLength = 0;
                int start = 0;
                int end = 0;
+               bool overlap = false;
                
                string seqA = A.getAligned();
                string seqB = B.getAligned();
@@ -35,6 +36,7 @@ public:
                        if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
                                start = i;
 //                             cout << "start: " << start << endl;
+                               overlap = true;
                                break;
                        }
                }
@@ -42,6 +44,7 @@ public:
                        if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
                                end = i;
 //                             cout << "end: " << end << endl;
+                               overlap = true;
                                break;
                        }
                }
@@ -73,7 +76,10 @@ public:
                                openGapB = 0;
                        }
                }
-
+               
+               //non-overlapping sequences
+               if (!overlap) { minLength = 0; }
+               
                if(minLength == 0)      {       dist = 1.0000;                                                  }
                else                            {       dist = (double)difference / minLength;  }
        }
index 2c71cd56aa8a6341def135ec0a7ddcb092993885..022ff3af04dcc23933b05f4b7a76d3131db20ac2 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "otuhierarchycommand.h"
 
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"list","label","output","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+OtuHierarchyCommand::OtuHierarchyCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["otuheirarchy"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getRequiredParameters(){   
+       try {
+               string Array[] =  {"list","label"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> OtuHierarchyCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "OtuHierarchyCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 OtuHierarchyCommand::OtuHierarchyCommand(string option) {
        try {
@@ -33,6 +80,10 @@ OtuHierarchyCommand::OtuHierarchyCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["otuheirarchy"] = 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 = "";          }
@@ -110,7 +161,7 @@ int OtuHierarchyCommand::execute(){
                //get listvectors that correspond to labels requested, (or use smart distancing to get closest listvector)
                vector<ListVector> lists = getListVectors();
                
-               if (m->control_pressed) { return 0; }
+               if (m->control_pressed) { outputTypes.clear(); return 0; }
                
                //determine which is little and which is big, putting little first
                if (lists.size() == 2) {
@@ -148,7 +199,7 @@ int OtuHierarchyCommand::execute(){
                //go through each bin in "big" otu and output the bins in "little" otu which created it
                for (int i = 0; i < lists[1].getNumBins(); i++) {
                
-                       if (m->control_pressed) { out.close(); remove(outputFileName.c_str()); return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); out.close(); remove(outputFileName.c_str()); return 0; }
                        
                        string names = lists[1].get(i);
                        
@@ -181,11 +232,11 @@ int OtuHierarchyCommand::execute(){
                
                out.close();
                
-               if (m->control_pressed) { remove(outputFileName.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear(); remove(outputFileName.c_str()); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
+               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["otuheirarchy"].push_back(outputFileName); 
                m->mothurOutEndLine();
                
                return 0;
index 1cd427f1a7af8442d4747e65662bbf431ccdcbbd..dd5f3a7adc759733bf3972392485c79b94669977 100644 (file)
@@ -18,7 +18,12 @@ class OtuHierarchyCommand : public Command {
 
 public:
        OtuHierarchyCommand(string);
+       OtuHierarchyCommand();
        ~OtuHierarchyCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -26,6 +31,8 @@ private:
        bool abort;
        set<string> labels; //holds labels to be used
        string label, listFile, outputDir, output;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        vector<ListVector> getListVectors();
                
index e808b9b45c7213de48a0f2ceed8a74e59f7e020f..31de119591dc333cc71ff08305822c018af861be 100644 (file)
 #include "parsefastaqcommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> ParseFastaQCommand::getValidParameters(){       
+       try {
+               string Array[] =  {"fastq", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseFastaQCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ParseFastaQCommand::ParseFastaQCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["qual"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseFastaQCommand", "ParseFastaQCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseFastaQCommand::getRequiredParameters(){    
+       try {
+               string Array[] =  {"fastq"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseFastaQCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseFastaQCommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseFastaQCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 ParseFastaQCommand::ParseFastaQCommand(string option){
        try {
@@ -33,6 +81,11 @@ ParseFastaQCommand::ParseFastaQCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["qual"] = 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 = "";          }
@@ -92,8 +145,8 @@ int ParseFastaQCommand::execute(){
                string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "fasta";
                string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "qual";
                ofstream outFasta, outQual;
-               m->openOutputFile(fastaFile, outFasta);  outputNames.push_back(fastaFile);
-               m->openOutputFile(qualFile, outQual);   outputNames.push_back(qualFile);
+               m->openOutputFile(fastaFile, outFasta);  outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile);
+               m->openOutputFile(qualFile, outQual);   outputNames.push_back(qualFile);  outputTypes["qual"].push_back(qualFile);
                
                ifstream in;
                m->openInputFile(fastaQFile, in);
@@ -139,7 +192,7 @@ int ParseFastaQCommand::execute(){
                outFasta.close();
                outQual.close();
                
-               if (m->control_pressed) { remove(fastaFile.c_str()); remove(qualFile.c_str()); return 0; }
+               if (m->control_pressed) { outputTypes.clear(); remove(fastaFile.c_str()); remove(qualFile.c_str()); return 0; }
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
index 071077577f1bec0fb39b05a6d18b01917e7a839e..c45405f42455de7bbdf93d7f2c391756d0700a05 100644 (file)
@@ -17,13 +17,19 @@ class ParseFastaQCommand : public Command {
 
 public:
        ParseFastaQCommand(string);
+       ParseFastaQCommand();
        ~ParseFastaQCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
 private:
 
        vector<string> outputNames;     
+       map<string, vector<string> > outputTypes;
        string outputDir, fastaQFile;
        bool abort;
        
index 4b24236e3497ab67f2be5299163798a9f43e8667..84d91048b181ddf19fc3f2c3977541e2ccebd2bd 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "parselistscommand.h"
 
+//**********************************************************************************************************************
+vector<string> ParseListCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"list","group", "label", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseListCommand", "getValidParameters");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+ParseListCommand::ParseListCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseListCommand", "ParseListCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseListCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"list","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseListCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseListCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseListCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 ParseListCommand::ParseListCommand(string option)  {
        try {
@@ -33,7 +81,11 @@ ParseListCommand::ParseListCommand(string option)  {
                        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["list"] = 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 = "";          }
@@ -121,7 +173,6 @@ int ParseListCommand::execute(){
                
                //set fileroot
                string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
-               vector<string> outputNames;
                
                //fill filehandles with neccessary ofstreams
                int i;
@@ -131,7 +182,7 @@ int ParseListCommand::execute(){
                        filehandles[groupMap->namesOfGroups[i]] = temp;
                        
                        string filename = fileroot +  groupMap->namesOfGroups[i] + ".list";
-                       outputNames.push_back(filename);
+                       outputNames.push_back(filename); outputTypes["list"].push_back(filename);
                        m->openOutputFile(filename, *temp);
                }
                
@@ -146,7 +197,7 @@ int ParseListCommand::execute(){
                if (m->control_pressed) { 
                        delete input; delete list; delete groupMap;
                        for (i=0; i<groupMap->namesOfGroups.size(); i++) {  (*(filehandles[groupMap->namesOfGroups[i]])).close();  delete filehandles[groupMap->namesOfGroups[i]]; } 
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                        return 0;
                }
                
@@ -155,7 +206,7 @@ int ParseListCommand::execute(){
                        if (m->control_pressed) { 
                                delete input; delete list; delete groupMap;
                                for (i=0; i<groupMap->namesOfGroups.size(); i++) {  (*(filehandles[groupMap->namesOfGroups[i]])).close();  delete filehandles[groupMap->namesOfGroups[i]]; } 
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                return 0;
                        }
                        
@@ -194,7 +245,7 @@ int ParseListCommand::execute(){
                if (m->control_pressed) { 
                                delete input; delete groupMap;
                                for (i=0; i<groupMap->namesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close();  delete filehandles[groupMap->namesOfGroups[i]]; } 
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                return 0;
                }
                
@@ -215,7 +266,7 @@ int ParseListCommand::execute(){
                if (m->control_pressed) { 
                                delete input; delete groupMap;
                                for (i=0; i<groupMap->namesOfGroups.size(); i++) {  (*(filehandles[groupMap->namesOfGroups[i]])).close();  delete filehandles[groupMap->namesOfGroups[i]]; } 
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                return 0;
                }
                
@@ -240,7 +291,7 @@ int ParseListCommand::execute(){
                delete input;
                
                if (m->control_pressed) { 
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                        return 0;
                }
                
index c765bcdd86c34c89b688685969e89d55928809f6..5ecc7ab13205d4f34d7c496a6b2cc3221615eafe 100644 (file)
 class ParseListCommand : public Command {
        
 public:
-       ParseListCommand(string);       
+       ParseListCommand(string);
+       ParseListCommand();     
        ~ParseListCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -35,6 +40,8 @@ private:
        string outputDir, listfile, groupfile, label;
        set<string> labels;
        bool abort, allLines;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        map<string, ofstream*> filehandles;
        map<string, ofstream*>::iterator it3;
index 03d8e96d44308c6a07eaba10344d8fce860e3943..c636ec99221d874ec6b497e2ae3965fd353c8dc0 100644 (file)
 #include "parsesffcommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"sff", "oligos", "minlength", "outputdir", "inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ParseSFFCommand::ParseSFFCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["flow"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "ParseSFFCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"sff"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParseSFFCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParseSFFCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ParseSFFCommand::ParseSFFCommand(string option){
@@ -36,6 +83,10 @@ ParseSFFCommand::ParseSFFCommand(string option){
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["flow"] = 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 = "";          }
@@ -115,7 +166,7 @@ int ParseSFFCommand::execute(){
                }
                else{
                        flowFileNames.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow").c_str(), ios::ate));
-                       outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow"));
+                       outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow")); outputTypes["flow"].push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow"));
                }
                
                for(int i=0;i<flowFileNames.size();i++){
@@ -124,7 +175,7 @@ int ParseSFFCommand::execute(){
                        *flowFileNames[i] << setprecision(2);
                }                       
                
-               if (m->control_pressed) { for(int i=0;i<flowFileNames.size();i++){      flowFileNames[i]->close();  } return 0; }
+               if (m->control_pressed) { outputTypes.clear(); for(int i=0;i<flowFileNames.size();i++){ flowFileNames[i]->close();  } return 0; }
                
 //             ofstream fastaFile;
 //             m->openOutputFile(m->getRootName(sffFile) + "fasta", fastaFile);
@@ -151,7 +202,7 @@ int ParseSFFCommand::execute(){
                
                for(int i=0;i<numReads;i++){
                        
-                       if (m->control_pressed) { for(int i=0;i<flowFileNames.size();i++){      flowFileNames[i]->close();  } return 0; }
+                       if (m->control_pressed) { outputTypes.clear(); for(int i=0;i<flowFileNames.size();i++){ flowFileNames[i]->close();  } return 0; }
                        
                        inSFF >> seqName;
                        seqName = seqName.substr(1);
@@ -282,6 +333,7 @@ void ParseSFFCommand::getOligos(vector<ofstream*>& outSFFFlowVec){
                                        
                                        outSFFFlowVec.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + ".flow").c_str(), ios::ate));
                                        outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + "flow"));
+                                       outputTypes["flow"].push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + "flow"));
                                }
                        }
                        m->gobble(inOligos);
index 5714e0df851abd68cd52cbd195e0f10fc61a69fa..9dfa083369d2241b428709119e2c2508bd667867 100644 (file)
 class ParseSFFCommand : public Command {
 public:
        ParseSFFCommand(string);
+       ParseSFFCommand();
        ~ParseSFFCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -42,6 +47,7 @@ private:
        map<string, int> barcodes;
        vector<string> groupVector;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
 //     string stripSeqQual(string, int, int);
 //     string stripQualQual(string, int, int);
index 3295de2d5c4db657b2a828c8be090476109d0f9a..b879395b528b845805c622acd107e637e3af74f8 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "parsimonycommand.h"
 
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"random","groups","iters","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ParsimonyCommand::ParsimonyCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["parsimony"] = tempOutNames;
+               outputTypes["psummary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ParsimonyCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ParsimonyCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /***********************************************************/
 ParsimonyCommand::ParsimonyCommand(string option)  {
        try {
@@ -34,6 +81,11 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["parsimony"] = tempOutNames;
+                       outputTypes["psummary"] = tempOutNames;
+                       
                        randomtree = validParameter.validFile(parameters, "random", false);             if (randomtree == "not found") { randomtree = ""; }
                        
                        //are you trying to use parsimony without reading a tree or saying you want random distribution
@@ -67,10 +119,12 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                                        if(outputDir == "") { outputDir += m->hasPath(globaldata->getTreeFile()); }
                                        output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony", itersString);
                                        outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony");
+                                       outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  +  ".parsimony");
                                        
                                        sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".psummary";
                                        m->openOutputFile(sumFile, outSum);
                                        outputNames.push_back(sumFile);
+                                       outputTypes["psummary"].push_back(sumFile);
                                }else { //user wants random distribution
                                        savetmap = globaldata->gTreemap;
                                        getUserInput();
@@ -78,6 +132,7 @@ ParsimonyCommand::ParsimonyCommand(string option)  {
                                        if(outputDir == "") { outputDir += m->hasPath(randomtree); }
                                        output = new ColumnFile(outputDir+ m->getSimpleName(randomtree), itersString);
                                        outputNames.push_back(outputDir+ m->getSimpleName(randomtree));
+                                       outputTypes["parsimony"].push_back(outputDir+ m->getSimpleName(randomtree));
                                }
                                
                                //set users groups to analyze
@@ -134,7 +189,7 @@ int ParsimonyCommand::execute() {
                if (m->control_pressed) { 
                        delete reading; delete pars; delete util; delete output;
                        if (randomtree == "") {  outSum.close();  }
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                        globaldata->Groups.clear();
                        return 0;
                }
@@ -158,7 +213,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output;
                                        if (randomtree == "") {  outSum.close();  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -196,7 +251,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        if (randomtree == "") {  outSum.close();  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -233,7 +288,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        globaldata->gTreemap = savetmap; 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -245,7 +300,7 @@ int ParsimonyCommand::execute() {
                                if (m->control_pressed) { 
                                        delete reading; delete pars; delete util; delete output; delete randT;
                                        globaldata->gTreemap = savetmap; 
-                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                        globaldata->Groups.clear();
                                        return 0;
                                }
@@ -302,7 +357,7 @@ int ParsimonyCommand::execute() {
                                delete reading; delete pars; delete util; delete output;
                                if (randomtree == "") {  outSum.close();  }
                                else { globaldata->gTreemap = savetmap; }
-                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                               for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                                globaldata->Groups.clear();
                                return 0;
                }
@@ -327,7 +382,7 @@ int ParsimonyCommand::execute() {
                
                if (m->control_pressed) { 
                        delete pars; delete util; delete output;
-                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
+                       for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); } outputTypes.clear();
                        return 0;
                }
                
index 6fa1914f31e320517ff89389a34fc3e5a1cd6dc6..04acd302891f36df23399ac9d9b1694535c7005e 100644 (file)
@@ -23,7 +23,12 @@ class ParsimonyCommand : public Command {
 
 public:
        ParsimonyCommand(string);       
+       ParsimonyCommand();
        ~ParsimonyCommand() { if (abort == false) { delete pars; delete util; delete output; }  }
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
 
@@ -57,6 +62,7 @@ private:
        bool abort;
        string groups, itersString;
        vector<string> Groups, outputNames; //holds groups to be used
+       map<string, vector<string> > outputTypes;
 
        void printParsimonyFile();  
        int printUSummaryFile();
index 51e3c319f377b893224e1e2f2d7093b3665c0d8a..4a4e55e2c01788141dc6d1173e3e14ed768d1fec 100644 (file)
 
 #include "pcacommand.h"
 
+//**********************************************************************************************************************
+vector<string> PCACommand::getValidParameters(){       
+       try {
+               string Array[] =  {"phylip", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PCACommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+PCACommand::PCACommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["pcoa"] = tempOutNames;
+               outputTypes["loadings"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PCACommand", "PCACommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PCACommand::getRequiredParameters(){    
+       try {
+               string Array[] =  {"phylip"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PCACommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PCACommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PCACommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 PCACommand::PCACommand(string option)  {
@@ -47,7 +95,12 @@ PCACommand::PCACommand(string option)  {
                                        if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
                                }
                        }
-
+                       
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["pcoa"] = tempOutNames;
+                       outputTypes["loadings"] = tempOutNames;
+                       
                        //required parameters
                        phylipfile = validParameter.validFile(parameters, "phylip", true);
                        if (phylipfile == "not open") { abort = true; }
@@ -516,11 +569,13 @@ void PCACommand::output(string fnameRoot, vector<string> name_list, vector<vecto
                pcaData.setf(ios::fixed, ios::floatfield);
                pcaData.setf(ios::showpoint);   
                outputNames.push_back(fnameRoot+"pcoa");
+               outputTypes["pcoa"].push_back(fnameRoot+"pcoa");
                
                ofstream pcaLoadings((fnameRoot+"pcoa.loadings").c_str(), ios::trunc);
                pcaLoadings.setf(ios::fixed, ios::floatfield);
                pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+"pcoa.loadings");       
+               outputNames.push_back(fnameRoot+"pcoa.loadings");
+               outputTypes["loadings"].push_back(fnameRoot+"pcoa.loadings");   
                
                pcaLoadings << "axis\tloading\n";
                for(int i=0;i<rank;i++){
index 089d1c102f38d66bfa0d83c2120dd3d3f1cd883e..22f288a7e768a74c939781df1302e42b92124600 100644 (file)
@@ -18,7 +18,12 @@ class PCACommand : public Command {
        
 public:
        PCACommand(string);     
+       PCACommand();
        ~PCACommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -28,6 +33,7 @@ private:
        string phylipfile, columnfile, namefile, format, filename, fbase, outputDir;
        float cutoff, precision;
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        void get_comment(istream&, char, char);
        int read_phylip(istream&, int, vector<string>&, vector<vector<double> >&);
index 6e9e7b1525301a59c825c283a4de3607f338a25e..6198f139ccb117b157dea30fb31a5ef2330e1aae 100644 (file)
@@ -9,6 +9,55 @@
 
 #include "phylodiversitycommand.h"
 
+//**********************************************************************************************************************
+vector<string> PhyloDiversityCommand::getValidParameters(){    
+       try {
+               string Array[] =  {"freq","rarefy","iters","groups","processors","summary","collect","scale","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloDiversityCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+PhyloDiversityCommand::PhyloDiversityCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["phylodiv"] = tempOutNames;
+               outputTypes["rarefy"] = tempOutNames;
+               outputTypes["summary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloDiversityCommand", "PhyloDiversityCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PhyloDiversityCommand::getRequiredParameters(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloDiversityCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PhyloDiversityCommand::getRequiredFiles(){      
+       try {
+               string Array[] =  {"tree","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhyloDiversityCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 PhyloDiversityCommand::PhyloDiversityCommand(string option)  {
        try {
@@ -33,6 +82,12 @@ PhyloDiversityCommand::PhyloDiversityCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["phylodiv"] = tempOutNames;
+                       outputTypes["rarefy"] = tempOutNames;
+                       outputTypes["summary"] = 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 = m->hasPath(globaldata->getTreeFile());              }
                        
@@ -132,9 +187,9 @@ int PhyloDiversityCommand::execute(){
                        string outRareFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getTreeFile()))  + toString(i+1) + ".phylodiv.rarefaction";
                        string outCollectFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getTreeFile()))  + toString(i+1) + ".phylodiv";
                        
-                       if (summary)    { m->openOutputFile(outSumFile, outSum); outputNames.push_back(outSumFile);                             }
-                       if (rarefy)             { m->openOutputFile(outRareFile, outRare); outputNames.push_back(outRareFile);                          }
-                       if (collect)    { m->openOutputFile(outCollectFile, outCollect); outputNames.push_back(outCollectFile); }
+                       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);                   }
+                       if (collect)    { m->openOutputFile(outCollectFile, outCollect); outputNames.push_back(outCollectFile);  outputTypes["phylodiv"].push_back(outCollectFile);  }
                        
                        int numLeafNodes = trees[i]->getNumLeaves();
                        
index 7d4b2d89484a88e4bc5016f19e2e24c89ab07a4e..f6c3bbe1d06495717310a464d423c884fb1ac717 100644 (file)
@@ -18,7 +18,12 @@ class PhyloDiversityCommand : public Command {
        
        public:
                PhyloDiversityCommand(string);
+               PhyloDiversityCommand();
                ~PhyloDiversityCommand();
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();  
                void help();
        
@@ -30,6 +35,7 @@ class PhyloDiversityCommand : public Command {
                bool abort, rarefy, summary, collect, scale;
                string groups, outputDir;
                vector<string> Groups, outputNames; //holds groups to be used, and outputFile names
+               map<string, vector<string> > outputTypes;
                
                void printData(set<int>&, map< string, vector<float> >&, ofstream&, int);
                void printSumData(map< string, vector<float> >&, ofstream&, int);
index c4f367a06d3e810afd954800ac637f29dc1818a1..c4751b5481a8c11803f3fd2582bdd013810644ff 100644 (file)
 #include "rabundvector.hpp"
 #include "sabundvector.hpp"
 
+//**********************************************************************************************************************
+vector<string> PhylotypeCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"taxonomy","cutoff","label","name","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhylotypeCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+PhylotypeCommand::PhylotypeCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["sabund"] = tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhylotypeCommand", "PhylotypeCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PhylotypeCommand::getRequiredParameters(){      
+       try {
+               string Array[] =  {"taxonomy"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhylotypeCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PhylotypeCommand::getRequiredFiles(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PhylotypeCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**********************************************************************************************************************/
 PhylotypeCommand::PhylotypeCommand(string option)  {
        try {
@@ -38,6 +87,12 @@ PhylotypeCommand::PhylotypeCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["sabund"] = tempOutNames;
+                       outputTypes["rabund"] = 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 = "";          }
@@ -127,8 +182,6 @@ int PhylotypeCommand::execute(){
        
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                //reads in taxonomy file and makes all the taxonomies the same length 
                //by appending the last taxon to a given taxonomy as many times as needed to 
                //make it as long as the longest taxonomy in the file 
@@ -164,9 +217,9 @@ int PhylotypeCommand::execute(){
                string outputRabundFile = fileroot + "tx.rabund";
                m->openOutputFile(outputRabundFile, outRabund);
                
-               outputNames.push_back(outputListFile);
-               outputNames.push_back(outputSabundFile);
-               outputNames.push_back(outputRabundFile);
+               outputNames.push_back(outputListFile); outputTypes["list"].push_back(outputListFile);
+               outputNames.push_back(outputSabundFile); outputTypes["sabund"].push_back(outputSabundFile);
+               outputNames.push_back(outputRabundFile); outputTypes["rabund"].push_back(outputRabundFile);
                
                int count = 1;          
                //start at leaves of tree and work towards root, processing the labels the user wants
index c5aea714714d2f95e5f57ced3fb8289f3039a481..e45e21b74a9ae58a6beef19a9a484344364c31de 100644 (file)
@@ -20,7 +20,12 @@ class PhylotypeCommand : public Command {
        
 public:
        PhylotypeCommand(string);       
+       PhylotypeCommand();
        ~PhylotypeCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute(); 
        void help();    
        
@@ -30,6 +35,8 @@ private:
        set<string> labels; //holds labels to be used
        int cutoff;
        map<string, string> namemap;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        map<int, int> currentNodes;
        map<int, int> parentNodes;
diff --git a/pipelinepdscommand.cpp b/pipelinepdscommand.cpp
new file mode 100644 (file)
index 0000000..46081df
--- /dev/null
@@ -0,0 +1,787 @@
+/*
+ *  pipelinepdscommand.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 10/5/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "pipelinepdscommand.h"
+#include "sffinfocommand.h"
+#include "commandoptionparser.hpp"
+
+//**********************************************************************************************************************
+vector<string> PipelineCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"sff","oligos","align","chimera","classify","taxonomy","pipeline","processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PipelineCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PipelineCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+PipelineCommand::PipelineCommand(string option) {
+       try {
+               cFactory = CommandFactory::getInstance();
+               abort = false;
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
+               
+               else {
+                       
+                       //valid paramters for this command
+                       string AlignArray[] =  {"sff","oligos","align","chimera","classify","taxonomy","pipeline","processors","outputdir","inputdir"};
+                       vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/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;  }
+                       }
+                       
+                       //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("sff");
+                               //user has given a template file
+                               if(it != parameters.end()){ 
+                                       path = m->hasPath(it->second);
+                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                       if (path == "") {       parameters["sff"] = inputDir + it->second;              }
+                               }
+                               
+                               it = parameters.find("oligos");
+                               //user has given a template file
+                               if(it != parameters.end()){ 
+                                       path = m->hasPath(it->second);
+                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
+                               }
+                               
+                               it = parameters.find("align");
+                               //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["align"] = inputDir + it->second;            }
+                               }
+                               
+                               it = parameters.find("chimera");
+                               //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["chimera"] = inputDir + it->second;          }
+                               }
+                               
+                               it = parameters.find("classify");
+                               //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["classify"] = inputDir + it->second;         }
+                               }
+                               
+                               it = parameters.find("taxonomy");
+                               //user has given a template file
+                               if(it != parameters.end()){ 
+                                       path = m->hasPath(it->second);
+                                       //if the user has not given a path then, add inputdir. else leave path alone.
+                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
+                               }
+                               
+                               it = parameters.find("pipeline");
+                               //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["pipeline"] = inputDir + it->second;         }
+                               }
+                       }
+                       
+                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
+                       
+                       pipeFilename = validParameter.validFile(parameters, "pipeline", true);
+                       if (pipeFilename == "not found") { pipeFilename = "";  }
+                       else if (pipeFilename == "not open") { pipeFilename = ""; abort = true; }
+                       
+                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = "1";                             }
+                       convert(temp, processors); 
+                       
+                       if (pipeFilename != "") {
+                               abort = readUsersPipeline();
+                       }else{
+                               sffFile = validParameter.validFile(parameters, "sff", true);
+                               if (sffFile == "not found") { m->mothurOut("sff is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
+                               else if (sffFile == "not open") { sffFile = ""; abort = true; }
+                                       
+                               oligosFile = validParameter.validFile(parameters, "oligos", true);
+                               if (oligosFile == "not found") { m->mothurOut("oligos is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
+                               else if (oligosFile == "not open") { oligosFile = ""; abort = true; }
+                                       
+                               alignFile = validParameter.validFile(parameters, "align", true);
+                               if (alignFile == "not found") { m->mothurOut("align is a required parameter for the pipeline command. Please provide the template to align with."); m->mothurOutEndLine(); abort = true;  }
+                               else if (alignFile == "not open") { alignFile = ""; abort = true; }
+
+                               chimeraFile = validParameter.validFile(parameters, "chimera", true);
+                               if (chimeraFile == "not found") { m->mothurOut("chimera is a required parameter for the pipeline command. Please provide the template to check for chimeras with."); m->mothurOutEndLine(); abort = true;  }
+                               else if (chimeraFile == "not open") { chimeraFile = ""; abort = true; }
+
+                               classifyFile = validParameter.validFile(parameters, "classify", true);
+                               if (classifyFile == "not found") { m->mothurOut("classify is a required parameter for the pipeline command. Please provide the template to use with the classifier."); m->mothurOutEndLine(); abort = true;  }
+                               else if (classifyFile == "not open") { classifyFile = ""; abort = true; }
+
+                               taxonomyFile = validParameter.validFile(parameters, "taxonomy", true);
+                               if (taxonomyFile == "not found") { m->mothurOut("taxonomy is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
+                               else if (taxonomyFile == "not open") { taxonomyFile = ""; abort = true; }
+                       }
+               }
+
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "PipelineCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void PipelineCommand::help(){
+       try {
+                m->mothurOut("The pipeline command is designed to guide you through your analysis using mothur.\n"); 
+                m->mothurOut("The pipeline command parameters are pipeline, sff, oligos, align, chimera, classify, taxonomy and processors.\n"); 
+                m->mothurOut("The sff parameter allows you to enter your sff file. It is required.\n"); 
+                m->mothurOut("The oligos parameter allows you to enter your oligos file. It is required.\n"); 
+                m->mothurOut("The align parameter allows you to enter a template to use with the aligner. It is required.\n"); 
+                m->mothurOut("The chimera parameter allows you to enter a template to use for chimera detection. It is required.\n"); 
+                m->mothurOut("The classify parameter allows you to enter a template to use for classification. It is required.\n"); 
+                m->mothurOut("The taxonomy parameter allows you to enter a taxonomy file for the classify template to use for classification. It is required.\n"); 
+                m->mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n");
+                m->mothurOut("The pipeline parameter allows you to enter your own pipeline file. This file should look like a mothur batchfile, but where you would be using a mothur generated file, you can use mothurmade instead.\n"); 
+                m->mothurOut("First column contains the command name, and the second column contains the parameter options or 'defaults', meaning use defaults. You may leave out file options.\n");
+                m->mothurOut("Example: trim.seqs(processors=8, allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, fasta=may1.v13.fasta, oligos=may1.v13.oligos, qfile=may1.v13.qual)\n");
+                m->mothurOut("then, you could enter unique.seqs(fasta=mothurmade), and mothur would use the .trim.fasta file from the trim.seqs command. \n");
+                m->mothurOut("then you could enter align.seqs(candidate=mothurmade, template=silva.v13.align, processors=8). , and mothur would use the .trim.unique.fasta file from the unique.seqs command. \n");
+                m->mothurOut("If no pipeline file is given then mothur will use Pat's pipeline. \n\n");
+                m->mothurOut("Here is a list of the commands used in Pat's pipeline.\n"); 
+                m->mothurOut("All paralellized commands will use the processors you entered.\n"); 
+                m->mothurOut("The sffinfo command takes your sff file and extracts the fasta and quality files.\n"); 
+                m->mothurOut("The trim.seqs command uses your oligos file and the quality and fasta files generated by sffinfo.\n"); 
+                m->mothurOut("The trim.seqs command sets the following parameters: allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50.\n"); 
+                m->mothurOut("The unique.seqs command uses the trimmed fasta file and removes redundant sequences, don't worry the names file generated by unique.seqs will be used in the pipeline to make sure they are included.\n"); 
+                m->mothurOut("The align.seqs command aligns the unique sequences using the aligners default options. \n"); 
+                m->mothurOut("The screen.seqs command screens the sequences using optimize=end-minlength. \n"); 
+                m->mothurOut("The pipeline uses chimera.slayer to detect chimeras using the default options. \n");
+                m->mothurOut("The pipeline removes all sequences determined to be chimeric by chimera.slayer. \n");
+                m->mothurOut("The filter.seqs command filters the sequences using vertical=T, trump=. \n"); 
+                m->mothurOut("The unique.seqs command uses the filtered fasta file and name file to remove sequences that have become redundant after filtering.\n"); 
+                m->mothurOut("The pre.cluster command clusters sequences that have no more than 2 differences.\n"); 
+                m->mothurOut("The dist.seqs command is used to generate a column and phylip formatted distance matrix using cutoff=0.20 for column.\n"); 
+                m->mothurOut("The pipeline uses cluster with method=average, hard=T. \n");
+                m->mothurOut("The classify.seqs command is used to classify the sequences using the bayesian method with a cutoff of 80.\n"); 
+                m->mothurOut("The phylotype command is used to cluster the sequences based on their classification.\n"); 
+                m->mothurOut("The clearcut command is used to generate a tree using neighbor=T. \n");
+                m->mothurOut("The summary.single and summary.shared commands are run on the otu files from cluster and phylotype commands. \n");
+                m->mothurOut("The summary.shared command uses calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc. \n");
+                m->mothurOut("The summary.single command uses calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson. \n");
+                m->mothurOut("The classify.otu command is used to get the concensus taxonomy for otu files from cluster and phylotype commands. \n");
+                m->mothurOut("The phylo.diversity command run on the tree generated by clearcut with rarefy=T, iters=100. \n");
+                m->mothurOut("The unifrac commands are also run on the tree generated by clearcut with random=F, distance=T. \n");
+                m->mothurOut("\n\n");
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "help");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+
+PipelineCommand::~PipelineCommand(){}
+
+//**********************************************************************************************************************
+
+int PipelineCommand::execute(){
+       try {
+               if (abort == true) { return 0; }
+               
+               if (pipeFilename == "") { 
+                       createPatsPipeline(); 
+                       
+                       //run Pats pipeline
+                       for (int i = 0; i < commands.size(); i++) {
+                               m->mothurOutEndLine(); m->mothurOut("mothur > " + commands[i]); m->mothurOutEndLine();
+                                                       
+                               if (m->control_pressed) { return 0; }
+
+                               CommandOptionParser parser(commands[i]);
+                               string commandName = parser.getCommandString();
+                               string options = parser.getOptionString();
+                                       
+                               #ifdef USE_MPI
+                                       int pid;
+                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
+                                       
+                                       if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
+                               #endif
+                               
+                               //executes valid command
+                               Command* command = cFactory->getCommand(commandName, options, "pipe");
+                               command->execute();
+                               
+                               //add output files to list
+                               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
+                               map<string, vector<string> >::iterator itMade;
+                               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
+                                       vector<string> temp = itMade->second; 
+                                       for (int j = 0; j < temp.size(); j++) { outputNames.push_back(temp[j]); }
+                               }
+                                                                       
+                               #ifdef USE_MPI
+                                       }
+                               #endif
+                       }
+                       
+               }else {  runUsersPipeline(); }
+               
+               if (m->control_pressed) { return 0; }
+               
+               m->mothurOutEndLine();
+               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
+               m->mothurOutEndLine();
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+bool PipelineCommand::readUsersPipeline(){
+       try {
+               
+               ifstream in;
+               m->openInputFile(pipeFilename, in);
+               
+               string nextCommand = "";
+               
+               map<string, vector<string> > mothurMadeFiles;
+               
+               while(!in.eof()) {
+                       nextCommand = m->getline(in); m->gobble(in);
+
+                       if (nextCommand[0] != '#') {
+                               bool error = false;
+                               
+                               string commandName, options;
+                               error = parseCommand(nextCommand, commandName, options);
+                               
+                               if (error) { in.close(); return error; }
+                               if (commandName == "pipeline.pds") { m->mothurOut("Cannot run the pipeline.pds command from inside the pipeline.pds command."); m->mothurOutEndLine(); in.close(); return true; }
+                               
+                               error = checkForValidAndRequiredParameters(commandName, options, mothurMadeFiles);
+                               
+                               if (error) { in.close(); return error; }
+                       }
+               }
+               
+               in.close();
+               
+               return false;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "readUsersPipeline");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+bool PipelineCommand::parseCommand(string nextCommand, string& name, string& options){
+       try {
+               CommandOptionParser parser(nextCommand);
+               name = parser.getCommandString();
+               options = parser.getOptionString();
+               
+               if (name == "") { return true; } //name == "" if () are not right
+               
+               return false;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "parseCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+bool PipelineCommand::checkForValidAndRequiredParameters(string name, string options, map<string, vector<string> >& mothurMadeFiles){
+       try {
+               
+               //get shell of the command so we can check to make sure its valid without running it
+               Command* command = cFactory->getCommand(name);
+               
+               //check to make sure all parameters are valid for command
+               vector<string> validParameters = command->getValidParameters();
+               
+               OptionParser parser(options);
+               map<string, string> parameters = parser.getParameters(); 
+                       
+               ValidParameters validParameter;
+               map<string, string>::iterator it;
+               map<string, vector<string> >::iterator itMade;
+                       
+               for (it = parameters.begin(); it != parameters.end(); it++) { 
+                       if (validParameter.isValidParameter(it->first, validParameters, it->second) != true) {  return true;  } // not valid
+                       if (it->second == "mothurmade") {
+                               itMade = mothurMadeFiles.find(it->first);
+                               
+                               if (itMade == mothurMadeFiles.end()) {  
+                                       m->mothurOut("You have the " + it->first + " listed as a mothurmade file for the " + name + " command, but it seems mothur will not make that file in your current pipeline, please correct."); m->mothurOutEndLine();
+                                       return true;
+                               }
+                       }
+               }
+               
+               //is the command missing any required
+               vector<string> requiredParameters = command->getRequiredParameters();
+               
+               //check for or
+               bool hasOr = false;
+               int numFound = 0;
+               if (requiredParameters.size() > 2) {  
+                       if (requiredParameters[(requiredParameters.size()-1)] == "or") { hasOr = true; }
+               }
+                       
+               for (int i = 0; i < requiredParameters.size(); i++) { 
+                       it = parameters.find(requiredParameters[i]);
+                       
+                       if (it != parameters.end()) { numFound++; }
+                       else {
+                               if (!hasOr) { m->mothurOut(name + " requires the " + requiredParameters[i] + " parameter, please correct."); m->mothurOutEndLine(); }
+                       }
+               }
+               
+               // if all are needed and not all are found
+               if ((!hasOr) && (numFound != requiredParameters.size())) { return true; }
+               //if one is needed and none are found
+               else if ((hasOr) && (numFound == 0)) { return true; }
+               
+               //update MothurMade
+               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
+               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
+                       mothurMadeFiles[itMade->first] = itMade->second; //adds any new types
+               }
+               
+               return false;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "checkForValidAndRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int PipelineCommand::runUsersPipeline(){
+       try {
+               ifstream in;
+               m->openInputFile(pipeFilename, in);
+               
+               string nextCommand = "";
+               
+               map<string, vector<string> > mothurMadeFiles;
+               
+               while(!in.eof()) {
+                       nextCommand = m->getline(in);  m->gobble(in);
+               
+                       if (nextCommand[0] != '#') {
+                               CommandOptionParser parser(nextCommand);
+                               string commandName = parser.getCommandString();
+                               string options = parser.getOptionString();
+                               
+                               if (options != "") {
+                                       bool error = fillInMothurMade(options, mothurMadeFiles);
+                                       if (error) { in.close(); return 0; }
+                               }
+                               
+                               m->mothurOutEndLine(); m->mothurOut("mothur > " + commandName + "(" + options + ")"); m->mothurOutEndLine();
+                                                               
+                               if (m->control_pressed) { return 0; }
+                                       
+                               #ifdef USE_MPI
+                                       int pid;
+                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
+                                       
+                                       if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
+                               #endif
+                               
+                               //executes valid command
+                               Command* command = cFactory->getCommand(commandName, options, "pipe");
+                               command->execute();
+                               
+                               //add output files to list
+                               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
+                               map<string, vector<string> >::iterator itMade;
+                               map<string, vector<string> >::iterator it;
+                               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
+               
+                                       vector<string> temp = itMade->second;
+                                       for (int k = 0; k < temp.size(); k++) { outputNames.push_back(temp[k]); }  //
+                                       
+                                       //update Mothur Made for each file
+                                       it = mothurMadeFiles.find(itMade->first);
+                                       
+                                       if (it == mothurMadeFiles.end()) { //new type
+                       
+                                               mothurMadeFiles[itMade->first] = temp;
+                               
+                                       }else{ //update existing type
+                                               vector<string> oldFileNames = it->second;
+                                               //look at new files, see if an old version of the file exists, if so update, else just add.
+                                               //for example you may have abrecovery.fasta and amazon.fasta as old files and you created a new amazon.trim.fasta.
+                                               
+                                               for (int k = 0; k < temp.size(); k++) {
+                                                       
+                                                       //get base name
+                                                       string root = m->getSimpleName(temp[k]);
+                                                       string individual = "";
+                                                       for(int i=0;i<root.length();i++){
+                                                               if(root[i] == '.'){
+                                                                       root = individual;
+                                                                       break;
+                                                               }else{
+                                                                       individual += root[i];
+                                                               }
+                                                       }
+                                                       
+                                                       //look for that base name in oldfiles
+                                                       int spot = -1;
+                                                       for (int l = 0; l < oldFileNames.size(); l++) {
+                                                               int pos = oldFileNames[l].find(root);
+                                                               if (pos != string::npos) {
+                                                                       spot = l;
+                                                                       break;
+                                                               }
+                                                       }
+                                                       
+                                                       //if you found it update it, else add it
+                                                       if (spot != -1) {
+                                                               mothurMadeFiles[it->first][spot] = temp[k];
+                                                       }else{
+                                                               mothurMadeFiles[it->first].push_back(temp[k]);
+                                                       }
+                                               }
+                                       }
+                               }
+                                                                       
+                               #ifdef USE_MPI
+                                       }
+                               #endif
+                       }
+               }
+               
+               in.close();
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "runUsersPipeline");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+bool PipelineCommand::fillInMothurMade(string& options, map<string, vector<string> > mothurMadeFiles){
+       try {
+               OptionParser parser(options);
+               map<string, string> parameters = parser.getParameters(); 
+               map<string, string>::iterator it;
+               map<string, vector<string> >::iterator itMade;
+               
+               options = "";
+               
+               //fill in mothurmade filenames
+               for (it = parameters.begin(); it != parameters.end(); it++) { 
+                       if (it->second == "mothurmade") {
+                               itMade = mothurMadeFiles.find(it->first);
+                               
+                               if (itMade == mothurMadeFiles.end()) { 
+                                       m->mothurOut("Looking for a mothurmade " + it->first + " file, but it seems mothur has not made that file type in your current pipeline, please correct."); m->mothurOutEndLine();
+                                       return true;
+                               }else{
+                                       vector<string> temp = itMade->second;
+                                       
+                                       if (temp.size() > 1) {
+                                               //ask user which file to use
+                                               m->mothurOut("More than one file has been created for the " + it->first + " parameter. "); m->mothurOutEndLine();
+                                               for (int i = 0; i < temp.size(); i++) {
+                                                       m->mothurOut(toString(i) + " - " + temp[i]); m->mothurOutEndLine();
+                                               }
+                                               m->mothurOut("Please select the number of the file you would like to use: ");
+                                               int num = 0;
+                                               cin >> num;
+                                               m->mothurOutJustToLog(toString(num)); m->mothurOutEndLine();
+                                               
+                                               if ((num < 0) || (num > (temp.size()-1))) { m->mothurOut("Not a valid response, quitting."); m->mothurOutEndLine(); return true; }
+                                               else {
+                                                       parameters[it->first] = temp[num];
+                                               }
+                               
+                                               //clears buffer so next command doesn't have error
+                                               string s;       
+                                               getline(cin, s);
+                                               
+                                       }else if (temp.size() == 0){
+                                               m->mothurOut("Sorry, we seem to think you created a " + it->first + " file, but it seems mothur doesn't have a filename."); m->mothurOutEndLine();
+                                               return true;
+                                       }else{
+                                               parameters[it->first] = temp[0];
+                                       }
+                               }
+                       }
+                       
+                       options += it->first + "=" + parameters[it->first] + ", ";
+               }
+               
+               //rip off extra comma
+               options = options.substr(0, (options.length()-2));
+               
+               return false;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "fillInMothurMade");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+void PipelineCommand::createPatsPipeline(){
+       try {
+               
+               //sff.info command
+               string thisCommand = "sffinfo(sff=" + sffFile + ")";
+               commands.push_back(thisCommand);
+               
+               //trim.seqs command
+               string fastaFile = m->getRootName(m->getSimpleName(sffFile)) + "fasta";
+               string qualFile = m->getRootName(m->getSimpleName(sffFile)) + "qual";
+               thisCommand = "trim.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", allfiles=F, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, oligos=" + oligosFile + ", qfile=" + qualFile + ")";
+               commands.push_back(thisCommand);
+               
+               //unique.seqs
+               string groupFile = m->getRootName(m->getSimpleName(fastaFile)) + "groups";
+               qualFile =  m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual";
+               fastaFile =  m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
+               thisCommand = "unique.seqs(fasta=" + fastaFile + ")"; 
+               commands.push_back(thisCommand);
+               
+               //align.seqs
+               string nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "names";
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "unique" + m->getExtension(fastaFile);
+               thisCommand = "align.seqs(processors=" + toString(processors) + ", candidate=" + fastaFile + ", template=" + alignFile + ")";
+               commands.push_back(thisCommand);
+               
+               //screen.seqs
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "align";
+               thisCommand = "screen.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", name=" + nameFile + "group=" + groupFile + ", optimize=end-minlength)";
+               commands.push_back(thisCommand);
+               
+               //chimera.slayer
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "good" + m->getExtension(fastaFile);
+               nameFile = m->getRootName(m->getSimpleName(nameFile)) + "good" + m->getExtension(nameFile);
+               groupFile = m->getRootName(m->getSimpleName(groupFile)) + "good" + m->getExtension(groupFile);
+               thisCommand = "chimera.slayer(processors=" + toString(processors) + ", fasta=" + fastaFile + ", template=" + chimeraFile + ")";
+               commands.push_back(thisCommand);
+               
+               //remove.seqs
+               string accnosFile = m->getRootName(m->getSimpleName(fastaFile))  + "slayer.accnos";
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "slayer.chimeras";
+               thisCommand = "remove.seqs(fasta=" + fastaFile + ", name=" + nameFile + ", group=" + groupFile + ", accnos=" + accnosFile + ", dups=T)";
+               commands.push_back(thisCommand);
+               
+               //filter.seqs
+               nameFile = m->getRootName(m->getSimpleName(nameFile)) + "pick" + m->getExtension(nameFile);
+               groupFile = m->getRootName(m->getSimpleName(groupFile)) + "pick" + m->getExtension(groupFile);
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "pick" + m->getExtension(fastaFile);
+               thisCommand = "filter.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", vertical=T, trump=.)";
+               commands.push_back(thisCommand);
+               
+               //unique.seqs
+               fastaFile =  m->getRootName(m->getSimpleName(fastaFile)) + "filter.fasta";
+               thisCommand = "unique.seqs(fasta=" + fastaFile + ", name=" + nameFile + ")"; 
+               commands.push_back(thisCommand);
+               
+               //pre.cluster
+               nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "names";
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "unique" + m->getExtension(fastaFile);
+               thisCommand = "pre.cluster(fasta=" + fastaFile + ", name=" + nameFile + ", diffs=2)"; 
+               commands.push_back(thisCommand);
+               
+               //dist.seqs
+               nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "precluster.names";
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "precluster" + m->getExtension(fastaFile);
+               thisCommand = "dist.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", cutoff=0.20)";
+               commands.push_back(thisCommand);
+               
+               //dist.seqs
+               string columnFile = m->getRootName(m->getSimpleName(fastaFile)) + "dist";
+               thisCommand = "dist.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", output=lt)";
+               commands.push_back(thisCommand);
+               
+               //read.dist
+               string phylipFile = m->getRootName(m->getSimpleName(fastaFile)) + "phylip.dist";
+               thisCommand = "read.dist(column=" + columnFile + ", name=" + nameFile + ")";
+               commands.push_back(thisCommand);
+               
+               //cluster
+               thisCommand = "cluster(method=average, hard=T)";
+               commands.push_back(thisCommand);
+               
+               string listFile = m->getRootName(m->getSimpleName(columnFile)) + "an.list";
+               string rabundFile = m->getRootName(m->getSimpleName(columnFile)) + "an.rabund";
+               
+               //degap.seqs
+               thisCommand = "degap.seqs(fasta=" + fastaFile + ")";
+               commands.push_back(thisCommand);
+               
+               //classify.seqs
+               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "ng.fasta";
+               thisCommand = "classify.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", name=" + nameFile + ", template=" + classifyFile + ", taxonomy=" + taxonomyFile + ", cutoff=80)";
+               commands.push_back(thisCommand);
+               
+               string RippedTaxName = m->getRootName(m->getSimpleName(taxonomyFile));
+               RippedTaxName = m->getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1));
+               if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); }
+               RippedTaxName +=  "."; 
+               
+               string fastaTaxFile = m->getRootName(m->getSimpleName(fastaFile)) + RippedTaxName + "taxonomy";
+               string taxSummaryFile = m->getRootName(m->getSimpleName(fastaFile)) + RippedTaxName + "tax.summary";
+               
+               //phylotype
+               thisCommand = "phylotype(taxonomy=" + fastaTaxFile + ", name=" + nameFile + ")";
+               commands.push_back(thisCommand);
+               
+               string phyloListFile = m->getRootName(m->getSimpleName(fastaTaxFile)) + "tx.list";
+               string phyloRabundFile = m->getRootName(m->getSimpleName(fastaTaxFile)) + "tx.rabund";
+               
+               //clearcut
+               thisCommand = "clearcut(phylip=" + phylipFile + ", neighbor=T)";
+               commands.push_back(thisCommand);
+               
+               string treeFile = m->getRootName(m->getSimpleName(phylipFile)) + "tre";
+               
+               //read.otu
+               thisCommand = "read.otu(list=" + listFile + ", group=" + groupFile + ", label=0.03)";
+               commands.push_back(thisCommand);
+               
+               string sharedFile = m->getRootName(m->getSimpleName(listFile)) + "shared";
+               
+               //read.otu
+               thisCommand = "read.otu(list=" + phyloListFile + ", group=" + groupFile + ", label=1)";
+               commands.push_back(thisCommand);
+               
+               string phyloSharedFile = m->getRootName(m->getSimpleName(phyloListFile)) + "shared";
+               
+               //read.otu
+               thisCommand = "read.otu(shared=" + sharedFile + ")";
+               commands.push_back(thisCommand);
+
+               //summary.single
+               thisCommand = "summary.single(calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
+               commands.push_back(thisCommand);
+               
+               //summary.shared
+               thisCommand = "summary.shared(calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc)";
+               commands.push_back(thisCommand);
+               
+               //read.otu
+               thisCommand = "read.otu(rabund=" + rabundFile + ", label=0.03)";
+               commands.push_back(thisCommand);
+               
+               //summary.single
+               thisCommand = "summary.single(calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
+               commands.push_back(thisCommand);
+               
+               //read.otu
+               thisCommand = "read.otu(shared=" + phyloSharedFile + ")";
+               commands.push_back(thisCommand);
+               
+               //summary.single
+               thisCommand = "summary.single(calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
+               commands.push_back(thisCommand);
+               
+               //summary.shared
+               thisCommand = "summary.shared(calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc)";
+               commands.push_back(thisCommand);
+
+               //read.otu
+               thisCommand = "read.otu(rabund=" + phyloRabundFile + ", label=1)";
+               commands.push_back(thisCommand);
+               
+               //summary.single
+               thisCommand = "summary.single(calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
+               commands.push_back(thisCommand);
+               
+               //classify.otu
+               thisCommand = "classify.otu(taxonomy=" + fastaTaxFile + ", name=" + nameFile + ", list=" + listFile + ", cutoff=51, label=0.03)";
+               commands.push_back(thisCommand);
+               
+               //classify.otu
+               thisCommand = "classify.otu(taxonomy=" + fastaTaxFile + ", name=" + nameFile + ", list=" + phyloListFile + ", cutoff=51, label=1)";
+               commands.push_back(thisCommand);
+               
+               //read.tree
+               thisCommand = "read.tree(tree=" + treeFile + ", name=" + nameFile + ", group=" + groupFile + ")";
+               commands.push_back(thisCommand);
+               
+               //phylo.diversity
+               thisCommand = "phylo.diversity(iters=100,rarefy=T)";
+               commands.push_back(thisCommand);
+               
+               //unifrac.weighted
+               thisCommand = "unifrac.weighted(random=false, distance=true, groups=all, processors=" + toString(processors) + ")";
+               commands.push_back(thisCommand);
+               
+               //unifrac.unweighted
+               thisCommand = "unifrac.unweighted(random=false, distance=true, processors=" + toString(processors) + ")";
+               commands.push_back(thisCommand);
+               
+               
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PipelineCommand", "createPatsPipeline");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
diff --git a/pipelinepdscommand.h b/pipelinepdscommand.h
new file mode 100644 (file)
index 0000000..8a8a195
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef PIPELINEPDSCOMMAND_H
+#define PIPELINEPDSCOMMAND_H
+
+/*
+ *  pipelinepdscommand.h
+ *  Mothur
+ *
+ *  Created by westcott on 10/5/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "command.hpp"
+#include "commandfactory.hpp"
+
+/****************************************************/
+
+class PipelineCommand : public Command {
+       
+public:
+       PipelineCommand(string);
+       PipelineCommand() {}
+       ~PipelineCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; } //empty
+       int execute();
+       void help();
+       
+private:
+       bool abort;
+       CommandFactory* cFactory;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
+       vector<string> commands;
+       string outputDir, sffFile, alignFile, oligosFile, taxonomyFile, pipeFilename, classifyFile, chimeraFile;
+       int processors;
+       
+       bool readUsersPipeline();
+       int runUsersPipeline();
+       void createPatsPipeline();
+       bool parseCommand(string, string&, string&);
+       bool checkForValidAndRequiredParameters(string, string, map<string, vector<string> >&);
+       bool fillInMothurMade(string&, map<string, vector<string> >);
+};
+
+/****************************************************/
+
+#endif
+
index a7f211345697a72c18b6fa0aaa1ac40200c46d94..e6ccc9b70455089d5dffc1c6f512f3e17ca1d76e 100644 (file)
 //**********************************************************************************************************************
 inline bool comparePriority(seqPNode first, seqPNode second) {  return (first.numIdentical > second.numIdentical); }
 //**********************************************************************************************************************
+vector<string> PreClusterCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta", "name", "diffs", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PreClusterCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+PreClusterCommand::PreClusterCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PreClusterCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PreClusterCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> PreClusterCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "PreClusterCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 
 PreClusterCommand::PreClusterCommand(string option) {
        try {
@@ -36,6 +84,11 @@ PreClusterCommand::PreClusterCommand(string option) {
                                if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["name"] = 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 = "";          }
@@ -189,8 +242,8 @@ int PreClusterCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(newFastaFile); m->mothurOutEndLine();      
-               m->mothurOut(newNamesFile); m->mothurOutEndLine();      
+               m->mothurOut(newFastaFile); m->mothurOutEndLine();      outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile);
+               m->mothurOut(newNamesFile); m->mothurOutEndLine();      outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile);
                m->mothurOutEndLine();
 
                return 0;
index de6a5727575a7f35d2605239968a37435faa388f..7bbb5a7f448351d1bf72616e3c40f7f10b41eda4 100644 (file)
@@ -31,7 +31,12 @@ class PreClusterCommand : public Command {
        
 public:
        PreClusterCommand(string);
+       PreClusterCommand();
        ~PreClusterCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -44,6 +49,8 @@ private:
        map<string, int> sizes;  //this map a seq name to the number of identical seqs in the names file
        map<string, int>::iterator itSize; 
 //     map<string, bool> active; //maps sequence name to whether it has already been merged or not.
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        int readFASTA();
        void readNameFile();
index 8e6fd15412167f9b2ae26eec7b9d93a8e19c6bd2..0dd2dec189317e56518fbfafce1c93a3c7a84f1b 100644 (file)
@@ -9,6 +9,39 @@
 
 #include "quitcommand.h"
 
+//**********************************************************************************************************************
+vector<string> QuitCommand::getValidParameters(){      
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "QuitCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> QuitCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "QuitCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> QuitCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "QuitCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 QuitCommand::QuitCommand(string option) {
index 8b893064dc5fb243d4f63084242d4df346bd7587..f901b17083b54f059e2cb9eef6d020318c9d5cda 100644 (file)
@@ -20,12 +20,19 @@ class QuitCommand : public Command {
        
 public:
        QuitCommand(string);
+       QuitCommand() {}
        ~QuitCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
 private:
        bool abort;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 };
 
 #endif
index ae28d230b419db28c36272e57fc38ac7e2feff65..d430ffc01184cd505ca97ed7a46bb727ab1292b8 100644 (file)
 #include "coverage.h"
 
 //**********************************************************************************************************************
-
-
+vector<string> RareFactCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"iters","freq","label","calc","abund","processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactCommand::getRequiredFiles(){    
+       try {
+               string AlignArray[] =  {"shared","list","rabund","sabund","or"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+RareFactCommand::RareFactCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["rarefaction"] = tempOutNames;
+               outputTypes["r_chao"] = tempOutNames;
+               outputTypes["r_ace"] = tempOutNames;
+               outputTypes["r_jack"] = tempOutNames;
+               outputTypes["r_shannon"] = tempOutNames;
+               outputTypes["r_shannoneven"] = tempOutNames;
+               outputTypes["r_heip"] = tempOutNames;
+               outputTypes["r_smithwilson"] = tempOutNames;
+               outputTypes["r_npshannon"] = tempOutNames;
+               outputTypes["r_simpson"] = tempOutNames;
+               outputTypes["r_simpsoneven"] = tempOutNames;
+               outputTypes["r_invsimpson"] = tempOutNames;
+               outputTypes["r_bootstrap"] = tempOutNames;
+               outputTypes["r_coverage"] = tempOutNames;
+               outputTypes["r_nseqs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactCommand", "RareFactCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 RareFactCommand::RareFactCommand(string option)  {
        try {
                globaldata = GlobalData::getInstance();
@@ -53,6 +112,24 @@ RareFactCommand::RareFactCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["rarefaction"] = tempOutNames;
+                       outputTypes["r_chao"] = tempOutNames;
+                       outputTypes["r_ace"] = tempOutNames;
+                       outputTypes["r_jack"] = tempOutNames;
+                       outputTypes["r_shannon"] = tempOutNames;
+                       outputTypes["r_shannoneven"] = tempOutNames;
+                       outputTypes["r_heip"] = tempOutNames;
+                       outputTypes["r_smithwilson"] = tempOutNames;
+                       outputTypes["r_npshannon"] = tempOutNames;
+                       outputTypes["r_simpson"] = tempOutNames;
+                       outputTypes["r_simpsoneven"] = tempOutNames;
+                       outputTypes["r_invsimpson"] = tempOutNames;
+                       outputTypes["r_bootstrap"] = tempOutNames;
+                       outputTypes["r_coverage"] = tempOutNames;
+                       outputTypes["r_nseqs"] = 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 = ""; 
@@ -138,8 +215,6 @@ int RareFactCommand::execute(){
        
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
                else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
@@ -164,51 +239,51 @@ int RareFactCommand::execute(){
                                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");
+                                               outputNames.push_back(fileNameRoot+"rarefaction"); outputTypes["rarefaction"].push_back(fileNameRoot+"rarefaction");
                                        }else if (Estimators[i] == "chao") { 
                                                rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
-                                               outputNames.push_back(fileNameRoot+"r_chao");
+                                               outputNames.push_back(fileNameRoot+"r_chao"); outputTypes["r_chao"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_ace"); outputTypes["r_ace"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_jack"); outputTypes["r_jack"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_shannon"); outputTypes["r_shannon"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_shannoneven"); outputTypes["r_shannoneven"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_heip"); outputTypes["r_heip"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_smithwilson"); outputTypes["r_smithwilson"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_npshannon"); outputTypes["r_npshannon"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_simpson"); outputTypes["r_simpson"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_simpsoneven"); outputTypes["r_simpsoneven"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_invsimpson"); outputTypes["r_invsimpson"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_bootstrap"); outputTypes["r_bootstrap"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_coverage"); outputTypes["r_coverage"].push_back(fileNameRoot+"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");
+                                               outputNames.push_back(fileNameRoot+"r_nseqs"); outputTypes["r_nseqs"].push_back(fileNameRoot+"r_nseqs");
                                        }
                                }
                        }
index 3cf0ef7f4cf68a5976d67dfe9cc4c9a9f0c7d57c..7da0b2f9f5301d80302d97f7da23d1cd8fee12c1 100644 (file)
@@ -23,8 +23,13 @@ class GlobalData;
 class RareFactCommand : public Command {
        
 public:
-       RareFactCommand(string);        
+       RareFactCommand(string);
+       RareFactCommand();      
        ~RareFactCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();    
        
@@ -43,8 +48,9 @@ private:
        set<string> labels; //holds labels to be used
        string label, calc;
        vector<string>  Estimators;
-       vector<string> inputFileNames;
+       vector<string> inputFileNames, outputNames;
        vector<string> groups;
+       map<string, vector<string> > outputTypes;
        string outputDir;
        
        vector<string> parseSharedFile(string);
index c0f5ec0c4daba141c9267817836522e0d22c1a3a..0be8141636a1fffaacce16f2592e6bf8738ad400 100644 (file)
 #include "sharedsobs.h"
 #include "sharednseqs.h"
 
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getValidParameters(){    
+       try {
+               string Array[] =  {"iters","freq","label","calc","groups", "jumble","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+RareFactSharedCommand::RareFactSharedCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["sharedrarefaction"] = tempOutNames;
+               outputTypes["sharedr_nseqs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getRequiredParameters(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RareFactSharedCommand::getRequiredFiles(){      
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RareFactSharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 RareFactSharedCommand::RareFactSharedCommand(string option)  {
@@ -41,6 +89,11 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sharedrarefaction"] = tempOutNames;
+                       outputTypes["sharedr_nseqs"] = tempOutNames;
+                       
                        //make sure the user has already run the read.otu command
                        if (globaldata->getSharedFile() == "") {
                                if (globaldata->getListFile() == "") { m->mothurOut("You must read a list and a group, or a shared before you can use the collect.shared command."); m->mothurOutEndLine(); abort = true; }
@@ -107,10 +160,10 @@ RareFactSharedCommand::RareFactSharedCommand(string option)  {
                                        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");
+                                                       outputNames.push_back(fileNameRoot+"shared.rarefaction"); outputTypes["sharedrarefaction"].push_back(fileNameRoot+"shared.rarefaction");
                                                }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");
+                                                       outputNames.push_back(fileNameRoot+"shared.r_nseqs"); outputTypes["sharedr_nseqs"].push_back(fileNameRoot+"shared.r_nseqs");
                                                }
                                        }
                                }
index 1bcddb5257f56967a63b66f0740e648811509204..ee16221903ce2ee738cd7b941ca90c5b57e05c04 100644 (file)
@@ -22,7 +22,12 @@ class RareFactSharedCommand : public Command {
        
 public:
        RareFactSharedCommand(string);
+       RareFactSharedCommand();
        ~RareFactSharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -42,6 +47,7 @@ private:
        set<string> labels; //holds labels to be used
        string label, calc, groups, outputDir;
        vector<string>  Estimators, Groups, outputNames;
+       map<string, vector<string> > outputTypes;
 
 
 };
index 0445eec63328e2cf7a646f1cc662bb36fdd3bb98..c600eb86c969303f608b6a440dedb77af3e50b1d 100644 (file)
 #include "readcolumn.h"
 #include "readmatrix.hpp"
 
+//**********************************************************************************************************************
+vector<string> ReadDistCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"phylip", "column", "name", "cutoff", "precision", "group","outputdir","inputdir","sim"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadDistCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadDistCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"phylip","column","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadDistCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadDistCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadDistCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 ReadDistCommand::ReadDistCommand(string option) {
        try {
                globaldata = GlobalData::getInstance();
@@ -208,8 +244,6 @@ int ReadDistCommand::execute(){
                time_t start = time(NULL);
                size_t numDists = 0;
                
-               vector<string> outputNames;
-               
                if (format == "matrix") {
                        ifstream in;
                        m->openInputFile(distFileName, in);
index 937ca3f0797c58bc24dc3a239ac5f7c0e4624339..984b4a78ec40fc5b9d643cd51434ef4255d3e239 100644 (file)
@@ -27,7 +27,12 @@ class GlobalData;
 class ReadDistCommand : public Command {
 public:
        ReadDistCommand(string);
+       ReadDistCommand() {}
        ~ReadDistCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -41,6 +46,8 @@ private:
        string distFileName, format, method;
        string phylipfile, columnfile, namefile, groupfile, outputDir;
        NameAssignment* nameMap;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort, sim;
 
index efd7073fae39fd493ef28f22d81d6bfdcf795859..24a30cb5cbe925097e63639d50cdfc7163183ead 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "readotucommand.h"
 
+//**********************************************************************************************************************
+vector<string> ReadOtuCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"list","order","shared","relabund","label","group","sabund", "rabund","groups","ordergroup","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadOtuCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ReadOtuCommand::ReadOtuCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["shared"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadOtuCommand::getRequiredParameters(){        
+       try {
+               string Array[] =  {"list","shared","relabund","sabund","rabund","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ChopSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadOtuCommand::getRequiredFiles(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadOtuCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 ReadOtuCommand::ReadOtuCommand(string option)  {
        try {
@@ -34,7 +82,12 @@ ReadOtuCommand::ReadOtuCommand(string option)  {
                        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 
@@ -255,6 +308,8 @@ int ReadOtuCommand::execute(){
                                //m->mothurOutEndLine();
                        }
                        
+                       outputTypes = shared->getOutputFiles();
+                       
                        delete shared;
                }
                return 0;
index bf9ccc00d0e7151ea4dce787b42265f092416bbd..eb0ca8f7832e5f1877a172fa0449a3ae29e5416f 100644 (file)
@@ -20,7 +20,12 @@ class GlobalData;
 class ReadOtuCommand : public Command {
 public:
        ReadOtuCommand(string);
+       ReadOtuCommand();
        ~ReadOtuCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -30,7 +35,8 @@ private:
        Command* shared;
        GroupMap* groupMap;
        string filename, listfile, orderfile, sharedfile, label, groupfile, sabundfile, rabundfile, format, groups, outputDir, ordergroupfile, relAbundfile;
-       vector<string> Groups;
+       vector<string> Groups, outputNames;
+       map<string, vector<string> > outputTypes;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used
index 89efc9abcf0057f68189ddad6975b5e1464fca09..edfdf3b77e0d85ff51afce83323d0204ab987a66 100644 (file)
@@ -9,6 +9,41 @@
 
 #include "readtreecommand.h"
 
+//**********************************************************************************************************************
+vector<string> ReadTreeCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"tree","group","name","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadTreeCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadTreeCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"tree"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadTreeCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReadTreeCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReadTreeCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 ReadTreeCommand::ReadTreeCommand(string option)  {
        try {
@@ -122,7 +157,7 @@ void ReadTreeCommand::help(){
                m->mothurOut("It also must be run before using the parsimony command, unless you are using the randomtree parameter.\n");
                m->mothurOut("The read.tree command parameters are tree, group and name.\n");
                m->mothurOut("The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile).\n");
-               m->mothurOut("The tree and group parameters are both required.\n");
+               m->mothurOut("The tree and group parameters are both required, if no group file is given then one group is assumed.\n");
                m->mothurOut("The name parameter allows you to enter a namefile.\n");
                m->mothurOut("Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n\n");
        }
index 5d5b9b5eb74f17983d58fd55610218d2c23a8866..97391d0982bbadb437ebe13318c47babeca4a981 100644 (file)
@@ -19,7 +19,12 @@ class GlobalData;
 class ReadTreeCommand : public Command {
 public:
        ReadTreeCommand(string);
+       ReadTreeCommand() {}
        ~ReadTreeCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -30,6 +35,8 @@ private:
        string filename, treefile, groupfile, namefile;
        bool abort;
        map<string, string> nameMap;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        int readNamesFile();
        int numUniquesInName;
index d3160194fa5bea985ae0fd96e7cad8de3e73020a..557622db59b1f5480a87fda36050e98cfb9439a9 100644 (file)
 #include "listvector.hpp"
 
 //**********************************************************************************************************************
-
+vector<string> RemoveLineageCommand::getValidParameters(){     
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport", "taxon", "dups", "list","taxonomy","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveLineageCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+RemoveLineageCommand::RemoveLineageCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["taxonomy"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["list"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RemoveLineageCommand::getRequiredParameters(){  
+       try {
+               string Array[] =  {"taxonomy"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveLineageCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RemoveLineageCommand::getRequiredFiles(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveLineageCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 RemoveLineageCommand::RemoveLineageCommand(string option)  {
        try {
                abort = false;
@@ -36,6 +87,15 @@ RemoveLineageCommand::RemoveLineageCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["taxonomy"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["list"] = 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 = "";         }
                        
@@ -237,7 +297,7 @@ int RemoveLineageCommand::readFasta(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["fasta"].push_back(outputFileName); 
                
                return 0;
                
@@ -308,7 +368,7 @@ int RemoveLineageCommand::readList(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["list"].push_back(outputFileName); 
                                
                return 0;
 
@@ -394,7 +454,7 @@ int RemoveLineageCommand::readName(){
                out.close();
 
                if (wroteSomething == false) {  m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["name"].push_back(outputFileName);
                                
                return 0;
        }
@@ -438,7 +498,7 @@ int RemoveLineageCommand::readGroup(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["group"].push_back(outputFileName);
                
                return 0;
        }
@@ -492,7 +552,7 @@ int RemoveLineageCommand::readTax(){
                out.close();
                
                if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["taxonomy"].push_back(outputFileName);
                        
                return 0;
 
@@ -582,7 +642,7 @@ int RemoveLineageCommand::readAlign(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["alignreport"].push_back(outputFileName);
                
                return 0;
                
index d18fc23076d83a8a3d4083ce2423af47cfd08e2f..c590ec640dbbfec2f9cbc886041aadfe614fd719 100644 (file)
@@ -17,13 +17,19 @@ class RemoveLineageCommand : public Command {
        public:
        
                RemoveLineageCommand(string);
+               RemoveLineageCommand();
                ~RemoveLineageCommand(){};
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
        private:
                set<string> names;
                vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                string fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir, taxons;
                bool abort, dups;
                
index 0ab181b411738d38b769a0255baeaf5968308d35..afba6514e0ea1360ef78f65d9470f89e63e18d53 100644 (file)
 #include "listvector.hpp"
 
 //**********************************************************************************************************************
-
+vector<string> RemoveSeqsCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta","name", "group", "alignreport", "accnos", "list","taxonomy","outputdir","inputdir", "dups" };
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+RemoveSeqsCommand::RemoveSeqsCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["taxonomy"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["list"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveSeqsCommand", "RemoveSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RemoveSeqsCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"accnos"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> RemoveSeqsCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "RemoveSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
        try {
                abort = false;
@@ -36,6 +87,15 @@ RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["taxonomy"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["list"] = 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 = "";         }
                        
@@ -243,7 +303,7 @@ int RemoveSeqsCommand::readFasta(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["fasta"].push_back(outputFileName); 
                
                return 0;
                
@@ -314,7 +374,7 @@ int RemoveSeqsCommand::readList(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["list"].push_back(outputFileName); 
                                
                return 0;
 
@@ -400,7 +460,7 @@ int RemoveSeqsCommand::readName(){
                out.close();
 
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["name"].push_back(outputFileName);
                                
                return 0;
        }
@@ -444,7 +504,7 @@ int RemoveSeqsCommand::readGroup(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["group"].push_back(outputFileName); 
                
                return 0;
        }
@@ -486,7 +546,7 @@ int RemoveSeqsCommand::readTax(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["taxonomy"].push_back(outputFileName);
                
                return 0;
        }
@@ -552,7 +612,7 @@ int RemoveSeqsCommand::readAlign(){
                out.close();
                
                if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); 
+               outputTypes["alignreport"].push_back(outputFileName);
                
                return 0;
                
index 8238c649489e3dff52371fa06ab8e2f49b93258f..8321212fff48bb240c54f1a1df4516b393f7216f 100644 (file)
@@ -17,7 +17,12 @@ class RemoveSeqsCommand : public Command {
        public:
        
                RemoveSeqsCommand(string);      
-               ~RemoveSeqsCommand(){};
+               RemoveSeqsCommand();
+               ~RemoveSeqsCommand(){}
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -26,6 +31,7 @@ class RemoveSeqsCommand : public Command {
                string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir;
                bool abort, dups;
                vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                
                int readFasta();
                int readName();
index 296c95410df58f1aeabfbd5b3195b327a18fe170..d179f0d89c54923de0516aceb6bf6aef9fe406c6 100644 (file)
 #include "reversecommand.h"
 #include "sequence.hpp"
 
-
+//**********************************************************************************************************************
+vector<string> ReverseSeqsCommand::getValidParameters(){       
+       try {
+               string Array[] =  {"fasta", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReverseSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ReverseSeqsCommand::ReverseSeqsCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReverseSeqsCommand::getRequiredParameters(){    
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReverseSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ReverseSeqsCommand::getRequiredFiles(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ReverseSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 ReverseSeqsCommand::ReverseSeqsCommand(string option)  {
@@ -36,6 +82,10 @@ ReverseSeqsCommand::ReverseSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -72,7 +122,7 @@ ReverseSeqsCommand::ReverseSeqsCommand(string option)  {
 
 void ReverseSeqsCommand::help(){
        try {
-               m->mothurOut("The reverse.seqs command reads a fastafile and ....\n");
+               m->mothurOut("The reverse.seqs command reads a fastafile and outputs a fasta file containing the reverse compliment.\n");
                m->mothurOut("The reverse.seqs command parameter is fasta and it is required.\n");
                m->mothurOut("The reverse.seqs command should be in the following format: \n");
                m->mothurOut("reverse.seqs(fasta=yourFastaFile) \n");   
@@ -118,7 +168,7 @@ int ReverseSeqsCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(reverseFile); m->mothurOutEndLine();       
+               m->mothurOut(reverseFile); m->mothurOutEndLine();       outputNames.push_back(reverseFile); outputTypes["fasta"].push_back(reverseFile);
                m->mothurOutEndLine();
 
                
index 874bde62ff5f315d392fc3c51479099b41ada008..8b5bcd262528e36f756093a8236f8a1b3a447ce8 100644 (file)
 class ReverseSeqsCommand : public Command {
 public:
        ReverseSeqsCommand(string);
+       ReverseSeqsCommand();
        ~ReverseSeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -23,6 +28,8 @@ private:
 
        bool abort;
        string fasta, outputDir;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
 };
 
index 581264cbe62b1ecc6b56a848476bdccff1d31545..5845b8f86ae7c718c0dbc25fe351d493faff57c3 100644 (file)
 #include "screenseqscommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> ScreenSeqsCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta", "start", "end", "maxambig", "maxhomop","optimize","criteria", "minlength", "maxlength",
+                                                                       "name", "group", "alignreport","processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ScreenSeqsCommand::ScreenSeqsCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["alignreport"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ScreenSeqsCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ScreenSeqsCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
@@ -21,7 +73,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
                
                else {
                        //valid paramters for this command
-                       string AlignArray[] =  {"fasta", "start", "end", "maxambig", "maxhomop", "minlength", "maxlength",
+                       string AlignArray[] =  {"fasta", "start", "end", "maxambig", "maxhomop","optimize","criteria", "minlength", "maxlength",
                                                                        "name", "group", "alignreport","processors","outputdir","inputdir"};
                        vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
                        
@@ -36,6 +88,14 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["alignreport"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -120,7 +180,25 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
                        
                        temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = "1";                             }
                        convert(temp, processors); 
-
+                       
+                       temp = validParameter.validFile(parameters, "optimize", false); //optimizing trumps the optimized values original value
+                       if (temp == "not found"){       temp = "";              }
+                       else {  m->splitAtDash(temp, optimize);         }
+                       
+                       //check for invalid optimize options
+                       set<string> validOptimizers;
+                       validOptimizers.insert("start"); validOptimizers.insert("end"); validOptimizers.insert("maxambig"); validOptimizers.insert("maxhomop"); validOptimizers.insert("minlength"); validOptimizers.insert("maxlength");
+                       
+                       for (int i = 0; i < optimize.size(); i++) { 
+                               if (validOptimizers.count(optimize[i]) == 0) { 
+                                       m->mothurOut(optimize[i] + " is not a valid optimizer. Valid options are start, end, maxambig, maxhomop, minlength and maxlength."); m->mothurOutEndLine();
+                                       optimize.erase(optimize.begin()+i);
+                                       i--;
+                               }
+                       }
+                       
+                       temp = validParameter.validFile(parameters, "criteria", false); if (temp == "not found"){       temp = "90";                            }
+                       convert(temp, criteria); 
                }
 
        }
@@ -134,7 +212,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
 void ScreenSeqsCommand::help(){
        try {
                m->mothurOut("The screen.seqs command reads a fastafile and creates .....\n");
-               m->mothurOut("The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, group and processors.\n");
+               m->mothurOut("The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, group, optimize, criteria and processors.\n");
                m->mothurOut("The fasta parameter is required.\n");
                m->mothurOut("The start parameter .... The default is -1.\n");
                m->mothurOut("The end parameter .... The default is -1.\n");
@@ -143,6 +221,8 @@ void ScreenSeqsCommand::help(){
                m->mothurOut("The minlength parameter .... The default is -1.\n");
                m->mothurOut("The maxlength parameter .... The default is -1.\n");
                m->mothurOut("The processors parameter allows you to specify the number of processors to use while running the command. The default is 1.\n");
+               m->mothurOut("The optimize and criteria parameters allow you set the start, end, maxabig, maxhomop, minlength and maxlength parameters relative to your set of sequences .\n");
+               m->mothurOut("For example optimize=start-end, criteria=90, would set the start and end values to the position 90% of your sequences started and ended.\n");
                m->mothurOut("The name parameter allows you to provide a namesfile, and the group parameter allows you to provide a groupfile.\n");
                m->mothurOut("The screen.seqs command should be in the following format: \n");
                m->mothurOut("screen.seqs(fasta=yourFastaFile, name=youNameFile, group=yourGroupFIle, start=yourStart, end=yourEnd, maxambig=yourMaxambig,  \n");
@@ -167,6 +247,16 @@ int ScreenSeqsCommand::execute(){
        try{
                
                if (abort == true) { return 0; }
+               
+               //if the user want to optimize we need to no the 90% mark
+               vector<unsigned long int> positions;
+               if (optimize.size() != 0) {  getSummary(positions); } //get summary is paralellized so we need to divideFile, no need to do this step twice so I moved it here
+               else { 
+                       positions = m->divideFile(fastafile, processors);
+                       for (int i = 0; i < (positions.size()-1); i++) {
+                               lines.push_back(new linePair(positions[i], positions[(i+1)]));
+                       }       
+               }
                                
                string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "good" + m->getExtension(fastafile);
                string badAccnosFile =  outputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
@@ -283,11 +373,6 @@ int ScreenSeqsCommand::execute(){
                        MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                                        
 #else
-                       vector<unsigned long int> positions = m->divideFile(fastafile, processors);
-                               
-                       for (int i = 0; i < (positions.size()-1); i++) {
-                               lines.push_back(new linePair(positions[i], positions[(i+1)]));
-                       }       
                                                
        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                        if(processors == 1){
@@ -390,8 +475,8 @@ int ScreenSeqsCommand::execute(){
 
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(goodSeqFile); m->mothurOutEndLine();       
-               m->mothurOut(badAccnosFile); m->mothurOutEndLine();     
+               m->mothurOut(goodSeqFile); m->mothurOutEndLine();       outputTypes["fasta"].push_back(goodSeqFile);
+               m->mothurOut(badAccnosFile); m->mothurOutEndLine();      outputTypes["accnos"].push_back(badAccnosFile);
                for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
                m->mothurOutEndLine();
                m->mothurOutEndLine();
@@ -418,7 +503,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                set<string>::iterator it;
 
                string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + "good" + m->getExtension(namefile);
-               outputNames.push_back(goodNameFile); 
+               outputNames.push_back(goodNameFile);  outputTypes["name"].push_back(goodNameFile);
                
                ofstream goodNameOut;   m->openOutputFile(goodNameFile, goodNameOut);
        
@@ -464,7 +549,7 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                        m->openInputFile(groupfile, inputGroups);
 
                        string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
-                       outputNames.push_back(goodGroupFile);  
+                       outputNames.push_back(goodGroupFile);   outputTypes["group"].push_back(goodGroupFile);
                        
                        ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
                        
@@ -503,6 +588,175 @@ int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
                exit(1);
        }
 }
+//***************************************************************************************************************
+int ScreenSeqsCommand::getSummary(vector<unsigned long int>& positions){
+       try {
+               
+               vector<int> startPosition;
+               vector<int> endPosition;
+               vector<int> seqLength;
+               vector<int> ambigBases;
+               vector<int> longHomoPolymer;
+               
+               vector<unsigned long int> positions = m->divideFile(fastafile, processors);
+                               
+               for (int i = 0; i < (positions.size()-1); i++) {
+                       lines.push_back(new linePair(positions[i], positions[(i+1)]));
+               }       
+               
+               int numSeqs = 0;
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       if(processors == 1){
+                               numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
+                       }else{
+                               numSeqs = createProcessesCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile); 
+                       }
+                               
+                       if (m->control_pressed) {  return 0; }
+               #else
+                       numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
+                       if (m->control_pressed) {  return 0; }
+               #endif
+
+               sort(startPosition.begin(), startPosition.end());
+               sort(endPosition.begin(), endPosition.end());
+               sort(seqLength.begin(), seqLength.end());
+               sort(ambigBases.begin(), ambigBases.end());
+               sort(longHomoPolymer.begin(), longHomoPolymer.end());
+               
+               int criteriaPercentile  = int(numSeqs * (criteria / (float) 100));
+               
+               for (int i = 0; i < optimize.size(); i++) {
+                       if (optimize[i] == "start") { startPos = startPosition[criteriaPercentile]; m->mothurOut("Optimizing start to " + toString(startPos) + "."); m->mothurOutEndLine(); }
+                       else if (optimize[i] == "end") { int endcriteriaPercentile = int(numSeqs * ((100 - criteria) / (float) 100));  endPos = endPosition[endcriteriaPercentile]; m->mothurOut("Optimizing end to " + toString(endPos) + "."); m->mothurOutEndLine();}
+                       else if (optimize[i] == "maxambig") { maxAmbig = ambigBases[criteriaPercentile]; m->mothurOut("Optimizing maxambig to " + toString(maxAmbig) + "."); m->mothurOutEndLine(); }
+                       else if (optimize[i] == "maxhomop") { maxHomoP = longHomoPolymer[criteriaPercentile]; m->mothurOut("Optimizing maxhomop to " + toString(maxHomoP) + "."); m->mothurOutEndLine(); }
+                       else if (optimize[i] == "minlength") { int mincriteriaPercentile = int(numSeqs * ((100 - criteria) / (float) 100)); minLength = seqLength[mincriteriaPercentile]; m->mothurOut("Optimizing minlength to " + toString(minLength) + "."); m->mothurOutEndLine(); }
+                       else if (optimize[i] == "maxlength") { maxLength = seqLength[criteriaPercentile]; m->mothurOut("Optimizing maxlength to " + toString(maxLength) + "."); m->mothurOutEndLine(); }
+               }
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "getSummary");
+               exit(1);
+       }
+}
+/**************************************************************************************/
+int ScreenSeqsCommand::driverCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename, linePair* filePos) {  
+       try {
+               
+               ifstream in;
+               m->openInputFile(filename, in);
+                               
+               in.seekg(filePos->start);
+
+               bool done = false;
+               int count = 0;
+       
+               while (!done) {
+                               
+                       if (m->control_pressed) { in.close(); return 1; }
+                                       
+                       Sequence current(in); m->gobble(in);
+       
+                       if (current.getName() != "") {
+                               startPosition.push_back(current.getStartPos());
+                               endPosition.push_back(current.getEndPos());
+                               seqLength.push_back(current.getNumBases());
+                               ambigBases.push_back(current.getAmbigBases());
+                               longHomoPolymer.push_back(current.getLongHomoPolymer());
+                               count++;
+                       }
+                       
+                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               unsigned long int pos = in.tellg();
+                               if ((pos == -1) || (pos >= filePos->end)) { break; }
+                       #else
+                               if (in.eof()) { break; }
+                       #endif
+                       
+               }
+               
+               in.close();
+               
+               return count;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "driverCreateSummary");
+               exit(1);
+       }
+}
+/**************************************************************************************************/
+int ScreenSeqsCommand::createProcessesCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename) {
+       try {
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+               int process = 1;
+               int num = 0;
+               processIDS.clear();
+               
+               //loop through and create all the processes you want
+               while (process != processors) {
+                       int pid = fork();
+                       
+                       if (pid > 0) {
+                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
+                               process++;
+                       }else if (pid == 0){
+                               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[process]);
+                               
+                               //pass numSeqs to parent
+                               ofstream out;
+                               string tempFile = fastafile + toString(getpid()) + ".num.temp";
+                               m->openOutputFile(tempFile, out);
+                               
+                               out << num << endl;
+                               for (int k = 0; k < startPosition.size(); k++)          {               out << startPosition[k] << '\t'; }  out << endl;
+                               for (int k = 0; k < endPosition.size(); k++)            {               out << endPosition[k] << '\t'; }  out << endl;
+                               for (int k = 0; k < seqLength.size(); k++)                      {               out << seqLength[k] << '\t'; }  out << endl;
+                               for (int k = 0; k < ambigBases.size(); k++)                     {               out << ambigBases[k] << '\t'; }  out << endl;
+                               for (int k = 0; k < longHomoPolymer.size(); k++)        {               out << longHomoPolymer[k] << '\t'; }  out << endl;
+                               
+                               out.close();
+                               
+                               exit(0);
+                       }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
+               }
+               
+               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
+               
+               //force parent to wait until all the processes are done
+               for (int i=0;i<processIDS.size();i++) { 
+                       int temp = processIDS[i];
+                       wait(&temp);
+               }
+               
+               //parent reads in and combine Filter info
+               for (int i = 0; i < processIDS.size(); i++) {
+                       string tempFilename = fastafile + toString(processIDS[i]) + ".num.temp";
+                       ifstream in;
+                       m->openInputFile(tempFilename, in);
+                       
+                       int temp, tempNum;
+                       in >> tempNum; m->gobble(in); num += tempNum;
+                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; startPosition.push_back(temp);              }               m->gobble(in);
+                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; endPosition.push_back(temp);                }               m->gobble(in);
+                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; seqLength.push_back(temp);                  }               m->gobble(in);
+                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; ambigBases.push_back(temp);                 }               m->gobble(in);
+                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; longHomoPolymer.push_back(temp);    }               m->gobble(in);
+                               
+                       in.close();
+                       remove(tempFilename.c_str());
+               }
+               
+               return num;
+#endif         
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ScreenSeqsCommand", "createProcessesCreateSummary");
+               exit(1);
+       }
+}
 
 //***************************************************************************************************************
 
@@ -514,7 +768,7 @@ int ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
                set<string>::iterator it;
                
                string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
-               outputNames.push_back(goodGroupFile); 
+               outputNames.push_back(goodGroupFile);  outputTypes["group"].push_back(goodGroupFile);
                ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
                
                while(!inputGroups.eof()){
@@ -566,7 +820,7 @@ int ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
                set<string>::iterator it;
                
                string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + "good" + m->getExtension(alignreport);
-               outputNames.push_back(goodAlignReportFile);  
+               outputNames.push_back(goodAlignReportFile);  outputTypes["alignreport"].push_back(goodAlignReportFile);
                ofstream goodAlignReportOut;    m->openOutputFile(goodAlignReportFile, goodAlignReportOut);
 
                while (!inputAlignReport.eof()) {               //      need to copy header
index 2c31ba2245b523b7f18c0a3559ee9cd6f85890df..81b915efcbf97e4b91bfca3bf27353da8f9ea8e9 100644 (file)
@@ -16,7 +16,12 @@ class ScreenSeqsCommand : public Command {
        
 public:
        ScreenSeqsCommand(string);
+       ScreenSeqsCommand();
        ~ScreenSeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -44,8 +49,14 @@ private:
 
        bool abort;
        string fastafile, namefile, groupfile, alignreport, outputDir;
-       int startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength, processors;
+       int startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength, processors, criteria;
        vector<string> outputNames;
+       vector<string> optimize;
+       map<string, vector<string> > outputTypes;
+       
+       int getSummary(vector<unsigned long int>&);
+       int createProcessesCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string);
+       int driverCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string, linePair*);       
 };
 
 #endif
index c08ee6ab2d512b56c6d39fa2a1290ab12da22bde..36e0f609ca67bd3cd37e7c0d33a98e88cee65e6f 100644 (file)
 #include "secondarystructurecommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> AlignCheckCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta","map", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCheckCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+AlignCheckCommand::AlignCheckCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["aligncheck"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCheckCommand", "AlignCheckCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> AlignCheckCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta","map"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCheckCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> AlignCheckCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "AlignCheckCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 AlignCheckCommand::AlignCheckCommand(string option)  {
@@ -36,6 +83,10 @@ AlignCheckCommand::AlignCheckCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["aligncheck"] = 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 = "";          }
@@ -140,7 +191,7 @@ int AlignCheckCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outfile); m->mothurOutEndLine();   
+               m->mothurOut(outfile); m->mothurOutEndLine();   outputNames.push_back(outfile); outputTypes["aligncheck"].push_back(outfile);
                m->mothurOutEndLine();
                
                return 0;               
index 2e6191ca67f47f92f38bb8c030a8ad3e32920af6..c1cc057cd190cd4570b57d9bcc9f622a8f6bf0f4 100644 (file)
@@ -33,7 +33,12 @@ class AlignCheckCommand : public Command {
        public:
        
                AlignCheckCommand(string);      
-               ~AlignCheckCommand(){};
+               AlignCheckCommand();
+               ~AlignCheckCommand(){}
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
@@ -42,6 +47,8 @@ class AlignCheckCommand : public Command {
                string mapfile, fastafile, outputDir;
                bool abort;
                int seqLength, haderror;
+               vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                
                void readMap();
                statData getStats(string sequence);
index 8489bfefc841f6dd34fea17ef15b416e08c4c6c8..78dce1794003457a077fe993958c75909c1020a7 100644 (file)
@@ -9,6 +9,53 @@
 
 #include "sensspeccommand.h"
 
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"list", "phylip", "column", "name", "hard", "label", "cutoff", "precision", "outputdir", "inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SensSpecCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SensSpecCommand::SensSpecCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["sensspec"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"list","phylip","column","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SensSpecCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SensSpecCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SensSpecCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 SensSpecCommand::SensSpecCommand(string option)  {
@@ -38,6 +85,10 @@ SensSpecCommand::SensSpecCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["sensspec"] = 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 = "";          }
@@ -159,6 +210,7 @@ int SensSpecCommand::execute(){
                if (abort == true) { return 0; }
 
                setUpOutput();
+               outputNames.push_back(sensSpecFileName); outputTypes["sensspec"].push_back(sensSpecFileName);
                if(format == "phylip")          {       processPhylip();        }
                else if(format == "column")     {       processColumn();        }
                
index 818667a1c52729a2610564334d13225472eaac39..687834c5b1b9098830747b79dd0e9e6135e6951b 100644 (file)
@@ -18,7 +18,12 @@ class SensSpecCommand : public Command {
        
 public:
        SensSpecCommand(string);
+       SensSpecCommand();
        ~SensSpecCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -31,6 +36,8 @@ private:
        string listFile, distFile, nameFile, sensSpecFileName;
        string outputDir;
        string format;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
 
        long int truePositives, falsePositives, trueNegatives, falseNegatives;
        bool abort;
index f1b9cd8103a2d5f9c8836f657411359b0845785c..1f880f38cdf5c48d4dd0418c1d9c68172af7b8b7 100644 (file)
@@ -9,6 +9,54 @@
 
 #include "seqerrorcommand.h"
 
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"query", "reference", "name", "threshold", "inputdir", "outputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqErrorCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SeqErrorCommand::SeqErrorCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["error"] = tempOutNames;
+               outputTypes["count"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqErrorCommand", "SeqErrorCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"query","reference"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqErrorCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SeqErrorCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqErrorCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 SeqErrorCommand::SeqErrorCommand(string option)  {
@@ -23,7 +71,7 @@ SeqErrorCommand::SeqErrorCommand(string option)  {
                        string temp;
                        
                        //valid paramters for this command
-                       string AlignArray[] =  {"query", "reference", "name", "threshold"};
+                       string AlignArray[] =  {"query", "reference", "name", "threshold", "inputdir", "outputdir"};
                        
 //need to implement name file option
                        
@@ -40,6 +88,11 @@ SeqErrorCommand::SeqErrorCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["error"] = tempOutNames;
+                       outputTypes["count"] = 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 = "";          }
@@ -97,6 +150,7 @@ SeqErrorCommand::SeqErrorCommand(string option)  {
                                                
                        errorFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".errors";
                        m->openOutputFile(errorFileName, errorFile);
+                       outputNames.push_back(errorFileName); outputTypes["error"].push_back(errorFileName);
                        printErrorHeader();
                }
        }
@@ -195,6 +249,7 @@ int SeqErrorCommand::execute(){
                string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".count";
                ofstream errorCountFile;
                m->openOutputFile(errorCountFileName, errorCountFile);
+               outputNames.push_back(errorCountFileName);  outputTypes["count"].push_back(errorCountFileName);
                
                m->mothurOut("Overall error rate:\t" + toString((double)(totalBases - totalMatches) / (double)totalBases) + "\n\n");
                m->mothurOut("Errors\tSequences\n");
index 1eb2576d2b6867f132be866b4b3e96b1cc7a1c44..983383bdc3b6842db303685e2dd96f421e30d614 100644 (file)
@@ -41,7 +41,12 @@ struct Compare {
 class SeqErrorCommand : public Command {
 public:
        SeqErrorCommand(string);
+       SeqErrorCommand();
        ~SeqErrorCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -58,6 +63,8 @@ private:
        double threshold;
        int numRefs;
        ofstream errorFile;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        vector<Sequence> referenceSeqs;
 };
index a47364adf9cf436a6f780f541f1fcfbf6bf3ef04..7d074c4e05d441d350d552d2eb3796007191943a 100644 (file)
 #include "seqsummarycommand.h"
 #include "sequence.hpp"
 
+//**********************************************************************************************************************
+vector<string> SeqSummaryCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"fasta","processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqSummaryCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SeqSummaryCommand::SeqSummaryCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["summary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SeqSummaryCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqSummaryCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SeqSummaryCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SeqSummaryCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 SeqSummaryCommand::SeqSummaryCommand(string option)  {
@@ -49,6 +96,10 @@ SeqSummaryCommand::SeqSummaryCommand(string option)  {
                                }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["summary"] = tempOutNames;
+                       
                        //check for required parameters
                        fastafile = validParameter.validFile(parameters, "fasta", true);
                        if (fastafile == "not open") { abort = true; }
@@ -289,7 +340,7 @@ int SeqSummaryCommand::execute(){
                
                m->mothurOutEndLine();
                m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(summaryFile); m->mothurOutEndLine();       
+               m->mothurOut(summaryFile); m->mothurOutEndLine();       outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile);
                m->mothurOutEndLine();
                
                #ifdef USE_MPI
index 6abf06a6fcf11bba1a714c6b3efdfd2be37b7285..305c6e34dd0fcf1a66e434b797ea3a5af991dfd0 100644 (file)
 class SeqSummaryCommand : public Command {
 public:
        SeqSummaryCommand(string);
+       SeqSummaryCommand();
        ~SeqSummaryCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -24,6 +29,8 @@ private:
        bool abort;
        string fastafile, outputDir;
        int processors;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        
        struct linePair {
                unsigned long int start;
index a9ae730fba554945fb737c08b0f4cc739af5bec8..214bd172e80208f246bede7978ad69329f6e23db 100644 (file)
@@ -9,6 +9,40 @@
 
 #include "setdircommand.h"
 
+//**********************************************************************************************************************
+vector<string> SetDirectoryCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"output","input","tempdefault","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetDirectoryCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SetDirectoryCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetDirectoryCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SetDirectoryCommand::getRequiredFiles(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetDirectoryCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SetDirectoryCommand::SetDirectoryCommand(string option)  {
index 330adf14ee11061c9b049b6aab2bde783113d6d0..1afab07244ef9f9464b98224249fea447f00402e 100644 (file)
@@ -20,7 +20,12 @@ class SetDirectoryCommand : public Command {
        
 public:
        SetDirectoryCommand(string);
+       SetDirectoryCommand() {}
        ~SetDirectoryCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -28,6 +33,8 @@ private:
        CommandFactory* commandFactory;
        string output, input, tempdefault;
        bool abort;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
                
 };
 
index 19f3ed129ab85b9f66dbea06c56637ea2f8daa42..b99b833a5651c80d4b54b1d957810303fe65b199 100644 (file)
@@ -9,6 +9,41 @@
 
 #include "setlogfilecommand.h"
 
+//**********************************************************************************************************************
+vector<string> SetLogFileCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"name","append","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SetLogFileCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"name"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SetLogFileCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SetLogFileCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SetLogFileCommand::SetLogFileCommand(string option)  {
index d16bcd65a3949f987eb6ed7521e83789608d2e79..d2b5c3d63bc3490d6a478fd3ced457706422f2ec 100644 (file)
@@ -19,7 +19,12 @@ class SetLogFileCommand : public Command {
        
 public:
        SetLogFileCommand(string);
+       SetLogFileCommand() {}
        ~SetLogFileCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -27,6 +32,8 @@ private:
        CommandFactory* commandFactory;
        string name;
        bool abort, append;
+       vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
                
 };
 
index a691a405ddb31fb022ebf37c98b40deb8e54c6a5..e51f7f22acda22ac6a852dfebad627275c58d073 100644 (file)
 #include "sffinfocommand.h"
 #include "endiannessmacros.h"
 
+//**********************************************************************************************************************
+vector<string> SffInfoCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SffInfoCommand::SffInfoCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["flow"] = tempOutNames;
+               outputTypes["sfftxt"] = tempOutNames;
+               outputTypes["qual"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SffInfoCommand::getRequiredParameters(){        
+       try {
+               string Array[] =  {"sff"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SffInfoCommand::getRequiredFiles(){     
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SffInfoCommand::SffInfoCommand(string option)  {
@@ -34,6 +84,13 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["flow"] = tempOutNames;
+                       outputTypes["sfftxt"] = tempOutNames;
+                       outputTypes["qual"] = 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 = "";         }
                        
@@ -65,6 +122,17 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                                        filenames[i] = tryPath;
                                                }
                                        }
+                                       
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(filenames[i]);
+                                                       m->mothurOut("Unable to open " + filenames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       filenames[i] = tryPath;
+                                               }
+                                       }
+                                       
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -105,6 +173,15 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                                        accnosFileNames[i] = tryPath;
                                                }
                                        }
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getOutputDir() != "") { //default path is set
+                                                       string tryPath = m->getOutputDir() + m->getSimpleName(accnosFileNames[i]);
+                                                       m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                                       accnosFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
@@ -227,10 +304,10 @@ int SffInfoCommand::extractSffInfo(string input, string accnos){
                        outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.qual";
                }
                
-               if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName); }
-               if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); }
-               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName);  }
-               if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  }
+               if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName);  outputTypes["sfftxt"].push_back(sfftxtFileName); }
+               if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
+               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName);  }
+               if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  outputTypes["flow"].push_back(outFlowFileName);  }
                
                ifstream in;
                in.open(input.c_str(), ios::binary);
index 939a1c70bf87ee50c97aa95bc387599cf0b866f5..7cf357e07499ad5797dec8bbc1e647c163993aa8 100644 (file)
@@ -60,7 +60,12 @@ class SffInfoCommand : public Command {
        
 public:
        SffInfoCommand(string);
+       SffInfoCommand();
        ~SffInfoCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -69,6 +74,7 @@ private:
        vector<string> filenames, outputNames, accnosFileNames;
        bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos;
        set<string> seqNames;
+       map<string, vector<string> > outputTypes;
        
        int extractSffInfo(string, string);
        int readCommonHeader(ifstream&, CommonHeader&);
index fb3691e662a7ee2b378d8e1dd13e4221b698106d..454bb0558cce6080cdd1859fc0382ed3d47360e3 100644 (file)
@@ -14,17 +14,69 @@ inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* r
        return (left->getGroup() < right->getGroup());  
 } 
 //**********************************************************************************************************************
+vector<string> SharedCommand::getValidParameters(){    
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SharedCommand::SharedCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["shared"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedCommand", "SharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SharedCommand::getRequiredParameters(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SharedCommand::getRequiredFiles(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
 
 SharedCommand::SharedCommand(string o) : outputDir(o) {
        try {
                globaldata = GlobalData::getInstance();
                
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["rabund"] = tempOutNames;
+               outputTypes["shared"] = tempOutNames;
+               
                //getting output filename
                filename = globaldata->inputFileName;
                if (outputDir == "") { outputDir += m->hasPath(filename); }
                
                filename = outputDir + m->getRootName(m->getSimpleName(filename));
                filename = filename + "shared";
+               outputTypes["shared"].push_back(filename);
                
                m->openOutputFile(filename, out);
                pickedGroups = false;
@@ -54,6 +106,7 @@ SharedCommand::SharedCommand(string o) : outputDir(o) {
                for (int i=0; i<groups.size(); i++) {
                        remove((fileroot + groups[i] + ".rabund").c_str());
                        outputNames.push_back((fileroot + groups[i] + ".rabund"));
+                       outputTypes["rabund"].push_back((fileroot + groups[i] + ".rabund"));
                }
 
        }
index 0f3e7ef2289b39f9ab4807ccda5cbe179ff51d04..2c5ab237a2d39b006dee4eca4e9b9b2c65a57ebe 100644 (file)
@@ -27,7 +27,12 @@ class SharedCommand : public Command {
        
 public:
        SharedCommand(string);  
+       SharedCommand();
        ~SharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help() {}
        
@@ -37,6 +42,7 @@ private:
        int readOrderFile();
        bool isValidGroup(string, vector<string>);
        int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
+       map<string, vector<string> > outputTypes;
        
        GlobalData* globaldata;
        ReadOTUFile* read;
index 17809631f9e9cc590e510a33ec5528e493a14d3c..607009129b3c13ec8b7adfafd66e4d3fb006c486 100644 (file)
@@ -9,6 +9,57 @@
 
 #include "splitabundcommand.h"
 
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"name","group","list","label","accnos","groups","fasta","cutoff","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SplitAbundCommand::SplitAbundCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "SplitAbundCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta","list","name","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 SplitAbundCommand::SplitAbundCommand(string option)  {
        try {
@@ -33,7 +84,15 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                        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["list"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;                    
+                                                                                               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -186,6 +245,8 @@ int SplitAbundCommand::execute(){
                                
                                outputNames.push_back((fileroot + "rare.list"));
                                outputNames.push_back((fileroot + "abund.list"));
+                               outputTypes["list"].push_back((fileroot + "rare.list"));
+                               outputTypes["list"].push_back((fileroot + "abund.list"));
                        }else{
                                for (int i=0; i<Groups.size(); i++) {
                                        remove((fileroot + Groups[i] + ".rare.list").c_str());
@@ -193,6 +254,8 @@ int SplitAbundCommand::execute(){
                                        
                                        outputNames.push_back((fileroot + Groups[i] + ".rare.list"));
                                        outputNames.push_back((fileroot + Groups[i] + ".abund.list"));
+                                       outputTypes["list"].push_back((fileroot + Groups[i] + ".rare.list"));
+                                       outputTypes["list"].push_back((fileroot + Groups[i] + ".abund.list"));
                                }
                        }
                        
@@ -572,11 +635,11 @@ int SplitAbundCommand::writeNames() { //namefile
                        
                        string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare.names";
                        m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       outputNames.push_back(rare); outputTypes["name"].push_back(rare);
                        
                        string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund.names";
                        m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       outputNames.push_back(abund); outputTypes["name"].push_back(abund);
                        
                        if (rareNames.size() != 0) {
                                for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
@@ -642,7 +705,7 @@ int SplitAbundCommand::writeNames() { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + it3->first + ".names");  
+                               outputNames.push_back(fileroot + it3->first + ".names");  outputTypes["name"].push_back(fileroot + it3->first + ".names");
                                delete it3->second;
                        }
                }
@@ -669,7 +732,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        
                        string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare.accnos";
                        m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       outputNames.push_back(rare); outputTypes["accnos"].push_back(rare); 
                        
                        for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
                                rout << (*itRare) << endl;
@@ -678,7 +741,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                
                        string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund.accnos";
                        m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
                        
                        for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
                                aout << (*itAbund) << endl;
@@ -723,7 +786,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");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".accnos");  outputTypes["accnos"].push_back(fileroot + tag + it3->first + ".accnos");
                                delete it3->second;
                        }
                }
@@ -748,11 +811,11 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        
                        string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare.groups";
                        m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       outputNames.push_back(rare); outputTypes["group"].push_back(rare);
                
                        string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund.groups";
                        m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       outputNames.push_back(abund); outputTypes["group"].push_back(abund);
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
                                vector<string> names;
@@ -817,7 +880,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");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".groups");  outputTypes["group"].push_back(fileroot + tag + it3->first + ".groups");
                                delete it3->second;
                        }
                }
@@ -842,11 +905,11 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        
                        string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare.fasta";
                        m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
                
                        string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund.fasta";
                        m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
                
                        //open input file
                        ifstream in;
@@ -937,7 +1000,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");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".fasta");  outputTypes["fasta"].push_back(fileroot + tag + it3->first + ".fasta");
                                delete it3->second;
                        }
                }
index df5bd55305a502803a8c1bfe36f24d60474061bb..02d61f3dc3b7f343a9e0d9a73bb71e84fcdacbbd 100644 (file)
@@ -28,7 +28,12 @@ class SplitAbundCommand : public Command {
        
 public:
        SplitAbundCommand(string);      
+       SplitAbundCommand();
        ~SplitAbundCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
 
@@ -45,6 +50,7 @@ private:
        int createNameMap(ListVector*);
        
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        ListVector* list;
        GroupMap* groupMap;
        InputData* input;
index 6f8788a28daed38deeed9b419b28b699cffb6b55..4be7a0ec8a82133a9eb4def8ee78bd47e0ecbe44 100644 (file)
 #include "splitgroupscommand.h"
 #include "sharedutilities.h"
 
+//**********************************************************************************************************************
+vector<string> SplitGroupCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"name","group","groups","fasta","outputdir","inputdir"}; 
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitGroupCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitGroupCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitGroupCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitGroupCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitGroupCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SplitGroupCommand::SplitGroupCommand(){        
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitGroupCommand", "SplitGroupCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 SplitGroupCommand::SplitGroupCommand(string option)  {
        try {
@@ -33,7 +81,12 @@ SplitGroupCommand::SplitGroupCommand(string option)  {
                        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["fasta"] = tempOutNames;
+                       outputTypes["name"] = 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 = "";          }
@@ -187,13 +240,13 @@ int SplitGroupCommand::splitFasta() {
                        temp = new ofstream;
                        filehandles[Groups[i]+"fasta"] = temp;
                        m->openOutputFile(filerootFasta + Groups[i] + ".fasta", *(filehandles[Groups[i]+"fasta"]));
-                       outputNames.push_back(filerootFasta + Groups[i] + ".fasta");
+                       outputNames.push_back(filerootFasta + Groups[i] + ".fasta"); outputTypes["fasta"].push_back(filerootFasta + Groups[i] + ".fasta");
                        
                        if (namefile != "") {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+"name"] = temp2;
                                m->openOutputFile(filerootName + Groups[i] + ".names", *(filehandles[Groups[i]+"name"]));
-                               outputNames.push_back(filerootName + Groups[i] + ".names");
+                               outputNames.push_back(filerootName + Groups[i] + ".names"); outputTypes["name"].push_back(filerootFasta + Groups[i] + ".names");
                        }
                }
                        
index f6e8760e11ef8e02661dc275f22bc94414aa1517..c45c7ff6b386111ba34897c3e13ff213e832b79f 100644 (file)
@@ -24,7 +24,12 @@ class SplitGroupCommand : public Command {
        
 public:
        SplitGroupCommand(string);      
+       SplitGroupCommand();
        ~SplitGroupCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
 
@@ -34,6 +39,7 @@ private:
        int splitFasta(); 
        
        vector<string> outputNames;
+       map<string, vector<string> > outputTypes;
        map<string, vector<string> > nameMap;
        map<string, vector<string> >::iterator itNames;
        GroupMap* groupMap;
index b7a3b49362dbd7c67f54649ba1b846a5c7cf6c79..dcc5b50ef8b396d9186c755c3ba949f9c789cf64 100644 (file)
@@ -24,12 +24,13 @@ SplitMatrix::SplitMatrix(string distfile, string name, string tax, float c, stri
 }
 /***********************************************************************/
 
-SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, string t, int p, string output){
+SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, float cu, string t, int p, string output){
        m = MothurOut::getInstance();
        fastafile = ffile;
        namefile = name;
        taxFile = tax;
-       cutoff = c;
+       cutoff = c;  //tax level cutoff
+       distCutoff = cu; //for fasta method if you are creating distance matrix you need a cutoff for that
        method = t;
        processors = p;
        outputDir = output;
@@ -181,7 +182,7 @@ int SplitMatrix::createDistanceFilesFromTax(map<string, int>& seqGroup, int numG
                //process each distance file
                for (int i = 0; i < numGroups; i++) { 
                        
-                       string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(cutoff);
+                       string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff);
                        
                        Command* command = new DistanceCommand(options);
                        command->execute();
index acaa8c5b711a220e76e48be2fc983122514d6b32..4ff316073789b694916a75fae5d2081a813d96c7 100644 (file)
@@ -20,7 +20,7 @@ class SplitMatrix  {
        public:
 
                SplitMatrix(string, string, string, float, string, bool); //column formatted distance file, namesfile, cutoff, method, large
-               SplitMatrix(string, string, string, float, string, int, string); //fastafile, namefile, taxFile, cutoff, method, processors, outputDir
+               SplitMatrix(string, string, string, float, float, string, int, string); //fastafile, namefile, taxFile, taxcutoff, cutoff, method, processors, outputDir
                
                ~SplitMatrix();
                int split();
@@ -32,7 +32,7 @@ class SplitMatrix  {
 
                string distFile, namefile, singleton, method, taxFile, fastafile, outputDir;
                vector< map< string, string> > dists;
-               float cutoff;
+               float cutoff, distCutoff;
                bool large;
                int processors;
                                
index 638119543480ffe0a8364379edfef0b184c526bf..17258159b7562dbee9830a03746602d935bb43a6 100644 (file)
 #include "solow.h"
 #include "shen.h"
 
+//**********************************************************************************************************************
+vector<string> SummaryCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"label","calc","abund","size","outputdir","groupmode","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummaryCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SummaryCommand::SummaryCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["summary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummaryCommand", "SummaryCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SummaryCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummaryCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SummaryCommand::getRequiredFiles(){     
+       try {
+               string AlignArray[] =  {"shared","list","rabund","sabund","or"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummaryCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SummaryCommand::SummaryCommand(string option)  {
@@ -62,6 +109,10 @@ SummaryCommand::SummaryCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["summary"] = tempOutNames;
+                       
                        //make sure the user has already run the read.otu command
                        if ((globaldata->getSharedFile() == "") && (globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund, rabund or shared file before you can use the summary.single command."); m->mothurOutEndLine(); abort = true; }
                        
@@ -144,8 +195,6 @@ int SummaryCommand::execute(){
        
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
                else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
@@ -162,7 +211,7 @@ int SummaryCommand::execute(){
                        
                        string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "summary";
                        globaldata->inputFileName = inputFileNames[p];
-                       outputNames.push_back(fileNameRoot);
+                       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();
index 7c7ee2c8eea829a9c6dc95fa794df5fcccc7bda1..d225109359d4950ad88be6a1ff41dd49cf062251 100644 (file)
@@ -22,7 +22,12 @@ class SummaryCommand : public Command {
 
 public:
        SummaryCommand(string);
+       SummaryCommand();
        ~SummaryCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -39,7 +44,8 @@ private:
        set<string> labels; //holds labels to be used
        string label, calc, outputDir;
        vector<string>  Estimators;
-       vector<string> inputFileNames;
+       vector<string> inputFileNames, outputNames;
+       map<string, vector<string> > outputTypes;
        vector<string> groups;
        
        vector<string> parseSharedFile(string);
index 3069a6ffbd8a43f1a0d3c956d3d3190769404a07..99c62a53c0580d51859673288a7955b7347442ae 100644 (file)
 #include "sharedjackknife.h"
 #include "whittaker.h"
 
-
+//**********************************************************************************************************************
+vector<string> SummarySharedCommand::getValidParameters(){     
+       try {
+               string Array[] =  {"label","calc","groups","all","outputdir","distance","inputdir", "processors"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummarySharedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SummarySharedCommand::SummarySharedCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["summary"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SummarySharedCommand::getRequiredParameters(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummarySharedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SummarySharedCommand::getRequiredFiles(){       
+       try {
+               string Array[] =  {"shared"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummarySharedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SummarySharedCommand::SummarySharedCommand(string option)  {
@@ -66,6 +112,10 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                                 m->mothurOut("You must read a list and a group, or a shared before you can use the summary.shared command."); m->mothurOutEndLine(); abort = true; 
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["summary"] = 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 = ""; 
@@ -398,8 +448,8 @@ int SummarySharedCommand::execute(){
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               if (mult) { m->mothurOut(outAllFileName); m->mothurOutEndLine();        }
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
+               if (mult) { m->mothurOut(outAllFileName); m->mothurOutEndLine();        outputTypes["summary"].push_back(outAllFileName); }
+               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    } outputTypes["summary"].push_back(outputFileName);
                m->mothurOutEndLine();
 
                return 0;
index c0172645387d4846aca623d4bfbe7827ca08cd74..077181220a836f6b118f68008996b411f81822fa 100644 (file)
@@ -23,7 +23,12 @@ class SummarySharedCommand : public Command {
 
 public:
        SummarySharedCommand(string);
+       SummarySharedCommand();
        ~SummarySharedCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -43,6 +48,7 @@ private:
        set<string> labels; //holds labels to be used
        string label, calc, groups;
        vector<string>  Estimators, Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        vector<SharedRAbundVector*> lookup;
        string format, outputDir;
        int numGroups, processors;
index 708724a4e5cd46643e7ec29464b61c1f34c7cd41..fb250d7fe96cb4ed38df8c0ce33d1c7e17911945 100644 (file)
@@ -9,6 +9,39 @@
 
 #include "systemcommand.h"
 
+//**********************************************************************************************************************
+vector<string> SystemCommand::getValidParameters(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SystemCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SystemCommand::getRequiredParameters(){ 
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SystemCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SystemCommand::getRequiredFiles(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SystemCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 SystemCommand::SystemCommand(string option)  {
index 410a12e7657a1c0625281429e261a519dccf45ef..3b48642aeec3b1cb5e4fc9e1a24d152d09dccc94 100644 (file)
@@ -18,13 +18,20 @@ class SystemCommand : public Command {
        public:
        
                SystemCommand(string);  
-               ~SystemCommand(){};
+               SystemCommand() {}
+               ~SystemCommand(){}
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
                
        private:
                string command;
                bool abort;
+               vector<string> outputNames;
+               map<string, vector<string> > outputTypes;
                
 };
 
index 3403b9934dfb9366d066a64ed5552484b2e4275c..a36e599fb3b04c01d2651423382566a26e7ac6d7 100644 (file)
 #include "sharedmorisitahorn.h"
 #include "sharedbraycurtis.h"
 
-
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"label","calc","groups", "phylip", "column", "name", "precision","cutoff","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TreeGroupCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+TreeGroupCommand::TreeGroupCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TreeGroupCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getRequiredFiles(){   
+       try {
+               string Array[] =  {"phylip","column","shared","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TreeGroupCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 TreeGroupCommand::TreeGroupCommand(string option)  {
@@ -50,6 +96,10 @@ TreeGroupCommand::TreeGroupCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["tree"] = 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 = "";          }
@@ -324,7 +374,7 @@ int TreeGroupCommand::execute(){
 
                        //create a new filename
                        outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "tre";   
-                       outputNames.push_back(outputFile);
+                       outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
                                
                        createTree();
                        
@@ -595,7 +645,7 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                
                                        //create a new filename
                                        outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";                                
-                                       outputNames.push_back(outputFile);
+                                       outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
                                                                                                
                                        for (int k = 0; k < thisLookup.size(); k++) { 
                                                for (int l = k; l < thisLookup.size(); l++) {
index 3e8fbb01c4df3c34540a11342a5a960a03788145..c61c9fbfa63bf84a2482955ca20aa914f89b9400 100644 (file)
@@ -35,7 +35,12 @@ class TreeGroupCommand : public Command {
        
 public:
        TreeGroupCommand(string);       
+       TreeGroupCommand();
        ~TreeGroupCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();  
        void help();
        
@@ -64,6 +69,7 @@ private:
        int numGroups;
        ofstream out;
        float precision, cutoff;
+       map<string, vector<string> > outputTypes;
 
        bool abort, allLines;
        set<string> labels; //holds labels to be used
index 1d70fb17d7fd7391de4a147ea73367c67f96f786..1f8dc579a986350d51d88f3be2e84cd9617f90d7 100644 (file)
 #include "trimseqscommand.h"
 #include "needlemanoverlap.hpp"
 
+//**********************************************************************************************************************
+vector<string> TrimSeqsCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"fasta", "flip", "oligos", "maxambig", "maxhomop", "minlength", "maxlength", "qfile", 
+                                                                       "qthreshold", "qwindowaverage", "qstepsize", "qwindowsize", "qaverage", "rollaverage", "allfiles", "qtrim","tdiffs", "pdiffs", "bdiffs", "processors", "outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TrimSeqsCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+TrimSeqsCommand::TrimSeqsCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+               outputTypes["qual"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> TrimSeqsCommand::getRequiredParameters(){       
+       try {
+               string Array[] =  {"fasta"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TrimSeqsCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> TrimSeqsCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "TrimSeqsCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //***************************************************************************************************************
 
 TrimSeqsCommand::TrimSeqsCommand(string option)  {
@@ -39,6 +89,12 @@ TrimSeqsCommand::TrimSeqsCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;
+                       outputTypes["qual"] = tempOutNames;
+                       outputTypes["group"] = 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 = "";          }
@@ -72,7 +128,7 @@ TrimSeqsCommand::TrimSeqsCommand(string option)  {
                        
                        //check for required parameters
                        fastaFile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastaFile == "not found") { m->mothurOut("fasta is a required parameter for the screen.seqs command."); m->mothurOutEndLine(); abort = true; }
+                       if (fastaFile == "not found") { m->mothurOut("fasta is a required parameter for the trim.seqs command."); m->mothurOutEndLine(); abort = true; }
                        else if (fastaFile == "not open") { abort = true; }     
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
@@ -220,18 +276,18 @@ int TrimSeqsCommand::execute(){
                numRPrimers = 0;
                
                string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
-               outputNames.push_back(trimSeqFile);
+               outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
                string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.fasta";
-               outputNames.push_back(scrapSeqFile);
+               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";
-               if (qFileName != "") {  outputNames.push_back(trimQualFile); outputNames.push_back(scrapQualFile);  }
+               if (qFileName != "") {  outputNames.push_back(trimQualFile); outputNames.push_back(scrapQualFile);  outputTypes["qual"].push_back(trimQualFile); outputTypes["qual"].push_back(scrapQualFile); }
                string groupFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "groups";
                
                vector<string> fastaFileNames;
                vector<string> qualFileNames;
                if(oligoFile != ""){
-                       outputNames.push_back(groupFile);
+                       outputNames.push_back(groupFile); outputTypes["group"].push_back(groupFile);
                        getOligos(fastaFileNames, qualFileNames);
                }
 
@@ -339,7 +395,7 @@ int TrimSeqsCommand::execute(){
                                ofstream outGroups;
                                string outGroupFilename = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "groups";
                                m->openOutputFile(outGroupFilename, outGroups);
-                               outputNames.push_back(outGroupFilename);
+                               outputNames.push_back(outGroupFilename); outputTypes["group"].push_back(outGroupFilename);  
                                
                                string thisGroup = "";
                                if (i > comboStarts) {
@@ -791,8 +847,10 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec, vector<string>& out
                                                        }
                                                }else {
                                                        outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
+                                                       outputTypes["fasta"].push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
                                                        if(qFileName != ""){
                                                                outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
+                                                               outputTypes["qual"].push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
                                                        }                                                       
                                                }
                                        }
@@ -814,11 +872,13 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec, vector<string>& out
                                        groupVector.push_back(group);
                                        
                                        if(allFiles){
+                                               outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
                                                outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
                                                outFASTAVec.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
                                                if(qFileName != ""){
                                                        outQualVec.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
                                                        outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
+                                                       outputTypes["qual"].push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
                                                }                                                       
                                        }
                                }else{  m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine();  }
@@ -835,12 +895,14 @@ void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec, vector<string>& out
                                for (map<string, int>::iterator itPrime = primers.begin(); itPrime != primers.end(); itPrime++) {
                                        if (groupVector[itPrime->second] != "") { //there is a group for this primer
                                                outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
+                                               outputTypes["fasta"].push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
                                                outFASTAVec.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
                                                combos[(groupVector[itBar->second] + "." + groupVector[itPrime->second])] = outFASTAVec.size()-1;
                                                
                                                if(qFileName != ""){
                                                        outQualVec.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
                                                        outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
+                                                       outputTypes["qual"].push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
                                                }
                                        }
                                }
index 93e8c776918ec9fa2d6f661d7c178380a4f47d66..20b11a85ac05e57b453906475d73ab4fd2ecb2e0 100644 (file)
 class TrimSeqsCommand : public Command {
 public:
        TrimSeqsCommand(string);
+       TrimSeqsCommand();
        ~TrimSeqsCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -39,6 +44,7 @@ private:
        bool cullAmbigs(Sequence&);
        bool compareDNASeq(string, string);
        int countDiffs(string, string);
+       map<string, vector<string> > outputTypes;
 
        bool abort;
        string fastaFile, oligoFile, qFileName, outputDir;
index 88df73d44c97b4311e1c1ce8b20a0f815b072f12..b2d439b4e1b5481f87dc244df980c5a8c475eea2 100644 (file)
@@ -9,6 +9,56 @@
 
 #include "unifracunweightedcommand.h"
 
+//**********************************************************************************************************************
+vector<string> UnifracUnweightedCommand::getValidParameters(){ 
+       try {
+               string Array[] =  {"groups","iters","distance","random", "processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracUnweightedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+UnifracUnweightedCommand::UnifracUnweightedCommand(){  
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["unweighted"] = tempOutNames;
+               outputTypes["uwsummary"] = tempOutNames;
+               outputTypes["phylip"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> UnifracUnweightedCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracUnweightedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> UnifracUnweightedCommand::getRequiredFiles(){   
+       try {
+               string Array[] =  {"tree","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracUnweightedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /***********************************************************/
 UnifracUnweightedCommand::UnifracUnweightedCommand(string option)  {
        try {
@@ -34,6 +84,12 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["unweighted"] = tempOutNames;
+                       outputTypes["uwsummary"] = tempOutNames;
+                       outputTypes["phylip"] = tempOutNames;
+                       
                        if (globaldata->gTree.size() == 0) {//no trees were read
                                m->mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); m->mothurOutEndLine(); abort = true;  }
                        
@@ -77,7 +133,7 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option)  {
                                T = globaldata->gTree;
                                tmap = globaldata->gTreemap;
                                sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
-                               outputNames.push_back(sumFile);
+                               outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile);
                                m->openOutputFile(sumFile, outSum);
                                
                                util = new SharedUtil();
@@ -151,6 +207,7 @@ int UnifracUnweightedCommand::execute() {
                        if (random)  {  
                                output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".unweighted", itersString);
                                outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".unweighted");
+                               outputTypes["unweighted"].push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".unweighted");
                        }
                        
                        
@@ -316,7 +373,7 @@ void UnifracUnweightedCommand::printUWSummaryFile(int i) {
 void UnifracUnweightedCommand::createPhylipFile(int i) {
        try {
                string phylipFileName = outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".unweighted.dist";
-               outputNames.push_back(phylipFileName);
+               outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
                
                ofstream out;
                m->openOutputFile(phylipFileName, out);
index 3e6d8354af5eda2c21f85c632a09b886962afb37..91f005c2500b9011b9149f3b7a18996c00af5c6f 100644 (file)
@@ -23,7 +23,12 @@ class UnifracUnweightedCommand : public Command {
        
        public:
                UnifracUnweightedCommand(string);       
+               UnifracUnweightedCommand();
                ~UnifracUnweightedCommand() { globaldata->Groups.clear();  if (abort == false) { delete unweighted; delete util; } }
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();
                void help();    
        
@@ -48,6 +53,7 @@ class UnifracUnweightedCommand : public Command {
                bool abort, phylip, random;
                string groups, itersString, outputDir;
                vector<string> Groups, outputNames; //holds groups to be used
+               map<string, vector<string> > outputTypes;
 
                ofstream outSum, out;
                ifstream inFile;
index e8add90a259bac0da04bf2b8d52be247e9fc1fd1..9f961a9a6658683a3661290757ebe01048002371 100644 (file)
@@ -9,6 +9,56 @@
 
 #include "unifracweightedcommand.h"
 
+//**********************************************************************************************************************
+vector<string> UnifracWeightedCommand::getValidParameters(){   
+       try {
+               string Array[] =  {"groups","iters","distance","random","processors","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracWeightedCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+UnifracWeightedCommand::UnifracWeightedCommand(){      
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["weighted"] = tempOutNames;
+               outputTypes["wsummary"] = tempOutNames;
+               outputTypes["phylip"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> UnifracWeightedCommand::getRequiredParameters(){        
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracWeightedCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> UnifracWeightedCommand::getRequiredFiles(){     
+       try {
+               string Array[] =  {"tree","group"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "UnifracWeightedCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /***********************************************************/
 UnifracWeightedCommand::UnifracWeightedCommand(string option) {
        try {
@@ -34,6 +84,12 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["weighted"] = tempOutNames;
+                       outputTypes["wsummary"] = tempOutNames;
+                       outputTypes["phylip"] = tempOutNames;
+                       
                        if (globaldata->gTree.size() == 0) {//no trees were read
                                m->mothurOut("You must execute the read.tree command, before you may execute the unifrac.weighted command."); m->mothurOutEndLine(); abort = true;  }
                        
@@ -72,7 +128,7 @@ UnifracWeightedCommand::UnifracWeightedCommand(string option) {
                                tmap = globaldata->gTreemap;
                                sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".wsummary";
                                m->openOutputFile(sumFile, outSum);
-                               outputNames.push_back(sumFile);
+                               outputNames.push_back(sumFile);  outputTypes["wsummary"].push_back(sumFile);
                                
                                util = new SharedUtil();
                                string s; //to make work with setgroups
@@ -138,6 +194,7 @@ int UnifracWeightedCommand::execute() {
                        if (random) {  
                                output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".weighted", itersString);  
                                outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".weighted");
+                               outputTypes["weighted"].push_back(outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".weighted");
                        } 
 
                        userData = weighted->getValues(T[i], processors, outputDir);  //userData[0] = weightedscore
@@ -438,6 +495,7 @@ void UnifracWeightedCommand::createPhylipFile() {
                
                        string phylipFileName = outputDir + m->getSimpleName(globaldata->getTreeFile())  + toString(i+1) + ".weighted.dist";
                        outputNames.push_back(phylipFileName);
+                       outputTypes["phylip"].push_back(phylipFileName);
                        ofstream out;
                        m->openOutputFile(phylipFileName, out);
                        
index 7317c8a43092a5712a06dda00589d1eb4528c649..fa87d8fa2a705287045489f9cdfef7f3bf51901c 100644 (file)
@@ -24,7 +24,12 @@ class UnifracWeightedCommand : public Command {
        
        public:
                UnifracWeightedCommand(string);
+               UnifracWeightedCommand();
                ~UnifracWeightedCommand() { if (abort == false) {  delete weighted; delete util; } }
+               vector<string> getRequiredParameters();
+               vector<string> getValidParameters();
+               vector<string> getRequiredFiles();
+               map<string, vector<string> > getOutputFiles() { return outputTypes; }
                int execute();  
                void help();
        
@@ -58,6 +63,7 @@ class UnifracWeightedCommand : public Command {
                bool abort, phylip, random;
                string groups, itersString;
                vector<string> Groups, outputNames; //holds groups to be used
+               map<string, vector<string> > outputTypes;
                int processors;
 
                
index 2afc4a71486617b61308b651fef413895ba05b54..da6ad2c1cc0bd6cea255546890b303888a46d6d7 100644 (file)
@@ -170,10 +170,12 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                EstOutput results; results.resize(num);
                
                int count = 0;
+               int numLeaves = t->getNumLeaves();
                int total = num;
                int twentyPercent = (total * 0.20);
                if (twentyPercent == 0) { twentyPercent = 1; }
                
+               
                for (int h = start; h < (start+num); h++) {
                
                        if (m->control_pressed) { return results; }
@@ -181,6 +183,9 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                        double UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
                        double totalBL = 0.00;  //all branch lengths
                        double UW = 0.00;               //Unweighted Value = UniqueBL / totalBL;
+                       map<int, double> tempTotals; //maps node to total Branch Length
+                       map<int, int> nodePcountSize; //maps node to pcountSize
+                       map<int, int>::iterator itCount;
                                
                        for(int i=0;i<t->getNumNodes();i++){
                        
@@ -195,15 +200,38 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                                        map<string, int>::iterator itGroup = t->tree[i].pcount.find(namesOfGroupCombos[h][j]);
                                        if (itGroup != t->tree[i].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } } 
                                }
+
+                               nodePcountSize[i] = pcountSize;
                                
-                               if (pcountSize == 0) { }
-                               else if ((t->tree[i].getBranchLength() != -1) && (pcountSize == 1)) {  UniqueBL += abs(t->tree[i].getBranchLength());   }
+                               if (pcountSize == 0) { ; }
+                               else if ((t->tree[i].getBranchLength() != -1) && (pcountSize == 1)) {  UniqueBL += abs(t->tree[i].getBranchLength()); }
+                                                               
+                               //if you are a leaf from a users group add to total
+                               if (i < numLeaves) {
+                                       if ((t->tree[i].getBranchLength() != -1) && pcountSize != 0) {  
+                                               totalBL += abs(t->tree[i].getBranchLength()); 
+                                       }
+                                       tempTotals[i] = 0.0;  //we don't care about you, or we have already added you
+                               }else{ //if you are not a leaf 
+                                       //do both your chidren have have descendants from the users groups? 
+                                       int lc = t->tree[i].getLChild();
+                                       int rc = t->tree[i].getRChild();
                                        
-                               if ((t->tree[i].getBranchLength() != -1) && (pcountSize != 0)) {  
-                                       totalBL += abs(t->tree[i].getBranchLength()); 
+                                       //if yes, add to total your childrens branchLengths and your childrens tempTotals
+                                       if ((nodePcountSize[lc] != 0) && (nodePcountSize[rc] != 0)) {
+                                               totalBL += tempTotals[lc] + tempTotals[rc]; 
+                                               if (t->tree[i].getBranchLength() != -1) {
+                                                       tempTotals[i] = abs(t->tree[i].getBranchLength());
+                                               }else {
+                                                       tempTotals[i] = 0.0;
+                                               }
+                                               //tempTotals[i] = tempTotals[lc] + tempTotals[rc]; 
+                                       }else { //if no, your tempTotal is your childrens temp totals
+                                               tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(t->tree[i].getBranchLength()); 
+                                       }
                                }
                        }
-       
+                       
                        UW = (UniqueBL / totalBL);  
        
                        if (isnan(UW) || isinf(UW)) { UW = 0; }
@@ -384,6 +412,7 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                int count = 0;
                int total = num;
                int twentyPercent = (total * 0.20);
+               int numLeaves = t->getNumLeaves();
                
                Tree* copyTree = new Tree;
                
@@ -400,6 +429,8 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                        double UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
                        double totalBL = 0.00;  //all branch lengths
                        double UW = 0.00;               //Unweighted Value = UniqueBL / totalBL;
+                       map<int, double> tempTotals; //maps node to total Branch Length
+                       map<int, int> nodePcountSize; //maps node to pcountSize
                                
                        for(int i=0;i<copyTree->getNumNodes();i++){
                        
@@ -415,12 +446,36 @@ EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombo
                                        if (itGroup != copyTree->tree[i].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } } 
                                }
                                
+                               nodePcountSize[i] = pcountSize;
+                               
                                if (pcountSize == 0) { }
                                else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize == 1)) {  UniqueBL += abs(copyTree->tree[i].getBranchLength());     }
+                               
+                               //if you are a leaf from a users group add to total
+                               if (i < numLeaves) {
+                                       if ((copyTree->tree[i].getBranchLength() != -1) && pcountSize != 0) {  
+                                               totalBL += abs(copyTree->tree[i].getBranchLength()); 
+                                       }
+                                       tempTotals[i] = 0.0;  //we don't care about you, or we have already added you
+                               }else{ //if you are not a leaf 
+                                       //do both your chidren have have descendants from the users groups? 
+                                       int lc = copyTree->tree[i].getLChild();
+                                       int rc = copyTree->tree[i].getRChild();
                                        
-                               if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize != 0)) {  
-                                       totalBL += abs(copyTree->tree[i].getBranchLength()); 
+                                       //if yes, add to total your childrens branchLengths and your childrens tempTotals
+                                       if ((nodePcountSize[lc] != 0) && (nodePcountSize[rc] != 0)) {
+                                               totalBL += tempTotals[lc] + tempTotals[rc]; 
+                                               if (copyTree->tree[i].getBranchLength() != -1) {
+                                                       tempTotals[i] = abs(copyTree->tree[i].getBranchLength());
+                                               }else {
+                                                       tempTotals[i] = 0.0;
+                                               }
+                                               //tempTotals[i] = tempTotals[lc] + tempTotals[rc]; 
+                                       }else { //if no, your tempTotal is your childrens temp totals
+                                               tempTotals[i] = tempTotals[lc] + tempTotals[rc] + abs(copyTree->tree[i].getBranchLength()); 
+                                       }
                                }
+
                        }
                
                        UW = (UniqueBL / totalBL);  
index 50cd4e316186847b350a13b465f6d032ed91fcb8..cfe9d509112e921aef92c0cf914e10f6ca885079 100644 (file)
@@ -245,6 +245,16 @@ string ValidParameters::validFile(map<string, string>& container, string paramet
                                        }
                                }
                                
+                               //if you can't open it, try default location
+                               if (ableToOpen == 1) {
+                                       if (m->getOutputDir() != "") { //default path is set
+                                               string tryPath = m->getOutputDir() + m->getSimpleName(it->second);
+                                               m->mothurOut("Unable to open " + it->second + ". Trying output directory " + tryPath); m->mothurOutEndLine();
+                                               ableToOpen = m->openInputFile(tryPath, in, "noerror");
+                                               container[parameter] = tryPath;
+                                       }
+                               }
+                               
                                in.close();
 
                        #ifdef USE_MPI  
index 852ee8c7ccb79f2a6422448b4d46f3dd752d6c94..ab4f7a2fbff2da7e79ad8f5021dc10d074d8b688 100644 (file)
 #include "nseqs.h"
 
 
+//**********************************************************************************************************************
+vector<string> VennCommand::getValidParameters(){      
+       try {
+               string Array[] =  {"groups","label","calc","permute", "abund","nseqs","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+VennCommand::VennCommand(){    
+       try {
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["svg"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "VennCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> VennCommand::getRequiredParameters(){   
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> VennCommand::getRequiredFiles(){        
+       try {
+               string Array[] =  {"list","shared","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "VennCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 VennCommand::VennCommand(string option)  {
@@ -198,7 +245,6 @@ int VennCommand::execute(){
                if (abort == true) { return 0; }
                
                string lastLabel;
-               vector<string> outputNames;
                
                if (format == "sharedfile") {
                        //you have groups
@@ -247,7 +293,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  } }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -259,11 +305,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }                                       
                                }
                                
@@ -282,7 +328,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -294,11 +340,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }
                                                                                
                                        //restore real lastlabel to save below
@@ -348,7 +394,7 @@ int VennCommand::execute(){
                                                for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
                                        
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
 
                                        }else if ((lookup.size() > 4) && (perm)) {
                                                set< set<int> >::iterator it3;
@@ -360,11 +406,11 @@ int VennCommand::execute(){
                                                        for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
                                                        
                                                        vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
                                                }               
                                        }else {
                                                vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
                                        }
                                        
                                        for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
@@ -396,7 +442,7 @@ int VennCommand::execute(){
        
                                        m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                        vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -411,7 +457,7 @@ int VennCommand::execute(){
                                        
                                        m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                        vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                        
                                        processedLabels.insert(sabund->getLabel());
@@ -453,7 +499,7 @@ int VennCommand::execute(){
                                        
                                m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
                                vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); }  }
+                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
 
                                delete sabund;
                                        
index f6bdf395e20eeba3af9c7c7b4bba206daa9ebe56..29beeadc32f422f8b053e1da86f483032e496e8d 100644 (file)
@@ -24,7 +24,12 @@ class VennCommand : public Command {
 
 public:
        VennCommand(string);
+       VennCommand();
        ~VennCommand();
+       vector<string> getRequiredParameters();
+       vector<string> getValidParameters();
+       vector<string> getRequiredFiles();
+       map<string, vector<string> > getOutputFiles() { return outputTypes; }
        int execute();
        void help();
        
@@ -44,7 +49,8 @@ private:
        bool abort, allLines, nseqs, perm;
        set<string> labels; //holds labels to be used
        string format, groups, calc, label, outputDir;
-       vector<string> Estimators, Groups;
+       vector<string> Estimators, Groups, outputNames;
+       map<string, vector<string> > outputTypes;
        
        set< set<int> > findCombinations(int);
        int getCombos(set<int>, set< set<int> >&);