From 0e14094b51dd81c07c6a56b7b51533eff2332339 Mon Sep 17 00:00:00 2001 From: westcott Date: Thu, 21 May 2009 12:35:43 +0000 Subject: [PATCH] added dist.shared command --- commandfactory.cpp | 2 ++ errorchecking.cpp | 8 ++++---- globaldata.cpp | 2 +- helpcommand.cpp | 14 +++++++++++++- matrixoutputcommand.cpp | 4 ++-- validcalculator.cpp | 4 ++++ validcommands.cpp | 3 ++- validparameter.cpp | 3 +++ 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/commandfactory.cpp b/commandfactory.cpp index e48bc6a..21e7b54 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -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(); } diff --git a/errorchecking.cpp b/errorchecking.cpp index 19d1f8a..f82e806 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -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(); } diff --git a/globaldata.cpp b/globaldata.cpp index 1baf4ed..16d434b 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -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); diff --git a/helpcommand.cpp b/helpcommand.cpp index a30caef..72ab80d 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -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); diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index 7b9ea96..a5e7a4e 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -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 } } } diff --git a/validcalculator.cpp b/validcalculator.cpp index 99cd47a..25efa1f 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -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 << ", "; diff --git a/validcommands.cpp b/validcommands.cpp index c648585..787cc80 100644 --- a/validcommands.cpp +++ b/validcommands.cpp @@ -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"; diff --git a/validparameter.cpp b/validparameter.cpp index 5e93a5c..5da87d1 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -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)); -- 2.39.2