void setLabel(string l) { label = l; }
string getLabel() { return label; }
- //virtual RAbundVector getRAbundVector() = 0;
+ virtual RAbundVector getRAbundVector() = 0;
virtual SAbundVector getSAbundVector() = 0;
virtual OrderVector getOrderVector(map<string,int>* hold = NULL) = 0;
vector<Tree*> gTree;
SharedListVector* gSharedList;
SAbundVector* sabund;
+ RAbundVector* rabund;
GroupMap* gGroupmap;
FullMatrix* gMatrix;
TreeMap* gTreemap;
globaldata = GlobalData::getInstance();
format = globaldata->getFormat();
sorted = globaldata->getSorted();
- util = new SharedUtil();
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
//**********************************************************************************************************************
-void HeatMap::getPic(OrderVector* order) {
+void HeatMap::getPic(RAbundVector* rabund) {
try {
-
- RAbundVector rabund = order->getRAbundVector();
-
//get users scaling method
scaler = globaldata->getScale();
float maxRelAbund = 0.0;
- for(int i=0;i<rabund.size();i++){
- float relAbund = rabund.get(i) / (float)rabund.getNumSeqs();
+ for(int i=0;i<rabund->size();i++){
+ float relAbund = rabund->get(i) / (float)rabund->getNumSeqs();
if(relAbund > maxRelAbund){ maxRelAbund = relAbund; }
}
scaler = globaldata->getScale();
- vector<string> scaleRelAbund(rabund.size(), "");
+ vector<string> scaleRelAbund(rabund->size(), "");
- for(int i=0;i<rabund.size();i++){
- float relAbund = rabund.get(i) / (float)rabund.getNumSeqs();
+ for(int i=0;i<rabund->size();i++){
+ float relAbund = rabund->get(i) / (float)rabund->getNumSeqs();
- if (rabund.get(i) != 0) { //don't want log value of 0.
+ if (rabund->get(i) != 0) { //don't want log value of 0.
if (scaler == "log10") {
scaleRelAbund[i] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund))) + "0000";
}else if (scaler == "log2") {
}
- string filenamesvg = getRootName(globaldata->inputFileName) + rabund.getLabel() + ".heatmap.svg";
+ string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.svg";
openOutputFile(filenamesvg, outsvg);
//svg image
- outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((rabund.getNumBins()*5 + 120)) + "\">\n";
+ outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((rabund->getNumBins()*5 + 120)) + "\">\n";
outsvg << "<g>\n";
//white backround
- outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(300) + "\" height=\"" + toString((rabund.getNumBins()*5 + 120)) + "\"/>";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((150) - 40) + "\" y=\"25\">Heatmap at distance " + rabund.getLabel() + "</text>\n";
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(300) + "\" height=\"" + toString((rabund->getNumBins()*5 + 120)) + "\"/>";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((150) - 40) + "\" y=\"25\">Heatmap at distance " + rabund->getLabel() + "</text>\n";
//output legend and color labels
string color;
int x = 0;
- int y = 103 + (rabund.getNumBins()*5);
+ int y = 103 + (rabund->getNumBins()*5);
printLegend(y, maxRelAbund);
y = 70;
//**********************************************************************************************************************
-void HeatMap::getPic(SharedOrderVector* sharedorder) {
+void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
try {
- //fills vector of sharedsabunds - lookup
- vector<SharedRAbundVector*> lookup;
-
- util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector.
-
//sort lookup so shared bins are on top
if (sorted == "T") { sortSharedVectors(lookup); }
}
}
- string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".heatmap.svg";
+ string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.svg";
openOutputFile(filenamesvg, outsvg);
//svg image
//white backround
outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * 300) + "\" height=\"" + toString((lookup[0]->getNumBins()*5 + 120)) + "\"/>";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
//column labels
for (int h = 0; h < lookup.size(); h++) {
else if(scaler== "log2") { label = maxbin * log2(51*i) / log2(255); }
else if(scaler== "linear") { label = maxbin * 51 * i / 255; }
else { label = maxbin * log10(51*i) / log10(255); }
-
+ file://localhost/Users/westcott/Desktop/c.amazon.fn.0.19.rep.fasta
label = int(label * 1000 + 0.5);
label /= 1000.0;
string text = toString(label, 3);
using namespace std;
-#include "ordervector.hpp"
#include "rabundvector.hpp"
#include "sharedrabundvector.h"
-#include "sharedordervector.h"
#include "datavector.hpp"
#include "globaldata.hpp"
-#include "sharedutilities.h"
/***********************************************************************/
public:
HeatMap();
- ~HeatMap(){ delete util; };
+ ~HeatMap(){};
- void getPic(OrderVector*);
- void getPic(SharedOrderVector*);
+ void getPic(RAbundVector*);
+ void getPic(vector<SharedRAbundVector*>);
private:
void sortSharedVectors(vector<SharedRAbundVector*>& );
void printLegend(int, float);
GlobalData* globaldata;
- SharedUtil* util;
string format, sorted, groupComb, scaler;
ofstream outsvg;
+
globaldata = GlobalData::getInstance();
heatmap = new HeatMap();
format = globaldata->getFormat();
- util = new SharedUtil();
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function HeatMapCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
delete input;
delete read;
delete heatmap;
- delete util;
}
//**********************************************************************************************************************
read->read(&*globaldata);
input = globaldata->ginput;
- order = input->getSharedOrderVector();
+ lookup = input->getSharedRAbundVectors();
}else if (format == "shared") {
//you are using a list and a groupfile
read = new ReadOTUFile(globaldata->inputFileName);
input = globaldata->ginput;
SharedList = globaldata->gSharedList;
- order = SharedList->getSharedOrderVector();
+ lookup = SharedList->getSharedRAbundVector();
}else if (format == "list") {
//you are using just a list file and have only one group
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
- ordersingle = globaldata->gorder;
- input = globaldata->ginput;
+ rabund = globaldata->rabund;
+ input = globaldata->ginput;
}
if (format != "list") {
- util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "heat");
- globaldata->setGroups("");
-
-
- while(order != NULL){
+ while(lookup[0] != NULL){
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lookup[0]->getLabel()) == 1){
- cout << order->getLabel() << '\t' << count << endl;
- heatmap->getPic(order);
-
+ cout << lookup[0]->getLabel() << '\t' << count << endl;
+ heatmap->getPic(lookup);
}
//get next line to process
- if (format == "sharedfile") {
- order = input->getSharedOrderVector();
- }else {
- //you are using a list and a groupfile
- SharedList = input->getSharedListVector(); //get new list vector to process
- if (SharedList != NULL) {
- order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
- }else {
- break;
- }
- }
+ lookup = input->getSharedRAbundVectors();
count++;
}
globaldata->Groups.clear();
}else{
- while(ordersingle != NULL){
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){
+ while(rabund != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(rabund->getLabel()) == 1){
- cout << ordersingle->getLabel() << '\t' << count << endl;
- heatmap->getPic(ordersingle);
-
+ cout << rabund->getLabel() << '\t' << count << endl;
+ heatmap->getPic(rabund);
}
- ordersingle = (input->getOrderVector());
+ rabund = input->getRAbundVector();
count++;
}
}
+ globaldata->setGroups("");
return 0;
}
catch(exception& e) {
#include "readotu.h"
#include "sharedlistvector.h"
#include "heatmap.h"
-#include "sharedutilities.h"
-
+#include "rabundvector.hpp"
class GlobalData;
-
class HeatMapCommand : public Command {
public:
private:
GlobalData* globaldata;
ReadOTUFile* read;
- SharedUtil* util;
InputData* input;
SharedListVector* SharedList;
- SharedOrderVector* order;
- OrderVector* ordersingle;
+ RAbundVector* rabund;
+ vector<SharedRAbundVector*> lookup;
HeatMap* heatmap;
string format;
#include "inputdata.h"
#include "ordervector.hpp"
#include "listvector.hpp"
+#include "rabundvector.hpp"
/***********************************************************************/
exit(1);
}
}
+/***********************************************************************/
+
+vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
+ try {
+ if(fileHandle){
+ if (format == "sharedfile") {
+ SharedOrder = new SharedOrderVector(fileHandle);
+ if (SharedOrder != NULL) {
+ return SharedOrder->getSharedRAbundVector();
+ }
+ }else if (format == "shared") {
+ SharedList = new SharedListVector(fileHandle);
+ if (SharedList != NULL) {
+ return SharedList->getSharedRAbundVector();
+ }
+ }
+ gobble(fileHandle);
+ }
+
+ //this is created to signal to calling function that the input file is at eof
+ vector<SharedRAbundVector*> null; null.push_back(NULL);
+ return null;
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the InputData class function getSharedRAbundVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
/***********************************************************************/
}
/***********************************************************************/
+RAbundVector* InputData::getRAbundVector(){
+ try {
+ if(fileHandle){
+ if (format == "list") {
+ input = new ListVector(fileHandle);
+ }
+ else if (format == "shared") {
+ input = new SharedListVector(fileHandle);
+ }
+ else if(format == "rabund"){
+ input = new RAbundVector(fileHandle);
+ }
+ else if(format == "order"){
+ input = new OrderVector(fileHandle);
+ }
+ else if(format == "sabund"){
+ input = new SAbundVector(fileHandle);
+ }
+
+ gobble(fileHandle);
+
+ rabund = new RAbundVector();
+ *rabund = (input->getRAbundVector());
+
+ return rabund;
+ }
+ else{
+ return NULL;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the InputData class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+
+
OrderVector* getOrderVector();
SharedOrderVector* getSharedOrderVector();
SAbundVector* getSAbundVector();
+ RAbundVector* getRAbundVector();
+ vector<SharedRAbundVector*> getSharedRAbundVectors();
private:
string format;
OrderVector* output;
SharedOrderVector* SharedOrder;
SAbundVector* sabund;
+ RAbundVector* rabund;
map<string,int> orderMap;
};
input = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
inputList = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund or shared.
+ inputRabund = new InputData(philFile, globaldata->getFormat());
}else {//there is an orderfile
input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
}
globaldata->gorder = order; //saving to be used by collect and rarefact commands.
sabund = inputSabund->getSAbundVector();
globaldata->sabund = sabund; //saving to be used by summary command.
+ rabund = inputRabund->getRAbundVector();
+ globaldata->rabund = rabund; //saving to be used by heatmap command.
list = inputList->getListVector();
globaldata->gListVector = list;
}else if (globaldata->getFormat() == "shared") {
string philFile;
InputData* input;
InputData* inputSabund;
+ InputData* inputRabund;
InputData* inputList;
ListVector* list;
SharedListVector* SharedList;
OrderVector* order;
SAbundVector* sabund;
+ RAbundVector* rabund;
GlobalData* globaldata;
// InputData* getInput() { return input; }
};
#include "ordervector.hpp"
#include "sharedlistvector.h"
#include "sharedordervector.h"
+#include "sharedutilities.h"
/***********************************************************************/
exit(1);
}
}
+/***********************************************************************/
+vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
+ try {
+ SharedUtil* util;
+ util = new SharedUtil();
+ vector<SharedRAbundVector*> lookup;
+
+ util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
+ util->getSharedVectors(globaldata->Groups, lookup, this->getSharedOrderVector());
+
+ return lookup;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
/***********************************************************************/
SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {
SharedOrderVector* getSharedOrderVector();
SharedRAbundVector getSharedRAbundVector(string); //get sharedrabundvector for a certain group
SharedSAbundVector getSharedSAbundVector(string); //get sharedsabundvector for a certain group
+ vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
private:
vector<string> data; //data[i] is a list of names of sequences in the ith OTU.
#include "sharedordervector.h"
-
+#include "sharedutilities.h"
/***********************************************************************/
exit(1);
}
+}
+/***********************************************************************/
+vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
+ try {
+ SharedUtil* util;
+ util = new SharedUtil();
+ vector<SharedRAbundVector*> lookup;
+
+ util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
+ util->getSharedVectors(globaldata->Groups, lookup, this);
+
+ return lookup;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
}
/***********************************************************************/
SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
SharedOrderVector getSharedOrderVector();
SharedRAbundVector getSharedRAbundVector(string); //get the sharedRabundvector for a sepecific group
SharedSAbundVector getSharedSAbundVector(string); //get the sharedSabundvector for a sepecific group
+ vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
private:
GlobalData* globaldata;
/**************************************************************************************************/
//need to have mode because different commands require different number of valid groups
-void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string mode) {
+void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups) {
try {
if (userGroups.size() != 0) {
if (userGroups[0] != "all") {
i--;
}
}
+
+ //if the user only entered invalid groups
+ if (userGroups.size() == 0) {
+ cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl;
+ for (int i = 0; i < allGroups.size(); i++) {
+ userGroups.push_back(allGroups[i]);
+ }
+ }
}else{//user has enter "all" and wants the default groups
userGroups.clear();
}
}
- if (mode == "venn") {
- //if the user only entered invalid groups
- if (userGroups.size() == 0) {
- if (allGroups.size() > 4) {
- cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first four groups in your groupfile." << endl;
- for (int i = 0; i < 4; i++) {
- userGroups.push_back(allGroups[i]);
- }
- }else {
- cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl;
- for (int i = 0; i < allGroups.size(); i++) {
- userGroups.push_back(allGroups[i]);
- }
- }
- }
-
- //check to make sure their are only 4 groups
- if (userGroups.size() > 4) {
- cout << "You may only use up to 4 groups at a time with this command. I will choose the first four and disregard the rest." << endl;
- for (int i = 4; i < userGroups.size(); i++) {
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/**************************************************************************************************/
+//need to have mode because different commands require different number of valid groups
+void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string mode) {
+ try {
+ if (userGroups.size() != 0) {
+ if (userGroups[0] != "all") {
+ //check that groups are valid
+ for (int i = 0; i < userGroups.size(); i++) {
+ if (isValidGroup(userGroups[i], allGroups) != true) {
+ cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl;
+ // erase the invalid group from userGroups
userGroups.erase(userGroups.begin()+i);
+ i--;
}
}
- }else if (mode == "heat") {
- //if the user only entered invalid groups
- if (userGroups.size() == 0) {
- cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl;
- for (int i = 0; i < allGroups.size(); i++) {
- userGroups.push_back(allGroups[i]);
- }
+
+ }else{//user has enter "all" and wants the default groups
+ userGroups.clear();
+ for (int i = 0; i < allGroups.size(); i++) {
+ userGroups.push_back(allGroups[i]);
}
- }else if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) {
+ }
+ }else { //the user has not entered groups
+ for (int i = 0; i < allGroups.size(); i++) {
+ userGroups.push_back(allGroups[i]);
+ }
+ }
+
+ if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) {
//if the user only entered invalid groups
if ((userGroups.size() == 0) || (userGroups.size() == 1)) {
cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl;
}
+
/**************************************************************************************/
//for parsimony and unifrac commands you set pairwise groups as well as an allgroups in calc
void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string& label, int& numGroups, string mode){ //globaldata->Groups, your tree or group map, allgroups, mode
void getSharedVectors(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
void getSharedVectorswithReplacement(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
+ void setGroups(vector<string>&, vector<string>&); //globaldata->Groups, your tree or group map
void setGroups(vector<string>&, vector<string>&, string); //globaldata->Groups, your tree or group map, mode
void setGroups(vector<string>&, vector<string>&, string&, int&, string); //globaldata->Groups, your tree or group map, allgroups, numGroups, mode
void getCombos(vector<string>&, vector<string>, int&); //groupcomb, globaldata->Groups, numcomb
try {
globaldata = GlobalData::getInstance();
format = globaldata->getFormat();
- util = new SharedUtil();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
}
}
//**********************************************************************************************************************
-void Venn::getPic(OrderVector* order, vector<Calculator*> vCalcs) {
+void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
try {
- SAbundVector s;
- s = order->getSAbundVector(); sabund = &s;
-
+
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = globaldata->inputFileName + ".venn." + order->getLabel() + vCalcs[i]->getName() + ".svg";
+ string filenamesvg = globaldata->inputFileName + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg";
openOutputFile(filenamesvg, outsvg);
vector<double> data = vCalcs[i]->getValues(sabund);
outsvg << "<g>\n";
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 " + order->getLabel() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>";
outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";
}
}
//**********************************************************************************************************************
-void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
+void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
try {
//fills vector of sharedsabunds - lookup
- util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector.
+ //util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector.
/******************* 1 Group **************************/
if (lookup.size() == 1) {
SAbundVector s;
- s = lookup[0]->getSAbundVector(); sabund = &s;
+ s = lookup[0]->getSAbundVector(); SAbundVector* sabund = &s;
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ 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
outsvg << "<g>\n";
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 " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>";
outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"165\">" + lookup[0]->getGroup() + "</text>\n";
outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
openOutputFile(filenamesvg, outsvg);
//get estimates for sharedAB
//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 " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"250\" cy=\"200\" r=\"150\"/>";
outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"435\" cy=\"200\" r=\"150\"/>";
outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]).length() / 2)) + "\" y=\"195\">" + toString(numA[0] - shared[0]) + "</text>\n";
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
+ string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
openOutputFile(filenamesvg, outsvg);
//get estimates for sharedAB, sharedAC and sharedBC
//draw circles
outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"800\" height=\"800\"/>";
- outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sharedorder->getLabel() + "</text>\n";
+ outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>";
outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>";
outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>";
if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0)) { sharedABCD++; }
}
- string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn.sharedsobs.svg";
+ string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn.sharedsobs.svg";
openOutputFile(filenamesvg, outsvg);
//image window
//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 " + sharedorder->getLabel() + "</text>\n";
+ 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 ";
using namespace std;
-#include "ordervector.hpp"
#include "sabundvector.hpp"
#include "sharedrabundvector.h"
-#include "sharedordervector.h"
#include "datavector.hpp"
#include "globaldata.hpp"
#include "calculator.h"
-#include "sharedutilities.h"
+
/***********************************************************************/
Venn();
~Venn(){};
- void getPic(OrderVector*, vector<Calculator*>);
- void getPic(SharedOrderVector*, vector<Calculator*>);
+ void getPic(SAbundVector*, vector<Calculator*>);
+ void getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
private:
- SharedUtil* util;
- SAbundVector* sabund;
GlobalData* globaldata;
Calculator* singleCalc;
- vector<SharedRAbundVector*> lookup;
string format, groupComb;
ofstream outsvg;
globaldata = GlobalData::getInstance();
format = globaldata->getFormat();
validCalculator = new ValidCalculators();
- util = new SharedUtil();
int i;
delete input;
delete read;
delete venn;
- delete util;
}
//**********************************************************************************************************************
read->read(&*globaldata);
input = globaldata->ginput;
- order = input->getSharedOrderVector();
+ lookup = input->getSharedRAbundVectors();
}else if (format == "shared") {
//you are using a list and a groupfile
read = new ReadOTUFile(globaldata->inputFileName);
input = globaldata->ginput;
SharedList = globaldata->gSharedList;
- order = SharedList->getSharedOrderVector();
+ lookup = SharedList->getSharedRAbundVector();
}else if (format == "list") {
//you are using just a list file and have only one group
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
- ordersingle = globaldata->gorder;
+ sabund = globaldata->sabund;
input = globaldata->ginput;
}
if (format != "list") {
- util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "venn");
- globaldata->setGroups("");
-
- while(order != NULL){
+ while(lookup[0] != NULL){
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lookup[0]->getLabel()) == 1){
- cout << order->getLabel() << '\t' << count << endl;
- venn->getPic(order, vennCalculators);
-
+ cout << lookup[0]->getLabel() << '\t' << count << endl;
+
+ if (lookup.size() > 4) {
+ cout << "Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile." << endl;
+ for (int i = lookup.size(); i > 3; i--) { delete lookup[i]; lookup.pop_back(); }
+ }
+
+ //util->getSharedVectors(globaldata->Groups, lookup, order); //fills group vectors from order vector.
+ venn->getPic(lookup, vennCalculators);
}
//get next line to process
- if (format == "sharedfile") {
- order = input->getSharedOrderVector();
- }else {
- //you are using a list and a groupfile
- SharedList = input->getSharedListVector(); //get new list vector to process
- if (SharedList != NULL) {
- order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
- }else {
- break;
- }
- }
+ lookup = input->getSharedRAbundVectors();
count++;
}
globaldata->Groups.clear();
}else{
- while(ordersingle != NULL){
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(ordersingle->getLabel()) == 1){
+ while(sabund != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(sabund->getLabel()) == 1){
- cout << ordersingle->getLabel() << '\t' << count << endl;
- venn->getPic(ordersingle, vennCalculators);
-
+ cout << sabund->getLabel() << '\t' << count << endl;
+ venn->getPic(sabund, vennCalculators);
}
- ordersingle = (input->getOrderVector());
+ sabund = input->getSAbundVector();
count++;
}
}
+ globaldata->setGroups("");
return 0;
}
catch(exception& e) {
}
}
-//**********************************************************************************************************************
-
+//**********************************************************************************************************************
\ No newline at end of file
#include "sharedlistvector.h"
#include "venn.h"
#include "validcalculator.h"
-#include "sharedutilities.h"
class GlobalData;
private:
GlobalData* globaldata;
ReadOTUFile* read;
- SharedUtil* util;
InputData* input;
SharedListVector* SharedList;
- SharedOrderVector* order;
- OrderVector* ordersingle;
Venn* venn;
string format;
vector<Calculator*> vennCalculators;
ValidCalculators* validCalculator;
+ vector<SharedRAbundVector*> lookup;
+ SAbundVector* sabund;
int abund;
};