1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
/*
* getcurrentcommand.cpp
* Mothur
*
* Created by westcott on 3/16/11.
* Copyright 2011 Schloss Lab. All rights reserved.
*
*/
#include "getcurrentcommand.h"
//**********************************************************************************************************************
vector<string> GetCurrentCommand::setParameters(){
try {
CommandParameter pclear("clear", "String", "", "", "", "", "","",false,false); parameters.push_back(pclear);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
return myArray;
}
catch(exception& e) {
m->errorOut(e, "GetCurrentCommand", "setParameters");
exit(1);
}
}
//**********************************************************************************************************************
string GetCurrentCommand::getHelpString(){
try {
string helpString = "";
helpString += "The get.current command outputs the current files saved by mothur.\n";
helpString += "The get.current command has one parameter: clear.\n";
helpString += "The clear parameter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n";
helpString += "The get.current command should be in the following format: \n";
helpString += "get.current() or get.current(clear=fasta-name-accnos)\n";
return helpString;
}
catch(exception& e) {
m->errorOut(e, "GetCurrentCommand", "getHelpString");
exit(1);
}
}
//**********************************************************************************************************************
GetCurrentCommand::GetCurrentCommand(){
try {
abort = true; calledHelp = true;
setParameters();
}
catch(exception& e) {
m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
exit(1);
}
}
//**********************************************************************************************************************
GetCurrentCommand::GetCurrentCommand(string option) {
try {
abort = false; calledHelp = false;
//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else {
vector<string> myArray = setParameters();
OptionParser parser(option);
map<string,string> parameters = parser.getParameters();
ValidParameters validParameter;
//check to make sure all parameters are valid for command
for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
clearTypes = validParameter.validFile(parameters, "clear", false);
if (clearTypes == "not found") { clearTypes = ""; }
else { m->splitAtDash(clearTypes, types); }
}
}
catch(exception& e) {
m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
exit(1);
}
}
//**********************************************************************************************************************
int GetCurrentCommand::execute(){
try {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
cFactory = CommandFactory::getInstance();
//user wants to clear a type
if (types.size() != 0) {
for (int i = 0; i < types.size(); i++) {
if (m->control_pressed) { break; }
//look for file types
if (types[i] == "fasta") {
m->setFastaFile("");
}else if (types[i] == "qfile") {
m->setQualFile("");
}else if (types[i] == "phylip") {
m->setPhylipFile("");
}else if (types[i] == "column") {
m->setColumnFile("");
}else if (types[i] == "list") {
m->setListFile("");
}else if (types[i] == "rabund") {
m->setRabundFile("");
}else if (types[i] == "sabund") {
m->setSabundFile("");
}else if (types[i] == "name") {
m->setNameFile("");
}else if (types[i] == "group") {
m->setGroupFile("");
}else if (types[i] == "order") {
m->setOrderFile("");
}else if (types[i] == "ordergroup") {
m->setOrderGroupFile("");
}else if (types[i] == "tree") {
m->setTreeFile("");
}else if (types[i] == "shared") {
m->setSharedFile("");
}else if (types[i] == "relabund") {
m->setRelAbundFile("");
}else if (types[i] == "design") {
m->setDesignFile("");
}else if (types[i] == "sff") {
m->setSFFFile("");
}else if (types[i] == "oligos") {
m->setOligosFile("");
}else if (types[i] == "accnos") {
m->setAccnosFile("");
}else if (types[i] == "taxonomy") {
m->setTaxonomyFile("");
}else if (types[i] == "flow") {
m->setFlowFile("");
}else if (types[i] == "biom") {
m->setBiomFile("");
}else if (types[i] == "count") {
m->setCountTableFile("");
}else if (types[i] == "summary") {
m->setSummaryFile("");
}else if (types[i] == "processors") {
m->setProcessors("1");
}else if (types[i] == "all") {
m->clearCurrentFiles();
}else {
m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
}
}
}
if (m->hasCurrentFiles()) {
m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
m->printCurrentFiles();
}
string inputDir = cFactory->getInputDir();
if (inputDir != "") {
m->mothurOutEndLine(); m->mothurOut("Current input directory saved by mothur: " + inputDir); m->mothurOutEndLine();
}
string outputDir = cFactory->getOutputDir();
if (outputDir != "") {
m->mothurOutEndLine(); m->mothurOut("Current output directory saved by mothur: " + outputDir); m->mothurOutEndLine();
}
string defaultPath = m->getDefaultPath();
if (defaultPath != "") {
m->mothurOutEndLine(); m->mothurOut("Current default directory saved by mothur: " + defaultPath); m->mothurOutEndLine();
}
string temp = "./";
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
#else
temp = ".\\";
#endif
temp = m->getFullPathName(temp);
m->mothurOutEndLine(); m->mothurOut("Current working directory: " + temp); m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
m->errorOut(e, "GetCurrentCommand", "execute");
exit(1);
}
}
//**********************************************************************************************************************
|