X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=concensuscommand.cpp;h=30da32cfe05db5de942cebd213cf9cc9631cb717;hb=510b1cfc25cd79391d6973ca20c5ec25fb1bb3b2;hp=01df253a0dfbcbb18d37f9adb1cc241ad3ff78ce;hpb=c76b65598a0b85183126bd764c83f354e9f490d1;p=mothur.git diff --git a/concensuscommand.cpp b/concensuscommand.cpp index 01df253..30da32c 100644 --- a/concensuscommand.cpp +++ b/concensuscommand.cpp @@ -11,20 +11,47 @@ //********************************************************************************************************************** -ConcensusCommand::ConcensusCommand(){ +ConcensusCommand::ConcensusCommand(string option){ try { globaldata = GlobalData::getInstance(); - t = globaldata->gTree; + abort = false; + + //allow user to run help + if(option == "help") { help(); abort = true; } + + else { + if (option != "") { mothurOut("There are no valid parameters for the concensus command."); mothurOutEndLine(); abort = true; } + + //no trees were read + if (globaldata->gTree.size() == 0) { mothurOut("You must execute the read.tree command, before you may use the concensus command."); mothurOutEndLine(); abort = true; } + else { t = globaldata->gTree; } + } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function ConcensusCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "ConcensusCommand"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function ConcensusCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; +} + +//********************************************************************************************************************** + +void ConcensusCommand::help(){ + try { + mothurOut("The concensus command can only be executed after a successful read.tree command.\n"); + mothurOut("The concensus command has no parameters.\n"); + mothurOut("The concensus command should be in the following format: concensus().\n"); + mothurOut("The concensus command output two files: .concensus.tre and .concensuspairs.\n"); + mothurOut("The .concensus.tre file contains the concensus tree of the trees in your input file.\n"); + mothurOut("The branch lengths are the percentage of trees in your input file that had the given pair.\n"); + mothurOut("The .concensuspairs file contains a list of the internal nodes in your tree. For each node, the pair that was used in the concensus tree \n"); + 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) { + errorOut(e, "ConcensusCommand", "help"); exit(1); - } + } } + //********************************************************************************************************************** ConcensusCommand::~ConcensusCommand(){} @@ -34,7 +61,7 @@ ConcensusCommand::~ConcensusCommand(){} int ConcensusCommand::execute(){ try { - if (t.size() == 0) { return 0; } + if (abort == true) { return 0; } else { numNodes = t[0]->getNumNodes(); numLeaves = t[0]->getNumLeaves(); @@ -43,16 +70,6 @@ int ConcensusCommand::execute(){ //get the possible pairings getSets(); - //print out pairings for testing - /*cout << "possible pairing " << endl; - for (it2 = nodePairs.begin(); it2 != nodePairs.end(); it2++) { - for (int i = 0; i < it2->first.size(); i++) { - cout << it2->first[i] << " "; - } - cout << '\t' << it2->second << endl; - }*/ - - //open file for pairing not included in the tree notIncluded = getRootName(globaldata->inputFileName) + "concensuspairs"; openOutputFile(notIncluded, out2); @@ -135,13 +152,9 @@ int ConcensusCommand::execute(){ return 0; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "execute"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //********************************************************************************************************************** @@ -171,13 +184,9 @@ int ConcensusCommand::buildConcensusTree(vector nodeSet) { } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function buildConcensusTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "buildConcensusTree"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function buildConcensusTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //********************************************************************************************************************** @@ -228,13 +237,9 @@ void ConcensusCommand::getSets() { sort(treeSet.begin(), treeSet.end()); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getSets. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "getSets"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function getSets. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //********************************************************************************************************************** @@ -267,14 +272,9 @@ vector ConcensusCommand::getNextAvailableSet(vector bigset) { } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getNextAvailableSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "getNextAvailableSet"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function getNextAvailableSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } //********************************************************************************************************************** @@ -302,14 +302,9 @@ vector ConcensusCommand::getRestSet(vector bigset, vector bigset, vector subset) { } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function isSubset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "isSubset"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function isSubset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //********************************************************************************************************************** int ConcensusCommand::findSpot(string node) { @@ -353,13 +344,9 @@ int ConcensusCommand::findSpot(string node) { } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function findSpot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + errorOut(e, "ConcensusCommand", "findSpot"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the ConcensusCommand class function findSpot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //**********************************************************************************************************************