From 5e031adc86a1fc125c4abb3d4048f209d52f9b6d Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 15 Mar 2011 19:40:48 +0000 Subject: [PATCH] adding current file class --- aligncommand.cpp | 1 + aligncommand.h | 2 ++ amovacommand.cpp | 8 ++++---- anosimcommand.cpp | 20 +++++++++++--------- command.hpp | 5 ++--- currentfile.cpp | 2 ++ currentfile.h | 37 ++++++++++++++++++++----------------- 7 files changed, 42 insertions(+), 33 deletions(-) diff --git a/aligncommand.cpp b/aligncommand.cpp index cfedd3b..77e99c0 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -79,6 +79,7 @@ AlignCommand::AlignCommand(){ AlignCommand::AlignCommand(string option) { try { abort = false; calledHelp = false; + currentFiles = CurrentFile::getInstance(); //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true;} diff --git a/aligncommand.h b/aligncommand.h index 169b435..d519e91 100644 --- a/aligncommand.h +++ b/aligncommand.h @@ -15,6 +15,7 @@ #include "database.hpp" #include "alignment.hpp" #include "alignmentdb.h" +#include "mothurfiles.h" class AlignCommand : public Command { @@ -59,6 +60,7 @@ private: vector outputNames; bool abort, flip, calledHelp; + CurrentFile* currentFiles; }; diff --git a/amovacommand.cpp b/amovacommand.cpp index 74fbda7..13c8b26 100644 --- a/amovacommand.cpp +++ b/amovacommand.cpp @@ -119,8 +119,8 @@ AmovaCommand::AmovaCommand(string option) { phylipFileName = ""; //check currentFiles for a phylip file - if (currentFiles->getPhylipFile() != "") { phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine(); - }else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true; } + //if (currentFiles->getPhylipFile() != "") { phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine(); + //}else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true; } } //check for required parameters @@ -130,8 +130,8 @@ AmovaCommand::AmovaCommand(string option) { designFileName = ""; //check currentFiles for a design file - if (currentFiles->getDesignFile() != "") { designFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + designFileName + " as phylip file."); m->mothurOutEndLine(); - }else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true; } + //if (currentFiles->getDesignFile() != "") { designFileName = currentFiles->getDesignFile(); m->mothurOut("Using " + designFileName + " as design file."); m->mothurOutEndLine(); + //}else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true; } } string temp = validParameter.validFile(parameters, "iters", false); diff --git a/anosimcommand.cpp b/anosimcommand.cpp index bb0f495..443cf8a 100644 --- a/anosimcommand.cpp +++ b/anosimcommand.cpp @@ -115,12 +115,12 @@ AnosimCommand::AnosimCommand(string option) { phylipFileName = validParameter.validFile(parameters, "phylip", true); if (phylipFileName == "not open") { phylipFileName = ""; abort = true; } - else if (phylipFileName == "not found") { phylipFileName = ""; } - else if (designFileName == "not found") { - designFileName = ""; - m->mothurOut("You must provide an phylip file."); - m->mothurOutEndLine(); - abort = true; + else if (phylipFileName == "not found") { + phylipFileName = ""; + + //check currentFiles for a phylip file + //if (currentFiles->getPhylipFile() != "") { phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine(); + //}else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true; } } //check for required parameters @@ -128,9 +128,11 @@ AnosimCommand::AnosimCommand(string option) { if (designFileName == "not open") { abort = true; } else if (designFileName == "not found") { designFileName = ""; - m->mothurOut("You must provide an design file."); - m->mothurOutEndLine(); - abort = true; + + //check currentFiles for a design file + //if (currentFiles->getDesignFile() != "") { designFileName = currentFiles->getDesignFile(); m->mothurOut("Using " + designFileName + " as design file."); m->mothurOutEndLine(); + //}else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true; } + } string temp = validParameter.validFile(parameters, "iters", false); diff --git a/command.hpp b/command.hpp index 2d1981a..f65f6cc 100644 --- a/command.hpp +++ b/command.hpp @@ -17,12 +17,11 @@ #include "optionparser.h" #include "validparameter.h" #include "mothurout.h" -#include "currentfile.h" class Command { public: - Command() { m = MothurOut::getInstance(); currentFiles = CurrentFile::getInstance(); } + Command() { m = MothurOut::getInstance(); } virtual vector getValidParameters() = 0; virtual vector getRequiredParameters() = 0; //adding "or" as the last element indicates one of the previous is needed virtual vector getRequiredFiles() = 0; //adding "or" as the last element indicates one of the previous is needed @@ -32,7 +31,7 @@ class Command { virtual ~Command() { } protected: MothurOut* m; - CurrentFile* currentFiles; + bool calledHelp; map >::iterator itTypes; diff --git a/currentfile.cpp b/currentfile.cpp index 6990a2a..cf4800a 100644 --- a/currentfile.cpp +++ b/currentfile.cpp @@ -18,6 +18,8 @@ CurrentFile* CurrentFile::getInstance() { } /*********************************************************************************************/ CurrentFile::CurrentFile() { + m = MothurOut::getInstance(); + phylipfile = ""; columnfile = ""; listfile = ""; diff --git a/currentfile.h b/currentfile.h index 8acf2a9..b763971 100644 --- a/currentfile.h +++ b/currentfile.h @@ -10,6 +10,7 @@ * */ +#include "mothurout.h" #include "mothur.h" /***********************************************/ @@ -39,31 +40,33 @@ public: string getOligosFile() { return oligosfile; } - void setListFile(string f) { listfile = f; } - void setTreeFile(string f) { treefile = f; } - void setGroupFile(string f) { groupfile = f; } - void setPhylipFile(string f) { phylipfile = f; } - void setColumnFile(string f) { columnfile = f; } - void setNameFile(string f) { namefile = f; } - void setRabundFile(string f) { rabundfile = f; } - void setSabundFile(string f) { sabundfile = f; } - void setSharedFile(string f) { sharedfile = f; } - void setRelAbundFile(string f) { relabundfile = f; } - void setOrderFile(string f) { orderfile = f; } - void setOrderGroupFile(string f) { ordergroupfile = f; } - void setDesignFile(string f) { designfile = f; } - void setFastaFile(string f) { fastafile = f; } - void setSFFFile(string f) { sfffile = f; } - void setQualFile(string f) { qualfile = f; } - void setOligosFile(string f) { oligosfile = f; } + void setListFile(string f) { listfile = m->getFullPathName(f); } + void setTreeFile(string f) { treefile = m->getFullPathName(f); } + void setGroupFile(string f) { groupfile = m->getFullPathName(f); } + void setPhylipFile(string f) { phylipfile = m->getFullPathName(f); } + void setColumnFile(string f) { columnfile = m->getFullPathName(f); } + void setNameFile(string f) { namefile = m->getFullPathName(f); } + void setRabundFile(string f) { rabundfile = m->getFullPathName(f); } + void setSabundFile(string f) { sabundfile = m->getFullPathName(f); } + void setSharedFile(string f) { sharedfile = m->getFullPathName(f); } + void setRelAbundFile(string f) { relabundfile = m->getFullPathName(f); } + void setOrderFile(string f) { orderfile = m->getFullPathName(f); } + void setOrderGroupFile(string f) { ordergroupfile = m->getFullPathName(f); } + void setDesignFile(string f) { designfile = m->getFullPathName(f); } + void setFastaFile(string f) { fastafile = m->getFullPathName(f); } + void setSFFFile(string f) { sfffile = m->getFullPathName(f); } + void setQualFile(string f) { qualfile = m->getFullPathName(f); } + void setOligosFile(string f) { oligosfile = m->getFullPathName(f); } private: + static CurrentFile* _uniqueInstance; CurrentFile( const CurrentFile& ); // Disable copy constructor void operator=( const CurrentFile& ); // Disable assignment operator CurrentFile(); ~CurrentFile(); + MothurOut* m; string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile; string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; -- 2.39.2