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 */,
//**********************************************************************************************************************
-
+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
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 = ""; }
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) {
exit(1);
}
}
-
//**********************************************************************************************************************
AlignCommand::~AlignCommand(){
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();
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
//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;
//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);
}
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; }
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; }
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
}
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();
vector<int> processIDS; //processid
vector<linePair*> lines;
bool MPIWroteAccnos;
+ map<string, vector<string> > outputTypes;
AlignmentDB* templateDB;
Alignment* alignment;
float match, misMatch, gapOpen, gapExtend, threshold;
int processors, kmerSize;
vector<string> candidateFileNames;
+ vector<string> outputNames;
bool abort, flip;
};
//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;
#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 {
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 = "";
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();
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();
ofstream out;
ifstream in, inNames;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
void readNamesFile();
int process(ListVector*);
#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();
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 = "";
//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();
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();
string outputFile, calc, groups, label, outputDir;
int numGroups, iters;
vector<string> Estimators, Groups, outputNames; //holds estimators to be used
+ map< string, vector<string> > outputTypes;
};
#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 {
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 = ""; }
//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);
if (abort == true) { return 0; }
- vector<string> outputNames;
-
//prepare full output directory
outputDir = m->getFullPathName(outputDir);
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();
string outputDir, sabundfile, rabundfile, listfile, format;
bool abort, allLines;
set<string> labels;
+ vector<string> outputNames;
+ map< string, vector<string> > outputTypes;
string process(SAbundVector*);
};
#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;
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 = ""; }
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) {
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;
#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;
}
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();
int processors, window, increment, numSeqs;
Chimera* chimera;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
vector<string> fastaFileNames;
};
#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;
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);
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 = ""; }
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) {
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
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";
//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);
//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
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);
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;
#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
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();
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();
Chimera* chimera;
vector<string> fastaFileNames;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#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;
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 = ""; }
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) {
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) {
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
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
//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++) {
//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];
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);
}
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;
#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;
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();
vector<string> fastaFileNames;
vector<string> nameFileNames;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#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;
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 = ""; }
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) {
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();
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
//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);
//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
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);
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;
#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
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();
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();
int processors, window, increment, numSeqs, templateSeqsLength;
Chimera* chimera;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
vector<string> fastaFileNames;
#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) {}
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;
};
#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;
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 = ""; }
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) {
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();
//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);
//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
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);
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
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();
}
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();
Chimera* chimera;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
vector<string> fastaFileNames;
};
#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;
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 = ""; }
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);
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();
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();
string fastafile, outputDir, keep;
bool abort, countGaps;
int numbases;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
string getChopped(Sequence);
+
};
#endif
#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{
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 = ""; }
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))) {
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());
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());
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();
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++) {
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();
vector<string> outputNames;
map<string, string> nameMap;
map<string, string> taxMap;
+ map<string, vector<string> > outputTypes;
int readNamesFile();
int readTaxonomyFile();
#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;
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 = ""; }
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) {
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) {
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) {
if (m->control_pressed) { delete classify; return 0; }
- vector<string> outputNames;
for (int s = 0; s < fastaFileNames.size(); s++) {
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;
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());
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
//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;
//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);
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 {
}
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;
//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);
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();
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;
#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 {
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 = ""; }
//prepare filename
string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
+ outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
vector<char*> cPara;
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") {
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();
}
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();
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;
};
/****************************************************************************/
#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) {
}
}
+ //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 = ""; }
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");
}
}
}
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;
}
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();
void printData(string label);
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#endif
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;
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 = ""; }
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;
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();
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();
#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) {
}
}
+ //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
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();
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;
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();
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;
#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 {
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 = ""; }
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]));
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");
}
}
}
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;
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;
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;
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;
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();
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
#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();
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 = ""; }
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");
}
}
}
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();
}
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;
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();
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();
set<string> labels; //holds labels to be used
string label, calc, groups, outputDir;
vector<string> Estimators, Groups, outputNames;
+ map<string, vector<string> > outputTypes;
};
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() { }
#include "getlineagecommand.h"
#include "removelineagecommand.h"
#include "parsefastaqcommand.h"
+#include "pipelinepdscommand.h"
/*******************************************************/
m = MothurOut::getInstance();
command = new NoCommand(s);
+ shellcommand = new NoCommand(s);
+ pipecommand = new NoCommand(s);
outputDir = ""; inputDir = "";
logFileName = "";
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";
CommandFactory::~CommandFactory(){
_uniqueInstance = 0;
delete command;
+ delete shellcommand;
+ delete pipecommand;
}
/***********************************************************/
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;
}
}
/***********************************************************/
+
+/***********************************************************/
+//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 {
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 {
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
\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
#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) {
globaldata = GlobalData::getInstance();
abort = false;
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["tree"] = tempOutNames;
+ outputTypes["nodepairs"] = tempOutNames;
+
filename = fileroot;
t = globaldata->gTree;
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();
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);
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();
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>);
#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 {
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 = ""; }
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();
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;
};
#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;
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 = ""; }
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) {
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() != "") {
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();
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();
string fastafile, outputDir;
vector<string> outputNames;
vector<string> fastaFileNames;
-
+ map<string, vector<string> > outputTypes;
};
#endif
#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;
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 = ""; }
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) {
}else { //assume square
outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist";
remove(outputFile.c_str());
+ outputTypes["phylip"].push_back(outputFile);
}
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);
//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");
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;
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);
#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);
}
#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;
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;
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();
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);
int length = 0;
int start = 0;
int end = 0;
+ bool overlap = false;
string seqA = A.getAligned();
string seqB = B.getAligned();
if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
start = i;
// cout << "start: " << start << endl;
+ overlap = true;
break;
}
}
if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
end = i;
// cout << "end: " << end << endl;
+ overlap = true;
break;
}
}
}
}
+ //non-overlapping sequences
+ if (!overlap) { length = 0; }
+
if(length == 0) { dist = 1.0000; }
else { dist = ((double)diff / (double)length); }
string name, sequence, line;
sequence = "";
string temp;
-
+ map<string, string>::iterator itName;
+
+
while(!in.eof()){
if (m->control_pressed) { break; }
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.
#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;
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 = ""; }
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) {
m->mothurOutEndLine(); m->mothurOutEndLine();
- if (m->control_pressed) { return 0; }
+ if (m->control_pressed) { outputTypes.clear(); return 0; }
#ifdef USE_MPI
int pid;
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
}
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();
if (m->control_pressed) { return 1; }
#endif
#endif
- outputNames.push_back(filteredFasta);
+ outputNames.push_back(filteredFasta); outputTypes["fasta"].push_back(filteredFasta);
}
return 0;
\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
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
#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 {
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 = ""; }
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++;
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;
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();
GlobalData* globaldata;
GroupMap* groupMap;
string outputFile, sharedfile;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
ofstream out;
ifstream in;
bool abort;
#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) {
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();
GlobalData* globaldata;
string filename;
bool abort;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#endif
#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;
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 = ""; }
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();
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;
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;
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;
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;
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;
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;
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();
vector<string> outputNames;
string fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir, taxons;
bool abort, dups;
+ map<string, vector<string> > outputTypes;
int readFasta();
int readName();
#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 {
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
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;
}
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;
}
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;
}
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();
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();
string label, listfile, outputDir, sort;
ofstream out;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
void process(ListVector*);
};
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();
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 = ""; }
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;
}
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;
}
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;
}
}
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;
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];
}
}
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";
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();
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*);
#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();
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; }
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))) {
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); }
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); }
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); }
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();
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();
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
#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();
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 = "";
//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){
//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;
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;
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();
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);
#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();
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 = "";
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))) {
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());
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());
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;
}
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;
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();
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
#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;
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 = ""; }
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();
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;
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;
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;
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;
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;
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;
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();
vector<string> outputNames;
string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir;
bool abort, dups;
+ map<string, vector<string> > outputTypes;
int readFasta();
int readName();
#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 {
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 = ""; }
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); }
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;
}
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();
}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
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; }
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();
map<string, string>::iterator it;
vector<Sequence> seqs;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
int process(ListVector*);
#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) {
}
}
+ //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
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");
}
}
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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();
time_t start;
unsigned long loops;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
void printData(string label);
};
#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) {
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 = "";
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;
}
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());
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());
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;
}
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]; }
}
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());
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());
}
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;
}
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;
}
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;
}
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());
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());
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;
}
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]; }
}
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;
}
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();
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;
#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) {
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 = ""; }
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();
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());
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());
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]; }
}
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;
}
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();
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();
#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) {
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:
int diff = 0;
int length = 0;
int start = 0;
+ bool overlap = false;
string seqA = A.getAligned();
string seqB = B.getAligned();
for(int i=0;i<alignLength;i++){
if(seqA[i] != '.' && seqB[i] != '.'){
start = i;
+ overlap = true;
break;
}
}
length++;
}
}
+
+ //non-overlapping sequences
+ if (!overlap) { length = 0; }
if(length == 0) { dist = 1.0000; }
else { dist = ((double)diff / (double)length); }
#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) {
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 = "";
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
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);
}
}
}
- 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;
//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();
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);
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);
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();
bool abort;
string outputFile, groups, userform, savegroups, outputDir;
vector<string> Groups, outputNames; //holds groups to be used
+ map<string, vector<string> > outputTypes;
};
#endif
#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) {
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 = ""; }
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());
//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;
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;
#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) {
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 = ""; }
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) {
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);
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; }
}
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;
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();
string fastaFileName, groups, outputDir, filename;
vector<string> fastaFileNames;
- vector<string> groupsNames;
+ vector<string> groupsNames, outputNames;
+ map<string, vector<string> > outputTypes;
bool abort;
};
#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) {
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 = "";
//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();
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;
}
}
- 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) {
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();
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();
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();
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;
};
#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) {
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 = ""; }
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); }
}
}
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
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;
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;
#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) {
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 = "";
//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){
//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;
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();
//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());
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();
ReadOTUFile* read;
InputData* input;
vector<SharedRAbundVector*> lookup;
+ map<string, vector<string> > outputTypes;
bool abort, allLines, pickedGroups;
set<string> labels; //holds labels to be used
#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 {
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 = ""; }
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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();
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();
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;
}
}
/*********************************************************************************************/
+void MothurOut::setOutputDir(string pathname) {
+ try {
+ outputDir = pathname;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setOutputDir");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
void MothurOut::closeLog() {
try {
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; }
~MothurOut();
string logFileName;
- string defaultPath;
+ string defaultPath, outputDir;
string releaseDate, version;
ofstream out;
#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) {}
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;
};
#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) {
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 = "";
//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){
//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;
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;
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();
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);
int minLength = 0;
int start = 0;
int end = 0;
+ bool overlap = false;
string seqA = A.getAligned();
string seqB = B.getAligned();
if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
start = i;
// cout << "start: " << start << endl;
+ overlap = true;
break;
}
}
if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
end = i;
// cout << "end: " << end << endl;
+ overlap = true;
break;
}
}
openGapB = 0;
}
}
-
+
+ //non-overlapping sequences
+ if (!overlap) { minLength = 0; }
+
if(minLength == 0) { dist = 1.0000; }
else { dist = (double)difference / minLength; }
}
#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 {
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 = ""; }
//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) {
//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);
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;
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();
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();
#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 {
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 = ""; }
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);
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();
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;
#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 {
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 = ""; }
//set fileroot
string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
- vector<string> outputNames;
//fill filehandles with neccessary ofstreams
int i;
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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();
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;
#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){
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 = ""; }
}
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++){
*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);
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);
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);
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();
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);
#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 {
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
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();
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
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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();
bool abort;
string groups, itersString;
vector<string> Groups, outputNames; //holds groups to be used
+ map<string, vector<string> > outputTypes;
void printParsimonyFile();
int printUSummaryFile();
#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) {
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; }
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++){
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();
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> >&);
#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 {
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()); }
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();
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();
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);
#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 {
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 = ""; }
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
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
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();
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;
--- /dev/null
+/*
+ * 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);
+ }
+}
+
+//**********************************************************************************************************************
--- /dev/null
+#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
+
//**********************************************************************************************************************
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 {
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 = ""; }
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;
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();
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();
#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) {
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
#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();
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 = "";
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"); }
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");
}
}
}
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();
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);
#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) {
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; }
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");
}
}
}
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();
set<string> labels; //holds labels to be used
string label, calc, groups, outputDir;
vector<string> Estimators, Groups, outputNames;
+ map<string, vector<string> > outputTypes;
};
#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();
time_t start = time(NULL);
size_t numDists = 0;
- vector<string> outputNames;
-
if (format == "matrix") {
ifstream in;
m->openInputFile(distFileName, in);
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();
string distFileName, format, method;
string phylipfile, columnfile, namefile, groupfile, outputDir;
NameAssignment* nameMap;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
bool abort, sim;
#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 {
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
//m->mothurOutEndLine();
}
+ outputTypes = shared->getOutputFiles();
+
delete shared;
}
return 0;
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();
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
#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 {
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");
}
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();
string filename, treefile, groupfile, namefile;
bool abort;
map<string, string> nameMap;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
int readNamesFile();
int numUniquesInName;
#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;
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 = ""; }
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;
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;
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;
}
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;
}
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;
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;
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;
#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;
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 = ""; }
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;
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;
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;
}
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;
}
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;
}
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;
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();
string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir;
bool abort, dups;
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
int readFasta();
int readName();
#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) {
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 = ""; }
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");
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();
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();
bool abort;
string fasta, outputDir;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#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) {
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)));
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 = ""; }
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);
}
}
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");
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");
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";
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){
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();
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);
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);
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);
+ }
+}
//***************************************************************************************************************
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()){
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
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();
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
#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) {
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 = ""; }
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;
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();
string mapfile, fastafile, outputDir;
bool abort;
int seqLength, haderror;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
void readMap();
statData getStats(string sequence);
#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) {
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 = ""; }
if (abort == true) { return 0; }
setUpOutput();
+ outputNames.push_back(sensSpecFileName); outputTypes["sensspec"].push_back(sensSpecFileName);
if(format == "phylip") { processPhylip(); }
else if(format == "column") { processColumn(); }
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();
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;
#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) {
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
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 = ""; }
errorFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".errors";
m->openOutputFile(errorFileName, errorFile);
+ outputNames.push_back(errorFileName); outputTypes["error"].push_back(errorFileName);
printErrorHeader();
}
}
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");
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();
double threshold;
int numRefs;
ofstream errorFile;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
vector<Sequence> referenceSeqs;
};
#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) {
}
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["summary"] = tempOutNames;
+
//check for required parameters
fastafile = validParameter.validFile(parameters, "fasta", true);
if (fastafile == "not open") { abort = true; }
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
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();
bool abort;
string fastafile, outputDir;
int processors;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
struct linePair {
unsigned long int start;
#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) {
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();
CommandFactory* commandFactory;
string output, input, tempdefault;
bool abort;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#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) {
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();
CommandFactory* commandFactory;
string name;
bool abort, append;
+ vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
};
#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) {
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 = ""; }
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) {
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) {
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);
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();
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&);
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;
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"));
}
}
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() {}
int readOrderFile();
bool isValidGroup(string, vector<string>);
int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
+ map<string, vector<string> > outputTypes;
GlobalData* globaldata;
ReadOTUFile* read;
#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 {
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 = ""; }
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());
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"));
}
}
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++) {
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;
}
}
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;
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;
//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;
}
}
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;
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;
}
}
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;
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;
}
}
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();
int createNameMap(ListVector*);
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
ListVector* list;
GroupMap* groupMap;
InputData* input;
#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 {
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 = ""; }
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");
}
}
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();
int splitFasta();
vector<string> outputNames;
+ map<string, vector<string> > outputTypes;
map<string, vector<string> > nameMap;
map<string, vector<string> >::iterator itNames;
GroupMap* groupMap;
}
/***********************************************************************/
-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;
//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();
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();
string distFile, namefile, singleton, method, taxFile, fastafile, outputDir;
vector< map< string, string> > dists;
- float cutoff;
+ float cutoff, distCutoff;
bool large;
int processors;
#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) {
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; }
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"); }
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();
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();
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);
#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) {
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 = "";
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;
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();
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;
#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) {
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;
};
#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) {
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 = ""; }
//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();
//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++) {
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();
int numGroups;
ofstream out;
float precision, cutoff;
+ map<string, vector<string> > outputTypes;
bool abort, allLines;
set<string> labels; //holds labels to be used
#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) {
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 = ""; }
//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
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);
}
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) {
}
}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"));
}
}
}
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(); }
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"));
}
}
}
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();
bool cullAmbigs(Sequence&);
bool compareDNASeq(string, string);
int countDiffs(string, string);
+ map<string, vector<string> > outputTypes;
bool abort;
string fastaFile, oligoFile, qFileName, outputDir;
#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 {
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; }
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();
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");
}
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);
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();
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;
#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 {
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; }
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
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
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);
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();
bool abort, phylip, random;
string groups, itersString;
vector<string> Groups, outputNames; //holds groups to be used
+ map<string, vector<string> > outputTypes;
int processors;
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; }
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++){
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; }
int count = 0;
int total = num;
int twentyPercent = (total * 0.20);
+ int numLeaves = t->getNumLeaves();
Tree* copyTree = new Tree;
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++){
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);
}
}
+ //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
#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) {
if (abort == true) { return 0; }
string lastLabel;
- vector<string> outputNames;
if (format == "sharedfile") {
//you have groups
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;
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 = 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;
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
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;
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]; }
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());
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());
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;
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();
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> >&);