]> git.donarmstrong.com Git - mothur.git/blobdiff - treegroupscommand.cpp
added otu.association command. added calcSpearman, calcKendall and calcPearson functi...
[mothur.git] / treegroupscommand.cpp
index e5b7e74a7d71343af56fcb0dc6c54a18b61afd73..8c5aa4bbdc926515c6e3796a3a7969aa9abffca9 100644 (file)
@@ -94,7 +94,7 @@ string TreeGroupCommand::getHelpString(){
                helpString += validCalculator.printCalc("treegroup");
                helpString += "Or the tree.shared command can be in the following format: tree.shared(phylip=yourPhylipFile).\n";
                helpString += "Example tree.shared(phylip=abrecovery.dist).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n";
+               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
                return helpString;
        }
        catch(exception& e) {
@@ -125,6 +125,7 @@ TreeGroupCommand::TreeGroupCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -178,21 +179,22 @@ TreeGroupCommand::TreeGroupCommand(string option)  {
                        phylipfile = validParameter.validFile(parameters, "phylip", true);
                        if (phylipfile == "not open") { phylipfile = ""; abort = true; }
                        else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  inputfile = phylipfile;  format = "phylip";     }
+                       else {  inputfile = phylipfile;  format = "phylip"; m->setPhylipFile(phylipfile);       }
                        
                        columnfile = validParameter.validFile(parameters, "column", true);
                        if (columnfile == "not open") { columnfile = ""; abort = true; }        
                        else if (columnfile == "not found") { columnfile = ""; }
-                       else {  inputfile = columnfile; format = "column";      }
+                       else {  inputfile = columnfile; format = "column";      m->setColumnFile(columnfile); }
                        
                        sharedfile = validParameter.validFile(parameters, "shared", true);
                        if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
                        else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  inputfile = sharedfile; format = "sharedfile";  }
+                       else {  inputfile = sharedfile; format = "sharedfile";  m->setSharedFile(sharedfile); }
                        
                        namefile = validParameter.validFile(parameters, "name", true);
                        if (namefile == "not open") { abort = true; }   
                        else if (namefile == "not found") { namefile = ""; }
+                       else { m->setNameFile(namefile); }
                        
                        if ((phylipfile == "") && (columnfile == "") && (sharedfile == "")) { 
                                //is there are current file available for either of these?
@@ -238,7 +240,7 @@ TreeGroupCommand::TreeGroupCommand(string option)  {
                        if (groups == "not found") { groups = ""; }
                        else { 
                                m->splitAtDash(groups, Groups);
-                               m->Groups = Groups;
+                               m->setGroups(Groups);
                        }
                                
                        calc = validParameter.validFile(parameters, "calc", false);                     
@@ -247,13 +249,18 @@ TreeGroupCommand::TreeGroupCommand(string option)  {
                                 if (calc == "default")  {  calc = "jclass-thetayc";  }
                        }
                        m->splitAtDash(calc, Estimators);
+                       if (m->inUsersGroups("citation", Estimators)) { 
+                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
+                               //remove citation from list of calcs
+                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
+                       }
 
                        string temp;
                        temp = validParameter.validFile(parameters, "precision", false);                        if (temp == "not found") { temp = "100"; }
-                       convert(temp, precision); 
+                       m->mothurConvert(temp, precision); 
                        
                        temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "10"; }
-                       convert(temp, cutoff); 
+                       m->mothurConvert(temp, cutoff); 
                        cutoff += (5 / (precision * 10.0));
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
@@ -389,20 +396,20 @@ int TreeGroupCommand::execute(){
                        
                        //create treemap class from groupmap for tree class to use
                        tmap = new TreeMap();
-                       tmap->makeSim(m->namesOfGroups);
+                       tmap->makeSim(m->getAllGroups());
                        
                        //clear globaldatas old tree names if any
                        m->Treenames.clear();
                        
                        //fills globaldatas tree names
-                       m->Treenames = m->Groups;
+                       m->Treenames = m->getGroups();
                
                        if (m->control_pressed) { return 0; }
                        
                        //create tree file
                        makeSimsShared();
                        
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
+                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
                }else{
                        //read in dist file
                        filename = inputfile;
@@ -431,13 +438,14 @@ int TreeGroupCommand::execute(){
                        
                        tmap->makeSim(list);
                        
-                       m->Groups = tmap->namesOfGroups;
+                       vector<string> namesGroups = tmap->getNamesOfGroups();
+                       m->setGroups(namesGroups);
                
                        //clear globaldatas old tree names if any
                        m->Treenames.clear();
                
                        //fills globaldatas tree names
-                       m->Treenames = m->Groups;
+                       m->Treenames = m->getGroups();
                        
                        //used in tree constructor 
                        m->runParse = false;
@@ -461,7 +469,7 @@ int TreeGroupCommand::execute(){
                }
                                
                //reset groups parameter
-               m->Groups.clear(); 
+               m->clearGroups(); 
                
                //set tree file as new current treefile
                string current = "";
@@ -557,7 +565,7 @@ int TreeGroupCommand::createTree(){
                //delete tree
                delete t;
                
-               if (m->control_pressed) { remove(outputFile.c_str()); outputNames.pop_back(); return 1; }
+               if (m->control_pressed) { m->mothurRemove(outputFile); outputNames.pop_back(); return 1; }
                
                return 0;
        
@@ -752,8 +760,8 @@ int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
                                                                if (m->control_pressed) { return 1; }
                                                                
                                                                //save values in similarity matrix
-                                                               simMatrix[k][l] = data[0];
-                                                               simMatrix[l][k] = data[0];
+                                                               simMatrix[k][l] = -(data[0]-1.0);
+                                                               simMatrix[l][k] = -(data[0]-1.0);
                                                        }
                                                }
                                        }