]> git.donarmstrong.com Git - mothur.git/commitdiff
altered venn command to make use of sharedchao for any number of groups, fixed window...
authorwestcott <westcott>
Fri, 8 May 2009 16:52:01 +0000 (16:52 +0000)
committerwestcott <westcott>
Fri, 8 May 2009 16:52:01 +0000 (16:52 +0000)
46 files changed:
Mothur.xcodeproj/project.pbxproj
dist.h [new file with mode: 0644]
distancecommand.cpp [new file with mode: 0644]
distancecommand.h [new file with mode: 0644]
eachgapdist.h [new file with mode: 0644]
eachgapignore.h [new file with mode: 0644]
errorchecking.cpp
errorchecking.h
fastamap.cpp
filterseqscommand.cpp
filterseqscommand.h
getgroupcommand.cpp
getgroupcommand.h
globaldata.cpp
globaldata.hpp
goodscoverage.cpp
goodscoverage.h
ignoregaps.h [new file with mode: 0644]
mothur.h
onegapdist.h [new file with mode: 0644]
onegapignore.h [new file with mode: 0644]
readclustal.cpp
readclustal.h
readfasta.cpp
readfasta.h
readnexus.cpp
readnexus.h
readnexusal.h
readseqscommand.cpp
readseqscommand.h
readseqsphylip.cpp
readseqsphylip.h
sequencedb.cpp
sequencedb.h
shared.cpp
sharedjackknife.cpp
sharedjackknife.h
sharedjest.cpp
sharedmarczewski.cpp
sharedmarczewski.h
simpson.h
validcalculator.cpp
validcalculator.h
validcommands.cpp
validparameter.cpp
venn.cpp

index 5e6e7920a17077dbb517e0fd0cab6bd36b59dc7c..d29d52e10c177f12f9721223058495cfd28fffde 100644 (file)
@@ -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 */; };
                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;
                };
diff --git a/dist.h b/dist.h
new file mode 100644 (file)
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 (file)
index 0000000..c20ddb9
--- /dev/null
@@ -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; 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);
+       }       
+
+}
+
+/**************************************************************************************************/
+
diff --git a/distancecommand.h b/distancecommand.h
new file mode 100644 (file)
index 0000000..a43e395
--- /dev/null
@@ -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 (file)
index 0000000..767c4bf
--- /dev/null
@@ -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<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
diff --git a/eachgapignore.h b/eachgapignore.h
new file mode 100644 (file)
index 0000000..9b9d167
--- /dev/null
@@ -0,0 +1,72 @@
+#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
+
+
index eaf49dfe6937c4201330981cacf8cb5bfbf198cc..803a83635071d01f35c964aa4a5b424895d08fd2 100644 (file)
@@ -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;   }
 
                        }
                }
index bbc3050f020c8ae10699bb050acca467363b2acf..0f6dbb590bd4c66873697e12eb920900cb973f7e 100644 (file)
@@ -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;
index 97c090d34564f92363da4ef1340853b7a204cdee..a1beda31ac5ee82c532676163179197a004f91eb 100644 (file)
@@ -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;
index f92253d4b39d8cd444d60018843b70a27187e676..dec53a5b6f72d5f365295cfc71386bbe7797d0b2 100644 (file)
@@ -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.
  *
  */
 
index fffa45770cde70da74792b6bab1feb105b0bd1d5..9e703ceeb62c2d610776c7f245980de651ab28a1 100644 (file)
@@ -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.
  *
  */
 
index b4d2d74d0cc72d6c7f4db7acbd4202e3ea5b9972..3fc67d11612bccfdced922b1a8276b90cfc5b023 100644 (file)
@@ -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<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;       
        }
 
index 6750373102c4621d6ed4abf5062f537d55849449..26190b50139745531e2b8ae06201251c73f530aa 100644 (file)
@@ -24,6 +24,9 @@ public:
 private:
        GlobalData* globaldata;
        GroupMap* groupMap;
+       string outputFile;
+       ofstream out;
+
 };
 
 #endif
index 6849b880bd34fc20b74d720b86c299451be71802..ae1b0e2ebbb463fefc32a2f8ad3fd1816b01109d 100644 (file)
@@ -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";
 }
 /*******************************************************/
 
index aa68dc2c1dffd0fe90f82e8eabff554e0c8c0000..801ca6013889e7300d99fa3763ab6701ec4bf530 100644 (file)
@@ -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;
index 07b78b33a2005e27341893d29b23fb189d71c34b..61ffe418f1380ddb4d02fa216a5f6b6ada8b9d58 100644 (file)
@@ -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.
  *
  */
 
index b4065c0488db035cfee65d5a8c2cd4282cf5eb9a..4cce78b59f2c240a31e94382decc8251dd737da3 100644 (file)
@@ -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 (file)
index 0000000..8127b62
--- /dev/null
@@ -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<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
+
index c1d93ed197fe2990c24ca2ba0d89f52f8fe8320e..e4a9bfc69e23ee143fab64726e4631c0cd95580c 100644 (file)
--- 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<y){   return x;    }
+    else   {   return y;    }
+}
 
 /***********************************************************************/
 
diff --git a/onegapdist.h b/onegapdist.h
new file mode 100644 (file)
index 0000000..b6b257c
--- /dev/null
@@ -0,0 +1,79 @@
+#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
diff --git a/onegapignore.h b/onegapignore.h
new file mode 100644 (file)
index 0000000..ee6cc52
--- /dev/null
@@ -0,0 +1,87 @@
+#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
+
index 2211ccd58c34b4bc11c39caca6d56b199872ee83..2f31539623d91656f26740d803795752e156e177 100644 (file)
@@ -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.
  *
  */
 
index 8556486cca62908eab5a64de7e08f8cefddfa3a7..e09e900cbc19f2439708cbd64a75f4bc54039c86 100644 (file)
@@ -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;
index ff39e01cfe5a5e5ee90c717bb4a160648914f808..347432f40c0f872e9951592de90b2363d480f25c 100644 (file)
@@ -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.
  *
  */
 
index a4fe4363dcab40fe7fcd977b07251bb2cbcc6a68..8f5d70df46e555f22dd9d19bc69e044c7edfe659 100644 (file)
@@ -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.
  *
  */
 
index bc91e160cc5c83b331e126a33936704512cd9236..25444d5093f637d6b0ff8a09bc8816463745299d 100644 (file)
@@ -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.
  *
  */
 
index 6cd49733fe4a3a47ffe1a07918b1887153038151..f6bfcbbef72826fb76a3dd33677fadae9f2fbe26 100644 (file)
@@ -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;
index 455044aeb24f03e373b0b1621d029c3de30c016c..4d0e4005d48ed65b6a73bd28f3ab12c6a4f58268 100644 (file)
@@ -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.
  *
  */
 
index 2ca75679b3a9ca5869e380ccfc4ff4328336f0a4..dee09f5cfd9b80e5c579b60ee5b411f15ff666f3 100644 (file)
@@ -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.
  *
  */
 
index 660eb3f37055ffe9d34f8c36c771ded2af327959..52c8a7c69615a432d48d40ebef60ff7acbab2eb2 100644 (file)
@@ -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.
  *
  */
 
 #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;
 };
 
index b6be40efb1ff744d2565d94f5cefd847e4ecb26a..40f56a0c7efe29962418b4cb056ef51374517867 100644 (file)
@@ -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.
  *
  */
 
index c08c9774e953516a30ab5c7bd453b0382fe19818..13c0202dd48eba1c692658e4219abe70d0525eea 100644 (file)
@@ -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;
index 1f81ba82fb553bf54828216870121614214d2406..657573e8b3d24ee40d5f7ac10270f72a792f69e0 100644 (file)
@@ -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.
  *
  */
 
index 35636bf492d78b809dbe0b010f2d1ecf1abab050..5dcf9bd9ffb721378a2523cc447702d887dd22a8 100644 (file)
@@ -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.
  *
  */
 
index c8a1d5e8e6a061edf8cdf00a6f2025b6b8a8c53c..91c4ce5f3411971484f8849aa0510b3a289c7a62 100644 (file)
@@ -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.
  *
  */
 
index c267a0789ae294edc3086d42bc88d8bc028cbb0c..6db2d112d8050dfb436e5fda155c7f2c7741d8cd 100644 (file)
@@ -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.
  *
  */
 
index 00c0de08af07a132a3d38ce8cb6a67a614dfd5aa..bdec8f713f777f6df061038fae677676a609eb1a 100644 (file)
@@ -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.
  *
  */
 
index 3e370463aba858c2c3a824f4c38e055b800b1fd7..a1b506eb131f4f96f89d865ef4f27072ab150c20 100644 (file)
@@ -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.
  *
  */
  
index be1a2fb581251cf89544994d46fca517e4725907..d382f9b5d7b186fd8559bf2bfb1288f8b6991eb5 100644 (file)
@@ -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.
  *
  */
 
index 55bc7e433f1673222858a108aa21e8cbc22725e7..40cc9a4a48e76828fa40a1a10adee9ebf9fc91b3 100644 (file)
@@ -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.
  *
  */
 
index 699a5d5b37da2c64a60c9e7ddf4c9aafa567bca9..3006e860204680809c7efd0293f8c98386708a93 100644 (file)
--- 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.
  *
  */
 
index f6fe280a86474ea35e78a18245ac24a0ba5e5349..14fa775e7398d4be2b5b13a02f111303093c9e9d 100644 (file)
@@ -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) {
index 9f0d9b47430fbef80d66d5883c8231daded87c7d..45381b8d2719d2ef80085893c7ced8550259a89b 100644 (file)
@@ -36,6 +36,7 @@ class ValidCalculators {
                map<string, string> vennshared;
                map<string, string> treegroup;
                map<string, string> boot;
+               map<string, string> distance;
                map<string, string>::iterator it;
                
                void initialSingle();
@@ -48,6 +49,7 @@ class ValidCalculators {
                void initialVennShared();
                void initialTreeGroups();
                void initialBoot();
+               void initialDistance();
 };
 
 #endif
index 4c72dceaf26d73d8d030641c33ab48d699f495a6..ad55d0d9c600594a908fb8e71a89b6c251f35aa9 100644 (file)
@@ -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"; 
index 2d070cb01bb545b31dc94224a0ab1fd3c1606f2f..3e6a9799353a78e4e87a7cd72ebc4d78a7199aa5 100644 (file)
@@ -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));
 
index 3c719ece9d3f68d886d4643fbd21f393b6673101..9e75cdb2be63a7f967e08ebe013dd88e1442e8f9 100644 (file)
--- 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<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                        
                        //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();
@@ -265,23 +219,85 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                
                                //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";
@@ -341,90 +357,165 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> 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<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;
+                               }
+                       }
 
                }