]> git.donarmstrong.com Git - mothur.git/commitdiff
added get.sharedotu command
authorwestcott <westcott>
Wed, 23 Sep 2009 13:32:40 +0000 (13:32 +0000)
committerwestcott <westcott>
Wed, 23 Sep 2009 13:32:40 +0000 (13:32 +0000)
Mothur.xcodeproj/project.pbxproj
commandfactory.cpp
getsharedotucommand.cpp [new file with mode: 0644]
getsharedotucommand.h [new file with mode: 0644]
summarysharedcommand.h
venn.cpp

index 7f74d48b66e3c8251cfedba52695f71b2457e720..59291a3d80849c433545b63e555c8f0af52084c9 100644 (file)
                A70DECD91063D8B40057C03C /* secondarystructurecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70DECD81063D8B40057C03C /* secondarystructurecommand.cpp */; };
                A7283FF81056CAE100D0CC69 /* chimeracheckrdp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7283FF71056CAE100D0CC69 /* chimeracheckrdp.cpp */; };
                A75B887E104C16860083C454 /* ccode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75B887B104C16860083C454 /* ccode.cpp */; };
+               A7E4A783106913F900688F62 /* getsharedotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E4A782106913F900688F62 /* getsharedotucommand.cpp */; };
                EB1216880F619B83004A865F /* bergerparker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB1216870F619B83004A865F /* bergerparker.cpp */; };
                EB1216E50F61ACFB004A865F /* bstick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB1216E40F61ACFB004A865F /* bstick.cpp */; };
                EB1217230F61C9AC004A865F /* sharedkstest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EB1217220F61C9AC004A865F /* sharedkstest.cpp */; };
                A7283FF71056CAE100D0CC69 /* chimeracheckrdp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeracheckrdp.cpp; sourceTree = SOURCE_ROOT; };
                A75B887B104C16860083C454 /* ccode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccode.cpp; sourceTree = SOURCE_ROOT; };
                A75B887C104C16860083C454 /* ccode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccode.h; sourceTree = SOURCE_ROOT; };
+               A7E4A781106913F900688F62 /* getsharedotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getsharedotucommand.h; sourceTree = "<group>"; };
+               A7E4A782106913F900688F62 /* getsharedotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getsharedotucommand.cpp; sourceTree = "<group>"; };
                C6859E8B029090EE04C91782 /* Mothur.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Mothur.1; sourceTree = "<group>"; };
                EB1216860F619B83004A865F /* bergerparker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bergerparker.h; sourceTree = SOURCE_ROOT; };
                EB1216870F619B83004A865F /* bergerparker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bergerparker.cpp; sourceTree = SOURCE_ROOT; };
                                3749271C0FD58C840031C06B /* getsabundcommand.cpp */,
                                37B73CA41004D89A008C4B41 /* getseqscommand.h */,
                                37B73CA51004D89A008C4B41 /* getseqscommand.cpp */,
+                               A7E4A781106913F900688F62 /* getsharedotucommand.h */,
+                               A7E4A782106913F900688F62 /* getsharedotucommand.cpp */,
                                375873F10F7D64800040F377 /* heatmapcommand.h */,
                                375873F00F7D64800040F377 /* heatmapcommand.cpp */,
                                378598640FDD497000EF9D03 /* heatmapsimcommand.h */,
                                A75B887E104C16860083C454 /* ccode.cpp in Sources */,
                                A7283FF81056CAE100D0CC69 /* chimeracheckrdp.cpp in Sources */,
                                A70DECD91063D8B40057C03C /* secondarystructurecommand.cpp in Sources */,
+                               A7E4A783106913F900688F62 /* getsharedotucommand.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index dd5b36317deae9007ccf8951f8133f573e75e316..433702466c5b531c84edb79a45018a589dceaf86 100644 (file)
@@ -55,6 +55,7 @@
 #include "removeseqscommand.h"
 #include "systemcommand.h"
 #include "secondarystructurecommand.h"
+#include "getsharedotucommand.h"
 
 /***********************************************************/
 
@@ -108,6 +109,7 @@ CommandFactory::CommandFactory(){
        commands["remove.seqs"]                 = "get.seqs";
        commands["system"]                              = "system";
        commands["align.check"]                 = "align.check";
+       commands["get.sharedotu"]               = "get.sharedotu";
        commands["quit"]                                = "quit"; 
 
 }
@@ -171,6 +173,7 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
                else if(commandName == "merge.files")                   {       command = new MergeFileCommand(optionString);                   }
                else if(commandName == "system")                                {       command = new SystemCommand(optionString);                              }
                else if(commandName == "align.check")                   {       command = new AlignCheckCommand(optionString);                  }
+               else if(commandName == "get.sharedotu")                 {       command = new GetSharedOTUCommand(optionString);                }
                else                                                                                    {       command = new NoCommand(optionString);                                  }
 
                return command;
diff --git a/getsharedotucommand.cpp b/getsharedotucommand.cpp
new file mode 100644 (file)
index 0000000..3def8bc
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ *  getsharedotucommand.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 9/22/09.
+ *  Copyright 2009 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "getsharedotucommand.h"
+
+//**********************************************************************************************************************
+
+GetSharedOTUCommand::GetSharedOTUCommand(string option){
+       try {
+       
+               globaldata = GlobalData::getInstance();
+               abort = false;
+               allLines = 1;
+               labels.clear();
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
+               
+               else {
+                       //valid paramters for this command
+                       string Array[] =  {"label","groups","fasta","list","group","output"};
+                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+                       
+                       OptionParser parser(option);
+                       map<string,string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+                       
+                       //check to make sure all parameters are valid for command
+                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+                       
+                       //check for required parameters
+                       listfile = validParameter.validFile(parameters, "list", true);
+                       if (listfile == "not open") { abort = true; }
+                       else if (listfile == "not found") { listfile = ""; }    
+                       else {  globaldata->setListFile(listfile);  globaldata->setFormat("list");      }
+                       
+                       groupfile = validParameter.validFile(parameters, "group", true);
+                       if (groupfile == "not open") { abort = true; }  
+                       else if (groupfile == "not found") { groupfile = ""; }
+                                               
+                       if ((listfile == "") || (groupfile == "")) { mothurOut("The list and group parameters are required."); mothurOutEndLine(); abort = true; }
+                       
+                       //check for optional parameter and set defaults
+                       // ...at some point should added some additional type checking...
+                       label = validParameter.validFile(parameters, "label", false);                   
+                       if (label == "not found") { label = ""; }
+                       else { 
+                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               else { allLines = 1;  }
+                       }
+                       
+                       output = validParameter.validFile(parameters, "output", false);                 
+                       if (output == "not found") { output = ""; }
+                       
+                       groups = validParameter.validFile(parameters, "groups", false);                 
+                       if (groups == "not found") { groups = ""; }
+                       else { 
+                               splitAtDash(groups, Groups);
+                               globaldata->Groups = Groups;
+                       }
+                       
+                       fastafile = validParameter.validFile(parameters, "fasta", true);
+                       if (fastafile == "not open") { abort = true; }
+                       else if (fastafile == "not found") {  fastafile = "";  }        
+                               
+               }
+
+       }
+       catch(exception& e) {
+               errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void GetSharedOTUCommand::help(){
+       try {
+               mothurOut("The get.sharedotu command parameters are list, group, label, groups, output and fasta.  The list and group parameters are required.\n");
+               mothurOut("The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n");
+               mothurOut("The groups parameter allows you to select groups you would like to know the shared info for, and are separated by dashes.\n");
+               mothurOut("The fasta parameter allows you to input a fasta file and outputs a fasta file for each distance level containing only the sequences that are in OTUs shared by the groups specified.\n");
+               mothurOut("The output parameter allows you to output the list of names without the group and bin number added. \n");
+               mothurOut("With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n");
+               mothurOut("The get.sharedotu command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n");
+               mothurOut("The get.sharedotu command should be in the following format: get.sabund(label=yourLabels, groups=yourGroups, fasta=yourFastafile, output=yourOutput).\n");
+               mothurOut("Example get.sharedotu(label=unique-0.01, group=forest-pasture, fasta=amazon.fasta, output=accnos).\n");
+               mothurOut("The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n");
+               mothurOut("Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n\n");
+       }
+       catch(exception& e) {
+               errorOut(e, "GetSharedOTUCommand", "help");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+
+GetSharedOTUCommand::~GetSharedOTUCommand(){}
+
+//**********************************************************************************************************************
+
+int GetSharedOTUCommand::execute(){
+       try {
+               
+               if (abort == true) { return 0; }
+               
+               groupMap = new GroupMap(groupfile);
+               groupMap->readMap();
+               globaldata->gGroupmap = groupMap;
+               
+               if (Groups.size() == 0) {
+                       Groups = groupMap->namesOfGroups;
+               }
+               
+               //put groups in map to find easier
+               for(int i = 0; i < Groups.size(); i++) {
+                       groupFinder[Groups[i]] = Groups[i];
+               }
+               
+               if (fastafile != "") {
+                       ifstream inFasta;
+                       openInputFile(fastafile, inFasta);
+                       
+                       while(!inFasta.eof()) {
+                               Sequence seq(inFasta);
+                               seqs.push_back(seq);
+                       }
+                       inFasta.close();
+               }
+               
+               ListVector* lastlist = NULL;
+               string lastLabel = "";
+               
+               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+               set<string> processedLabels;
+               set<string> userLabels = labels;
+               
+               ifstream in;
+               openInputFile(listfile, in);
+               
+               //as long as you are not at the end of the file or done wih the lines you want
+               while((!in.eof()) && ((allLines == 1) || (userLabels.size() != 0))) {
+                       
+                       list = new ListVector(in);
+                       
+                       if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
+                               mothurOut(list->getLabel()); 
+                               process(list);
+                               
+                               processedLabels.insert(list->getLabel());
+                               userLabels.erase(list->getLabel());
+                       }
+                       
+                       if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                                       
+                                       mothurOut(lastlist->getLabel()); 
+                                       process(lastlist);
+                                       
+                                       processedLabels.insert(lastlist->getLabel());
+                                       userLabels.erase(lastlist->getLabel());
+                       }
+
+                       lastLabel = list->getLabel();
+                       
+                       if (lastlist != NULL) {         delete lastlist;        }
+                       lastlist = list;                        
+               }
+               
+               in.close();
+               
+               //output error messages about any remaining user labels
+               set<string>::iterator it;
+               bool needToRun = false;
+               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
+                       mothurOut("Your file does not include the label " + *it); 
+                       if (processedLabels.count(lastLabel) != 1) {
+                               mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
+                               needToRun = true;
+                       }else {
+                               mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
+                       }
+               }
+               
+               //run last label if you need to
+               if (needToRun == true)  {
+                               mothurOut(lastlist->getLabel()); 
+                               process(lastlist);
+                                       
+                               processedLabels.insert(lastlist->getLabel());
+                               userLabels.erase(lastlist->getLabel());
+               }
+               
+
+               //reset groups parameter
+               globaldata->Groups.clear();  
+               
+               if (lastlist != NULL) {         delete lastlist;        }
+               return 0;
+       }
+
+       catch(exception& e) {
+               errorOut(e, "GetSharedOTUCommand", "execute");
+               exit(1);
+       }
+}
+/***********************************************************/
+void GetSharedOTUCommand::process(ListVector* shared) {
+       try {
+               
+               map<string, string> fastaMap;
+               
+               ofstream outNames;
+               string outputFileNames = getRootName(listfile) + shared->getLabel() + ".names";
+               openOutputFile(outputFileNames, outNames);
+               
+               bool wroteSomething = false;
+                               
+               //go through each bin, find out if shared
+               for (int i = 0; i < shared->getNumBins(); i++) {
+                       
+                       bool sharedByAll = true;
+                       
+                       map<string, int> atLeastOne;
+                       for (int m = 0; m < Groups.size(); m++) {
+                               atLeastOne[Groups[m]] = 0;
+                       }
+                       
+                       vector<string> namesOfSeqsInThisBin;
+                       
+                       string names = shared->get(i);  
+                       while ((names.find_first_of(',') != -1) && sharedByAll) { 
+                               string name = names.substr(0,names.find_first_of(','));
+                               names = names.substr(names.find_first_of(',')+1, names.length());
+                                                               
+                               //find group
+                               string seqGroup = groupMap->getGroup(name);
+                               if (output != "accnos") {
+                                       namesOfSeqsInThisBin.push_back((name + "|" + seqGroup + "|" + toString(i)));
+                               }else {  namesOfSeqsInThisBin.push_back(name);  }
+
+                               if (seqGroup == "not found") { mothurOut(name + " is not in your groupfile. Please correct."); mothurOutEndLine(); exit(1);  }
+                               
+                               //is this seq in one of hte groups we care about
+                               it = groupFinder.find(seqGroup);
+                               if (it == groupFinder.end()) {  sharedByAll = false;  } //you have a sequence from a group you don't want
+                               else {  atLeastOne[seqGroup]++;  }
+                       }
+                       
+                       //get last name
+                       //find group
+                       if (sharedByAll) {
+                               string seqGroup = groupMap->getGroup(names);
+                               if (output != "accnos") {
+                                       namesOfSeqsInThisBin.push_back((names + "|" + seqGroup + "|" + toString(i)));
+                               }else {  namesOfSeqsInThisBin.push_back(names); }
+                               
+                               if (seqGroup == "not found") { mothurOut(names + " is not in your groupfile. Please correct."); mothurOutEndLine(); exit(1);  }
+                       
+                               //is this seq in one of hte groups we care about
+                               it = groupFinder.find(seqGroup);
+                               if (it == groupFinder.end()) {  sharedByAll = false;  } //you have a sequence from a group you don't want
+                               else {  atLeastOne[seqGroup]++;  }
+                       }
+                       
+                       //make sure you have at least one seq from each group you want
+                       map<string, int>::iterator it2;
+                       for (it2 = atLeastOne.begin(); it2 != atLeastOne.end(); it2++) {
+                               if (it2->second == 0) {  sharedByAll = false;   }
+                       }
+                       
+                       //if shared, save names of seqs in that bin
+                       if (sharedByAll) {
+                               
+                               wroteSomething = true;
+                               
+                               //output list of names 
+                               for (int j = 0; j < namesOfSeqsInThisBin.size(); j++) {
+                                       outNames << namesOfSeqsInThisBin[j] << endl;
+                                       
+                                       if (fastafile != "") { 
+                                               if (output != "accnos") {
+                                                       string seqName = namesOfSeqsInThisBin[j].substr(0,namesOfSeqsInThisBin[j].find_last_of('|'));
+                                                       seqName = seqName.substr(0,seqName.find_last_of('|'));
+                                                       fastaMap[seqName] = namesOfSeqsInThisBin[j];  //fastaMap needs to contain just the seq name for output later
+                                               }else {
+                                                       fastaMap[namesOfSeqsInThisBin[j]] = namesOfSeqsInThisBin[j];
+                                               }
+                                       }
+                               }
+                       }
+                       
+                       
+                               
+               }
+               
+               outNames.close();
+               
+               if (!wroteSomething) {
+                       remove(outputFileNames.c_str());
+                       string outputString = " - No otus shared by groups";
+                       
+                       string groupString = "";
+                       for (int h = 0; h < Groups.size(); h++) {
+                               groupString += "  " + Groups[h];
+                       }
+                       
+                       outputString += groupString + ".";
+                       mothurOut(outputString); mothurOutEndLine();
+               }else { mothurOutEndLine(); }
+               
+               //if fasta file provided output new fasta file
+               if ((fastafile != "") && wroteSomething) {      
+                       string outputFileFasta = getRootName(fastafile) + shared->getLabel() + ".fasta";
+                       ofstream outFasta;
+                       openOutputFile(outputFileFasta, outFasta);
+                       
+                       for (int k = 0; k < seqs.size(); k++) {
+                               //if this is a sequence we want, output it
+                               it = fastaMap.find(seqs[k].getName());
+                               if (it != fastaMap.end()) {
+                               
+                                       if (output != "accnos") {
+                                               outFasta << ">" << it->second << endl;
+                                       }else {
+                                               outFasta << ">" << it->first << endl;
+                                       }
+                                       
+                                       outFasta << seqs[k].getAligned() << endl;
+                               }
+                       }
+                       
+                       outFasta.close();
+               }
+
+               
+       }
+       catch(exception& e) {
+               errorOut(e, "GetSharedOTUCommand", "process");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
diff --git a/getsharedotucommand.h b/getsharedotucommand.h
new file mode 100644 (file)
index 0000000..6470961
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef GETSHAREDOTUCOMMAND_H
+#define GETSHAREDOTUCOMMAND_H
+
+/*
+ *  getsharedotucommand.h
+ *  Mothur
+ *
+ *  Created by westcott on 9/22/09.
+ *  Copyright 2009 Schloss Lab. All rights reserved.
+ *
+ */
+#include "command.hpp"
+#include "listvector.hpp"
+#include "sequence.hpp"
+#include "groupmap.h"
+#include "globaldata.hpp"
+
+//**********************************************************************************************************************
+class GetSharedOTUCommand : public Command {
+       
+       public:
+       
+               GetSharedOTUCommand(string);    
+               ~GetSharedOTUCommand();
+               int execute();
+               void help();    
+               
+       private:
+               
+               GlobalData* globaldata;
+               ListVector* list;
+               GroupMap* groupMap;
+               
+               set<string> labels;
+               string fastafile, label, groups, listfile, groupfile, output;
+               bool abort, allLines;
+               vector<string> Groups;
+               map<string, string> groupFinder;
+               map<string, string>::iterator it;
+               vector<Sequence> seqs;
+               
+               void process(ListVector*);
+               
+};
+//**********************************************************************************************************************
+
+#endif
+
index 119a75c47438a85460b4b798501edbf0807569c0..63197e199493aba98106c43378340e4e394fdda1 100644 (file)
@@ -33,10 +33,7 @@ private:
        vector<Calculator*> sumCalculators;     
        InputData* input;
        ValidCalculators* validCalculator;
-       SharedListVector* SharedList;
-       OptionParser* parser;
-       map<string, string> parameters;
-       map<string, string>::iterator it;
+       
        bool abort, allLines, mult;
        set<string> labels; //holds labels to be used
        string label, calc, groups;
index bd4086988a6f304833cabdfa2235a8536eefc8ae..82020d46a18de0cb4ad4959498f3cbee1ddfe4a2 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -306,12 +306,12 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"305\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";  
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"280\">" + toString(sharedABC) + "</text>\n"; 
                                
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"720\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"740\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"760\">The number of sepecies shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"720\">The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"740\">The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"760\">The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"580\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
                                        if (numA.size() == 3) { 
                                                outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
@@ -389,9 +389,9 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"305\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";  
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedabc[0]).length() / 2)) + "\"  y=\"280\">" + toString(sharedabc[0]) + "</text>\n"; 
                                
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "</text>\n";
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"580\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
                                        if (numA.size() == 3) { 
                                                outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
@@ -546,17 +546,17 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"530\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "</text>\n";
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"550\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "</text>\n";
                                        
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"570\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"590\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"610\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"630\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"650\">The number of sepecies shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"670\">The number of sepecies shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"570\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"590\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"610\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"630\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"650\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"670\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "</text>\n";
                                        
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"690\">The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"710\">The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"730\">The number of sepecies shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"750\">The number of sepecies shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"690\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"710\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"730\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"750\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "</text>\n";
                                                                        
                                        //make adjustments
                                        sharedABC = sharedABC - sharedABCD;