From: westcott Date: Fri, 8 May 2009 16:52:01 +0000 (+0000) Subject: altered venn command to make use of sharedchao for any number of groups, fixed window... X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=3117b1c3109121dff476997d3c5db5b47a77729b altered venn command to make use of sharedchao for any number of groups, fixed windows users bug with deconvolute command. Began adding distance command. --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 5e6e792..d29d52e 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */; }; 37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B28F670F27590100808A62 /* deconvolutecommand.cpp */; }; 37C1D9730F86506E0059E3F0 /* binsequencecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */; }; + 37C753CE0FB3415200DBD02E /* distancecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C753CD0FB3415200DBD02E /* distancecommand.cpp */; }; 37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; }; 37D928560F21331F001D4494 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BA0F21331F001D4494 /* averagelinkage.cpp */; }; 37D928570F21331F001D4494 /* bootstrap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BB0F21331F001D4494 /* bootstrap.cpp */; }; @@ -253,6 +254,14 @@ 37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = ""; }; 37C1D9710F86506E0059E3F0 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binsequencecommand.h; sourceTree = ""; }; 37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binsequencecommand.cpp; sourceTree = ""; }; + 37C753CC0FB3415200DBD02E /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distancecommand.h; sourceTree = ""; }; + 37C753CD0FB3415200DBD02E /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancecommand.cpp; sourceTree = ""; }; + 37C753DF0FB3492400DBD02E /* dist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dist.h; sourceTree = ""; }; + 37C753ED0FB34A5700DBD02E /* ignoregaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ignoregaps.h; sourceTree = ""; }; + 37C753F00FB34AE800DBD02E /* eachgapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdist.h; sourceTree = ""; }; + 37C753F10FB34B4700DBD02E /* onegapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapdist.h; sourceTree = ""; }; + 37C753F30FB34BBF00DBD02E /* onegapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapignore.h; sourceTree = ""; }; + 37C753F40FB34C0300DBD02E /* eachgapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapignore.h; sourceTree = ""; }; 37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = ""; }; 37D927B90F21331F001D4494 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = ""; }; 37D927BA0F21331F001D4494 /* averagelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = averagelinkage.cpp; sourceTree = ""; }; @@ -475,6 +484,7 @@ 7E4130F70F8E58FA00381DD0 /* dlibshuff.h */, 7E4130F60F8E58FA00381DD0 /* dlibshuff.cpp */, 37D927D60F21331F001D4494 /* display.h */, + 37C753DF0FB3492400DBD02E /* dist.h */, 37D927D80F21331F001D4494 /* engine.hpp */, 37D927D70F21331F001D4494 /* engine.cpp */, 37D928B10F213472001D4494 /* errorcheckor */, @@ -514,8 +524,6 @@ 378C1AF70FB0644D004D63F5 /* readnexus.h */, 378C1AF60FB0644D004D63F5 /* readnexus.cpp */, 378C1AF80FB0644D004D63F5 /* readnexusal.h */, - 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */, - 378C1AFE0FB0644D004D63F5 /* sequencedb.h */, 375AA1360F9E433D008EF9B8 /* readotu.h */, 375AA1350F9E433D008EF9B8 /* readotu.cpp */, 375AA1380F9E433D008EF9B8 /* readphylip.h */, @@ -524,8 +532,6 @@ 378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */, 37AD4DC80F28F3DD00AA2D49 /* readtree.h */, 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */, - 37D9281D0F21331F001D4494 /* sequence.hpp */, - 37D9281C0F21331F001D4494 /* sequence.cpp */, 37D928210F21331F001D4494 /* shared.h */, 37D928200F21331F001D4494 /* shared.cpp */, 211C38310F961DD400FEE541 /* sharedutilities.h */, @@ -567,21 +573,26 @@ 37D927BF0F21331F001D4494 /* chao1.cpp */, 7EC3D4510FA0FFF900338DA5 /* coverage.h */, 7EC3D4500FA0FFF900338DA5 /* coverage.cpp */, + 37C753F00FB34AE800DBD02E /* eachgapdist.h */, + 37C753F40FB34C0300DBD02E /* eachgapignore.h */, EB9303F70F53517300E8EF26 /* geom.h */, EB9303F80F53517300E8EF26 /* geom.cpp */, 378C1AF10FB0644D004D63F5 /* goodscoverage.h */, 378C1AF00FB0644D004D63F5 /* goodscoverage.cpp */, - EB9303E90F534D9400E8EF26 /* logsd.h */, - EB9303EA0F534D9400E8EF26 /* logsd.cpp */, - EB6E68170F5F1C780044E17B /* qstat.h */, - EB6E68180F5F1C780044E17B /* qstat.cpp */, + 37C753ED0FB34A5700DBD02E /* ignoregaps.h */, 37D927E80F21331F001D4494 /* jackknife.h */, 37D927E70F21331F001D4494 /* jackknife.cpp */, + EB9303E90F534D9400E8EF26 /* logsd.h */, + EB9303EA0F534D9400E8EF26 /* logsd.cpp */, 375873F90F7D64AB0040F377 /* nseqs.h */, 37D927F50F21331F001D4494 /* npshannon.h */, 37D927F40F21331F001D4494 /* npshannon.cpp */, + 37C753F10FB34B4700DBD02E /* onegapdist.h */, + 37C753F30FB34BBF00DBD02E /* onegapignore.h */, 379294880F2E258500B9034A /* parsimony.h */, 379294890F2E258500B9034A /* parsimony.cpp */, + EB6E68170F5F1C780044E17B /* qstat.h */, + EB6E68180F5F1C780044E17B /* qstat.cpp */, 37D928020F21331F001D4494 /* rarecalc.h */, 37D928010F21331F001D4494 /* rarecalc.cpp */, 37D9281F0F21331F001D4494 /* shannon.h */, @@ -665,6 +676,8 @@ 377326630FAF16E0007ABB8B /* concensuscommand.cpp */, 37B28F660F27590100808A62 /* deconvolutecommand.h */, 37B28F670F27590100808A62 /* deconvolutecommand.cpp */, + 37C753CC0FB3415200DBD02E /* distancecommand.h */, + 37C753CD0FB3415200DBD02E /* distancecommand.cpp */, 378C1AEF0FB0644D004D63F5 /* filterseqscommand.h */, 378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */, A70B53A50F4CD7AD0064797E /* getgroupcommand.h */, @@ -737,6 +750,10 @@ 37D927FF0F21331F001D4494 /* rabundvector.cpp */, 37D9281B0F21331F001D4494 /* sabundvector.hpp */, 37D9281A0F21331F001D4494 /* sabundvector.cpp */, + 37D9281D0F21331F001D4494 /* sequence.hpp */, + 37D9281C0F21331F001D4494 /* sequence.cpp */, + 378C1AFE0FB0644D004D63F5 /* sequencedb.h */, + 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */, 37AD4CE20F28AEA300AA2D49 /* sharedlistvector.h */, 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */, 37D9282F0F21331F001D4494 /* sharedordervector.h */, @@ -953,6 +970,7 @@ 378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */, 378C1B0B0FB0644E004D63F5 /* sharedjackknife.cpp in Sources */, 378C1B0C0FB0644E004D63F5 /* sharedmarczewski.cpp in Sources */, + 37C753CE0FB3415200DBD02E /* distancecommand.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/dist.h b/dist.h new file mode 100644 index 0000000..4200bf9 --- /dev/null +++ b/dist.h @@ -0,0 +1,29 @@ +#ifndef DIST_H +#define DIST_H +/* + * dist.h + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "mothur.h" +#include "sequence.hpp" + +/**************************************************************************************************/ + +class Dist { + +public: + Dist(){dist = 0;} + virtual void calcDist(Sequence, Sequence) = 0; + double getDist() { return dist; } +protected: + double dist; +}; + +/**************************************************************************************************/ + +#endif \ No newline at end of file diff --git a/distancecommand.cpp b/distancecommand.cpp new file mode 100644 index 0000000..c20ddb9 --- /dev/null +++ b/distancecommand.cpp @@ -0,0 +1,227 @@ +/* + * distancecommand.cpp + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "distancecommand.h" +#include "ignoregaps.h" +#include "eachgapdist.h" +#include "eachgapignore.h" +#include "onegapdist.h" +#include "onegapignore.h" + +//********************************************************************************************************************** + +DistanceCommand::DistanceCommand(){ + try { + globaldata = GlobalData::getInstance(); + validCalculator = new ValidCalculators(); + ends = globaldata->getEnds(); + seqDB = globaldata->gSequenceDB; + convert(globaldata->getProcessors(), processors); + convert(globaldata->getCutOff(), cutoff); + distFile = getRootName(globaldata->getFastaFile()) + "dist"; + + int i; + if (ends != "T") { + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("distance", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "nogaps") { + distCalculator = new ignoreGaps(); + }else if (globaldata->Estimators[i] == "eachgap") { + distCalculator = new eachGapDist(); + }else if (globaldata->Estimators[i] == "onegap") { + distCalculator = new oneGapDist(); } + } + } + }else { + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("distance", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "nogaps") { + distCalculator = new ignoreGaps(); + }else if (globaldata->Estimators[i] == "eachgap") { + distCalculator = new eachGapIgnoreTermGapDist(); + }else if (globaldata->Estimators[i] == "onegap") { + distCalculator = new oneGapIgnoreTermGapDist(); + } + } + } + } + + + //reset calc for next command + globaldata->setCalc(""); + + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function DistanceCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the DistanceCommand class function DistanceCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +int DistanceCommand::execute(){ + try { + int numSeqs = seqDB->getNumSeqs(); + + system(("rm "+distFile).c_str() ); + if(processors == 1){ + driver(distCalculator, seqDB, 0, numSeqs, distFile, cutoff); + } + else if(processors == 2){ + + int pid = fork(); + if(pid > 0){ + driver(distCalculator, seqDB, 0, (numSeqs/sqrt(2)), distFile + "tempa", cutoff); +// system(("cat " + distFile + "tempa" + " >> " + distFile).c_str()); +// system(("rm " + distFile + "tempa").c_str()); + } + else{ + driver(distCalculator, seqDB, (numSeqs/sqrt(2)), numSeqs, distFile + "tempb", cutoff); +// system(("cat " + distFile + "tempb" + " >> " + distFile).c_str()); +// system(("rm " + distFile + "tempb").c_str()); + } + wait(NULL); + + } + else if(processors == 3){ + int pid1 = fork(); + if(pid1 > 0){ + int pid2 = fork(); + if(pid2 > 0){ + driver(distCalculator, seqDB, 0, sqrt(3) * numSeqs / 3, distFile + "tempa", cutoff); + #ifdef HAVE_CAT + system(("cat " + distFile + "tempa" + " >> " + distFile).c_str()); + #else + #ifdef HAVE_COPY +//get system call from pat system(("copy " + distFile + "tempa").c_str()); + #else + cout << "Sorry but I can't continue because this operating system doesn't appear to support the cat() or copy() system calls." << endl; + #endif + #endif + + #ifdef HAVE_RM + system(("rm " + distFile + "tempa").c_str()); + #else + #ifdef HAVE_ERASE + system(("erase " + distFile + "tempa").c_str()); + #else + cout << "Sorry but I can't remove the required files because this operating system doesn't appear to support the rm() or erase() system calls." << endl; + #endif + #endif + } + else{ + driver(distCalculator, seqDB, sqrt(3) * numSeqs / 3, sqrt(6) * numSeqs / 3, distFile + "tempb", cutoff); + system(("cat " + distFile + "tempb" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempb").c_str()); + } + wait(NULL); + } + else{ + driver(distCalculator, seqDB, sqrt(6) * numSeqs / 3, numSeqs, distFile + "tempc", cutoff); + system(("cat " + distFile + "tempc" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempc").c_str()); + } + wait(NULL); + } + else if(processors == 4){ + int pid1 = fork(); + if(pid1 > 0){ + int pid2 = fork(); + if(pid2 > 0){ + driver(distCalculator, seqDB, 0, numSeqs / 2, distFile + "tempa", cutoff); + system(("cat " + distFile + "tempa" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempa").c_str()); + } + else{ + driver(distCalculator, seqDB, numSeqs / 2, (numSeqs/sqrt(2)), distFile + "tempb", cutoff); + system(("cat " + distFile + "tempb" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempb").c_str()); + } + wait(NULL); + } + else{ + int pid3 = fork(); + if(pid3 > 0){ + driver(distCalculator, seqDB, (numSeqs/sqrt(2)), (sqrt(3) * numSeqs / 2), distFile + "tempc", cutoff); + system(("cat " + distFile + "tempc" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempc").c_str()); + } + else{ + driver(distCalculator, seqDB, (sqrt(3) * numSeqs / 2), numSeqs, distFile + "tempd", cutoff); + system(("cat " + distFile + "tempd" + " >> " + distFile).c_str()); + system(("rm " + distFile + "tempd").c_str()); + } + wait(NULL); + } + wait(NULL); + } + wait(NULL); + + delete distCalculator; + + return 0; + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the DistanceCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/**************************************************************************************************/ +/////// need to fix to work with calcs and sequencedb +int DistanceCommand::driver(Dist* distCalculator, SequenceDB* align, int startLine, int endLine, string dFileName, float cutoff){ + try { + int startTime = time(NULL); + + ofstream distFile(dFileName.c_str(), ios::trunc); + distFile.setf(ios::fixed, ios::showpoint); + distFile << setprecision(4); + + for(int i=startLine;icalcDist(align->get(i), align->get(j)); + double dist = distCalculator->getDist(); + if(dist <= cutoff){ + distFile << align->get(i).getName() << ' ' << align->get(j).getName() << ' ' << dist << endl; + } + + } + if(i % 100 == 0){ + cout << i << '\t' << time(NULL) - startTime << endl; + } + + } + cout << endLine-1 << '\t' << time(NULL) - startTime << endl; + + return 1; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the DistanceCommand class function driver. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +/**************************************************************************************************/ + diff --git a/distancecommand.h b/distancecommand.h new file mode 100644 index 0000000..a43e395 --- /dev/null +++ b/distancecommand.h @@ -0,0 +1,48 @@ +#ifndef DISTANCECOMMAND_H +#define DISTANCECOMMAND_H + +/* + * distancecommand.h + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "mothur.h" +#include "command.hpp" +#include "globaldata.hpp" +#include "validcalculator.h" +#include "dist.h" +#include "sequencedb.h" + + +using namespace std; + +class DistanceCommand : public Command { + +public: + DistanceCommand(); + ~DistanceCommand() {}; + int execute(); + +private: + GlobalData* globaldata; + ValidCalculators* validCalculator; + Dist* distCalculator; + SequenceDB* seqDB; + ofstream out; + string outputFileName; + string ends, distFile; + int processors; + float cutoff; + + int driver(Dist*, SequenceDB*, int, int, string, float); + +}; + +#endif + + + diff --git a/eachgapdist.h b/eachgapdist.h new file mode 100644 index 0000000..767c4bf --- /dev/null +++ b/eachgapdist.h @@ -0,0 +1,56 @@ +#ifndef EACHGAPDIST_H +#define EACHGAPDIST_H +/* + * eachgapdist.h + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "dist.h" + +/**************************************************************************************************/ + +class eachGapDist : public Dist { + +public: + void calcDist(Sequence A, Sequence B){ + int diff = 0; + int length = 0; + int start = 0; + + for(int i=0; i=0;i--){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ + } + else{ + end = i; + break; + } + } + + for(int i=start;i<=end;i++){ + if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){} + else if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){ + break; + } + else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){ + if(A.getAligned()[i] != B.getAligned()[i]){ + diff++; + } + length++; + } + else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){ + diff++; + length++; + } + } + + if(length == 0) { dist = 1.0000; } + else { dist = ((double)diff / (double)length); } + + } + +}; + +/**************************************************************************************************/ + +#endif + + diff --git a/errorchecking.cpp b/errorchecking.cpp index eaf49df..803a836 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -116,6 +116,8 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "soft" ) { soft = value; } if (parameter == "filter" ) { filter = value; } if (parameter == "scale" ) { scale = value; } + if (parameter == "ends" ) { ends = value; } + if (parameter == "processors" ) { processors = value; } } @@ -156,6 +158,8 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "soft" ) { soft = value; } if (parameter == "filter" ) { filter = value; } if (parameter == "scale" ) { scale = value; } + if (parameter == "ends" ) { ends = value; } + if (parameter == "processors" ) { processors = value; } } } diff --git a/errorchecking.h b/errorchecking.h index bbc3050..0f6dbb5 100644 --- a/errorchecking.h +++ b/errorchecking.h @@ -34,7 +34,7 @@ class ErrorCheck { void clear(); void refresh(); string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, cutoff, format; - string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, trump, soft, filter, scale; + string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, trump, soft, filter, scale, ends, processors; string commandName, optionText; bool errorFree; diff --git a/fastamap.cpp b/fastamap.cpp index 97c090d..a1beda3 100644 --- a/fastamap.cpp +++ b/fastamap.cpp @@ -15,11 +15,12 @@ void FastaMap::readFastaFile(ifstream& in) { string name, sequence, line; sequence = ""; - getline(in, line); + in >> line; name = line.substr(1, line.length()); //rips off '>' //read through file - while (getline(in, line)) { + while (in.eof() != true) { + in >> line; if (line != "") { if (isalnum(line.at(0))) { //if it's a sequence line sequence += line; diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index f92253d..dec53a5 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 5/4/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/filterseqscommand.h b/filterseqscommand.h index fffa457..9e703ce 100644 --- a/filterseqscommand.h +++ b/filterseqscommand.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 5/4/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp index b4d2d74..3fc67d1 100644 --- a/getgroupcommand.cpp +++ b/getgroupcommand.cpp @@ -14,6 +14,8 @@ GetgroupCommand::GetgroupCommand(){ try { globaldata = GlobalData::getInstance(); groupMap = globaldata->gGroupmap; + outputFile = globaldata->inputFileName + ".bootGroups"; + openOutputFile(outputFile, out); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -36,8 +38,11 @@ GetgroupCommand::~GetgroupCommand(){ int GetgroupCommand::execute(){ try { vector groupNames = groupMap->namesOfGroups; - for(int i = 0; i < groupNames.size(); i++) + for(int i = 0; i < groupNames.size(); i++) { cout << groupNames[i] << "\n"; + out << groupNames[i] << "\t" << groupNames[i] << "\n"; + } + out.close(); return 0; } diff --git a/getgroupcommand.h b/getgroupcommand.h index 6750373..26190b5 100644 --- a/getgroupcommand.h +++ b/getgroupcommand.h @@ -24,6 +24,9 @@ public: private: GlobalData* globaldata; GroupMap* groupMap; + string outputFile; + ofstream out; + }; #endif diff --git a/globaldata.cpp b/globaldata.cpp index 6849b88..ae1b0e2 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -42,6 +42,9 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ cutoff = "1.0"; } + //set default value for cutoff + if (commandName == "distance") { cutoff = "1.0"; } + string key, value; //reads in parameters and values if((optionText != "") && (commandName != "help")){ @@ -80,6 +83,8 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "filter") { filter = value; } if (key == "soft") { soft = value; } if (key == "scale") { scale = value; } + if (key == "ends" ) { ends = value; } + if (key == "processors" ) { processors = value; } @@ -144,9 +149,8 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "filter") { filter = value; } if (key == "soft") { soft = value; } if (key == "scale") { scale = value; } - - - + if (key == "ends" ) { ends = value; } + if (key == "processors" ) { processors = value; } if (key == "line") {//stores lines to be used in a vector @@ -211,6 +215,11 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ Estimators.clear(); splitAtDash(calc, Estimators); } + if (commandName == "distance") { + if ((calc == "default") || (calc == "")) { calc = "onegap"; } + Estimators.clear(); + splitAtDash(calc, Estimators); + } if (commandName == "venn") { if ((calc == "default") || (calc == "")) { if (format == "list") { calc = "sobs"; } @@ -278,6 +287,8 @@ string GlobalData::getTrump() { return trump; } string GlobalData::getSoft() { return soft; } string GlobalData::getFilter() { return filter; } string GlobalData::getScale() { return scale; } +string GlobalData::getEnds() { return ends; } +string GlobalData::getProcessors() { return processors; } void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;} void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;} @@ -289,6 +300,9 @@ void GlobalData::setFormat(string Format) { format = Format; } void GlobalData::setRandomTree(string Random) { randomtree = Random; } void GlobalData::setGroups(string g) { groups = g; } void GlobalData::setCalc(string Calc) { calc = Calc; } +void GlobalData::setEnds(string e) { ends = e; } +void GlobalData::setProcessors(string p) { processors = p; } + /*******************************************************/ @@ -338,7 +352,9 @@ void GlobalData::clear() { trump = ""; filter = ""; soft = ""; - scale = "log10"; + scale = "log10"; + ends = "T"; //yes + processors = "1"; } @@ -359,6 +375,8 @@ void GlobalData::reset() { abund = "10"; step = "0.01"; form = "integral"; + ends = "T"; + processors = "1"; } /*******************************************************/ diff --git a/globaldata.hpp b/globaldata.hpp index aa68dc2..801ca60 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -75,6 +75,8 @@ public: string getStep(); string getForm(); string getSorted(); + string getEnds(); + string getProcessors(); string getTrump(); string getSoft(); @@ -94,6 +96,8 @@ public: void setRandomTree(string); void setGroups(string); void setCalc(string); + void setEnds(string); + void setProcessors(string); void clear(); void clearLabels(); @@ -110,7 +114,7 @@ public: private: string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, line, label, randomtree, groups; - string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale; + string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale, ends, processors; static GlobalData* _uniqueInstance; diff --git a/goodscoverage.cpp b/goodscoverage.cpp index 07b78b3..61ffe41 100644 --- a/goodscoverage.cpp +++ b/goodscoverage.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/8/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/goodscoverage.h b/goodscoverage.h index b4065c0..4cce78b 100644 --- a/goodscoverage.h +++ b/goodscoverage.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/8/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ #include "calculator.h" diff --git a/ignoregaps.h b/ignoregaps.h new file mode 100644 index 0000000..8127b62 --- /dev/null +++ b/ignoregaps.h @@ -0,0 +1,67 @@ +#ifndef IGNOREGAPS_H +#define IGNOREGAPS_H +/* + * ignoregaps.h + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "dist.h" + +/**************************************************************************************************/ + +// this class calculates distances by ignoring all gap characters. so if seq a has an "A" and seq +// b has a '-', there is no penalty + +class ignoreGaps : public Dist { + +public: + + void calcDist(Sequence A, Sequence B){ + int diff = 0; + int length = 0; + int start = 0; + int end = 0; + + for(int i=0;i=0;i--){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ + } + else{ + end = i; + break; + } + } + + for(int i=start; i<=end; i++){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){ + break; + } + else if((A.getAligned()[i] != '-' && B.getAligned()[i] != '-')){ + if(A.getAligned()[i] != B.getAligned()[i]){ + diff++; + } + length++; + } + } + + if(length == 0) { dist = 1.0000; } + else { dist = ((double)diff / (double)length); } + + } + +}; + +/**************************************************************************************************/ +#endif + diff --git a/mothur.h b/mothur.h index c1d93ed..e4a9bfc 100644 --- a/mothur.h +++ b/mothur.h @@ -222,6 +222,13 @@ inline int factorial(int num){ return total; } +/************************************************************************************************** + +double min(double x, double y) +{ + if(x=0;i--){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ + } + else{ + end = i; + break; + } + } + + + for(int i=start;i<=end;i++){ + if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){} + else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-'){ + if(openGapA == 0){ + difference++; + minLength++; + openGapA = 1; + openGapB = 0; + } + } + else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-'){ + if(openGapB == 0){ + difference++; + minLength++; + openGapA = 0; + openGapB = 1; + } + } + else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){ + if(A.getAligned()[i] != B.getAligned()[i]){ + difference++; + minLength++; + openGapA = 0; + openGapB = 0; + } + else{ + minLength++; + openGapA = 0; + openGapB = 0; + } + } + } + if(minLength == 0) { dist = 1.0000; } + else { dist = (double)difference / minLength; } + } + +}; + +/**************************************************************************************************/ + +#endif + diff --git a/readclustal.cpp b/readclustal.cpp index 2211ccd..2f31539 100644 --- a/readclustal.cpp +++ b/readclustal.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/24/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readclustal.h b/readclustal.h index 8556486..e09e900 100644 --- a/readclustal.h +++ b/readclustal.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/24/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ using namespace std; diff --git a/readfasta.cpp b/readfasta.cpp index ff39e01..347432f 100644 --- a/readfasta.cpp +++ b/readfasta.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/21/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readfasta.h b/readfasta.h index a4fe436..8f5d70d 100644 --- a/readfasta.h +++ b/readfasta.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/21/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readnexus.cpp b/readnexus.cpp index bc91e16..25444d5 100644 --- a/readnexus.cpp +++ b/readnexus.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/22/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readnexus.h b/readnexus.h index 6cd4973..f6bfcbb 100644 --- a/readnexus.h +++ b/readnexus.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/22/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ using namespace std; diff --git a/readnexusal.h b/readnexusal.h index 455044a..4d0e400 100644 --- a/readnexusal.h +++ b/readnexusal.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/22/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readseqscommand.cpp b/readseqscommand.cpp index 2ca7567..dee09f5 100644 --- a/readseqscommand.cpp +++ b/readseqscommand.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/13/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readseqscommand.h b/readseqscommand.h index 660eb3f..52c8a7c 100644 --- a/readseqscommand.h +++ b/readseqscommand.h @@ -5,7 +5,7 @@ * Mothur * * Created by Thomas Ryabin on 4/13/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ @@ -14,23 +14,6 @@ #include "readnexus.h" #include "readclustal.h" #include "readseqsphylip.h" -#include "inputdata.h" -#include "groupmap.h" -#include "sharedcommand.h" -#include "parselistcommand.h" - -/* The read.otu must be run before you execute a collect.single, rarefaction.single, summary.single, -collect.shared, rarefaction.shared or summary.shared command. Mothur will generate a .list, .rabund and .sabund -upon completion of the cluster command or you may use your own. The read.otu command parameter options are -listfile, rabundfile, sabundfile, groupfile and orderfile. The reaad.otu command can be used in two ways. -The first is to read a listfile, rabundfile or sabundfile and run the collect.single, rarefaction.single or summary.single. -For this use the read.otu command should be in the following format: read.otu(listfile=yourListFile, orderfile=yourOrderFile). -The listfile, rabundfile or sabundfile parameter is required, but you may only use one of them. -The second way to use the read.otu command is to read a listfile and a groupfile so you can use the collect.shared, -rarefaction.shared or summary.shared commands. In this case the read.otu command should be in the following format: -read.otu(listfile=yourListFile, groupfile=yourGroupFile). The listfile parameter and groupfile paramaters are required. -When using the command the second way read.otu command parses the .list file and separates it into groups. -It outputs a .shared file containing the OTU information for each group. The read.otu command also outputs a .list file for each group. */ class GlobalData; @@ -46,9 +29,6 @@ private: ReadNexus* readNexus; ReadClustal* readClustal; ReadPhylip* readPhylip; - InputData* input; - Command* shared; - Command* parselist; string filename; }; diff --git a/readseqsphylip.cpp b/readseqsphylip.cpp index b6be40e..40f56a0 100644 --- a/readseqsphylip.cpp +++ b/readseqsphylip.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/24/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/readseqsphylip.h b/readseqsphylip.h index c08c977..13c0202 100644 --- a/readseqsphylip.h +++ b/readseqsphylip.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/24/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ using namespace std; diff --git a/sequencedb.cpp b/sequencedb.cpp index 1f81ba8..657573e 100644 --- a/sequencedb.cpp +++ b/sequencedb.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/13/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sequencedb.h b/sequencedb.h index 35636bf..5dcf9bd 100644 --- a/sequencedb.h +++ b/sequencedb.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/13/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/shared.cpp b/shared.cpp index c8a1d5e..91c4ce5 100644 --- a/shared.cpp +++ b/shared.cpp @@ -3,7 +3,7 @@ * Dotur * * Created by Sarah Westcott on 12/5/08. - * Copyright 2008 Schloss Lab Umass Amherst. All rights reserved. + * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sharedjackknife.cpp b/sharedjackknife.cpp index c267a07..6db2d11 100644 --- a/sharedjackknife.cpp +++ b/sharedjackknife.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 3/30/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sharedjackknife.h b/sharedjackknife.h index 00c0de0..bdec8f7 100644 --- a/sharedjackknife.h +++ b/sharedjackknife.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 3/30/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sharedjest.cpp b/sharedjest.cpp index 3e37046..a1b506e 100644 --- a/sharedjest.cpp +++ b/sharedjest.cpp @@ -3,7 +3,7 @@ * Dotur * * Created by Sarah Westcott on 1/8/09. - * Copyright 2009 Schloss Lab Umass Amherst. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sharedmarczewski.cpp b/sharedmarczewski.cpp index be1a2fb..d382f9b 100644 --- a/sharedmarczewski.cpp +++ b/sharedmarczewski.cpp @@ -3,7 +3,7 @@ * Mothur * * Created by Thomas Ryabin on 4/8/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/sharedmarczewski.h b/sharedmarczewski.h index 55bc7e4..40cc9a4 100644 --- a/sharedmarczewski.h +++ b/sharedmarczewski.h @@ -6,7 +6,7 @@ * Mothur * * Created by Thomas Ryabin on 4/8/09. - * Copyright 2009 __MyCompanyName__. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/simpson.h b/simpson.h index 699a5d5..3006e86 100644 --- a/simpson.h +++ b/simpson.h @@ -5,7 +5,7 @@ * Dotur * * Created by Sarah Westcott on 1/7/09. - * Copyright 2009 Schloss Lab Umass Amherst. All rights reserved. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ diff --git a/validcalculator.cpp b/validcalculator.cpp index f6fe280..14fa775 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -22,6 +22,7 @@ ValidCalculators::ValidCalculators() { initialVennShared(); initialTreeGroups(); initialBoot(); + initialDistance(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -139,7 +140,7 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) { if ((treegroup.find(calculator)) != (treegroup.end())) { return true; }else { - cout << calculator << " is not a valid estimator for the tree.shared command in shared mode and will be disregarded. Valid estimators are "; + cout << calculator << " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are "; for (it = treegroup.begin(); it != treegroup.end(); it++) { cout << it->first << ", "; } @@ -150,12 +151,23 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) { if ((boot.find(calculator)) != (boot.end())) { return true; }else { - cout << calculator << " is not a valid estimator for the bootstrap.shared command in shared mode and will be disregarded. Valid estimators are "; + cout << calculator << " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are "; for (it = boot.begin(); it != boot.end(); it++) { cout << it->first << ", "; } cout << endl; return false; } + }else if (parameter == "distance") { + //is it valid + if ((distance.find(calculator)) != (distance.end())) { + return true; + }else { + cout << calculator << " is not a valid estimator for the distance command and will be disregarded. Valid calculators are "; + for (it = distance.begin(); it != distance.end(); it++) { + cout << it->first << ", "; + } + cout << endl; + return false; } //not a valid parameter }else { return false; } @@ -208,7 +220,7 @@ void ValidCalculators::initialShared() { shared["sharedchao"] = "sharedchao"; shared["sharedace"] = "sharedace"; shared["jabund"] = "jabund"; - shared["sorabund"] = "sorabund"; + shared["sorabund"] = "sorabund"; shared["jclass"] = "jclass"; shared["sorclass"] = "sorclass"; shared["jest"] = "jest"; @@ -391,7 +403,7 @@ void ValidCalculators::initialVennShared() { void ValidCalculators::initialTreeGroups() { try { treegroup["jabund"] = "jabund"; - treegroup["sorabund"] = "sorabund"; + treegroup["sorabund"] = "sorabund"; treegroup["jclass"] = "jclass"; treegroup["sorclass"] = "sorclass"; treegroup["jest"] = "jest"; @@ -399,7 +411,7 @@ void ValidCalculators::initialTreeGroups() { treegroup["thetayc"] = "thetayc"; treegroup["thetan"] = "thetan"; treegroup["morisitahorn"] = "morisitahorn"; - treegroup["braycurtis"] = "braycurtis"; + treegroup["braycurtis"] = "braycurtis"; } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -414,7 +426,7 @@ void ValidCalculators::initialTreeGroups() { void ValidCalculators::initialBoot() { try { boot["jabund"] = "jabund"; - boot["sorabund"] = "sorabund"; + boot["sorabund"] = "sorabund"; boot["jclass"] = "jclass"; boot["sorclass"] = "orclass"; boot["jest"] = "jest"; @@ -433,6 +445,22 @@ void ValidCalculators::initialBoot() { exit(1); } } +/********************************************************************/ +void ValidCalculators::initialDistance() { + try { + distance["nogaps"] = "nogaps"; + distance["eachgap"] = "eachgap"; + distance["onegap"] = "onegap"; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} /********************************************************************/ void ValidCalculators::printCalc(string parameter, ostream& out) { @@ -483,7 +511,12 @@ void ValidCalculators::printCalc(string parameter, ostream& out) { for (it = boot.begin(); it != boot.end(); it++) { out << it->first << ", "; } + }else if (parameter == "distance") { + for (it = distance.begin(); it != distance.end(); it++) { + out << it->first << ", "; + } } + out << endl; } catch(exception& e) { diff --git a/validcalculator.h b/validcalculator.h index 9f0d9b4..45381b8 100644 --- a/validcalculator.h +++ b/validcalculator.h @@ -36,6 +36,7 @@ class ValidCalculators { map vennshared; map treegroup; map boot; + map distance; map::iterator it; void initialSingle(); @@ -48,6 +49,7 @@ class ValidCalculators { void initialVennShared(); void initialTreeGroups(); void initialBoot(); + void initialDistance(); }; #endif diff --git a/validcommands.cpp b/validcommands.cpp index 4c72dce..ad55d0d 100644 --- a/validcommands.cpp +++ b/validcommands.cpp @@ -22,6 +22,7 @@ ValidCommands::ValidCommands() { commands["get.oturep"] = "get.oturep"; commands["cluster"] = "cluster"; commands["deconvolute"] = "deconvolute"; + commands["distance"] = "distance"; commands["collect.single"] = "collect.single"; commands["collect.shared"] = "collect.shared"; commands["rarefaction.single"] = "rarefaction.single"; diff --git a/validparameter.cpp b/validparameter.cpp index 2d070cb..3e6a979 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -292,6 +292,9 @@ void ValidParameters::initCommandParameters() { string concensusArray[] = {}; commandParameters["concensus"] = addParameters(concensusArray, sizeof(concensusArray)/sizeof(string)); + string distanceArray[] = {"calc", "ends", "cutoff", "processors"}; + commandParameters["distance"] = addParameters(distanceArray, sizeof(distanceArray)/sizeof(string)); + string quitArray[] = {}; commandParameters["quit"] = addParameters(quitArray, sizeof(quitArray)/sizeof(string)); diff --git a/venn.cpp b/venn.cpp index 3c719ec..9e75cdb 100644 --- a/venn.cpp +++ b/venn.cpp @@ -11,6 +11,8 @@ #include "ace.h" #include "sobs.h" #include "chao1.h" +#include "sharedchao1.h" +#include "sharedsobscollectsummary.h" //********************************************************************************************************************** @@ -199,55 +201,7 @@ void Venn::getPic(vector lookup, vector vCalcs //make a file for each calculator for(int i=0;iinputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; - openOutputFile(filenamesvg, outsvg); - - //get estimates for sharedAB, sharedAC and sharedBC - subset.clear(); - subset.push_back(lookup[0]); subset.push_back(lookup[1]); - vector sharedAB = vCalcs[i]->getValues(subset); - - subset.clear(); - subset.push_back(lookup[0]); subset.push_back(lookup[2]); - vector sharedAC = vCalcs[i]->getValues(subset); - - subset.clear(); - subset.push_back(lookup[1]); subset.push_back(lookup[2]); - vector sharedBC = vCalcs[i]->getValues(subset); - - //merge BC and estimate with shared with A - SharedRAbundVector* merge = new SharedRAbundVector(); - for (int j = 0; j < lookup[1]->size(); j++) { - merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); - } - - subset.clear(); - subset.push_back(lookup[0]); subset.push_back(merge); - vector sharedAwithBC = vCalcs[i]->getValues(subset); - - delete merge; - //merge AC and estimate with shared with B - merge = new SharedRAbundVector(); - for (int j = 0; j < lookup[0]->size(); j++) { - merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); - } - - subset.clear(); - subset.push_back(merge); subset.push_back(lookup[1]); - vector sharedBwithAC = vCalcs[i]->getValues(subset); - delete merge; - //merge AB and estimate with shared with C - merge = new SharedRAbundVector(); - for (int j = 0; j < lookup[0]->size(); j++) { - merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), j, ""); - } - - subset.clear(); - subset.push_back(lookup[2]); subset.push_back(merge); - vector sharedCwithAB = vCalcs[i]->getValues(subset); - delete merge; - //in essence you want to run it like a single if (vCalcs[i]->getName() == "sharedsobs") { singleCalc = new Sobs(); @@ -265,23 +219,85 @@ void Venn::getPic(vector lookup, vector vCalcs //get estimates for numC vector numC = singleCalc->getValues(sabundC); - + + + string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + openOutputFile(filenamesvg, outsvg); + + //get estimates for sharedAB, sharedAC and sharedBC + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[1]); + vector sharedAB = vCalcs[i]->getValues(subset); + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[2]); + vector sharedAC = vCalcs[i]->getValues(subset); + + subset.clear(); + subset.push_back(lookup[1]); subset.push_back(lookup[2]); + vector sharedBC = vCalcs[i]->getValues(subset); + + vector sharedAwithBC; + vector sharedBwithAC; + vector sharedCwithAB; + //find possible sharedABC values float sharedABC1, sharedABC2, sharedABC3, sharedABC; + + if (vCalcs[i]->getName() != "sharedchao") { + //merge BC and estimate with shared with A + SharedRAbundVector* merge = new SharedRAbundVector(); + for (int j = 0; j < lookup[1]->size(); j++) { + merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); + } + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(merge); + sharedAwithBC = vCalcs[i]->getValues(subset); + + delete merge; + //merge AC and estimate with shared with B + merge = new SharedRAbundVector(); + for (int j = 0; j < lookup[0]->size(); j++) { + merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), j, ""); + } + + subset.clear(); + subset.push_back(merge); subset.push_back(lookup[1]); + sharedBwithAC = vCalcs[i]->getValues(subset); + + delete merge; + //merge AB and estimate with shared with C + merge = new SharedRAbundVector(); + for (int j = 0; j < lookup[0]->size(); j++) { + merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), j, ""); + } - sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0]; - sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0]; - sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0]; + subset.clear(); + subset.push_back(lookup[2]); subset.push_back(merge); + sharedCwithAB = vCalcs[i]->getValues(subset); + delete merge; + + sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0]; + sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0]; + sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0]; - //if any of the possible m's are - throw them out - if (sharedABC1 < 0.0) { sharedABC1 = 0; } - if (sharedABC2 < 0.0) { sharedABC2 = 0; } - if (sharedABC3 < 0.0) { sharedABC3 = 0; } + //if any of the possible m's are - throw them out + if (sharedABC1 < 0.0) { sharedABC1 = 0; } + if (sharedABC2 < 0.0) { sharedABC2 = 0; } + if (sharedABC3 < 0.0) { sharedABC3 = 0; } - //sharedABC is the minimum of the 3 possibilities - if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; } - else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; } - else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; } + //sharedABC is the minimum of the 3 possibilities + if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; } + else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; } + else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; } + }else{ + vector data = vCalcs[i]->getValues(lookup); + sharedABC = data[0]; + sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC); + sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC); + sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC); + } //image window outsvg << "\n"; @@ -341,90 +357,165 @@ void Venn::getPic(vector lookup, vector vCalcs }else if (lookup.size() == 4) { //calc the shared otu - int sharedABCD = 0; - int numA = 0; int numB = 0; int numC = 0; int numD = 0; - int sharedAB = 0; int sharedAC = 0; int sharedBC = 0; int sharedAD = 0; int sharedBD = 0; int sharedCD = 0; - int sharedABC = 0; int sharedACD = 0; int sharedBCD = 0; int sharedABD = 0; + float sharedABCD = 0; + float numA = 0; float numB = 0; float numC = 0; float numD = 0; + float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0; + float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0; + vector data; + //get sabund vector pointers so you can use the single calculators + //one for each group + SAbundVector sA, sB, sC, sD; + SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD; + sA = lookup[0]->getSAbundVector(); sabundA = &sA; + sB = lookup[1]->getSAbundVector(); sabundB = &sB; + sC = lookup[2]->getSAbundVector(); sabundC = &sC; + sD = lookup[3]->getSAbundVector(); sabundD = &sD; //A = red, B = green, C = blue, D = yellow - if ((vCalcs.size() > 1) || (vCalcs[0]->getName() != "sharedsobs")) { cout << "The only calculator able to be used with 4 groups is sharedsobs. I will run that for you. " << endl; } - - //for each bin - for (int i = 0; i < lookup[0]->size(); i++) { - //are they only in one - if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numA++; } - if ((lookup[1]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numB++; } - if ((lookup[2]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { numC++; } - if ((lookup[3]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[2]->getAbundance(i) == 0)) { numD++; } - //are they shared by 2 - if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedAB++; } - if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedAC++; } - if ((lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0) && (lookup[3]->getAbundance(i) == 0)) { sharedBC++; } - if ((lookup[0]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[1]->getAbundance(i) == 0)) { sharedAD++; } - if ((lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0) && (lookup[0]->getAbundance(i) == 0)) { sharedBD++; } - if ((lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0) && (lookup[0]->getAbundance(i) == 0)) { sharedCD++; } - //are they shared by 3 - if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) == 0)) { sharedABC++; } - if ((lookup[0]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) == 0)) { sharedACD++; } - if ((lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[0]->getAbundance(i) == 0)) { sharedBCD++; } - if ((lookup[0]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) == 0)) { sharedABD++; } - //are they shared by all - if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0)) { sharedABCD++; } - } + //make a file for each calculator + for(int i=0;iinputFileName) + lookup[0]->getLabel() + ".venn.sharedsobs.svg"; - openOutputFile(filenamesvg, outsvg); + if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { cout << vCalcs[i]->getName() << " is not a valid calculator with four groups. It will be disregarded. " << endl; } + else{ + string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; + openOutputFile(filenamesvg, outsvg); + + + //in essence you want to run it like a single + if (vCalcs[i]->getName() == "sharedsobs") { + singleCalc = new Sobs(); + }else if (vCalcs[i]->getName() == "sharedchao") { + singleCalc = new Chao1(); + } + + //get estimates for numA + data = singleCalc->getValues(sabundA); + numA = data[0]; + + //get estimates for numB + data = singleCalc->getValues(sabundB); + numB = data[0]; + + //get estimates for numC + data = singleCalc->getValues(sabundC); + numC = data[0]; + + //get estimates for numD + data = singleCalc->getValues(sabundD); + numD = data[0]; + + + //get estimates for pairs + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[1]); + data = vCalcs[i]->getValues(subset); + sharedAB = data[0]; + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[2]); + data = vCalcs[i]->getValues(subset); + sharedAC = data[0]; + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedAD = data[0]; + + subset.clear(); + subset.push_back(lookup[1]); subset.push_back(lookup[2]); + data = vCalcs[i]->getValues(subset); + sharedBC = data[0]; + + subset.clear(); + subset.push_back(lookup[1]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedBD = data[0]; + + subset.clear(); + subset.push_back(lookup[2]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedCD = data[0]; + + + //get estimates for combos of 3 + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]); + data = vCalcs[i]->getValues(subset); + sharedABC = data[0]; + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedACD = data[0]; + + subset.clear(); + subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedBCD = data[0]; + + subset.clear(); + subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]); + data = vCalcs[i]->getValues(subset); + sharedABD = data[0]; + + //get estimate for all four + data = vCalcs[i]->getValues(lookup); + sharedABCD = data[0]; + - //image window - outsvg << "\n"; - outsvg << "\n"; + //image window + outsvg << "\n"; + outsvg << "\n"; - //draw circles - outsvg << ""; - outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; - outsvg << "\n "; - outsvg << "\n "; - outsvg << "\n "; - outsvg << "\n "; + //draw circles + outsvg << ""; + outsvg << "Venn Diagram at distance " + lookup[0]->getLabel() + "\n"; + outsvg << "\n "; + outsvg << "\n "; + outsvg << "\n "; + outsvg << "\n "; - //A = red, B = green, C = blue, D = yellow + //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(sharedBC) + "\n"; - outsvg << "" + toString(numD) + "\n"; - outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "\n"; - outsvg << "" + toString(sharedAD) + "\n"; - outsvg << "" + toString(sharedBD) + "\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"; + //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(sharedBC) + "\n"; + outsvg << "" + toString(numD) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "\n"; + outsvg << "" + toString(sharedAD) + "\n"; + outsvg << "" + toString(sharedBD) + "\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 << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString(((sharedAC + sharedACD + sharedABC + sharedABCD) / (float)(numA + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[3] + " is " + toString(((sharedAD + sharedACD + sharedABD + sharedABCD) / (float)(numA + numD + sharedAB + sharedAC + sharedAD + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedBC + sharedABC + sharedBCD + sharedABCD) / (float)(numB + numC + sharedAB + sharedAC + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBD + sharedABD + sharedBCD + sharedABCD) / (float)(numB + numD + sharedAB + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedCD + sharedBCD + sharedACD + sharedABCD) / (float)(numC + numD + sharedAC + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedABC + sharedABCD) / (float)(numA + numB + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedABD + sharedABCD) / (float)(numA + numB + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedACD + sharedABCD) / (float)(numA + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBCD + sharedABCD) / (float)(numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString((sharedABCD / (float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString(((sharedAC + sharedACD + sharedABC + sharedABCD) / (float)(numA + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[3] + " is " + toString(((sharedAD + sharedACD + sharedABD + sharedABCD) / (float)(numA + numD + sharedAB + sharedAC + sharedAD + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedBC + sharedABC + sharedBCD + sharedABCD) / (float)(numB + numC + sharedAB + sharedAC + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBD + sharedABD + sharedBCD + sharedABCD) / (float)(numB + numD + sharedAB + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedCD + sharedBCD + sharedACD + sharedABCD) / (float)(numC + numD + sharedAC + sharedAD + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedABC + sharedABCD) / (float)(numA + numB + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + " and " + globaldata->Groups[3] + " is " + toString(((sharedABD + sharedABCD) / (float)(numA + numB + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedACD + sharedABCD) / (float)(numA + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString(((sharedBCD + sharedABCD) / (float)(numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; + //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + ", " + globaldata->Groups[1] + ", " + globaldata->Groups[2] + " and " + globaldata->Groups[3] + " is " + toString((sharedABCD / (float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; - outsvg << "\n\n"; - outsvg.close(); + outsvg << "\n\n"; + outsvg.close(); + delete singleCalc; + } + } }