]> git.donarmstrong.com Git - mothur.git/commitdiff
added dist.shared command
authorwestcott <westcott>
Thu, 21 May 2009 12:35:43 +0000 (12:35 +0000)
committerwestcott <westcott>
Thu, 21 May 2009 12:35:43 +0000 (12:35 +0000)
commandfactory.cpp
errorchecking.cpp
globaldata.cpp
helpcommand.cpp
matrixoutputcommand.cpp
validcalculator.cpp
validcommands.cpp
validparameter.cpp

index e48bc6abaaf3d2169cf70ae442909d93d511849e..21e7b54548a370065ab554d3a2b0f7b5c4887146 100644 (file)
@@ -43,6 +43,7 @@
 #include "distancecommand.h"
 #include "aligncommand.h"
 #include "getrepseqscommand.h"
+#include "matrixoutputcommand.h"
 
 
 /***********************************************************/
@@ -93,6 +94,7 @@ Command* CommandFactory::getCommand(string commandName){
                else if(commandName == "get.repseqs")                   {   command = new GetRepSeqsCommand();                  }
                else if(commandName == "get.oturep")                    {   command = new GetOTURepCommand();                   }
                else if(commandName == "tree.shared")                   {   command = new TreeGroupCommand();                   }
+               else if(commandName == "dist.shared")                   {   command = new MatrixOutputCommand();                }
                else if(commandName == "bootstrap.shared")              {   command = new BootSharedCommand();                  }
                else if(commandName == "concensus")                             {   command = new ConcensusCommand();                   }
                else if(commandName == "dist.seqs")                             {   command = new DistanceCommand();                    }
index 19d1f8aeacf25878fee069f1083b0465974d4645..f82e806e45d6b98be601720b3380ae21e142438a 100644 (file)
@@ -250,10 +250,10 @@ bool ErrorCheck::checkInput(string input) {
                        if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single, rarefaction.single or summary.single commands." << endl; return false; }
                }
                
-               if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.shared") || (commandName == "bootstrap.shared")){ 
+               if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared")){ 
                        if (globaldata->getSharedFile() == "") {
-                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
-                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared or bootstrap.shared commands." << endl; return false; }
+                               if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared, bootstrap.shared or dist.shared commands." << endl; return false; }
+                               else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared, tree.shared, bootstrap.shared or dist.shared commands." << endl; return false; }
                        }
                }
                
@@ -273,7 +273,7 @@ bool ErrorCheck::checkInput(string input) {
                }
                
                if ((commandName == "bin.seqs")) { 
-                       if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the bin.seqs command." << endl; return false; }
+                       if ((globaldata->getListFile() == "")) { cout << "You must read a list file before you can use the bin.seqs commands." << endl; return false; }
                        validateBinFiles();
                }
                
index 1baf4edf1bf90ef469a9426de2e06f0a3ce137fc..16d434bcb47dbd18e91914214cd8fda032e9f47b 100644 (file)
@@ -241,7 +241,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        Estimators.clear();
                        splitAtDash(calc, Estimators); 
                }
-               if ((commandName == "tree.shared") || (commandName == "bootstrap.shared")) {
+               if ((commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared")) {
                        if (calc != "") { 
                                Estimators.clear();
                                splitAtDash(calc, Estimators);                  
index a30caefd44e73df86b498b17ae28f6e671f1cb70..72ab80da603d1ca3f8ae55430151c25257a614ca 100644 (file)
@@ -266,6 +266,18 @@ int HelpCommand::execute(){
                validCalcs->printCalc("treegroup", cout);
                cout << "The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose." << "\n";
                cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
+       }else if (globaldata->helpRequest == "dist.shared") { 
+               cout << "The dist.shared command can only be executed after a successful read.otu command." << "\n";
+               cout << "The dist.shared command parameters are groups, calc, line and label.  The calc parameter is required, and you may not use line and label at the same time." << "\n";
+               cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included used." << "\n";
+               cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like distance matrices created for, and are also separated by dashes." << "\n";
+               cout << "The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, line=yourLines, label=yourLabels)." << "\n";
+               cout << "Example dist.shared(groups=A-B-C, line=1-3-5, calc=jabund-sorabund)." << "\n";
+               cout << "The default value for groups is all the groups in your groupfile." << "\n";
+               cout << "There is no default value for calc." << "\n";
+               validCalcs->printCalc("matrix", cout);
+               cout << "The dist.shared command outputs a .matrix file for each calculator you specify at each distance you choose." << "\n";
+               cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "bootstrap.shared") { 
                cout << "The bootstrap.shared command can only be executed after a successful read.otu command." << "\n";
                cout << "The bootstrap.shared command parameters are groups, calc, iters, line and label.  The calc parameter is required, and you may not use line and label at the same time." << "\n";
@@ -317,7 +329,7 @@ int HelpCommand::execute(){
                cout << "The get.oturep command outputs a .fastarep file for each distance you specify, selecting one OTU representative for each bin." << "\n";
                cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "quit") {
-               cout << "The quit command will terminate Dotur and should be in the following format: " << "\n";
+               cout << "The quit command will terminate mothur and should be in the following format: " << "\n";
                cout << "quit()" << "\n" << "\n";
        }else if (globaldata->helpRequest == "") {
                validCommands->printCommands(cout);
index 7b9ea960f3c6b979463cacc9e363ba5a6006ae44..a5e7a4ede8b0fbb77724bba444516251f353c12c 100644 (file)
@@ -125,8 +125,8 @@ int MatrixOutputCommand::execute(){
                                                                
                                                                data = matrixCalculators[i]->getValues(subset); //saves the calculator outputs
                                                                //save values in similarity matrix
-                                                               simMatrix[k][l] = data[0];
-                                                               simMatrix[l][k] = data[0];
+                                                               simMatrix[k][l] = 1.0 - data[0];  //convert similiarity to distance
+                                                               simMatrix[l][k] = 1.0 - data[0];  //convert similiarity to distance
                                                        }
                                                }
                                        }
index 99cd47a13bbc78b86b9332c24337d4dd2b726a42..25efa1f2fc784f2fca37e3a478fc2740507df8ab 100644 (file)
@@ -551,6 +551,10 @@ void ValidCalculators::printCalc(string parameter, ostream& out) {
                        for (it = treegroup.begin(); it != treegroup.end(); it++) {
                                out << it->first << ", ";
                        }
+               }else if (parameter == "matrix") {
+                       for (it = matrix.begin(); it != matrix.end(); it++) {
+                               out << it->first << ", ";
+                       }
                }else if (parameter == "boot") {
                        for (it = boot.begin(); it != boot.end(); it++) {
                                out << it->first << ", ";
index c648585d6b40515be32fa86f0e60804b3ca9c510..787cc8025a6c62d01be190a63c33e42429fe21a4 100644 (file)
@@ -23,7 +23,8 @@ ValidCommands::ValidCommands() {
                commands["get.oturep"]                  = "get.oturep";
                commands["cluster"]                             = "cluster"; 
                commands["deconvolute"]                 = "deconvolute"; 
-               commands["dist.seqs"]                   = "dist.seqs"; 
+               commands["dist.seqs"]                   = "dist.seqs";
+               commands["dist.shared"]                 = "dist.shared";  //matrix output
                commands["collect.single"]              = "collect.single"; 
                commands["collect.shared"]              = "collect.shared"; 
                commands["rarefaction.single"]  = "rarefaction.single"; 
index 5e93a5c10dab67d52494b36675f38a71f63b29ae..5da87d1df8ee6d568264313ece64bbc7177cae40 100644 (file)
@@ -276,6 +276,9 @@ void ValidParameters::initCommandParameters() {
                string binseqsArray[] =  {"fasta","line","label","name"};
                commandParameters["bin.seqs"] = addParameters(binseqsArray, sizeof(binseqsArray)/sizeof(string));
                
+               string distsharedArray[] =  {"line","label","calc","groups"};
+               commandParameters["dist.shared"] = addParameters(distsharedArray, sizeof(distsharedArray)/sizeof(string));
+               
                string getrepseqsArray[] =  {"fasta","line","label","name", "group"};
                commandParameters["get.repseqs"] = addParameters(getrepseqsArray, sizeof(getrepseqsArray)/sizeof(string));