X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=listseqscommand.cpp;h=cf884705cb26f341ef08713b118af32fd49c5bdf;hp=7c3f07f96e092d81c307673192dad29a31fee091;hb=050a3ff02473a3d4c0980964e1a9ebe52e55d6b8;hpb=ea4f373c28543cd1002b0dd7dc6e55c526647d59 diff --git a/listseqscommand.cpp b/listseqscommand.cpp index 7c3f07f..cf88470 100644 --- a/listseqscommand.cpp +++ b/listseqscommand.cpp @@ -16,15 +16,15 @@ //********************************************************************************************************************** vector ListSeqsCommand::setParameters(){ try { - CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pfasta); - CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pname); - CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pcount); - CommandParameter pgroup("group", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pgroup); - CommandParameter plist("list", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(plist); - CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy); - CommandParameter palignreport("alignreport", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(palignreport); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pfasta); + CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pname); + CommandParameter pcount("count", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pcount); + CommandParameter pgroup("group", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(pgroup); + CommandParameter plist("list", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(plist); + CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false,true); parameters.push_back(ptaxonomy); + CommandParameter palignreport("alignreport", "InputTypes", "", "", "FNGLT", "FNGLT", "none","accnos",false,false); parameters.push_back(palignreport); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -52,24 +52,19 @@ string ListSeqsCommand::getHelpString(){ } } //********************************************************************************************************************** -string ListSeqsCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string ListSeqsCommand::getOutputPattern(string type) { + try { + string pattern = ""; - //is this a type this command creates - it = outputTypes.find(type); - if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } - else { - if (type == "accnos") { outputFileName = "accnos"; } - else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } - } - return outputFileName; - } - catch(exception& e) { - m->errorOut(e, "ListSeqsCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "accnos") { pattern = "[filename],accnos"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "ListSeqsCommand", "getOutputPattern"); + exit(1); + } } //********************************************************************************************************************** ListSeqsCommand::ListSeqsCommand(){ @@ -249,7 +244,9 @@ int ListSeqsCommand::execute(){ if (outputDir == "") { outputDir += m->hasPath(inputFileName); } - string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + getOutputFileNameTag("accnos"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFileName)); + string outputFileName = getOutputFileName("accnos", variables); ofstream out; m->openOutputFile(outputFileName, out); @@ -269,7 +266,7 @@ int ListSeqsCommand::execute(){ m->setAccnosFile(outputFileName); m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); @@ -300,7 +297,7 @@ int ListSeqsCommand::readFasta(){ //ofstream out; //string newFastaName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "numsAdded.fasta"; //m->openOutputFile(newFastaName, out); - //int count = 1; + int count = 1; //string lastName = ""; while(!in.eof()){ @@ -313,7 +310,7 @@ int ListSeqsCommand::readFasta(){ if (name != "") { names.push_back(name); } m->gobble(in); - //count++; + if (m->debug) { count++; cout << "[DEBUG]: count = " + toString(count) + ", name = " + currSeq.getName() + "\n"; } } in.close(); //out.close(); @@ -418,7 +415,7 @@ int ListSeqsCommand::readGroup(){ int ListSeqsCommand::readCount(){ try { CountTable ct; - ct.readTable(countfile); + ct.readTable(countfile, false); if (m->control_pressed) { return 0; }