From 4a2d841cb97fb02351022efe9d7068b1dc212bf9 Mon Sep 17 00:00:00 2001 From: westcott Date: Fri, 14 May 2010 18:50:27 +0000 Subject: [PATCH] 1.10.0 --- alignmentdb.cpp | 59 ----- alignmentdb.h | 2 - bayesian.cpp | 12 + bayesian.h | 2 +- blastdb.cpp | 19 +- classify.h | 5 +- clearcutcommand.cpp | 495 ++++++++++++++++++++------------------ clearcutcommand.h | 4 +- collect.cpp | 8 +- collectcommand.cpp | 4 +- collectsharedcommand.cpp | 4 +- distancedb.hpp | 2 +- knn.cpp | 11 + knn.h | 2 +- mothur.cpp | 386 ++++++++++++++--------------- mothur.h | 2 +- phylodiversitycommand.cpp | 8 +- rarefact.cpp | 10 +- rarefactcommand.cpp | 4 +- rarefactsharedcommand.cpp | 4 +- seqsummarycommand.cpp | 2 +- trimseqscommand.cpp | 25 +- validparameter.cpp | 6 - venn.cpp | 256 ++++++++++---------- 24 files changed, 649 insertions(+), 683 deletions(-) diff --git a/alignmentdb.cpp b/alignmentdb.cpp index 1ea1b98..364ef12 100644 --- a/alignmentdb.cpp +++ b/alignmentdb.cpp @@ -194,65 +194,6 @@ Sequence AlignmentDB::findClosestSequence(Sequence* seq) { exit(1); } } -#ifdef USE_MPI -/**************************************************************************************************/ -int AlignmentDB::MPISend(int receiver) { - try { - - //send numSeqs - int - MPI_Send(&numSeqs, 1, MPI_INT, receiver, 2001, MPI_COMM_WORLD); - - //send longest - int - MPI_Send(&longest, 1, MPI_INT, receiver, 2001, MPI_COMM_WORLD); - - //send templateSequences - for (int i = 0; i < templateSequences.size(); i++) { - templateSequences[i].MPISend(receiver); - } - - //send Database - search->MPISend(receiver); - - return 0; - } - catch(exception& e) { - m->errorOut(e, "AlignmentDB", "MPISend"); - exit(1); - } -} -/**************************************************************************************************/ -int AlignmentDB::MPIRecv(int sender) { - try { - MPI_Status status; - //receive numSeqs - int - MPI_Recv(&numSeqs, 1, MPI_INT, sender, 2001, MPI_COMM_WORLD, &status); - - //receive longest - int - MPI_Recv(&longest, 1, MPI_INT, sender, 2001, MPI_COMM_WORLD, &status); - - //receive templateSequences - templateSequences.resize(numSeqs); - for (int i = 0; i < templateSequences.size(); i++) { - templateSequences[i].MPIRecv(sender); - } - - //receive Database - search->MPIRecv(sender); - - for (int i = 0; i < templateSequences.size(); i++) { - search->addSequence(templateSequences[i]); - } - search->generateDB(); - search->setNumSeqs(numSeqs); - - return 0; - } - catch(exception& e) { - m->errorOut(e, "AlignmentDB", "MPIRecv"); - exit(1); - } -} -#endif /**************************************************************************************************/ diff --git a/alignmentdb.h b/alignmentdb.h index a69b917..22d2dd3 100644 --- a/alignmentdb.h +++ b/alignmentdb.h @@ -27,8 +27,6 @@ public: Sequence findClosestSequence(Sequence*); float getSearchScore() { return search->getSearchScore(); } int getLongestBase() { return longest; } - int MPISend(int); - int MPIRecv(int); private: int numSeqs, longest; diff --git a/bayesian.cpp b/bayesian.cpp index a4229c6..22eab72 100644 --- a/bayesian.cpp +++ b/bayesian.cpp @@ -177,6 +177,18 @@ Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) { exit(1); } } +/**************************************************************************************************/ +Bayesian::~Bayesian() { + try { + delete phyloTree; + if (database != NULL) { delete database; } + } + catch(exception& e) { + m->errorOut(e, "Bayesian", "~Bayesian"); + exit(1); + } +} + /**************************************************************************************************/ string Bayesian::getTaxonomy(Sequence* seq) { try { diff --git a/bayesian.h b/bayesian.h index 70757be..fa6590a 100644 --- a/bayesian.h +++ b/bayesian.h @@ -19,7 +19,7 @@ class Bayesian : public Classify { public: Bayesian(string, string, string, int, int, int); - ~Bayesian() {}; + ~Bayesian(); string getTaxonomy(Sequence*); diff --git a/blastdb.cpp b/blastdb.cpp index 780afe0..b52c82e 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -85,23 +85,6 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { } m8FileHandle.close(); - string root = dbFileName; - string temp = dbFileName + ".nsq"; - remove(temp.c_str()); - temp = dbFileName + ".nsi"; - remove(temp.c_str()); - - temp = dbFileName + ".nsd"; - remove(temp.c_str()); - - temp = dbFileName + ".nin"; - remove(temp.c_str()); - - temp = dbFileName + ".nhr"; - remove(temp.c_str()); - - - return topMatches; } catch(exception& e) { @@ -167,7 +150,7 @@ void BlastDB::addSequence(Sequence seq) { unalignedFastaFile << '>' << count << endl; // sequences, which will be input to formatdb unalignedFastaFile << seq.getUnaligned() << endl; unalignedFastaFile.close(); - + count++; } catch(exception& e) { diff --git a/classify.h b/classify.h index a2401dd..bd9f34b 100644 --- a/classify.h +++ b/classify.h @@ -27,11 +27,8 @@ class Classify { public: Classify(); - - virtual ~Classify(){ delete phyloTree; if (database != NULL) { delete database; } }; + virtual ~Classify(){}; virtual string getTaxonomy(Sequence*) = 0; - //virtual map getConfidenceScores() { return taxConfidenceScore; } - //virtual vector parseTax(string); virtual string getSimpleTax() { return simpleTax; } virtual void generateDatabaseAndNames(string, string, string, int, float, float, float, float); diff --git a/clearcutcommand.cpp b/clearcutcommand.cpp index f8d389c..34341c0 100644 --- a/clearcutcommand.cpp +++ b/clearcutcommand.cpp @@ -1,240 +1,255 @@ -/* - * clearcutcommand.cpp - * Mothur - * - * Created by westcott on 5/11/10. - * Copyright 2010 Schloss Lab. All rights reserved. - * - */ - -#include "clearcutcommand.h" -#include "globaldata.hpp" - -/**************************************************************************************/ -ClearcutCommand::ClearcutCommand(string option) { - try { - abort = false; - - //allow user to run help - if(option == "help") { help(); abort = true; } - - else { - //valid paramters for this command - string Array[] = {"fasta","phylip","version","verbose","quiet","seed","norandom","shuffle","neighbor","expblen", - "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","stdin","outputdir","inputdir"}; - vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); - - OptionParser parser(option); - map parameters = parser.getParameters(); - - ValidParameters validParameter; - map::iterator it; - - //check to make sure all parameters are valid for command - for (it = parameters.begin(); it != parameters.end(); it++) { - if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } - } - - //if the user changes the input directory command factory will send this info to us in the output parameter - string inputDir = validParameter.validFile(parameters, "inputdir", false); - if (inputDir == "not found"){ inputDir = ""; } - else { - string path; - it = parameters.find("fasta"); - //user has given a template file - if(it != parameters.end()){ - path = hasPath(it->second); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { parameters["fasta"] = inputDir + it->second; } - } - - it = parameters.find("phylip"); - //user has given a template file - if(it != parameters.end()){ - path = hasPath(it->second); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { parameters["phylip"] = inputDir + it->second; } - } - } - - //check for required parameters - fastafile = validParameter.validFile(parameters, "fasta", true); - if (fastafile == "not open") { fastafile = ""; abort = true; } - else if (fastafile == "not found") { fastafile = ""; } - else { inputFile = fastafile; } - - phylipfile = validParameter.validFile(parameters, "phylip", true); - if (phylipfile == "not open") { phylipfile = ""; abort = true; } - else if (phylipfile == "not found") { phylipfile = ""; } - else { inputFile = phylipfile; } - - if ((phylipfile == "") && (fastafile == "")) { m->mothurOut("You must provide either a phylip formatted distance matrix or an aligned fasta file."); m->mothurOutEndLine(); abort=true; } - if ((phylipfile != "") && (fastafile != "")) { m->mothurOut("You must provide either a phylip formatted distance matrix or an aligned fasta file, not BOTH."); m->mothurOutEndLine(); abort=true; } - - - //if the user changes the output directory command factory will send this info to us in the output parameter - outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; } - - string temp; - temp = validParameter.validFile(parameters, "version", false); if (temp == "not found"){ temp = "F"; } - version = isTrue(temp); - - temp = validParameter.validFile(parameters, "verbose", false); if (temp == "not found"){ temp = "F"; } - verbose = isTrue(temp); - - temp = validParameter.validFile(parameters, "quiet", false); if (temp == "not found"){ temp = "F"; } - quiet = isTrue(temp); - - seed = validParameter.validFile(parameters, "seed", false); if (seed == "not found"){ seed = "*"; } - - temp = validParameter.validFile(parameters, "norandom", false); if (temp == "not found"){ temp = "F"; } - norandom = isTrue(temp); - - temp = validParameter.validFile(parameters, "shuffle", false); if (temp == "not found"){ temp = "F"; } - shuffle = isTrue(temp); - - temp = validParameter.validFile(parameters, "neighbor", false); if (temp == "not found"){ temp = "F"; } - neighbor = isTrue(temp); - - temp = validParameter.validFile(parameters, "stdin", false); if (temp == "not found"){ temp = "F"; } - stdin = isTrue(temp); - - temp = validParameter.validFile(parameters, "DNA", false); if (temp == "not found"){ temp = "F"; } - DNA = isTrue(temp); - - temp = validParameter.validFile(parameters, "protein", false); if (temp == "not found"){ temp = "F"; } - protein = isTrue(temp); - - temp = validParameter.validFile(parameters, "jukes", false); if (temp == "not found"){ temp = "F"; } - jukes = isTrue(temp); - - temp = validParameter.validFile(parameters, "kimura", false); if (temp == "not found"){ temp = "F"; } - kimura = isTrue(temp); - - temp = validParameter.validFile(parameters, "stdout", false); if (temp == "not found"){ temp = "F"; } - stdout = isTrue(temp); - - matrixout = validParameter.validFile(parameters, "matrixout", false); if (matrixout == "not found"){ matrixout = ""; } - - ntrees = validParameter.validFile(parameters, "ntrees", false); if (ntrees == "not found"){ ntrees = "1"; } - - temp = validParameter.validFile(parameters, "expblen", false); if (temp == "not found"){ temp = "F"; } - expblen = isTrue(temp); - - temp = validParameter.validFile(parameters, "expdist", false); if (temp == "not found"){ temp = "F"; } - expdist = isTrue(temp); - - if ((fastafile != "") && ((!DNA) && (!protein))) { m->mothurOut("You must specify the type of sequences you are using: DNA or protein"); m->mothurOutEndLine(); abort=true; } - } - - } - catch(exception& e) { - m->errorOut(e, "ClearcutCommand", "ClearcutCommand"); - exit(1); - } -} -//********************************************************************************************************************** - -void ClearcutCommand::help(){ - try { - m->mothurOut("The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n"); - m->mothurOut("For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n"); - m->mothurOut("The clearcut executable must be in a folder called clearcut in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n"); - m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA, stdin. \n"); - m->mothurOut("The phylip parameter allows you to enter your phylip formatted distance matrix. \n"); - m->mothurOut("The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n"); - - m->mothurOut("The version parameter prints out the version of clearcut you are using, default=F. \n"); - m->mothurOut("The verbose parameter prints out more output from clearcut, default=F. \n"); - m->mothurOut("The quiet parameter turns on silent operation mode, default=F. \n"); - m->mothurOut("The seed parameter allows you to explicitly set the PRNG seed to a specific value. \n"); - m->mothurOut("The norandom parameter allows you to attempt joins deterministically, default=F. \n"); - m->mothurOut("The shuffle parameter allows you to randomly shuffle the distance matrix, default=F. \n"); - m->mothurOut("The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=F. \n"); - - m->mothurOut("The stdin parameter reads input from STDIN, default=F. \n"); - m->mothurOut("The DNA parameter allows you to indicate your fasta file contains DNA sequences, default=F. \n"); - m->mothurOut("The protein parameter allows you to indicate your fasta file contains protein sequences, default=F. \n"); - - m->mothurOut("The stdout parameter outputs your tree to STDOUT, default=F. \n"); - m->mothurOut("The matrixout parameter allows you to specify a filename to output a distance matrix to. \n"); - m->mothurOut("The ntrees parameter allows you to specify the number of output trees, default=1. \n"); - m->mothurOut("The expblen parameter allows you to use exponential notation for branch lengths, default=F. \n"); - m->mothurOut("The expdist parameter allows you to use exponential notation for distance outputs, default=F. \n"); - - m->mothurOut("The clearcut command should be in the following format: \n"); - m->mothurOut("clearcut(phylip=yourDistanceFile) \n"); - m->mothurOut("Example: clearcut(phylip=abrecovery.phylip.dist) \n"); - } - catch(exception& e) { - m->errorOut(e, "ClearcutCommand", "help"); - exit(1); - } -} - -/**************************************************************************************/ -int ClearcutCommand::execute() { - try { - - if (abort == true) { return 0; } - - //prepare filename - string outputName = outputDir + getRootName(getSimpleName(inputFile)) + "tre"; - - //get location of clearcut - GlobalData* globaldata = GlobalData::getInstance(); - string path = globaldata->argv; - path = path.substr(0, (path.find_last_of('m'))); - - string clearcutCommand = path + "clearcut/clearcut "; - - //you gave us a distance matrix - if (phylipfile != "") { clearcutCommand += "--distance "; } - - //you gave us a fastafile - if (fastafile != "") { clearcutCommand += "--alignment "; } - - if (version) { clearcutCommand += "--version "; } - if (verbose) { clearcutCommand += "--verbose "; } - if (quiet) { clearcutCommand += "--quiet "; } - if (seed != "*") { clearcutCommand += "--seed=" + seed + " "; } - if (norandom) { clearcutCommand += "--norandom "; } - if (shuffle) { clearcutCommand += "--shuffle "; } - if (neighbor) { clearcutCommand += "--neighbor "; } - - if (stdin) { clearcutCommand += "--stdin "; } - else { clearcutCommand += "--in=" + inputFile + " "; } - if (stdout) { clearcutCommand += "--stdout "; } - else { clearcutCommand += "--out=" + outputName + " "; } - - if (DNA) { clearcutCommand += "--DNA "; } - if (protein) { clearcutCommand += "--protein "; } - if (jukes) { clearcutCommand += "--jukes "; } - if (kimura) { clearcutCommand += "--kimura "; } - if (matrixout != "") { clearcutCommand += "--matrixout=" + matrixout + " "; } - if (ntrees != "1") { clearcutCommand += "--ntrees=" + ntrees + " "; } - if (expblen) { clearcutCommand += "--expblen "; } - if (expdist) { clearcutCommand += "--expdist "; } - - //run clearcut - system(clearcutCommand.c_str()); - - if (!stdout) { - m->mothurOutEndLine(); - m->mothurOut("Output File Names: "); m->mothurOutEndLine(); - m->mothurOut(outputName); m->mothurOutEndLine(); - m->mothurOutEndLine(); - } - - return 0; - } - catch(exception& e) { - m->errorOut(e, "ClearcutCommand", "execute"); - exit(1); - } -} -/**************************************************************************************/ - - - - +/* + * clearcutcommand.cpp + * Mothur + * + * Created by westcott on 5/11/10. + * Copyright 2010 Schloss Lab. All rights reserved. + * + */ + +#include "clearcutcommand.h" + +/**************************************************************************************/ +ClearcutCommand::ClearcutCommand(string option) { + try { + abort = false; + + //allow user to run help + if(option == "help") { help(); abort = true; } + + else { + //valid paramters for this command + string Array[] = {"fasta","phylip","version","verbose","quiet","seed","norandom","shuffle","neighbor","expblen", + "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","stdin","outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + + OptionParser parser(option); + map parameters = parser.getParameters(); + + ValidParameters validParameter; + map::iterator it; + + //check to make sure all parameters are valid for command + for (it = parameters.begin(); it != parameters.end(); it++) { + if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } + } + + //if the user changes the input directory command factory will send this info to us in the output parameter + string inputDir = validParameter.validFile(parameters, "inputdir", false); + if (inputDir == "not found"){ inputDir = ""; } + else { + string path; + it = parameters.find("fasta"); + //user has given a template file + if(it != parameters.end()){ + path = hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["fasta"] = inputDir + it->second; } + } + + it = parameters.find("phylip"); + //user has given a template file + if(it != parameters.end()){ + path = hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["phylip"] = inputDir + it->second; } + } + } + + //check for required parameters + fastafile = validParameter.validFile(parameters, "fasta", true); + if (fastafile == "not open") { fastafile = ""; abort = true; } + else if (fastafile == "not found") { fastafile = ""; } + else { inputFile = fastafile; } + + phylipfile = validParameter.validFile(parameters, "phylip", true); + if (phylipfile == "not open") { phylipfile = ""; abort = true; } + else if (phylipfile == "not found") { phylipfile = ""; } + else { inputFile = phylipfile; } + + if ((phylipfile == "") && (fastafile == "")) { m->mothurOut("You must provide either a phylip formatted distance matrix or an aligned fasta file."); m->mothurOutEndLine(); abort=true; } + if ((phylipfile != "") && (fastafile != "")) { m->mothurOut("You must provide either a phylip formatted distance matrix or an aligned fasta file, not BOTH."); m->mothurOutEndLine(); abort=true; } + + + //if the user changes the output directory command factory will send this info to us in the output parameter + outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; } + + string temp; + temp = validParameter.validFile(parameters, "version", false); if (temp == "not found"){ temp = "F"; } + version = isTrue(temp); + + temp = validParameter.validFile(parameters, "verbose", false); if (temp == "not found"){ temp = "F"; } + verbose = isTrue(temp); + + temp = validParameter.validFile(parameters, "quiet", false); if (temp == "not found"){ temp = "F"; } + quiet = isTrue(temp); + + seed = validParameter.validFile(parameters, "seed", false); if (seed == "not found"){ seed = "*"; } + + temp = validParameter.validFile(parameters, "norandom", false); if (temp == "not found"){ temp = "F"; } + norandom = isTrue(temp); + + temp = validParameter.validFile(parameters, "shuffle", false); if (temp == "not found"){ temp = "F"; } + shuffle = isTrue(temp); + + temp = validParameter.validFile(parameters, "neighbor", false); if (temp == "not found"){ temp = "F"; } + neighbor = isTrue(temp); + + temp = validParameter.validFile(parameters, "stdin", false); if (temp == "not found"){ temp = "F"; } + stdinWanted = isTrue(temp); + + temp = validParameter.validFile(parameters, "DNA", false); if (temp == "not found"){ temp = "F"; } + DNA = isTrue(temp); + + temp = validParameter.validFile(parameters, "protein", false); if (temp == "not found"){ temp = "F"; } + protein = isTrue(temp); + + temp = validParameter.validFile(parameters, "jukes", false); if (temp == "not found"){ temp = "F"; } + jukes = isTrue(temp); + + temp = validParameter.validFile(parameters, "kimura", false); if (temp == "not found"){ temp = "F"; } + kimura = isTrue(temp); + + temp = validParameter.validFile(parameters, "stdout", false); if (temp == "not found"){ temp = "F"; } + stdoutWanted = isTrue(temp); + + matrixout = validParameter.validFile(parameters, "matrixout", false); if (matrixout == "not found"){ matrixout = ""; } + + ntrees = validParameter.validFile(parameters, "ntrees", false); if (ntrees == "not found"){ ntrees = "1"; } + + temp = validParameter.validFile(parameters, "expblen", false); if (temp == "not found"){ temp = "F"; } + expblen = isTrue(temp); + + temp = validParameter.validFile(parameters, "expdist", false); if (temp == "not found"){ temp = "F"; } + expdist = isTrue(temp); + + if ((fastafile != "") && ((!DNA) && (!protein))) { m->mothurOut("You must specify the type of sequences you are using: DNA or protein"); m->mothurOutEndLine(); abort=true; } + } + + } + catch(exception& e) { + m->errorOut(e, "ClearcutCommand", "ClearcutCommand"); + exit(1); + } +} +//********************************************************************************************************************** + +void ClearcutCommand::help(){ + try { + m->mothurOut("The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n"); + m->mothurOut("For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n"); + m->mothurOut("The clearcut executable must be in a folder called clearcut in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n"); + m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdoutWanted, kimura, jukes, protein, DNA, stdinWanted. \n"); + m->mothurOut("The phylip parameter allows you to enter your phylip formatted distance matrix. \n"); + m->mothurOut("The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n"); + + m->mothurOut("The version parameter prints out the version of clearcut you are using, default=F. \n"); + m->mothurOut("The verbose parameter prints out more output from clearcut, default=F. \n"); + m->mothurOut("The quiet parameter turns on silent operation mode, default=F. \n"); + m->mothurOut("The seed parameter allows you to explicitly set the PRNG seed to a specific value. \n"); + m->mothurOut("The norandom parameter allows you to attempt joins deterministically, default=F. \n"); + m->mothurOut("The shuffle parameter allows you to randomly shuffle the distance matrix, default=F. \n"); + m->mothurOut("The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=F. \n"); + + m->mothurOut("The stdinWanted parameter reads input from STDIN, default=F. \n"); + m->mothurOut("The DNA parameter allows you to indicate your fasta file contains DNA sequences, default=F. \n"); + m->mothurOut("The protein parameter allows you to indicate your fasta file contains protein sequences, default=F. \n"); + + m->mothurOut("The stdoutWanted parameter outputs your tree to STDOUT, default=F. \n"); + m->mothurOut("The matrixout parameter allows you to specify a filename to output a distance matrix to. \n"); + m->mothurOut("The ntrees parameter allows you to specify the number of output trees, default=1. \n"); + m->mothurOut("The expblen parameter allows you to use exponential notation for branch lengths, default=F. \n"); + m->mothurOut("The expdist parameter allows you to use exponential notation for distance outputs, default=F. \n"); + + m->mothurOut("The clearcut command should be in the following format: \n"); + m->mothurOut("clearcut(phylip=yourDistanceFile) \n"); + m->mothurOut("Example: clearcut(phylip=abrecovery.phylip.dist) \n"); + + } + catch(exception& e) { + m->errorOut(e, "ClearcutCommand", "help"); + exit(1); + } +} + +/**************************************************************************************/ +int ClearcutCommand::execute() { + try { + + if (abort == true) { return 0; } + + //prepare filename + string outputName = outputDir + getRootName(getSimpleName(inputFile)) + "tre"; + + //get location of clearcut + GlobalData* globaldata = GlobalData::getInstance(); + string path = globaldata->argv; + path = path.substr(0, (path.find_last_of('m'))); + + string clearcutCommand = ""; + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + clearcutCommand = path + "clearcut/clearcut "; + #else + clearcutCommand = path + "clearcut\\clearcut "; + #endif + + //you gave us a distance matrix + if (phylipfile != "") { clearcutCommand += "--distance "; } + + //you gave us a fastafile + if (fastafile != "") { clearcutCommand += "--alignment "; } + + if (version) { clearcutCommand += "--version "; } + if (verbose) { clearcutCommand += "--verbose "; } + if (quiet) { clearcutCommand += "--quiet "; } + if (seed != "*") { clearcutCommand += "--seed=" + seed + " "; } + if (norandom) { clearcutCommand += "--norandom "; } + if (shuffle) { clearcutCommand += "--shuffle "; } + if (neighbor) { clearcutCommand += "--neighbor "; } + + if (stdinWanted) { clearcutCommand += "--stdin "; } + else{ + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + clearcutCommand += "--in=" + inputFile + " "; } + #else + clearcutCommand += "--in=\"" + inputFile + "\" "; } + #endif + if (stdoutWanted) { clearcutCommand += "--stdout "; } + else{ + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + clearcutCommand += "--out=" + outputName + " "; } + #else + clearcutCommand += "--out=\"" + outputName + "\" "; } + #endif + + if (DNA) { clearcutCommand += "--DNA "; } + if (protein) { clearcutCommand += "--protein "; } + if (jukes) { clearcutCommand += "--jukes "; } + if (kimura) { clearcutCommand += "--kimura "; } + if (matrixout != "") { clearcutCommand += "--matrixout=" + matrixout + " "; } + if (ntrees != "1") { clearcutCommand += "--ntrees=" + ntrees + " "; } + if (expblen) { clearcutCommand += "--expblen "; } + if (expdist) { clearcutCommand += "--expdist "; } + + //run clearcut + system(clearcutCommand.c_str()); + + if (!stdoutWanted) { + m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); + m->mothurOut(outputName); m->mothurOutEndLine(); + m->mothurOutEndLine(); + } + + return 0; + } + catch(exception& e) { + m->errorOut(e, "ClearcutCommand", "execute"); + exit(1); + } +} +/**************************************************************************************/ + + + + diff --git a/clearcutcommand.h b/clearcutcommand.h index b3ac28e..d6c0a57 100644 --- a/clearcutcommand.h +++ b/clearcutcommand.h @@ -11,7 +11,7 @@ */ #include "command.hpp" - +#include "globaldata.hpp" /* Evans, J., L. Sheneman, and J.A. Foster (2006) Relaxed Neighbor-Joining: @@ -31,7 +31,7 @@ public: private: string outputDir, phylipfile, fastafile, matrixout, inputFile, seed, ntrees; - bool version, verbose, quiet, norandom, shuffle, neighbor, expblen, expdist, stdout, kimura, jukes, protein, DNA, stdin; + bool version, verbose, quiet, norandom, shuffle, neighbor, expblen, expdist, stdoutWanted, kimura, jukes, protein, DNA, stdinWanted; bool abort; }; diff --git a/collect.cpp b/collect.cpp index 379424c..fa6f677 100644 --- a/collect.cpp +++ b/collect.cpp @@ -24,7 +24,9 @@ int Collect::getCurve(float percentFreq = 0.01){ } //convert freq percentage to number - int increment = numSeqs * percentFreq; + int increment = 1; + if (percentFreq < 1.0) { increment = numSeqs * percentFreq; } + else { increment = percentFreq; } for(int i=0;imothurOut("The collect.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n"); m->mothurOut("The collect.single command parameters are label, freq, calc and abund. No parameters are required. \n"); m->mothurOut("The collect.single command should be in the following format: \n"); - m->mothurOut("The freq parameter is used indicate when to output your data. It is a percentage of the number of sequences. By default it is set to 0.10, meaning 10%. \n"); + m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n"); m->mothurOut("collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n"); m->mothurOut("Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n"); m->mothurOut("The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n"); diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 78ce5c4..40b911b 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -104,7 +104,7 @@ CollectSharedCommand::CollectSharedCommand(string option) { globaldata->Groups = Groups; string temp; - temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "0.10"; } + temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; } convert(temp, freq); temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; } @@ -208,7 +208,7 @@ void CollectSharedCommand::help(){ m->mothurOut("Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n"); m->mothurOut("The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n"); m->mothurOut("The default value for groups is all the groups in your groupfile.\n"); - m->mothurOut("The freq parameter is used indicate when to output your data. It is a percentage of the number of sequences. By default it is set to 0.10, meaning 10%. \n"); + m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n"); validCalculator->printCalc("shared", cout); m->mothurOut("The label parameter is used to analyze specific labels in your input.\n"); m->mothurOut("The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n"); diff --git a/distancedb.hpp b/distancedb.hpp index 47e5fd7..bfb5090 100644 --- a/distancedb.hpp +++ b/distancedb.hpp @@ -19,7 +19,7 @@ class DistanceDB : public Database { public: DistanceDB(); - ~DistanceDB() {} + ~DistanceDB() { delete distCalculator; } void generateDB() {} //doesn't generate a search db void addSequence(Sequence); diff --git a/knn.cpp b/knn.cpp index 64b5b3a..beee4af 100644 --- a/knn.cpp +++ b/knn.cpp @@ -22,6 +22,17 @@ Knn::Knn(string tfile, string tempFile, string method, int kmerSize, float gapOp } } /**************************************************************************************************/ +Knn::~Knn() { + try { + delete phyloTree; + if (database != NULL) { delete database; } + } + catch(exception& e) { + m->errorOut(e, "Knn", "~Knn"); + exit(1); + } +} +/**************************************************************************************************/ string Knn::getTaxonomy(Sequence* seq) { try { string tax; diff --git a/knn.h b/knn.h index 2c809c2..45cb0f1 100644 --- a/knn.h +++ b/knn.h @@ -19,7 +19,7 @@ class Knn : public Classify { public: Knn(string, string, string, int, float, float, float, float, int); - ~Knn() {}; + ~Knn(); string getTaxonomy(Sequence*); diff --git a/mothur.cpp b/mothur.cpp index d674ff4..43b838c 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -1,193 +1,193 @@ -/* - * interface.cpp - * - * - * Created by Pat Schloss on 8/14/08. - * Copyright 2008 Patrick D. Schloss. All rights reserved. - * - */ - -#include "mothur.h" -#include "engine.hpp" -#include "globaldata.hpp" -#include "mothurout.h" - - -/**************************************************************************************************/ - -GlobalData* GlobalData::_uniqueInstance = 0; -CommandFactory* CommandFactory::_uniqueInstance = 0; -MothurOut* MothurOut::_uniqueInstance = 0; - -/***********************************************************************/ -volatile int ctrlc_pressed = 0; -void ctrlc_handler ( int sig ) { - MothurOut* m = MothurOut::getInstance(); - ctrlc_pressed = 1; - m->control_pressed = ctrlc_pressed; - - if (m->executing) { //if mid command quit execution, else quit mothur - m->mothurOutEndLine(); m->mothurOut("quitting command..."); m->mothurOutEndLine(); - }else{ - m->mothurOut("quitting mothur"); m->mothurOutEndLine(); - exit(1); - } -} -/***********************************************************************/ -int main(int argc, char *argv[]){ - MothurOut* m = MothurOut::getInstance(); - try { - - signal(SIGINT, ctrlc_handler ); - - time_t ltime = time(NULL); /* calendar time */ - string logFileName = "mothur." + toString(ltime) + ".logfile"; - - #ifdef USE_MPI - MPI_Init(&argc, &argv); - #endif - - m->setFileName(logFileName); - - - //version - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - system("clear"); - #if defined (__APPLE__) || (__MACH__) - m->mothurOutJustToLog("Mac version"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - #else - m->mothurOutJustToLog("Linux version"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - #endif - - #else - system("CLS"); - m->mothurOutJustToLog("Windows version"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - #endif - - #ifdef USE_READLINE - m->mothurOutJustToLog("Using ReadLine"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - #endif - - //header - m->mothurOut("mothur v.1.9"); - m->mothurOutEndLine(); - m->mothurOut("Last updated: 4/16/2010"); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("by"); - m->mothurOutEndLine(); - m->mothurOut("Patrick D. Schloss"); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("Department of Microbiology & Immunology"); - m->mothurOutEndLine(); - m->mothurOut("University of Michigan"); - m->mothurOutEndLine(); - m->mothurOut("pschloss@umich.edu"); - m->mothurOutEndLine(); - m->mothurOut("http://www.mothur.org"); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("When using, please cite:"); - m->mothurOutEndLine(); - m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41."); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("Distributed under the GNU General Public License"); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("Type 'help()' for information on the commands that are available"); - m->mothurOutEndLine(); - m->mothurOutEndLine(); - m->mothurOut("Type 'quit()' to exit program"); - m->mothurOutEndLine(); - - #ifdef USE_MPI - m->mothurOutJustToLog("Using MPI\tversion "); - int version, subversion; - MPI_Get_version(&version, &subversion); - m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n"); - #endif - - //srand(54321); - srand( (unsigned)time( NULL ) ); - - Engine* mothur; - bool bail = 0; - string input; - - if(argc>1){ - input = argv[1]; - - if (input[0] == '#') { - m->mothurOutJustToLog("Script Mode"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - - mothur = new ScriptEngine(argv[0], argv[1]); - }else{ - m->mothurOutJustToLog("Batch Mode"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - - mothur = new BatchEngine(argv[0], argv[1]); - } - } - else{ - m->mothurOutJustToLog("Interactive Mode"); - m->mothurOutEndLine(); m->mothurOutEndLine(); - - mothur = new InteractEngine(argv[0]); - } - - while(bail == 0) { bail = mothur->getInput(); } - - //closes logfile so we can rename - m->closeLog(); - - string outputDir = mothur->getOutputDir(); - string tempLog = mothur->getLogFileName(); - bool append = mothur->getAppend(); - - string newlogFileName; - if (tempLog != "") { - newlogFileName = outputDir + tempLog; - - if (!append) { - //need this because m->mothurOut makes the logfile, but doesn't know where to put it - rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp - - }else { - ofstream outNewLog; - openOutputFileAppend(newlogFileName, outNewLog); - outNewLog << endl << endl << "*********************************************************************************" << endl << endl; - outNewLog.close(); - - appendFiles(logFileName, newlogFileName); - remove(logFileName.c_str()); - } - }else{ - newlogFileName = outputDir + logFileName; - //need this because m->mothurOut makes the logfile, but doesn't know where to put it - rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp - } - - - delete mothur; - - #ifdef USE_MPI - MPI_Finalize(); - #endif - - return 0; - } - catch(exception& e) { - m->errorOut(e, "mothur", "main"); - exit(1); - } -} - -/**************************************************************************************************/ - +/* + * interface.cpp + * + * + * Created by Pat Schloss on 8/14/08. + * Copyright 2008 Patrick D. Schloss. All rights reserved. + * + */ + +#include "mothur.h" +#include "engine.hpp" +#include "globaldata.hpp" +#include "mothurout.h" + + +/**************************************************************************************************/ + +GlobalData* GlobalData::_uniqueInstance = 0; +CommandFactory* CommandFactory::_uniqueInstance = 0; +MothurOut* MothurOut::_uniqueInstance = 0; + +/***********************************************************************/ +volatile int ctrlc_pressed = 0; +void ctrlc_handler ( int sig ) { + MothurOut* m = MothurOut::getInstance(); + ctrlc_pressed = 1; + m->control_pressed = ctrlc_pressed; + + if (m->executing) { //if mid command quit execution, else quit mothur + m->mothurOutEndLine(); m->mothurOut("quitting command..."); m->mothurOutEndLine(); + }else{ + m->mothurOut("quitting mothur"); m->mothurOutEndLine(); + exit(1); + } +} +/***********************************************************************/ +int main(int argc, char *argv[]){ + MothurOut* m = MothurOut::getInstance(); + try { + + signal(SIGINT, ctrlc_handler ); + + time_t ltime = time(NULL); /* calendar time */ + string logFileName = "mothur." + toString(ltime) + ".logfile"; + + #ifdef USE_MPI + MPI_Init(&argc, &argv); + #endif + + m->setFileName(logFileName); + + + //version + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + system("clear"); + #if defined (__APPLE__) || (__MACH__) + m->mothurOutJustToLog("Mac version"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + #else + m->mothurOutJustToLog("Linux version"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + #endif + + #else + system("CLS"); + m->mothurOutJustToLog("Windows version"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + #endif + + #ifdef USE_READLINE + m->mothurOutJustToLog("Using ReadLine"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + #endif + + //header + m->mothurOut("mothur v.1.10.0"); + m->mothurOutEndLine(); + m->mothurOut("Last updated: 5/14/2010"); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("by"); + m->mothurOutEndLine(); + m->mothurOut("Patrick D. Schloss"); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("Department of Microbiology & Immunology"); + m->mothurOutEndLine(); + m->mothurOut("University of Michigan"); + m->mothurOutEndLine(); + m->mothurOut("pschloss@umich.edu"); + m->mothurOutEndLine(); + m->mothurOut("http://www.mothur.org"); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("When using, please cite:"); + m->mothurOutEndLine(); + m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41."); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("Distributed under the GNU General Public License"); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("Type 'help()' for information on the commands that are available"); + m->mothurOutEndLine(); + m->mothurOutEndLine(); + m->mothurOut("Type 'quit()' to exit program"); + m->mothurOutEndLine(); + + #ifdef USE_MPI + m->mothurOutJustToLog("Using MPI\tversion "); + int version, subversion; + MPI_Get_version(&version, &subversion); + m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n"); + #endif + + //srand(54321); + srand( (unsigned)time( NULL ) ); + + Engine* mothur; + bool bail = 0; + string input; + + if(argc>1){ + input = argv[1]; + + if (input[0] == '#') { + m->mothurOutJustToLog("Script Mode"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + + mothur = new ScriptEngine(argv[0], argv[1]); + }else{ + m->mothurOutJustToLog("Batch Mode"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + + mothur = new BatchEngine(argv[0], argv[1]); + } + } + else{ + m->mothurOutJustToLog("Interactive Mode"); + m->mothurOutEndLine(); m->mothurOutEndLine(); + + mothur = new InteractEngine(argv[0]); + } + + while(bail == 0) { bail = mothur->getInput(); } + + //closes logfile so we can rename + m->closeLog(); + + string outputDir = mothur->getOutputDir(); + string tempLog = mothur->getLogFileName(); + bool append = mothur->getAppend(); + + string newlogFileName; + if (tempLog != "") { + newlogFileName = outputDir + tempLog; + + if (!append) { + //need this because m->mothurOut makes the logfile, but doesn't know where to put it + rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp + + }else { + ofstream outNewLog; + openOutputFileAppend(newlogFileName, outNewLog); + outNewLog << endl << endl << "*********************************************************************************" << endl << endl; + outNewLog.close(); + + appendFiles(logFileName, newlogFileName); + remove(logFileName.c_str()); + } + }else{ + newlogFileName = outputDir + logFileName; + //need this because m->mothurOut makes the logfile, but doesn't know where to put it + rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp + } + + + delete mothur; + + #ifdef USE_MPI + MPI_Finalize(); + #endif + + return 0; + } + catch(exception& e) { + m->errorOut(e, "mothur", "main"); + exit(1); + } +} + +/**************************************************************************************************/ + diff --git a/mothur.h b/mothur.h index f101d1f..ca19aea 100644 --- a/mothur.h +++ b/mothur.h @@ -487,7 +487,7 @@ inline string getFullPathName(string fileName){ } #else if (path.find("~") != -1) { //go to home directory - string homeDir = getenv ("HOME"); + string homeDir = getenv ("HOMEPATH"); newFileName = homeDir + fileName.substr(fileName.find("~")+1); return newFileName; }else { //find path diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp index 7e0574e..19c65ce 100644 --- a/phylodiversitycommand.cpp +++ b/phylodiversitycommand.cpp @@ -41,7 +41,7 @@ PhyloDiversityCommand::PhyloDiversityCommand(string option) { m->mothurOut("You must execute the read.tree command, before you may execute the phylo.diversity command."); m->mothurOutEndLine(); abort = true; } string temp; - temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "0.10"; } + temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; } convert(temp, freq); temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "1000"; } @@ -73,7 +73,7 @@ void PhyloDiversityCommand::help(){ m->mothurOut("The phylo.diversity command parameters are groups, iters, freq and rarefy. No parameters are required.\n"); m->mothurOut("The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. The group names are separated by dashes. By default all groups are used.\n"); m->mothurOut("The iters parameter allows you to specify the number of randomizations to preform, by default iters=1000, if you set rarefy to true.\n"); - m->mothurOut("The freq parameter is used indicate when to output your data. It is a percentage of the number of sequences. By default it is set to 0.10, meaning 10%. \n"); + m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n"); m->mothurOut("The rarefy parameter allows you to create a rarefaction curve. The default is false.\n"); m->mothurOut("The phylo.diversity command should be in the following format: phylo.diversity(groups=yourGroups, rarefy=yourRarefy, iters=yourIters).\n"); m->mothurOut("Example phylo.diversity(groups=A-B-C, rarefy=T, iters=500).\n"); @@ -132,7 +132,9 @@ int PhyloDiversityCommand::execute(){ numLeafNodes = randomLeaf.size(); //reset the number of leaf nodes you are using //convert freq percentage to number - int increment = numLeafNodes * freq; + int increment = 100; + if (freq < 1.0) { increment = numLeafNodes * freq; } + else { increment = freq; } //each group, each sampling, if no rarefy iters = 1; vector< vector > diversity; diff --git a/rarefact.cpp b/rarefact.cpp index 76f6829..691d017 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -20,8 +20,10 @@ int Rarefact::getCurve(float percentFreq = 0.01, int nIters = 1000){ } //convert freq percentage to number - int increment = numSeqs * percentFreq; - + int increment = 1; + if (percentFreq < 1.0) { increment = numSeqs * percentFreq; } + else { increment = percentFreq; } + for(int iter=0;iterjumble == false) { nIters = 1; } //convert freq percentage to number - int increment = numSeqs * percentFreq; + int increment = 1; + if (percentFreq < 1.0) { increment = numSeqs * percentFreq; } + else { increment = percentFreq; } for(int iter=0;itermothurOut("The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION.\n"); m->mothurOut("The rarefaction.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster.\n"); m->mothurOut("The rarefaction.single command parameters are label, iters, freq, calc and abund. No parameters are required. \n"); - m->mothurOut("The freq parameter is used indicate when to output your data. It is a percentage of the number of sequences. By default it is set to 0.10, meaning 10%. \n"); + m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n"); m->mothurOut("The rarefaction.single command should be in the following format: \n"); m->mothurOut("rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n"); m->mothurOut("Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n"); diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 357bc87..324f028 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -84,7 +84,7 @@ RareFactSharedCommand::RareFactSharedCommand(string option) { globaldata->Groups = Groups; string temp; - temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "0.10"; } + temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; } convert(temp, freq); temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "1000"; } @@ -133,7 +133,7 @@ void RareFactSharedCommand::help(){ m->mothurOut("The rarefaction.shared command parameters are label, iters, groups, jumble and calc. No parameters are required.\n"); m->mothurOut("The rarefaction command should be in the following format: \n"); m->mothurOut("rarefaction.shared(label=yourLabel, iters=yourIters, calc=yourEstimators, jumble=yourJumble, groups=yourGroups).\n"); - m->mothurOut("The freq parameter is used indicate when to output your data. It is a percentage of the number of sequences. By default it is set to 0.10, meaning 10%. \n"); + m->mothurOut("The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n"); m->mothurOut("Example rarefaction.shared(label=unique-0.01-0.03, iters=10000, groups=B-C, jumble=T, calc=sharedobserved).\n"); m->mothurOut("The default values for iters is 1000, freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness.\n"); m->mothurOut("The default value for groups is all the groups in your groupfile, and jumble is true.\n"); diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index f630052..f551edd 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -250,7 +250,7 @@ int SeqSummaryCommand::execute(){ if (m->control_pressed) { return 0; } #else ifstream inFASTA; - openInputFile(fastafileNames[s], inFASTA); + openInputFile(fastafile, inFASTA); numSeqs=count(istreambuf_iterator(inFASTA),istreambuf_iterator(), '>'); inFASTA.close(); diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index a544733..ae9c436 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -266,13 +266,13 @@ int TrimSeqsCommand::execute(){ if (m->control_pressed) { return 0; } #else ifstream inFASTA; - openInputFile(fastafileNames[s], inFASTA); - numSeqs=count(istreambuf_iterator(inFASTA),istreambuf_iterator(), '>'); + openInputFile(fastaFile, inFASTA); + int numSeqs=count(istreambuf_iterator(inFASTA),istreambuf_iterator(), '>'); inFASTA.close(); lines.push_back(new linePair(0, numSeqs)); - driverCreateSummary(fastafile, qFileName, trimSeqFile, scrapSeqFile, groupFile, fastaFileNames, lines[0], lines[0]); + driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, groupFile, fastaFileNames, lines[0], lines[0]); if (m->control_pressed) { return 0; } #endif @@ -331,7 +331,11 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string if (oligoFile != "") { openOutputFile(groupFile, outGroups); for (int i = 0; i < fastaNames.size(); i++) { + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) fastaFileNames.push_back(new ofstream((fastaNames[i] + toString(getpid()) + ".temp").c_str(), ios::ate)); + #else + fastaFileNames.push_back(new ofstream((fastaNames[i] + toString(i) + ".temp").c_str(), ios::ate)); + #endif } } @@ -674,12 +678,7 @@ int TrimSeqsCommand::stripBarcode(Sequence& seq, int& group){ } oligo = oligo.substr(0,alnLength); temp = temp.substr(0,alnLength); -// cout << "barcode = " << oligo << " raw = " << rawSequence.substr(0,alnLength) << " raw aligned = " << temp << endl; - cout << seq.getName() << endl; - cout << temp << endl; - cout << oligo << endl; - cout << alnLength << endl; - cout << endl; +// int newStart=0; int numDiff = countDiffs(oligo, temp); @@ -789,13 +788,7 @@ int TrimSeqsCommand::stripForward(Sequence& seq){ } oligo = oligo.substr(0,alnLength); temp = temp.substr(0,alnLength); -// cout << "barcode = " << oligo << " raw = " << rawSequence.substr(0,alnLength) << " raw aligned = " << temp << endl; - cout << seq.getName() << endl; - cout << temp << endl; - cout << oligo << endl; - cout << alnLength << endl; - cout << endl; - +// int newStart=0; int numDiff = countDiffs(oligo, temp); if(numDiff < minDiff){ diff --git a/validparameter.cpp b/validparameter.cpp index d693bcb..4ea677f 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -262,12 +262,6 @@ void ValidParameters::initParameterRanges() { string itersArray[] = {">=","10", "<","NA", "between"}; parameterRanges["iters"] = addParameters(itersArray, rangeSize); - string freqArray[] = {">=","1", "<","NA", "between"}; - parameterRanges["freq"] = addParameters(freqArray, rangeSize); - - //string lineArray[] = {">=","1", "<","NA", "between"}; - //parameterRanges["line"] = addParameters(lineArray, rangeSize); - string abundArray[] = {">=","5", "<","NA", "between"}; parameterRanges["abund"] = addParameters(abundArray, rangeSize); diff --git a/venn.cpp b/venn.cpp index 638a12f..7e24049 100644 --- a/venn.cpp +++ b/venn.cpp @@ -42,18 +42,21 @@ vector Venn::getPic(SAbundVector* sabund, vector vCalcs) { vector data = vCalcs[i]->getValues(sabund); + int width = 1500; + int height = 1500; + //svg image - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; - outsvg << ""; - outsvg << "Venn Diagram at distance " + sabund->getLabel() + "\n"; - outsvg << ""; - outsvg << "" + toString(data[0]) + "\n"; + outsvg << ""; + outsvg << "Venn Diagram at distance " + sabund->getLabel() + "\n"; + outsvg << ""; + outsvg << "" + toString(data[0]) + "\n"; if (data.size() == 3) { - outsvg << "The lower bound of the confidence interval is " + toString(data[1]) + "\n"; - outsvg << "The upper bound of the confidence interval is " + toString(data[2]) + "\n"; + outsvg << "The lower bound of the confidence interval is " + toString(data[1]) + "\n"; + outsvg << "The upper bound of the confidence interval is " + toString(data[2]) + "\n"; } outsvg << "\n\n"; @@ -74,6 +77,9 @@ vector Venn::getPic(vector lookup, vector subset; vector outputNames; + int width = 1500; + int height = 1500; + /******************* 1 Group **************************/ if (lookup.size() == 1) { @@ -100,18 +106,18 @@ vector Venn::getPic(vector lookup, vector data = singleCalc->getValues(sabund); //svg image - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << ""; - outsvg << "getGroup().length() / 2)) + "\" y=\"165\">" + lookup[0]->getGroup() + "\n"; - outsvg << "" + toString(data[0]) + "\n"; + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << ""; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.24 * height)) + "\">" + lookup[0]->getGroup() + "\n"; + outsvg << "" + toString(data[0]) + "\n"; if (data.size() == 3) { - outsvg << "The lower bound of the confidence interval is " + toString(data[1]) + "\n"; - outsvg << "The upper bound of the confidence interval is " + toString(data[2]) + "\n"; + outsvg << "The lower bound of the confidence interval is " + toString(data[1]) + "\n"; + outsvg << "The upper bound of the confidence interval is " + toString(data[2]) + "\n"; } outsvg << "\n\n"; @@ -159,32 +165,32 @@ vector Venn::getPic(vector lookup, vector numB = singleCalc->getValues(sabundB); //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << ""; - outsvg << ""; - outsvg << "" + toString(numA[0] - shared[0]) + "\n"; - outsvg << "" + toString(numB[0] - shared[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"175\">" + lookup[0]->getGroup() + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"175\">" + lookup[1]->getGroup() + "\n"; - outsvg << "" + toString(shared[0]) + "\n"; - outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << ""; + outsvg << ""; + outsvg << "" + toString(numA[0] - shared[0]) + "\n"; + outsvg << "" + toString(numB[0] - shared[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[0]->getGroup() + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.25 * height)) + "\">" + lookup[1]->getGroup() + "\n"; + outsvg << "" + toString(shared[0]) + "\n"; + outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); if (numA.size() == 3) { outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); + outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); if (numB.size() == 3) { outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]) + "\n"; - outsvg << "Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "\n"; - outsvg << "The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "\n"; + outsvg << "The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]) + "\n"; + outsvg << "Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "\n"; + outsvg << "The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "\n"; //close file outsvg << "\n\n"; @@ -194,6 +200,9 @@ vector Venn::getPic(vector lookup, vector Venn::getPic(vector lookup, vector\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << ""; - outsvg << ""; - outsvg << ""; + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << ""; + outsvg << ""; + outsvg << ""; //place labels within overlaps - outsvg << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "\n"; - outsvg << "" + toString(sharedAB[0] - sharedABC) + "\n"; - outsvg << "" + toString(numB[0]-sharedBwithAC[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[1]->getGroup() + "\n"; - outsvg << "" + toString(sharedAC[0] - sharedABC) + "\n"; - outsvg << "" + toString(numC[0]-sharedCwithAB[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"410\">" + lookup[2]->getGroup() + "\n"; - outsvg << "" + toString(sharedBC[0] - sharedABC) + "\n"; - outsvg << "" + toString(sharedABC) + "\n"; + outsvg << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "\n"; + outsvg << "" + toString(sharedAB[0] - sharedABC) + "\n"; + outsvg << "" + toString(numB[0]-sharedBwithAC[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "\n"; + outsvg << "" + toString(sharedAC[0] - sharedABC) + "\n"; + outsvg << "" + toString(numC[0]-sharedCwithAB[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.52 * height)) + "\">" + lookup[2]->getGroup() + "\n"; + outsvg << "" + toString(sharedBC[0] - sharedABC) + "\n"; + outsvg << "" + toString(sharedABC) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "\n"; - outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "\n"; + outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); if (numA.size() == 3) { outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); + outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); if (numB.size() == 3) { outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]); + outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]); if (numC.size() == 3) { outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "\n"; - outsvg << "The total shared richness is " + toString(sharedABC) + "\n"; + outsvg << "The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "\n"; + outsvg << "The total shared richness is " + toString(sharedABC) + "\n"; delete singleCalc; @@ -384,48 +393,48 @@ vector Venn::getPic(vector lookup, vector sharedabc = vCalcs[i]->getValues(subset); //image window - outsvg << "\n"; + outsvg << "\n"; outsvg << "\n"; //draw circles - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << ""; - outsvg << ""; - outsvg << ""; + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << ""; + outsvg << ""; + outsvg << ""; //place labels within overlaps - outsvg << "" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "\n"; - outsvg << "" + toString(sharedab[0] - sharedabc[0]) + "\n"; - outsvg << "" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[1]->getGroup() + "\n"; - outsvg << "" + toString(sharedac[0] - sharedabc[0]) + "\n"; - outsvg << "" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"410\">" + lookup[2]->getGroup() + "\n"; - outsvg << "" + toString(sharedbc[0] - sharedabc[0]) + "\n"; - outsvg << "" + toString(sharedabc[0]) + "\n"; + outsvg << "" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[0]->getGroup() + "\n"; + outsvg << "" + toString(sharedab[0] - sharedabc[0]) + "\n"; + outsvg << "" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.19 * height)) + "\">" + lookup[1]->getGroup() + "\n"; + outsvg << "" + toString(sharedac[0] - sharedabc[0]) + "\n"; + outsvg << "" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.51 * height)) + "\">" + lookup[2]->getGroup() + "\n"; + outsvg << "" + toString(sharedbc[0] - sharedabc[0]) + "\n"; + outsvg << "" + toString(sharedabc[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "\n"; - outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "\n"; + outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]); if (numA.size() == 3) { outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); + outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]); if (numB.size() == 3) { outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]); + outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]); if (numC.size() == 3) { outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "\n"; }else { outsvg << "\n"; } - outsvg << "The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "\n"; - outsvg << "The total shared richness is " + toString(sharedabc[0]) + "\n"; + outsvg << "The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "\n"; + outsvg << "The total shared richness is " + toString(sharedabc[0]) + "\n"; } @@ -441,6 +450,9 @@ vector Venn::getPic(vector lookup, vector Venn::getPic(vector lookup, vector\n"; + outsvg << "\n"; outsvg << "\n"; - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA) + "\n"; - outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB) + "\n"; - outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "\n"; - outsvg << "The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "\n"; + outsvg << "The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA) + "\n"; + outsvg << "The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB) + "\n"; + outsvg << "The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "\n"; + outsvg << "The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "\n"; - outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "\n"; + outsvg << "The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "\n"; //make adjustments sharedABC = sharedABC - sharedABCD; @@ -604,37 +616,37 @@ vector Venn::getPic(vector lookup, vector\n "; - outsvg << "\n "; - outsvg << "\n "; - outsvg << "\n "; + outsvg << "\n "; + outsvg << "\n "; + outsvg << "\n "; + outsvg << "\n "; //A = red, B = green, C = blue, D = yellow //place labels within overlaps - outsvg << "" + toString(numA) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "\n"; - outsvg << "" + toString(sharedAB) + "\n"; - outsvg << "" + toString(numB) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"90\">" + lookup[1]->getGroup() + "\n"; - outsvg << "" + toString(sharedAC) + "\n"; - outsvg << "" + toString(numC) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[2]->getGroup() + "\n"; - outsvg << "" + toString(sharedBD) + "\n"; - outsvg << "" + toString(numD) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "\n"; - outsvg << "" + toString(sharedAD) + "\n"; - outsvg << "" + toString(sharedBC) + "\n"; - outsvg << "" + toString(sharedCD) + "\n"; - outsvg << "" + toString(sharedABD) + "\n"; - outsvg << "" + toString(sharedBCD) + "\n"; - outsvg << "" + toString(sharedACD) + "\n"; - outsvg << "" + toString(sharedABC) + "\n"; - outsvg << "" + toString(sharedABCD) + "\n"; + outsvg << "" + toString(numA) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[0]->getGroup() + "\n"; + outsvg << "" + toString(sharedAB) + "\n"; + outsvg << "" + toString(numB) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.11 * height)) + "\">" + lookup[1]->getGroup() + "\n"; + outsvg << "" + toString(sharedAC) + "\n"; + outsvg << "" + toString(numC) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[2]->getGroup() + "\n"; + outsvg << "" + toString(sharedBD) + "\n"; + outsvg << "" + toString(numD) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"" + toString(int(0.26 * height)) + "\">" + lookup[3]->getGroup() + "\n"; + outsvg << "" + toString(sharedAD) + "\n"; + outsvg << "" + toString(sharedBC) + "\n"; + outsvg << "" + toString(sharedCD) + "\n"; + outsvg << "" + toString(sharedABD) + "\n"; + outsvg << "" + toString(sharedBCD) + "\n"; + outsvg << "" + toString(sharedACD) + "\n"; + outsvg << "" + toString(sharedABC) + "\n"; + outsvg << "" + toString(sharedABCD) + "\n"; - outsvg << "The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD)) + "\n"; + outsvg << "The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD)) + "\n"; outsvg << "\n\n"; -- 2.39.2