Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

1.39.0 #264

Merged
merged 18 commits into from Aug 9, 2016

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -152,6 +152,7 @@
#include "biominfocommand.h"
#include "renamefilecommand.h"
#include "chimeravsearchcommand.h"
+#include "mergecountcommand.hpp"
//needed for testing project
//CommandFactory* CommandFactory::_uniqueInstance;
@@ -327,6 +328,7 @@ CommandFactory::CommandFactory(){
commands["biom.info"] = "biom.info";
commands["set.seed"] = "set.seed";
commands["rename.file"] = "rename.file";
+ commands["merge.count"] = "merge.count";
}
@@ -526,6 +528,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
else if(commandName == "corr.axes") { command = new CorrAxesCommand(optionString); }
else if(commandName == "remove.rare") { command = new RemoveRareCommand(optionString); }
else if(commandName == "merge.groups") { command = new MergeGroupsCommand(optionString); }
+ else if(commandName == "merge.count") { command = new MergeCountCommand(optionString); }
else if(commandName == "amova") { command = new AmovaCommand(optionString); }
else if(commandName == "homova") { command = new HomovaCommand(optionString); }
else if(commandName == "mantel") { command = new MantelCommand(optionString); }
@@ -699,6 +702,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str
else if(commandName == "corr.axes") { pipecommand = new CorrAxesCommand(optionString); }
else if(commandName == "remove.rare") { pipecommand = new RemoveRareCommand(optionString); }
else if(commandName == "merge.groups") { pipecommand = new MergeGroupsCommand(optionString); }
+ else if(commandName == "merge.count") { pipecommand = new MergeCountCommand(optionString); }
else if(commandName == "amova") { pipecommand = new AmovaCommand(optionString); }
else if(commandName == "homova") { pipecommand = new HomovaCommand(optionString); }
else if(commandName == "mantel") { pipecommand = new MantelCommand(optionString); }
@@ -858,6 +862,7 @@ Command* CommandFactory::getCommand(string commandName){
else if(commandName == "corr.axes") { shellcommand = new CorrAxesCommand(); }
else if(commandName == "remove.rare") { shellcommand = new RemoveRareCommand(); }
else if(commandName == "merge.groups") { shellcommand = new MergeGroupsCommand(); }
+ else if(commandName == "merge.count") { shellcommand = new MergeCountCommand(); }
else if(commandName == "amova") { shellcommand = new AmovaCommand(); }
else if(commandName == "homova") { shellcommand = new HomovaCommand(); }
else if(commandName == "mantel") { shellcommand = new MantelCommand(); }
@@ -973,11 +978,15 @@ bool CommandFactory::isValidCommand(string command, string noError) {
/***********************************************************************/
void CommandFactory::printCommands(ostream& out) {
try {
- out << "Valid commands are: ";
- for (it = commands.begin(); it != commands.end(); it++) {
- out << it->first << ",";
+ it = commands.begin();
+ out << "Valid commands are: " << it->first << ", ";
+ it++;
+ out << it->first;
+ it++;
+ for (; it != commands.end(); it++) {
+ out << ", " << it->first;
}
- out << endl;
+ out << "." << endl;
}
catch(exception& e) {
m->errorOut(e, "CommandFactory", "printCommands");
@@ -30,8 +30,7 @@ vector<string> ClusterCommand::setParameters(){
CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
- CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
- CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
+ CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
//CommandParameter padjust("adjust", "String", "", "F", "", "", "","",false,false); parameters.push_back(padjust);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
@@ -49,7 +48,7 @@ vector<string> ClusterCommand::setParameters(){
string ClusterCommand::getHelpString(){
try {
string helpString = "";
- helpString += "The cluster command parameter options are phylip, column, name, count, method, cuttoff, hard, precision, sim, showabund and timing. Fasta or Phylip or column and name are required.\n";
+ helpString += "The cluster command parameter options are phylip, column, name, count, method, cutoff, precision, sim, showabund and timing. Fasta or Phylip or column and name are required.\n";
//helpString += "The adjust parameter is used to handle missing distances. If you set a cutoff, adjust=f by default. If not, adjust=t by default. Adjust=f, means ignore missing distances and adjust cutoff as needed with the average neighbor method. Adjust=t, will treat missing distances as 1.0. You can also set the value the missing distances should be set to, adjust=0.5 would give missing distances a value of 0.5.\n";
helpString += "The phylip and column parameter allow you to enter your distance file. \n";
helpString += "The fasta parameter allows you to enter your fasta file for use with the agc or dgc methods. \n";
@@ -249,10 +248,7 @@ ClusterCommand::ClusterCommand(string option) {
if (temp == "not found") { temp = "100"; }
//saves precision legnth for formatting below
length = temp.length();
- m->mothurConvert(temp, precision);
-
- temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
- hard = m->isTrue(temp);
+ m->mothurConvert(temp, precision);
temp = validParameter.validFile(parameters, "sim", false); if (temp == "not found") { temp = "F"; }
sim = m->isTrue(temp);
@@ -282,7 +278,6 @@ ClusterCommand::ClusterCommand(string option) {
if (temp == "not found") { temp = "10"; }
//else { cutoffSet = true; }
m->mothurConvert(temp, cutoff);
- if ((method != "agc") && (method != "dgc")) { cutoff += (5 / (precision * 10.0)); }
showabund = validParameter.validFile(parameters, "showabund", false);
if (showabund == "not found") { showabund = "T"; }
@@ -315,9 +310,7 @@ int ClusterCommand::execute(){
else if (countfile != "") { inputString += ", count=" + countfile; }
inputString += ", precision=" + toString(precision);
inputString += ", method=" + method;
- if (hard) { inputString += ", hard=T"; }
- else { inputString += ", hard=F"; }
- if (sim) { inputString += ", sim=T"; }
+ if (sim) { inputString += ", sim=T"; }
else { inputString += ", sim=F"; }
@@ -689,12 +682,7 @@ int ClusterCommand::runMothurCluster(){
cluster->update(cutoff);
float dist = matrix->getSmallDist();
- float rndDist;
- if (hard) {
- rndDist = m->ceilDist(dist, precision);
- }else{
- rndDist = m->roundDist(dist, precision);
- }
+ float rndDist = m->ceilDist(dist, precision);
if(previousDist <= 0.0000 && dist != previousDist){
printData("unique", counts);
@@ -733,10 +721,8 @@ int ClusterCommand::runMothurCluster(){
}
listFile.close();
- if (saveCutoff != cutoff) {
- if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); }
- else { saveCutoff = m->roundDist(saveCutoff, precision); }
-
+ if (saveCutoff != cutoff) {
+ saveCutoff = m->ceilDist(saveCutoff, precision);
m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine();
}
@@ -52,7 +52,7 @@ class ClusterCommand : public Command {
RAbundVector oldRAbund;
ListVector oldList;
- bool abort, hard, sim;
+ bool abort, sim;
string method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, format, distfile, countfile, fastafile, inputDir, vsearchLocation;
double cutoff;
@@ -19,7 +19,6 @@ vector<string> ClusterDoturCommand::setParameters(){
CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false); parameters.push_back(pmethod);
- CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
@@ -39,7 +38,7 @@ string ClusterDoturCommand::getHelpString(){
try {
string helpString = "";
helpString += "The cluster.classic command clusters using the algorithm from dotur. \n";
- helpString += "The cluster.classic command parameter options are phylip, name, count, method, cuttoff, hard, sim, precision. Phylip is required, unless you have a valid current file.\n";
+ helpString += "The cluster.classic command parameter options are phylip, name, count, method, cuttoff, sim, precision. Phylip is required, unless you have a valid current file.\n";
helpString += "The cluster.classic command should be in the following format: \n";
helpString += "cluster.classic(phylip=yourDistanceMatrix, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n";
helpString += "The acceptable cluster methods are furthest, nearest, weighted and average. If no method is provided then average is assumed.\n";
@@ -183,11 +182,7 @@ ClusterDoturCommand::ClusterDoturCommand(string option) {
temp = validParameter.validFile(parameters, "cutoff", false);
if (temp == "not found") { temp = "10"; }
- m->mothurConvert(temp, cutoff);
- cutoff += (5 / (precision * 10.0));
-
- temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
- hard = m->isTrue(temp);
+ m->mothurConvert(temp, cutoff);
temp = validParameter.validFile(parameters, "sim", false); if (temp == "not found") { temp = "F"; }
sim = m->isTrue(temp);
@@ -280,12 +275,7 @@ int ClusterDoturCommand::execute(){
cluster->update(cutoff);
float dist = cluster->getSmallDist();
- float rndDist;
- if (hard) {
- rndDist = m->ceilDist(dist, precision);
- }else{
- rndDist = m->roundDist(dist, precision);
- }
+ float rndDist = m->ceilDist(dist, precision);
if(previousDist <= 0.0000 && dist != previousDist){
printData("unique", counts);
@@ -37,7 +37,7 @@ class ClusterDoturCommand : public Command {
void help() { m->mothurOut(getHelpString()); }
private:
- bool abort, hard, sim;
+ bool abort, sim;
string method, fileroot, tag, outputDir, phylipfile, namefile, countfile;
double cutoff;
int precision, length;
@@ -31,7 +31,6 @@ vector<string> ClusterSplitCommand::setParameters(){
CommandParameter pcutoff("cutoff", "Number", "", "0.25", "", "", "","",false,false,true); parameters.push_back(pcutoff);
CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted-agc-dgc", "average", "", "", "","",false,false,true); parameters.push_back(pmethod);
- CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
CommandParameter pislist("islist", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pislist);
CommandParameter pclassic("classic", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pclassic);
CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
@@ -51,7 +50,7 @@ vector<string> ClusterSplitCommand::setParameters(){
string ClusterSplitCommand::getHelpString(){
try {
string helpString = "";
- helpString += "The cluster.split command parameter options are file, fasta, phylip, column, name, count, cutoff, precision, method, splitmethod, taxonomy, taxlevel, showabund, timing, hard, large, cluster, processors. Fasta or Phylip or column and name are required.\n";
+ helpString += "The cluster.split command parameter options are file, fasta, phylip, column, name, count, cutoff, precision, method, splitmethod, taxonomy, taxlevel, showabund, timing, large, cluster, processors. Fasta or Phylip or column and name are required.\n";
helpString += "The cluster.split command can split your files in 3 ways. Splitting by distance file, by classification, or by classification also using a fasta file. \n";
helpString += "For the distance file method, you need only provide your distance file and mothur will split the file into distinct groups. \n";
helpString += "For the classification method, you need to provide your distance file and taxonomy file, and set the splitmethod to classify. \n";
@@ -325,9 +324,6 @@ ClusterSplitCommand::ClusterSplitCommand(string option) {
length = temp.length();
m->mothurConvert(temp, precision);
- temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
- hard = m->isTrue(temp);
-
temp = validParameter.validFile(parameters, "large", false); if (temp == "not found") { temp = "F"; }
large = m->isTrue(temp);
@@ -367,7 +363,6 @@ ClusterSplitCommand::ClusterSplitCommand(string option) {
cutoffNotSet = false;
temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { cutoffNotSet = true; temp = "0.25"; }
m->mothurConvert(temp, cutoff);
- if ((method != "agc") && (method != "dgc")) { cutoff += (5 / (precision * 10.0)); }
if ((splitmethod == "distance") || (splitmethod == "classify") || (splitmethod == "fasta")) { }
else { m->mothurOut("[ERROR]: " + splitmethod + " is not a valid splitting method. Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); abort = true; }
@@ -1147,13 +1142,8 @@ string ClusterSplitCommand::clusterClassicFile(string thisDistFile, string thisN
cluster->update(cutoff);
float dist = cluster->getSmallDist();
- float rndDist;
- if (hard) {
- rndDist = m->ceilDist(dist, precision);
- }else{
- rndDist = m->roundDist(dist, precision);
- }
-
+ float rndDist = m->ceilDist(dist, precision);
+
if(previousDist <= 0.0000 && dist != previousDist){
oldList.setLabel("unique");
oldList.print(listFile);
@@ -1286,12 +1276,7 @@ string ClusterSplitCommand::clusterFile(string thisDistFile, string thisNamefile
cluster->update(saveCutoff);
float dist = matrix->getSmallDist();
- float rndDist;
- if (hard) {
- rndDist = m->ceilDist(dist, precision);
- }else{
- rndDist = m->roundDist(dist, precision);
- }
+ float rndDist = m->ceilDist(dist, precision);
if(previousDist <= 0.0000 && dist != previousDist){
oldList.setLabel("unique");
@@ -1336,9 +1321,7 @@ string ClusterSplitCommand::clusterFile(string thisDistFile, string thisNamefile
}
if (saveCutoff != cutoff) {
- if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); }
- else { saveCutoff = m->roundDist(saveCutoff, precision); }
-
+ saveCutoff = m->ceilDist(saveCutoff, precision);
m->mothurOut("Cutoff was " + toString(cutoff) + " changed cutoff to " + toString(saveCutoff)); m->mothurOutEndLine();
}
@@ -51,7 +51,7 @@ class ClusterSplitCommand : public Command {
string file, method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, countfile, distfile, format, showabund, timing, splitmethod, taxFile, fastafile, inputDir, vsearchLocation;
double cutoff, splitcutoff;
int precision, length, processors, taxLevelCutoff;
- bool print_start, abort, hard, large, classic, runCluster, deleteFiles, isList, cutoffNotSet;
+ bool print_start, abort, large, classic, runCluster, deleteFiles, isList, cutoffNotSet;
time_t start;
ofstream outList, outRabund, outSabund;
@@ -87,7 +87,13 @@ class Command {
if (filename.length() > 0) { //rip off last "."
filename = filename.substr(0, filename.length()-1);
}
- filename += it->second + ".";
+ filename += it->second + ".";
+ }else if ((it->first == "[group]") || (it->first == "[tag]")) {
+ string group = it->second;
+ for (int j = 0; j < group.length(); j++) {
+ if (group[j] == '-') { group[j] = '_'; }
+ }
+ filename += group + ".";
}else { filename += it->second + "."; }
}
}
@@ -589,7 +589,7 @@ set<string> GetMIMarksPackageCommand::createGroupNames(Oligos& oligos) {
//overwrite global oligos - assume fastq data like make.contigs
Oligos oligos;
if ((fileOption == 3) || (fileOption == 5)) { oligos.read(oligosfile, false); } //like make.contigs
- else { oligos.read(oligosfile); }
+ else { oligos.read(oligosfile, false); }
map<int, oligosPair> barcodes = oligos.getPairedBarcodes();
map<int, oligosPair> primers = oligos.getPairedPrimers();
Oops, something went wrong.