X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getrabundcommand.cpp;h=dd4fdd58178a0ce13467d5f45a00a105a8954fca;hb=e911fa88572a16ef40e0b51fb132ab6e02370797;hp=73862a85eda66077fdc51b9bbebc1dc579c8da02;hpb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2;p=mothur.git diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index 73862a8..dd4fdd5 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -24,7 +24,7 @@ GetRAbundCommand::GetRAbundCommand(string option){ else { //valid paramters for this command - string Array[] = {"line","label"}; + string Array[] = {"line","label","sorted"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -42,6 +42,11 @@ GetRAbundCommand::GetRAbundCommand(string option){ //check for optional parameter and set defaults // ...at some point should added some additional type checking... + + string temp; + temp = validParameter.validFile(parameters, "sorted", false); if (temp == "not found") { temp = "T"; } + sorted = isTrue(temp); + line = validParameter.validFile(parameters, "line", false); if (line == "not found") { line = ""; } else { @@ -82,10 +87,11 @@ GetRAbundCommand::GetRAbundCommand(string option){ void GetRAbundCommand::help(){ try { mothurOut("The get.rabund command can only be executed after a successful read.otu of a listfile.\n"); - mothurOut("The get.rabund command parameters are line and label. No parameters are required, and you may not use line and label at the same time.\n"); + mothurOut("The get.rabund command parameters are line, label and sorted. No parameters are required, and you may not use line and label at the same time.\n"); mothurOut("The line and label allow you to select what distance levels you would like included in your .rabund file, and are separated by dashes.\n"); - mothurOut("The get.rabund command should be in the following format: get.rabund(line=yourLines, label=yourLabels).\n"); - mothurOut("Example get.rabund(line=1-3-5).\n"); + mothurOut("The sorted parameters allows you to print the rabund results sorted by abundance or not. The default is sorted.\n"); + mothurOut("The get.rabund command should be in the following format: get.rabund(line=yourLines, label=yourLabels, sorted=yourSorted).\n"); + mothurOut("Example get.rabund(line=1-3-5, sorted=F).\n"); mothurOut("The default value for line and label are all lines in your inputfile.\n"); mothurOut("The get.rabund command outputs a .rabund file containing the lines you selected.\n"); mothurOut("Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines).\n\n"); @@ -128,10 +134,13 @@ int GetRAbundCommand::execute(){ while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { if(allLines == 1 || lines.count(count) == 1 || labels.count(list->getLabel()) == 1){ - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); - rabund = new RAbundVector(); + mothurOut(list->getLabel()); mothurOutEndLine(); + rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - rabund->print(out); + + if(sorted) { rabund->print(out); } + else { rabund->nonSortedPrint(out); } + delete rabund; processedLabels.insert(list->getLabel()); @@ -143,10 +152,13 @@ int GetRAbundCommand::execute(){ delete list; list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - rabund->print(out); + + if(sorted) { rabund->print(out); } + else { rabund->nonSortedPrint(out); } + delete rabund; processedLabels.insert(list->getLabel()); @@ -175,13 +187,16 @@ int GetRAbundCommand::execute(){ //run last line if you need to if (needToRun == true) { - delete list; + if (list != NULL) { delete list; } list = input->getListVector(lastLabel); - mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine(); + mothurOut(list->getLabel()); mothurOutEndLine(); rabund = new RAbundVector(); *rabund = (list->getRAbundVector()); - rabund->print(out); + + if(sorted) { rabund->print(out); } + else { rabund->nonSortedPrint(out); } + delete rabund; delete list; }