X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=treegroupscommand.cpp;h=c115c54ce1bcb39786ec7c54fcd4ba11df3115ab;hb=72ebb6fa35b45b149812d47c2b1cb8acaca64659;hp=27f701ffd20da0ea1d83a011b575a5d9fb5ea956;hpb=e911fa88572a16ef40e0b51fb132ab6e02370797;p=mothur.git diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 27f701f..c115c54 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -27,7 +27,6 @@ TreeGroupCommand::TreeGroupCommand(string option){ globaldata = GlobalData::getInstance(); abort = false; allLines = 1; - lines.clear(); labels.clear(); Groups.clear(); Estimators.clear(); @@ -37,7 +36,7 @@ TreeGroupCommand::TreeGroupCommand(string option){ else { //valid paramters for this command - string Array[] = {"line","label","calc","groups", "phylip", "column", "name", "precision","cutoff"}; + string Array[] = {"label","calc","groups", "phylip", "column", "name", "precision","cutoff"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -78,13 +77,6 @@ TreeGroupCommand::TreeGroupCommand(string option){ //check for optional parameter and set defaults // ...at some point should added some additional type checking... - line = validParameter.validFile(parameters, "line", false); - if (line == "not found") { line = ""; } - else { - if(line != "all") { splitAtDash(line, lines); allLines = 0; } - else { allLines = 1; } - } - label = validParameter.validFile(parameters, "label", false); if (label == "not found") { label = ""; } else { @@ -92,13 +84,10 @@ TreeGroupCommand::TreeGroupCommand(string option){ else { allLines = 1; } } - //make sure user did not use both the line and label parameters - if ((line != "") && (label != "")) { mothurOut("You cannot use both the line and label parameters at the same time. "); mothurOutEndLine(); abort = true; } - //if the user has not specified any line or labels use the ones from read.otu - else if((line == "") && (label == "")) { + //if the user has not specified any labels use the ones from read.otu + if(label == "") { allLines = globaldata->allLines; labels = globaldata->labels; - lines = globaldata->lines; } groups = validParameter.validFile(parameters, "groups", false); @@ -172,13 +161,13 @@ void TreeGroupCommand::help(){ try { mothurOut("The tree.shared command creates a .tre to represent the similiarity between groups or sequences.\n"); mothurOut("The tree.shared command can only be executed after a successful read.otu command or by providing a distance file.\n"); - mothurOut("The tree.shared command parameters are groups, calc, phylip, column, name, cutoff, precision, line and label. You may not use line and label at the same time.\n"); + mothurOut("The tree.shared command parameters are groups, calc, phylip, column, name, cutoff, precision and label.\n"); mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n"); - mothurOut("The group names are separated by dashes. The line and label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n"); + mothurOut("The group names are separated by dashes. The label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n"); mothurOut("The phylip or column parameter are required if you do not run the read.otu command first, and only one may be used. If you use a column file the name filename is required. \n"); mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n"); - mothurOut("The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels).\n"); - mothurOut("Example tree.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorabund).\n"); + mothurOut("The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n"); + mothurOut("Example tree.shared(groups=A-B-C, calc=jabund-sorabund).\n"); mothurOut("The default value for groups is all the groups in your groupfile.\n"); mothurOut("The default value for calc is jclass-thetayc.\n"); mothurOut("The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose.\n"); @@ -199,9 +188,9 @@ void TreeGroupCommand::help(){ TreeGroupCommand::~TreeGroupCommand(){ if (abort == false) { - if (format == "sharedfile") { delete read; delete input; globaldata->ginput = NULL;} + if (format == "sharedfile") { delete read; delete input; globaldata->ginput = NULL; } else { delete readMatrix; delete matrix; delete list; } - delete tmap; + delete tmap; globaldata->gTreemap = NULL; delete validCalculator; } @@ -427,7 +416,6 @@ void TreeGroupCommand::makeSimsDist() { /***********************************************************/ void TreeGroupCommand::makeSimsShared() { try { - int count = 1; //clear globaldatas old tree names if any globaldata->Treenames.clear(); @@ -442,21 +430,21 @@ void TreeGroupCommand::makeSimsShared() { set processedLabels; set userLabels = labels; - set userLines = lines; - + //as long as you are not at the end of the file or done wih the lines you want - while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) { + while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { - if(allLines == 1 || lines.count(count) == 1 || labels.count(lookup[0]->getLabel()) == 1){ + if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){ mothurOut(lookup[0]->getLabel()); mothurOutEndLine(); process(lookup); processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); - userLines.erase(count); } if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) { + string saveLabel = lookup[0]->getLabel(); + for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(lastLabel); @@ -465,6 +453,9 @@ void TreeGroupCommand::makeSimsShared() { processedLabels.insert(lookup[0]->getLabel()); userLabels.erase(lookup[0]->getLabel()); + + //restore real lastlabel to save below + lookup[0]->setLabel(saveLabel); } lastLabel = lookup[0]->getLabel(); @@ -472,7 +463,6 @@ void TreeGroupCommand::makeSimsShared() { //get next line to process for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup = input->getSharedRAbundVectors(); - count++; } //output error messages about any remaining user labels @@ -488,7 +478,7 @@ void TreeGroupCommand::makeSimsShared() { } } - //run last line if you need to + //run last label if you need to if (needToRun == true) { for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } } lookup = input->getSharedRAbundVectors(lastLabel);