X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=consensuscommand.cpp;h=e522b098f0703d6909f1906c3039fb4459e99854;hb=8dd3c225255d7084e3aff8740aa4f1f1cabb367a;hp=a7469902d44cb9f16b4a109f8e0bc7a0182f7f86;hpb=8bc3e5b38c2317a1715f53be22fa96455868c281;p=mothur.git diff --git a/consensuscommand.cpp b/consensuscommand.cpp index a746990..e522b09 100644 --- a/consensuscommand.cpp +++ b/consensuscommand.cpp @@ -10,43 +10,41 @@ #include "consensuscommand.h" //********************************************************************************************************************** -vector ConcensusCommand::getValidParameters(){ +vector ConcensusCommand::setParameters(){ try { - vector myArray; + vector myArray; + for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } return myArray; } catch(exception& e) { - m->errorOut(e, "ConcensusCommand", "getValidParameters"); + m->errorOut(e, "ConcensusCommand", "setParameters"); exit(1); } } //********************************************************************************************************************** -vector ConcensusCommand::getRequiredParameters(){ +string ConcensusCommand::getHelpString(){ try { - vector myArray; - return myArray; - } - catch(exception& e) { - m->errorOut(e, "ConcensusCommand", "getRequiredParameters"); - exit(1); - } -} -//********************************************************************************************************************** -vector ConcensusCommand::getRequiredFiles(){ - try { - string AlignArray[] = {"tree","group"}; - vector myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string))); - return myArray; + string helpString = ""; + helpString += "The consensus command can only be executed after a successful read.tree command.\n"; + helpString += "The consensus command has no parameters.\n"; + helpString += "The consensus command should be in the following format: consensus().\n"; + helpString += "The consensus command output two files: .consensus.tre and .consensuspairs.\n"; + helpString += "The .consensus.tre file contains the consensus tree of the trees in your input file.\n"; + helpString += "The branch lengths are the percentage of trees in your input file that had the given pair.\n"; + helpString += "The .consensuspairs file contains a list of the internal nodes in your tree. For each node, the pair that was used in the consensus tree \n"; + helpString += "is reported with its percentage, as well as the other pairs that were seen for that node but not used and their percentages.\n"; + return helpString; } catch(exception& e) { - m->errorOut(e, "ConcensusCommand", "getRequiredFiles"); + m->errorOut(e, "ConcensusCommand", "getHelpString"); exit(1); } } //********************************************************************************************************************** ConcensusCommand::ConcensusCommand(){ try { - //initialize outputTypes + abort = true; calledHelp = true; + setParameters(); vector tempOutNames; outputTypes["tree"] = tempOutNames; outputTypes["nodepairs"] = tempOutNames; @@ -60,8 +58,9 @@ ConcensusCommand::ConcensusCommand(){ ConcensusCommand::ConcensusCommand(string fileroot) { try { - globaldata = GlobalData::getInstance(); - abort = false; + abort = false; calledHelp = false; + + setParameters(); //initialize outputTypes vector tempOutNames; @@ -69,8 +68,6 @@ ConcensusCommand::ConcensusCommand(string fileroot) { outputTypes["nodepairs"] = tempOutNames; filename = fileroot; - - t = globaldata->gTree; } catch(exception& e) { @@ -78,40 +75,20 @@ ConcensusCommand::ConcensusCommand(string fileroot) { exit(1); } } - -//********************************************************************************************************************** - -void ConcensusCommand::help(){ - try { - m->mothurOut("The consensus command can only be executed after a successful read.tree command.\n"); - m->mothurOut("The consensus command has no parameters.\n"); - m->mothurOut("The consensus command should be in the following format: consensus().\n"); - m->mothurOut("The consensus command output two files: .consensus.tre and .consensuspairs.\n"); - m->mothurOut("The .consensus.tre file contains the consensus tree of the trees in your input file.\n"); - m->mothurOut("The branch lengths are the percentage of trees in your input file that had the given pair.\n"); - m->mothurOut("The .consensuspairs file contains a list of the internal nodes in your tree. For each node, the pair that was used in the consensus tree \n"); - m->mothurOut("is reported with its percentage, as well as the other pairs that were seen for that node but not used and their percentages.\n\n"); - } - catch(exception& e) { - m->errorOut(e, "ConcensusCommand", "help"); - exit(1); - } -} - -//********************************************************************************************************************** - -ConcensusCommand::~ConcensusCommand(){} - //********************************************************************************************************************** int ConcensusCommand::execute(){ try { - if (abort == true) { return 0; } - else { - numNodes = t[0]->getNumNodes(); - numLeaves = t[0]->getNumLeaves(); - } + if (abort == true) { if (calledHelp) { return 0; } return 2; } + + + m->mothurOut("This command is not currently in use."); m->mothurOutEndLine(); + /* + t = globaldata->gTree; + numNodes = t[0]->getNumNodes(); + numLeaves = t[0]->getNumLeaves(); + //get the possible pairings getSets(); @@ -205,12 +182,19 @@ int ConcensusCommand::execute(){ outputFile = filename + ".cons.tre"; outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); m->openOutputFile(outputFile, out); - consensusTree->printForBoot(out); + consensusTree->print(out, "boot"); out.close(); out2.close(); delete consensusTree; + //set first tree file as new current treefile + string currentTree = ""; + itTypes = outputTypes.find("tree"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); } + } + */ return 0; } catch(exception& e) {