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 */; };
37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = "<group>"; };
37C1D9710F86506E0059E3F0 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binsequencecommand.h; sourceTree = "<group>"; };
37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binsequencecommand.cpp; sourceTree = "<group>"; };
+ 37C753CC0FB3415200DBD02E /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distancecommand.h; sourceTree = "<group>"; };
+ 37C753CD0FB3415200DBD02E /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancecommand.cpp; sourceTree = "<group>"; };
+ 37C753DF0FB3492400DBD02E /* dist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dist.h; sourceTree = "<group>"; };
+ 37C753ED0FB34A5700DBD02E /* ignoregaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ignoregaps.h; sourceTree = "<group>"; };
+ 37C753F00FB34AE800DBD02E /* eachgapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdist.h; sourceTree = "<group>"; };
+ 37C753F10FB34B4700DBD02E /* onegapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapdist.h; sourceTree = "<group>"; };
+ 37C753F30FB34BBF00DBD02E /* onegapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapignore.h; sourceTree = "<group>"; };
+ 37C753F40FB34C0300DBD02E /* eachgapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapignore.h; sourceTree = "<group>"; };
37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
37D927B90F21331F001D4494 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = "<group>"; };
37D927BA0F21331F001D4494 /* averagelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = averagelinkage.cpp; sourceTree = "<group>"; };
7E4130F70F8E58FA00381DD0 /* dlibshuff.h */,
7E4130F60F8E58FA00381DD0 /* dlibshuff.cpp */,
37D927D60F21331F001D4494 /* display.h */,
+ 37C753DF0FB3492400DBD02E /* dist.h */,
37D927D80F21331F001D4494 /* engine.hpp */,
37D927D70F21331F001D4494 /* engine.cpp */,
37D928B10F213472001D4494 /* errorcheckor */,
378C1AF70FB0644D004D63F5 /* readnexus.h */,
378C1AF60FB0644D004D63F5 /* readnexus.cpp */,
378C1AF80FB0644D004D63F5 /* readnexusal.h */,
- 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */,
- 378C1AFE0FB0644D004D63F5 /* sequencedb.h */,
375AA1360F9E433D008EF9B8 /* readotu.h */,
375AA1350F9E433D008EF9B8 /* readotu.cpp */,
375AA1380F9E433D008EF9B8 /* readphylip.h */,
378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */,
37AD4DC80F28F3DD00AA2D49 /* readtree.h */,
37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */,
- 37D9281D0F21331F001D4494 /* sequence.hpp */,
- 37D9281C0F21331F001D4494 /* sequence.cpp */,
37D928210F21331F001D4494 /* shared.h */,
37D928200F21331F001D4494 /* shared.cpp */,
211C38310F961DD400FEE541 /* sharedutilities.h */,
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 */,
377326630FAF16E0007ABB8B /* concensuscommand.cpp */,
37B28F660F27590100808A62 /* deconvolutecommand.h */,
37B28F670F27590100808A62 /* deconvolutecommand.cpp */,
+ 37C753CC0FB3415200DBD02E /* distancecommand.h */,
+ 37C753CD0FB3415200DBD02E /* distancecommand.cpp */,
378C1AEF0FB0644D004D63F5 /* filterseqscommand.h */,
378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */,
A70B53A50F4CD7AD0064797E /* getgroupcommand.h */,
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 */,
378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */,
378C1B0B0FB0644E004D63F5 /* sharedjackknife.cpp in Sources */,
378C1B0C0FB0644E004D63F5 /* sharedmarczewski.cpp in Sources */,
+ 37C753CE0FB3415200DBD02E /* distancecommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+#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
--- /dev/null
+/*
+ * 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; i<globaldata->Estimators.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; i<globaldata->Estimators.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;i<endLine;i++){
+
+ for(int j=0;j<i;j++){
+
+ distCalculator->calcDist(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);
+ }
+
+}
+
+/**************************************************************************************************/
+
--- /dev/null
+#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
+
+
+
--- /dev/null
+#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<A.getLength(); i++){
+ if(A.getAligned()[i] != '.' || B.getAligned()[i] != '.'){
+ start = i;
+ break;
+ }
+ }
+
+ for(int i=start;i<A.getLength();i++){
+ if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (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
\ No newline at end of file
--- /dev/null
+#ifndef EACHGAPIGNORE_H
+#define EACHGAPIGNORE_H
+/*
+ * eachgapignore.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 5/7/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "dist.h"
+
+/**************************************************************************************************/
+
+class eachGapIgnoreTermGapDist : 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<A.getLength();i++){
+ if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ }
+ else{
+ start = i;
+ break;
+ }
+ }
+ for(int i=A.getLength()-1;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
+
+
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; }
}
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; }
}
}
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;
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;
* Mothur
*
* Created by Thomas Ryabin on 5/4/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 5/4/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
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";
int GetgroupCommand::execute(){
try {
vector<string> 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;
}
private:
GlobalData* globaldata;
GroupMap* groupMap;
+ string outputFile;
+ ofstream out;
+
};
#endif
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")){
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 == "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
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"; }
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;}
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; }
+
/*******************************************************/
trump = "";
filter = "";
soft = "";
- scale = "log10";
+ scale = "log10";
+ ends = "T"; //yes
+ processors = "1";
}
abund = "10";
step = "0.01";
form = "integral";
+ ends = "T";
+ processors = "1";
}
/*******************************************************/
string getStep();
string getForm();
string getSorted();
+ string getEnds();
+ string getProcessors();
string getTrump();
string getSoft();
void setRandomTree(string);
void setGroups(string);
void setCalc(string);
+ void setEnds(string);
+ void setProcessors(string);
void clear();
void clearLabels();
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;
* Mothur
*
* Created by Thomas Ryabin on 4/8/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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"
--- /dev/null
+#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<A.getLength();i++){
+ if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ }
+ else{
+ start = i;
+ break;
+ }
+ }
+ for(int i=A.getLength()-1;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
+
return total;
}
+/**************************************************************************************************
+
+double min(double x, double y)
+{
+ if(x<y){ return x; }
+ else { return y; }
+}
/***********************************************************************/
--- /dev/null
+#ifndef ONEGAPDIST_H
+#define ONEGAPDIST_H
+/*
+ * onegapdist.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 5/7/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "dist.h"
+
+
+/**************************************************************************************************/
+
+class oneGapDist : public Dist {
+
+public:
+ void calcDist(Sequence A, Sequence B){
+
+ int difference = 0;
+ int openGapA = 0;
+ int openGapB = 0;
+ int minLength = 0;
+ int start = 0;
+
+ for(int i=0;i<A.getLength();i++){
+ if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+ }
+ else{
+ start = i;
+ break;
+ }
+ }
+ for(int i=start;i<A.getLength();i++){
+ if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (A.getAligned()[i] == '.' || B.getAligned()[i] == '.')){}
+ else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-' && B.getAligned()[i] != '.'){
+ if(openGapA == 0){
+ difference++;
+ minLength++;
+ openGapA = 1;
+ openGapB = 0;
+ }
+ }
+ else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-' && A.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;
+ }
+ }
+ else if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+ break;
+ }
+ }
+ if(minLength == 0) { dist = 1.0000; }
+ else { dist = (double)difference / minLength; }
+ }
+
+};
+
+/**************************************************************************************************/
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef ONEIGNOREGAPS_H
+#define ONEIGNOREGAPS_H
+/*
+ * onegapignore.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 5/7/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "dist.h"
+
+/**************************************************************************************************/
+
+class oneGapIgnoreTermGapDist : public Dist {
+
+public:
+ void calcDist(Sequence A, Sequence B){
+
+ int difference = 0;
+ int openGapA = 0;
+ int openGapB = 0;
+ int minLength = 0;
+ int start = 0;
+ int end = 0;
+
+ for(int i=0;i<A.getLength();i++){
+ if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ }
+ else{
+ start = i;
+ break;
+ }
+ }
+ for(int i=A.getLength()-1;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] != '-'){
+ 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
+
* Mothur
*
* Created by Thomas Ryabin on 4/24/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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;
* Mothur
*
* Created by Thomas Ryabin on 4/21/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/21/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/22/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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;
* Mothur
*
* Created by Thomas Ryabin on 4/22/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#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;
ReadNexus* readNexus;
ReadClustal* readClustal;
ReadPhylip* readPhylip;
- InputData* input;
- Command* shared;
- Command* parselist;
string filename;
};
* Mothur
*
* Created by Thomas Ryabin on 4/24/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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;
* Mothur
*
* Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 3/30/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/8/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* Mothur
*
* Created by Thomas Ryabin on 4/8/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
* 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.
*
*/
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";
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 << ", ";
}
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; }
shared["sharedchao"] = "sharedchao";
shared["sharedace"] = "sharedace";
shared["jabund"] = "jabund";
- shared["sorabund"] = "sorabund";
+ shared["sorabund"] = "sorabund";
shared["jclass"] = "jclass";
shared["sorclass"] = "sorclass";
shared["jest"] = "jest";
void ValidCalculators::initialTreeGroups() {
try {
treegroup["jabund"] = "jabund";
- treegroup["sorabund"] = "sorabund";
+ treegroup["sorabund"] = "sorabund";
treegroup["jclass"] = "jclass";
treegroup["sorclass"] = "sorclass";
treegroup["jest"] = "jest";
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";
void ValidCalculators::initialBoot() {
try {
boot["jabund"] = "jabund";
- boot["sorabund"] = "sorabund";
+ boot["sorabund"] = "sorabund";
boot["jclass"] = "jclass";
boot["sorclass"] = "orclass";
boot["jest"] = "jest";
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) {
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) {
map<string, string> vennshared;
map<string, string> treegroup;
map<string, string> boot;
+ map<string, string> distance;
map<string, string>::iterator it;
void initialSingle();
void initialVennShared();
void initialTreeGroups();
void initialBoot();
+ void initialDistance();
};
#endif
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";
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));
#include "ace.h"
#include "sobs.h"
#include "chao1.h"
+#include "sharedchao1.h"
+#include "sharedsobscollectsummary.h"
//**********************************************************************************************************************
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- 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<double> sharedAB = vCalcs[i]->getValues(subset);
-
- subset.clear();
- subset.push_back(lookup[0]); subset.push_back(lookup[2]);
- vector<double> sharedAC = vCalcs[i]->getValues(subset);
-
- subset.clear();
- subset.push_back(lookup[1]); subset.push_back(lookup[2]);
- vector<double> 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<double> 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<double> 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<double> 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();
//get estimates for numC
vector<double> 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<double> sharedAB = vCalcs[i]->getValues(subset);
+
+ subset.clear();
+ subset.push_back(lookup[0]); subset.push_back(lookup[2]);
+ vector<double> sharedAC = vCalcs[i]->getValues(subset);
+
+ subset.clear();
+ subset.push_back(lookup[1]); subset.push_back(lookup[2]);
+ vector<double> sharedBC = vCalcs[i]->getValues(subset);
+
+ vector<double> sharedAwithBC;
+ vector<double> sharedBwithAC;
+ vector<double> 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<double> 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 << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 800 800\" >\n";
}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<double> 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;i<vCalcs.size();i++){
- string filenamesvg = getRootName(globaldata->inputFileName) + 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 << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
- outsvg << "<g>\n";
+ //image window
+ outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
+ outsvg << "<g>\n";
- //draw circles
- outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
- outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
- outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
- outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 440 315) \" cx=\"440\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
- outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 270 315) \" cx=\"270\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
+ //draw circles
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
+ outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
+ outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
+ outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 440 315) \" cx=\"440\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
+ outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 270 315) \" cx=\"270\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
- //A = red, B = green, C = blue, D = yellow
+ //A = red, B = green, C = blue, D = yellow
- //place labels within overlaps
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)toString(numA).length() / 2)) + "\" y=\"110\">" + toString(numA) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedAB).length() / 2)) + "\" y=\"160\">" + toString(sharedAB) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)toString(numB).length() / 2)) + "\" y=\"110\">" + toString(numB) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[1]->getGroup() + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(sharedAC).length() / 2)) + "\" y=\"190\">" + toString(sharedAC) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)toString(numC).length() / 2)) + "\" y=\"230\">" + toString(numC) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[2]->getGroup() + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"190\">" + toString(sharedBC) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)toString(numD).length() / 2)) + "\" y=\"230\">" + toString(numD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(305 - ((int)toString(sharedACD).length() / 2)) + "\" y=\"360\">" + toString(sharedACD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(440 - ((int)toString(sharedABC).length() / 2)) + "\" y=\"240\">" + toString(sharedABC) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"320\">" + toString(sharedABCD) + "</text>\n";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"250\" y=\"490\">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)) + "</text>\n";
+ //place labels within overlaps
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)toString(numA).length() / 2)) + "\" y=\"110\">" + toString(numA) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedAB).length() / 2)) + "\" y=\"160\">" + toString(sharedAB) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)toString(numB).length() / 2)) + "\" y=\"110\">" + toString(numB) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[1]->getGroup() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(sharedAC).length() / 2)) + "\" y=\"190\">" + toString(sharedAC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)toString(numC).length() / 2)) + "\" y=\"230\">" + toString(numC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(550 - ((int)lookup[2]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[2]->getGroup() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"190\">" + toString(sharedBC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)toString(numD).length() / 2)) + "\" y=\"230\">" + toString(numD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(150 - ((int)lookup[3]->getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(305 - ((int)toString(sharedACD).length() / 2)) + "\" y=\"360\">" + toString(sharedACD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(440 - ((int)toString(sharedABC).length() / 2)) + "\" y=\"240\">" + toString(sharedABC) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedABCD).length() / 2)) + "\" y=\"320\">" + toString(sharedABCD) + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"250\" y=\"490\">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)) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"510\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"530\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"550\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"570\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"590\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"630\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"650\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">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))) + "</text>\n";
- //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"690\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"510\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"530\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"550\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"570\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"590\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"610\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"630\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"650\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"670\">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))) + "</text>\n";
+ //outsvg << "<text fill=\"black\" class=\"seri\" x=\"100\" y=\"690\">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))) + "</text>\n";
- outsvg << "</g>\n</svg>\n";
- outsvg.close();
+ outsvg << "</g>\n</svg>\n";
+ outsvg.close();
+ delete singleCalc;
+ }
+ }
}