]> git.donarmstrong.com Git - mothur.git/blobdiff - consensuscommand.cpp
mods to trim.seqs
[mothur.git] / consensuscommand.cpp
index a65d56fb86c2a8a91ac2915def73d05c7e53b6d6..9880b8dbf01f72abe4a2a50d9630a2d09d3fd6d0 100644 (file)
@@ -9,12 +9,64 @@
 
 #include "consensuscommand.h"
 
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getValidParameters(){ 
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getRequiredParameters(){      
+       try {
+               vector<string> myArray; 
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> ConcensusCommand::getRequiredFiles(){   
+       try {
+               string AlignArray[] =  {"tree","group"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+ConcensusCommand::ConcensusCommand(){  
+       try {
+               abort = true; calledHelp = true; 
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "ConcensusCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ConcensusCommand::ConcensusCommand(string fileroot)  {
        try {
                globaldata = GlobalData::getInstance();
-               abort = false;
+               abort = false; calledHelp = false;   
+               
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
                
                filename = fileroot;
                
@@ -55,7 +107,7 @@ ConcensusCommand::~ConcensusCommand(){}
 int ConcensusCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                else {  
                        numNodes = t[0]->getNumNodes();
                        numLeaves = t[0]->getNumLeaves();
@@ -67,7 +119,7 @@ int ConcensusCommand::execute(){
                if (m->control_pressed) { return 0; }
                
                //open file for pairing not included in the tree
-               notIncluded = filename + ".cons.pairs";
+               notIncluded = filename + ".cons.pairs"; outputNames.push_back(notIncluded);  outputTypes["nodepairs"].push_back(notIncluded);
                m->openOutputFile(notIncluded, out2);
                
                consensusTree = new Tree();
@@ -150,10 +202,10 @@ int ConcensusCommand::execute(){
                        out2 << '\t' << it2->second << endl;
                }
                
-               outputFile = filename + ".cons.tre";
+               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();