//**********************************************************************************************************************
-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(){}
int ConcensusCommand::execute(){
try {
- if (t.size() == 0) { return 0; }
+ if (abort == true) { return 0; }
else {
numNodes = t[0]->getNumNodes();
numLeaves = t[0]->getNumLeaves();
//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);
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);
- }
}
//**********************************************************************************************************************
}
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);
- }
}
//**********************************************************************************************************************
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);
- }
}
//**********************************************************************************************************************
}
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);
- }
-
}
//**********************************************************************************************************************
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ConcensusCommand class Function getRestSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "ConcensusCommand", "getRestSet");
exit(1);
}
- catch(...) {
- cout << "An unknown error has occurred in the ConcensusCommand class function getRestSet. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
}
//**********************************************************************************************************************
}
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) {
}
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);
- }
}
//**********************************************************************************************************************