X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=splitabundcommand.cpp;h=8131fa9195f6b8d939b27891605dd862d618964b;hb=72e0be6b9c80009d4dbee24e8d690ad9514dc6fb;hp=810b83915dadb9ed8863340dcfb27ac34e286dd8;hpb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6;p=mothur.git diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp index 810b839..8131fa9 100644 --- a/splitabundcommand.cpp +++ b/splitabundcommand.cpp @@ -48,7 +48,7 @@ string SplitAbundCommand::getHelpString(){ helpString += "If you want .abund and .rare files for all groups, set groups=all. \n"; helpString += "The split.abund command should be used in the following format: split.abund(fasta=yourFasta, list=yourListFile, group=yourGroupFile, label=yourLabels, cutoff=yourCutoff).\n"; helpString += "Example: split.abund(fasta=abrecovery.fasta, list=abrecovery.fn.list, group=abrecovery.groups, label=0.03, cutoff=2).\n"; - helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n\n"; + helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n"; return helpString; } catch(exception& e) { @@ -82,11 +82,9 @@ SplitAbundCommand::SplitAbundCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } - + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { - //valid paramters for this command - string Array[] = {"name","group","list","label","accnos","groups","fasta","cutoff","outputdir","inputdir"}; // - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + vector myArray = setParameters(); OptionParser parser(option); map parameters = parser.getParameters(); @@ -154,12 +152,12 @@ SplitAbundCommand::SplitAbundCommand(string option) { listfile = validParameter.validFile(parameters, "list", true); if (listfile == "not open") { abort = true; } else if (listfile == "not found") { listfile = ""; } - else{ inputFile = listfile; } + else{ inputFile = listfile; m->setListFile(listfile); } namefile = validParameter.validFile(parameters, "name", true); if (namefile == "not open") { abort = true; } else if (namefile == "not found") { namefile = ""; } - else{ inputFile = namefile; } + else{ inputFile = namefile; m->setNameFile(namefile); } fastafile = validParameter.validFile(parameters, "fasta", true); if (fastafile == "not open") { abort = true; } @@ -167,7 +165,7 @@ SplitAbundCommand::SplitAbundCommand(string option) { fastafile = m->getFastaFile(); if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; } - } + }else { m->setFastaFile(fastafile); } groupfile = validParameter.validFile(parameters, "group", true); if (groupfile == "not open") { groupfile = ""; abort = true; } @@ -177,13 +175,13 @@ SplitAbundCommand::SplitAbundCommand(string option) { int error = groupMap->readMap(); if (error == 1) { abort = true; } - + m->setGroupFile(groupfile); } groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else if (groups == "all") { - if (groupfile != "") { Groups = groupMap->namesOfGroups; } + if (groupfile != "") { Groups = groupMap->getNamesOfGroups(); } else { m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = ""; } }else { m->splitAtDash(groups, Groups); @@ -215,10 +213,9 @@ SplitAbundCommand::SplitAbundCommand(string option) { accnos = m->isTrue(temp); temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "0"; } - convert(temp, cutoff); + m->mothurConvert(temp, cutoff); if (cutoff == 0) { m->mothurOut("You must provide a cutoff to qualify what is abundant for the split.abund command. "); m->mothurOutEndLine(); abort = true; } - } } @@ -252,11 +249,11 @@ int SplitAbundCommand::execute(){ if (namefile != "") { readNamesFile(); } else { createNameMap(list); } - 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) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - 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) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if(allLines == 1 || labels.count(list->getLabel()) == 1){ @@ -290,7 +287,7 @@ int SplitAbundCommand::execute(){ list = input->getListVector(); //get new list vector to process } - if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //output error messages about any remaining user labels set::iterator it; @@ -306,7 +303,7 @@ int SplitAbundCommand::execute(){ } - if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //run last label if you need to if (needToRun == true) { @@ -321,7 +318,7 @@ int SplitAbundCommand::execute(){ 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) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } }else { //you are using the namefile to determine abundance if (outputDir == "") { outputDir = m->hasPath(namefile); }