Calculator(string n, int c, bool f, bool a) : name(n), cols(c), multiple(f), needsAll(a) { m = MothurOut::getInstance(); };
virtual EstOutput getValues(SAbundVector*) = 0;
virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
+ //optional calc that returns the otus labels of shared otus
+ virtual EstOutput getValues(vector<SharedRAbundVector*> sv , vector<string>&) { data = getValues(sv); return data; }
virtual void print(ostream& f) { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
f << data[0]; for(int i=1;i<data.size();i++){ f << '\t' << data[i]; }}
virtual string getName() { return name; }
//**********************************************************************************************************************
vector<string> MakeContigsCommand::setParameters(){
try {
- CommandParameter pfasta("ffastq", "InputTypes", "", "", "none", "none", "none","fasta-qfile",false,true,true); parameters.push_back(pfasta);
- CommandParameter prfasta("rfastq", "InputTypes", "", "", "none", "none", "none","fasta-qfile",false,true,true); parameters.push_back(prfasta);
+ CommandParameter pfastq("ffastq", "InputTypes", "", "", "FastaFastqFile", "FastaFastqFile", "fastqGroup","fasta-qfile",false,false,true); parameters.push_back(pfastq);
+ CommandParameter prfastq("rfastq", "InputTypes", "", "", "none", "none", "fastqGroup","fasta-qfile",false,false,true); parameters.push_back(prfastq);
+ CommandParameter pfasta("ffasta", "InputTypes", "", "", "FastaFastqFile", "FastaFastqFile", "fastaGroup","fasta",false,false,true); parameters.push_back(pfasta);
+ CommandParameter prfasta("rfasta", "InputTypes", "", "", "none", "none", "none","fastaGroup",false,false,true); parameters.push_back(prfasta);
+ CommandParameter pfqual("fqfile", "InputTypes", "", "", "none", "none", "qfileGroup","qfile",false,false,true); parameters.push_back(pfqual);
+ CommandParameter prqual("rqfile", "InputTypes", "", "", "none", "none", "qfileGroup","qfile",false,false,true); parameters.push_back(prqual);
+ CommandParameter pfile("file", "InputTypes", "", "", "FastaFastqFile", "FastaFastqFile", "none","fasta-qfile",false,false,true); parameters.push_back(pfile);
CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","group",false,false,true); parameters.push_back(poligos);
CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
string MakeContigsCommand::getHelpString(){
try {
string helpString = "";
- helpString += "The make.contigs command reads a forward fastq file and a reverse fastq file and outputs new fasta and quality files.\n";
+ helpString += "The make.contigs command reads a file, forward fastq file and a reverse fastq file or forward fasta and reverse fasta files and outputs new fasta. It will also provide new quality files if the fastq or file parameter is used.\n";
helpString += "If an oligos file is provided barcodes and primers will be trimmed, and a group file will be created.\n";
helpString += "The make.contigs command parameters are ffastq, rfastq, oligos, tdiffs, bdiffs, ldiffs, sdiffs, pdiffs, align, match, mismatch, gapopen, gapextend, allfiles and processors.\n";
- helpString += "The ffastq and rfastq parameters are required.\n";
+ helpString += "The ffastq and rfastq, file, or ffasta and rfasta parameters are required.\n";
+ helpString += "The file parameter is 2 column file containing the forward fastq files in the first column and their matching reverse fastq files in the second column. Mothur will process each pair and create a combined fasta and qual file with all the sequences.\n";
+ helpString += "The ffastq and rfastq parameters are used to provide a forward fastq and reverse fastq file to process. If you provide one, you must provide the other.\n";
+ helpString += "The ffasta and rfasta parameters are used to provide a forward fasta and reverse fasta file to process. If you provide one, you must provide the other.\n";
+ helpString += "The fqfile and rqfile parameters are used to provide a forward quality and reverse quality files to process with the ffasta and rfasta parameters. If you provide one, you must provide the other.\n";
helpString += "The align parameter allows you to specify the alignment method to use. Your options are: gotoh and needleman. The default is needleman.\n";
helpString += "The tdiffs parameter is used to specify the total number of differences allowed in the sequence. The default is pdiffs + bdiffs + sdiffs + ldiffs.\n";
helpString += "The bdiffs parameter is used to specify the number of differences allowed in the barcode. The default is 0.\n";
if (path == "") { parameters["rfastq"] = inputDir + it->second; }
}
+ it = parameters.find("ffasta");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["ffasta"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("rfasta");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["rfasta"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("fqfile");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["fqfile"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("rqfile");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["rqfile"] = inputDir + it->second; }
+ }
+
+ it = parameters.find("file");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = m->hasPath(it->second);
+ //if the user has not given a path then, add inputdir. else leave path alone.
+ if (path == "") { parameters["file"] = inputDir + it->second; }
+ }
+
it = parameters.find("oligos");
//user has given a template file
if(it != parameters.end()){
}
ffastqfile = validParameter.validFile(parameters, "ffastq", true);
- if (ffastqfile == "not open") { ffastqfile = ""; abort = true; }
- else if (ffastqfile == "not found") { ffastqfile = ""; abort=true; m->mothurOut("The ffastq parameter is required.\n"); }
+ if (ffastqfile == "not open") { abort = true; }
+ else if (ffastqfile == "not found") { ffastqfile = ""; }
rfastqfile = validParameter.validFile(parameters, "rfastq", true);
- if (rfastqfile == "not open") { rfastqfile = ""; abort = true; }
- else if (rfastqfile == "not found") { rfastqfile = ""; abort=true; m->mothurOut("The rfastq parameter is required.\n"); }
+ if (rfastqfile == "not open") { abort = true; }
+ else if (rfastqfile == "not found") { rfastqfile = ""; }
+
+ ffastafile = validParameter.validFile(parameters, "ffasta", true);
+ if (ffastafile == "not open") { abort = true; }
+ else if (ffastafile == "not found") { ffastafile = ""; }
+
+ rfastafile = validParameter.validFile(parameters, "rfasta", true);
+ if (rfastafile == "not open") { abort = true; }
+ else if (rfastafile == "not found") { rfastafile = ""; }
+
+ fqualfile = validParameter.validFile(parameters, "fqfile", true);
+ if (fqualfile == "not open") { abort = true; }
+ else if (fqualfile == "not found") { fqualfile = ""; }
+
+ rqualfile = validParameter.validFile(parameters, "rqfile", true);
+ if (rqualfile == "not open") { abort = true; }
+ else if (rqualfile == "not found") { rqualfile = ""; }
+
+ file = validParameter.validFile(parameters, "file", true);
+ if (file == "not open") { abort = true; }
+ else if (file == "not found") { file = ""; }
+
+ if ((file == "") && (ffastafile == "") && (ffastqfile == "")) { abort = true; m->mothurOut("[ERROR]: ffastq and rfastq parameters are required.\n"); }
+ if ((ffastqfile != "") && (rfastqfile == "")) { abort = true; }
+ if ((ffastqfile == "") && (rfastqfile != "")) { abort = true; }
oligosfile = validParameter.validFile(parameters, "oligos", true);
if (oligosfile == "not found") { oligosfile = ""; }
//read ffastq and rfastq files creating fasta and qual files.
//this function will create a forward and reverse, fasta and qual files for each processor.
//files has an entry for each processor. files[i][0] = forwardFasta, files[i][1] = forwardQual, files[i][2] = reverseFasta, files[i][3] = reverseQual
- int numReads = 0;
+ unsigned long int numReads = 0;
int start = time(NULL);
longestBase = 1000;
m->mothurOut("Reading fastq data...\n");
vector< vector<string> > files = readFastqFiles(numReads);
m->mothurOut("Done.\n");
-
+
if (m->control_pressed) { return 0; }
vector<vector<string> > fastaFileNames;
}
}
//**********************************************************************************************************************
-vector< vector<string> > MakeContigsCommand::readFastqFiles(int& count){
+vector< vector<string> > MakeContigsCommand::readFastqFiles(unsigned long int& count){
try {
vector< vector<string> > files;
else { ignorer = true; }
vector<pairFastqRead> reads = getReads(ignoref, ignorer, thisFread, thisRread, uniques);
-
+
for (int i = 0; i < reads.size(); i++) {
fastqRead fread = reads[i].forward;
fastqRead rread = reads[i].reverse;
+ if (m->debug) { m->mothurOut(toString(count) + '\t' + fread.name + '\t' + rread.name + '\n'); }
+
if (checkReads(fread, rread)) {
if (m->control_pressed) { for (it = tempfiles.begin(); it!=tempfiles.end(); it++) { for (int i = 0; i < (it->second).size(); i++) { (*(it->second)[i]).close(); delete (it->second)[i]; } } for (int i = 0; i < files.size(); i++) { for(int j = 0; j < files[i].size(); j++) { m->mothurRemove(files[i][j]); } } inForward.close(); inReverse.close(); return files; }
pairFastqRead temp(forward, reverse);
reads.push_back(temp);
}else {
- //look for forward pair
- itUniques = uniques.find(forward.name);
- if (itUniques != uniques.end()) { //we have the pair for this read
- pairFastqRead temp(forward, itUniques->second);
- reads.push_back(temp);
- uniques.erase(itUniques);
- }else { //save this read for later
- uniques[forward.name] = forward;
+ bool match = false;
+ //if no match are the names only different by 1 and 2?
+ string tempFRead = forward.name.substr(0, forward.name.length()-1);
+ string tempRRead = reverse.name.substr(0, reverse.name.length()-1);
+ if (tempFRead == tempRRead) {
+ if ((forward.name[forward.name.length()-1] == '1') && (reverse.name[reverse.name.length()-1] == '2')) {
+ forward.name = tempFRead;
+ reverse.name = tempRRead;
+ pairFastqRead temp(forward, reverse);
+ reads.push_back(temp);
+ match = true;
+ }
}
- //look for reverse pair
- itUniques = uniques.find(reverse.name);
- if (itUniques != uniques.end()) { //we have the pair for this read
- pairFastqRead temp(itUniques->second, reverse);
- reads.push_back(temp);
- uniques.erase(itUniques);
- }else { //save this read for later
- uniques[reverse.name] = reverse;
+ if (!match) {
+ //look for forward pair
+ itUniques = uniques.find(forward.name);
+ if (itUniques != uniques.end()) { //we have the pair for this read
+ pairFastqRead temp(forward, itUniques->second);
+ reads.push_back(temp);
+ uniques.erase(itUniques);
+ }else { //save this read for later
+ uniques[forward.name] = forward;
+ }
+
+ //look for reverse pair
+ itUniques = uniques.find(reverse.name);
+ if (itUniques != uniques.end()) { //we have the pair for this read
+ pairFastqRead temp(itUniques->second, reverse);
+ reads.push_back(temp);
+ uniques.erase(itUniques);
+ }else { //save this read for later
+ uniques[reverse.name] = reverse;
+ }
}
+
}
}else if (!ignoref && ignorer) { //ignore reverse keep forward
//look for forward pair
private:
bool abort, allFiles, createGroup;
- string outputDir, ffastqfile, rfastqfile, align, oligosfile;
+ string outputDir, ffastqfile, rfastqfile, align, oligosfile, rfastafile, ffastafile, rqualfile, fqualfile, file;
float match, misMatch, gapOpen, gapExtend;
int processors, longestBase, threshold, tdiffs, bdiffs, pdiffs, ldiffs, sdiffs;
vector<string> outputNames;
//vector<string> groupVector;
fastqRead readFastq(ifstream&, bool&);
- vector< vector<string> > readFastqFiles(int&);
+ vector< vector<string> > readFastqFiles(unsigned long int&);
bool checkReads(fastqRead&, fastqRead&);
int createProcesses(vector< vector<string> >, string, string, string, string, string, vector<vector<string> >, vector<vector<string> >);
int driver(vector<string>, string, string, string, string, string, vector<vector<string> >, vector<vector<string> >);
exit(1);
}
}
+/***********************************************************************/
+//This returns the number of shared species observed in several groups.
+//The shared vector is each groups sharedrabundvector.
+
+EstOutput SharedSobsCS::getValues(vector<SharedRAbundVector*> shared, vector<string>& labels){
+ try {
+ data.resize(1,0);
+ double observed = 0;
+ int numGroups = shared.size();
+ labels.clear();
+
+ for (int i = 0; i < shared[0]->getNumBins(); i++) {
+ //get bin values and set sharedByAll
+ bool sharedByAll = true;
+ for (int j = 0; j < numGroups; j++) {
+ if (shared[j]->getAbundance(i) == 0) { sharedByAll = false; }
+ }
+
+ //they are shared
+ if (sharedByAll == true) { observed++; labels.push_back(m->currentBinLabels[i]); }
+ }
+
+ data[0] = observed;
+ return data;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedSobsCS", "getValues");
+ exit(1);
+ }
+}
/***********************************************************************/
SharedSobsCS() : Calculator("sharedsobs", 1, true) {};
EstOutput getValues(SAbundVector* rank){ return data; };
EstOutput getValues(vector<SharedRAbundVector*>);
+ EstOutput getValues(vector<SharedRAbundVector*>, vector<string>&);
string getCitation() { return "http://www.mothur.org/wiki/Sharedsobs"; }
};
//**********************************************************************************************************************
-Venn::Venn(string o, bool n, string f, int fs) : outputDir(o), nseqs(n), inputfile(f), fontSize(fs) {
+Venn::Venn(string o, bool n, string f, int fs, bool so) : outputDir(o), nseqs(n), inputfile(f), fontSize(fs), sharedOtus(so) {
try {
m = MothurOut::getInstance();
}
if (m->control_pressed) { outsvg.close(); return outputNames; }
//get estimates for sharedAB
- vector<double> shared = vCalcs[i]->getValues(subset);
+ vector<string> labels;
+ vector<double> shared = vCalcs[i]->getValues(subset, labels);
//in essence you want to run it like a single
if (vCalcs[i]->getName() == "sharedsobs") {
singleCalc = new Sobs();
+ if (sharedOtus) {
+ string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+
+ outputNames.push_back(filenameShared);
+ ofstream outShared;
+ m->openOutputFile(filenameShared, outShared);
+ outShared << "Groups\tNumShared\tOTULabels\n";
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ outShared.close();
+ }
}else if (vCalcs[i]->getName() == "sharedchao") {
singleCalc = new Chao1();
- }//else if (vCalcs[i]->getName() == "sharedace") {
- //singleCalc = new Ace(10);
- //}
+ }
int sharedVal, numSeqsA, numSeqsB, uniqSeqsToA, uniqSeqsToB;
if (nseqs) {
}else { //sharedchao and sharedsobs are multigroup
+ ofstream outShared;
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+
+ outputNames.push_back(filenameShared);
+
+ m->openOutputFile(filenameShared, outShared);
+ outShared << "Groups\tNumShared\tOTULabels\n";
+ }
vector<SharedRAbundVector*> subset;
//get estimates for numA
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[1]);
- vector<double> sharedab = vCalcs[i]->getValues(subset);
+ vector<string> labels;
+ vector<double> sharedab = vCalcs[i]->getValues(subset, labels);
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t' << labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[2]);
- vector<double> sharedac = vCalcs[i]->getValues(subset);
+ vector<double> sharedac = vCalcs[i]->getValues(subset, labels);
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
subset.clear();
subset.push_back(lookup[1]); subset.push_back(lookup[2]);
- vector<double> sharedbc = vCalcs[i]->getValues(subset);
+ vector<double> sharedbc = vCalcs[i]->getValues(subset, labels);
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
+
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
- vector<double> sharedabc = vCalcs[i]->getValues(subset);
+ vector<double> sharedabc = vCalcs[i]->getValues(subset, labels);
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ outShared.close();
+ }
//image window
outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(width) + " " + toString(windowSize) + " \" >\n";
data = singleCalc->getValues(sabundD);
numD = data[0];
//cout << "num d = " << numD << endl;
+
+ ofstream outShared;
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ string filenameShared = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + ".sharedotus";
+
+ outputNames.push_back(filenameShared);
+
+ m->openOutputFile(filenameShared, outShared);
+ outShared << "Groups\tNumShared\tOTULabels\n";
+ }
//get estimates for pairs
subset.clear();
+ vector<string> labels;
subset.push_back(lookup[0]); subset.push_back(lookup[1]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedAB = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num ab = " << sharedAB << endl;
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[2]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedAC = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num ac = " << sharedAC << endl;
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedAD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num ad = " << sharedAD << endl;
subset.clear();
subset.push_back(lookup[1]); subset.push_back(lookup[2]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedBC = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num bc = " << sharedBC << endl;
subset.clear();
subset.push_back(lookup[1]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedBD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[1]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num bd = " << sharedBD << endl;
subset.clear();
subset.push_back(lookup[2]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedCD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[2]->getGroup() + "-" + lookup[3]->getGroup() << '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num cd = " << sharedCD << endl;
//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);
+ data = vCalcs[i]->getValues(subset, labels);
sharedABC = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[2]->getGroup()<< '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num abc = " << sharedABC << endl;
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedACD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num acd = " << sharedACD << endl;
subset.clear();
subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset,labels);
sharedBCD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num bcd = " << sharedBCD << endl;
subset.clear();
subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
- data = vCalcs[i]->getValues(subset);
+ data = vCalcs[i]->getValues(subset, labels);
sharedABD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ }
//cout << "num abd = " << sharedABD << endl;
//get estimate for all four
- data = vCalcs[i]->getValues(lookup);
+ data = vCalcs[i]->getValues(lookup, labels);
sharedABCD = data[0];
+ if (sharedOtus && (vCalcs[i]->getName() == "sharedsobs")) {
+ outShared << lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup()+ "-" + lookup[3]->getGroup()<< '\t'<< labels.size() << '\t';
+ for (int k = 0; k < labels.size()-1; k++) {
+ outShared << labels[k] << ",";
+ }
+ if (labels.size() != 0) { outShared << labels[labels.size()-1]; }
+ outShared << endl;
+ outShared.close();
+ }
//cout << "num abcd = " << sharedABCD << endl << endl;
int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
class Venn {
public:
- Venn(string, bool, string, int);
+ Venn(string, bool, string, int, bool);
~Venn(){};
vector<string> getPic(SAbundVector*, vector<Calculator*>);
string groupComb, outputDir, inputfile;
ofstream outsvg;
MothurOut* m;
- bool nseqs;
+ bool nseqs, sharedOtus;
int fontSize;
};
CommandParameter pcalc("calc", "String", "", "", "", "", "","",false,false); parameters.push_back(pcalc);
CommandParameter pabund("abund", "Number", "", "10", "", "", "","",false,false); parameters.push_back(pabund);
CommandParameter pnseqs("nseqs", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pnseqs);
+ CommandParameter psharedotus("sharedotus", "Boolean", "", "t", "", "", "","",false,false); parameters.push_back(psharedotus);
CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "","",false,false); parameters.push_back(pfontsize);
CommandParameter ppermute("permute", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ppermute);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
temp = validParameter.validFile(parameters, "permute", false); if (temp == "not found"){ temp = "f"; }
perm = m->isTrue(temp);
+
+ temp = validParameter.validFile(parameters, "sharedotus", false); if (temp == "not found"){ temp = "t"; }
+ sharedOtus = m->isTrue(temp);
temp = validParameter.validFile(parameters, "fontsize", false); if (temp == "not found") { temp = "24"; }
m->mothurConvert(temp, fontsize);
//if the users entered no valid calculators don't execute command
if (vennCalculators.size() == 0) { m->mothurOut("No valid calculators given, please correct."); m->mothurOutEndLine(); return 0; }
- venn = new Venn(outputDir, nseqs, inputfile, fontsize);
+ venn = new Venn(outputDir, nseqs, inputfile, fontsize, sharedOtus);
input = new InputData(inputfile, format);
string lastLabel;
SAbundVector* sabund;
int abund, fontsize;
- bool abort, allLines, nseqs, perm;
+ bool abort, allLines, nseqs, perm, sharedOtus;
set<string> labels; //holds labels to be used
string format, groups, calc, label, outputDir, sharedfile, listfile, inputfile;
vector<string> Estimators, Groups, outputNames;