]> git.donarmstrong.com Git - mothur.git/blobdiff - consensuscommand.cpp
added get.otus and remove.otus commands
[mothur.git] / consensuscommand.cpp
index 37cd39578c953e3d843c4cd0892b1be992511a88..0671790a2152801536e3f1bf05335a86f86fca13 100644 (file)
@@ -9,6 +9,54 @@
 
 #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;
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ConcensusCommand", "ConcensusCommand");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
 ConcensusCommand::ConcensusCommand(string fileroot)  {
@@ -16,6 +64,11 @@ ConcensusCommand::ConcensusCommand(string fileroot)  {
                globaldata = GlobalData::getInstance();
                abort = false;
                
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["tree"] = tempOutNames;
+               outputTypes["nodepairs"] = tempOutNames;
+               
                filename = fileroot;
                
                t = globaldata->gTree;
@@ -67,8 +120,8 @@ int ConcensusCommand::execute(){
                if (m->control_pressed) { return 0; }
                
                //open file for pairing not included in the tree
-               notIncluded = filename + ".cons.pairs";
-               openOutputFile(notIncluded, out2);
+               notIncluded = filename + ".cons.pairs"; outputNames.push_back(notIncluded);  outputTypes["nodepairs"].push_back(notIncluded);
+               m->openOutputFile(notIncluded, out2);
                
                consensusTree = new Tree();
                
@@ -150,8 +203,8 @@ int ConcensusCommand::execute(){
                        out2 << '\t' << it2->second << endl;
                }
                
-               outputFile = filename + ".cons.tre";
-               openOutputFile(outputFile, out);
+               outputFile = filename + ".cons.tre";  outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
+               m->openOutputFile(outputFile, out);
                
                consensusTree->printForBoot(out);
                
@@ -262,13 +315,13 @@ int ConcensusCommand::getSets() {
                while (nodePairsCopy.size() != 0) {
                        if (m->control_pressed) { return 1; }
                
-                       vector<string> small = getSmallest(nodePairsCopy);
+                       vector<string> smallOne = getSmallest(nodePairsCopy);
                        
-                       int subgrouprate = getSubgroupRating(small);
+                       int subgrouprate = getSubgroupRating(smallOne);
                
-                       nodePairsInitialRate[small] = nodePairs[small] + subgrouprate;
+                       nodePairsInitialRate[smallOne] = nodePairs[smallOne] + subgrouprate;
                        
-                       nodePairsCopy.erase(small);
+                       nodePairsCopy.erase(smallOne);
                }
                
                return 0;