--- /dev/null
+/*
+ * boneh.cpp
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "boneh.h"
+#include <math.h>
+
+/***********************************************************************/
+double Boneh::getV(double f1, double n, double rs) {
+
+ //cout << "f1 = " << f1 << "\nn = " << n << "\nrs = " << rs << "\n\n";
+
+ double accuracy = .0001;
+ double v = 100000.0;
+ double step = v/2;
+ double ls = v * (1 - pow((1 - f1/(n*v)), n));
+
+ //cout << "ls = " << ls << "\n";
+
+ while(abs(ls - rs) > accuracy) {
+ if(ls > rs)
+ v -= step;
+ else
+ v += step;
+
+ ls = v* (1 - pow((1 - f1/(n*v)), n));
+ step /= 2;
+
+ // cout << "ls = " << ls << "\n";
+ }
+
+ return v;
+}
+
+/***********************************************************************/
+EstOutput Boneh::getValues(SAbundVector* rank){
+
+ try {
+ data.resize(1,0);
+
+ bool valid = false;
+ double sum = 0;
+ double n = (double)rank->size() - 1;
+ double f1 = (double)rank->get(1);
+
+ for(int i = 1; i < rank->size(); i++)
+ sum += (double)rank->get(i) * exp(-i);
+
+ if(rank->get(1) > sum)
+ valid = true;
+
+ sum = 0;
+ if(valid) {
+ for(int j = 1; j < rank->size(); j++)
+ sum += rank->get(j) * pow((1 - (double)j / n), n);
+
+ double v = getV(f1, n, sum);
+
+ // cout << "v = " << v << "\n";
+
+ sum = 0;
+ for(int j = 1; j < rank->size(); j++)
+ sum += pow(1 - (double)rank->get(j) / n, n) * (1 - pow(1 - (double)rank->get(j) / n, m)) + v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m));
+
+ }
+
+ data[0] = sum;
+
+ return data;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+};
+
+
+/***********************************************************************/
--- /dev/null
+#ifndef BONEH_H
+#define BONEH_H
+
+/*
+ * boneh.h
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/* This class implements the boneh calculator on single group.
+ It is a child of the calculator class. */
+
+/***********************************************************************/
+
+class Boneh : public Calculator {
+
+public:
+ Boneh(int size) : m(size), Calculator("boneh", 1, false) {};
+ EstOutput getValues(SAbundVector*);
+ EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
+private:
+ double getV(double, double, double);
+ int m;
+};
+
+
+/***********************************************************************/
+
+#endif
#include "bergerparker.h"
#include "bstick.h"
#include "goodscoverage.h"
-
+#include "efron.h"
+#include "boneh.h"
+#include "solow.h"
#include "coverage.h"
cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick")));
}else if (globaldata->Estimators[i] == "goodscoverage") {
cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage")));
+ }else if (globaldata->Estimators[i] == "efron") {
+ convert(globaldata->getSize(), size);
+ cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron")));
+ }else if (globaldata->Estimators[i] == "boneh") {
+ convert(globaldata->getSize(), size);
+ cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh")));
+ }else if (globaldata->Estimators[i] == "solow") {
+ convert(globaldata->getSize(), size);
+ cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
}
}
}
Collect* cCurve;
ValidCalculators* validCalculator;
vector<Display*> cDisplays;
- int freq, abund;
+ int freq, abund, size;
};
#include "sharedmorisitahorn.h"
#include "sharedbraycurtis.h"
#include "sharedjackknife.h"
-#include "sharedwhittaker.h"
+#include "whittaker.h"
--- /dev/null
+/*
+ * efron.cpp
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "efron.h"
+#include <math.h>
+
+/***********************************************************************/
+EstOutput Efron::getValues(SAbundVector* rank){
+
+ try {
+ data.resize(1,0);
+
+ if(m > rank->size()-1) {
+ cout << "Error in the 'efron' calculator. 'size' must be less than the length of the smalled sabund vector.\n";
+ data[0] = 0;
+ return data;
+ }
+
+ double sum = 0;
+ for(int i = 1; i < rank->size(); i++)
+ sum += pow(-1, (double)(i+1)) * pow(((double)m / (double)(rank->size()-1)), i) * (double)(rank->get(i));
+
+ data[0] = sum;
+
+ return data;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+};
+
+
+/***********************************************************************/
--- /dev/null
+#ifndef EFRON_H
+#define EFRON_H
+
+/*
+ * efron.h
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/* This class implements the efron calculator on single group.
+ It is a child of the calculator class. */
+
+/***********************************************************************/
+
+class Efron : public Calculator {
+
+public:
+ Efron(int size) : m(size), Calculator("efron", 1, false) {};
+ EstOutput getValues(SAbundVector*);
+ EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
+private:
+ int m;
+};
+
+
+/***********************************************************************/
+
+#endif
if (parameter == "scale" ) { scale = value; }
if (parameter == "ends" ) { ends = value; }
if (parameter == "processors" ) { processors = value; }
+ if (parameter == "size" ) { size = value; }
+
if (parameter == "template") { templatefile = value; }
if (parameter == "search") { search = value; }
if (parameter == "ksize") { ksize = value; }
if (parameter == "scale" ) { scale = value; }
if (parameter == "ends" ) { ends = value; }
if (parameter == "processors" ) { processors = value; }
+ if (parameter == "size" ) { size = value; }
if (parameter == "template") { templatefile = value; }
if (parameter == "search") { search = value; }
if (parameter == "ksize") { ksize = value; }
void clear();
void refresh();
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, cutoff, format;
- string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, trump, soft, filter, scale, ends, processors;
+ string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, trump, soft, filter, scale, ends, processors, size;
string templatefile, search, ksize, align, match, mismatch, gapopen, gapextend;
string commandName, optionText;
bool errorFree;
trump = globaldata->getTrump();
for(int i = 0; i < db->size(); i++) {
Sequence cur = db->get(i);
- string curAligned = cur.getUnaligned();
+ string curAligned = cur.getAligned();
for(int j = 0; j < curAligned.length(); j++) {
string curChar = curAligned.substr(j, 1);
if(curChar.compare(trump) == 0)
for(int i = 0; i < db->size(); i++) {
Sequence cur = db->get(i);
- string curAligned = cur.getUnaligned();
+ string curAligned = cur.getAligned();
for(int j = 0; j < curAligned.length(); j++) {
string curChar = curAligned.substr(j, 1);
db = readSeqs->getDB();
//for(int i = 0; i < db->size(); i++) {
-// cout << db->get(i).getLength() << "\n" << db->get(i).getName() << ": " << db->get(i).getUnaligned() << "\n\n";
+// cout << db->get(i).getLength() << "\n" << db->get(i).getName() << ": " << db->get(i).getAligned() << "\n\n";
// }
for(int i = 0; i < db->get(0).getLength(); i++)
SequenceDB newDB;
for(int i = 0; i < db->size(); i++) {
Sequence curSeq = db->get(i);
- string curAligned = curSeq.getUnaligned();
+ string curAligned = curSeq.getAligned();
string curName = curSeq.getName();
string newAligned = "";
for(int j = 0; j < curAligned.length(); j++)
if (key == "scale") { scale = value; }
if (key == "ends" ) { ends = value; }
if (key == "processors" ) { processors = value; }
+ if (key == "size" ) { size = value; }
+
+
+
+
if (key == "template") { templatefile = value; }
if (key == "search") { search = value; }
if (key == "ksize") { ksize = value; }
if (key == "scale") { scale = value; }
if (key == "ends" ) { ends = value; }
if (key == "processors" ) { processors = value; }
+ if (key == "size" ) { size = value; }
+
if (key == "template") { templatefile = value; }
if (key == "search") { search = value; }
if (key == "ksize") { ksize = value; }
//input defaults for calculators
if (commandName == "collect.single") {
- if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow"; }
Estimators.clear();
splitAtDash(calc, Estimators);
}
splitAtDash(calc, Estimators);
}
if (commandName == "summary.single") {
- if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow"; }
Estimators.clear();
splitAtDash(calc, Estimators);
}
string GlobalData::getScale() { return scale; }
string GlobalData::getEnds() { return ends; }
string GlobalData::getProcessors() { return processors; }
+string GlobalData::getSize() { return size; }
+
+void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;}
+void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;}
+void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;}
+void GlobalData::setPhylipFile(string file) { phylipfile = file; inputFileName = file;}
+void GlobalData::setColumnFile(string file) { columnfile = file; inputFileName = file;}
string GlobalData::getTemplateFile() { return templatefile;}
string GlobalData::getSearch() { return search; }
string GlobalData::getKSize() { return ksize; }
string GlobalData::getGapopen() { return gapopen; }
string GlobalData::getGapextend() { return gapextend; }
-void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;}
void GlobalData::setGroupFile(string file) { groupfile = file; }
-void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;}
-void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;}
-void GlobalData::setPhylipFile(string file) { phylipfile = file; inputFileName = file;}
-void GlobalData::setColumnFile(string file) { columnfile = file; inputFileName = file;}
void GlobalData::setSharedFile(string file) { sharedfile = file; inputFileName = file; fileroot = file;}
void GlobalData::setNameFile(string file) { namefile = file; }
void GlobalData::setFormat(string Format) { format = Format; }
scale = "log10";
ends = "T"; //yes
processors = "1";
+ size = "1000";
search = "suffix";
ksize = "7";
align = "blast";
mismatch = "-1.0";
gapopen = "-5.0";
gapextend = "-2.0";
-
-
}
//*******************************************************/
form = "integral";
ends = "T";
processors = "1";
+ size = "1000";
search = "suffix";
ksize = "7";
align = "blast";
string getSorted();
string getEnds();
string getProcessors();
+ string getSize();
string getTemplateFile();
string getSearch();
string getKSize();
private:
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, line, label, randomtree, groups;
- string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale, ends, processors, templatefile, search, ksize, align, match;
+ string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale, ends, processors, templatefile, search, ksize, align, match, size;
string mismatch, gapopen, gapextend;
--- /dev/null
+/*
+ * solow.cpp
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "solow.h"
+#include <math.h>
+
+
+/***********************************************************************/
+EstOutput Solow::getValues(SAbundVector* rank){
+
+ try {
+ data.resize(1,0);
+
+ double n = (double)rank->size() - 1;
+ double f1 = (double)rank->get(1);
+ double f2 = (double)rank->get(2);
+
+ data[0] = f1*f1/2/f2 * (1 - pow(1 - 2*f2/n/f1, m));
+
+ return data;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+};
+
+
+/***********************************************************************/
--- /dev/null
+#ifndef SOLOW_H
+#define SOLOW_H
+
+/*
+ * solow.h
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/13/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/* This class implements the solow calculator on single group.
+ It is a child of the calculator class. */
+
+/***********************************************************************/
+
+class Solow : public Calculator {
+
+public:
+ Solow(int size) : m(size), Calculator("solow", 1, false) {};
+ EstOutput getValues(SAbundVector*);
+ EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
+private:
+ int m;
+};
+
+
+/***********************************************************************/
+
+#endif
#include "bstick.h"
#include "goodscoverage.h"
#include "coverage.h"
+#include "efron.h"
+#include "boneh.h"
+#include "solow.h"
//**********************************************************************************************************************
sumCalculators.push_back(new NSeqs());
}else if (globaldata->Estimators[i] == "goodscoverage") {
sumCalculators.push_back(new GoodsCoverage());
+ }else if (globaldata->Estimators[i] == "efron") {
+ convert(globaldata->getSize(), size);
+ sumCalculators.push_back(new Efron(size));
+ }else if (globaldata->Estimators[i] == "boneh") {
+ convert(globaldata->getSize(), size);
+ sumCalculators.push_back(new Boneh(size));
+ }else if (globaldata->Estimators[i] == "solow") {
+ convert(globaldata->getSize(), size);
+ sumCalculators.push_back(new Solow(size));
}
}
}
SAbundVector* sabund;
string outputFileName;
ofstream outputFileHandle;
- int abund;
+ int abund, size;
};
#endif
#include "sharedmorisitahorn.h"
#include "sharedbraycurtis.h"
#include "sharedjackknife.h"
-#include "sharedwhittaker.h"
+#include "whittaker.h"
//**********************************************************************************************************************
single["goodscoverage"] = "goodscoverage";
single["nseqs"] = "nseqs";
single["coverage"] = "coverage";
+ single["efron"] = "efron";
+ single["boneh"] = "boneh";
+ single["solow"] = "solow";
single["default"] = "default";
}
catch(exception& e) {
summary["nseqs"] = "nseqs";
summary["goodscoverage"]= "goodscoverage";
summary["coverage"] = "coverage";
+ summary["efron"] = "efron";
+ summary["boneh"] = "boneh";
+ summary["solow"] = "solow";
summary["default"] = "default";
}
catch(exception& e) {
string deconvoluteArray[] = {"fasta"};
commandParameters["deconvolute"] = addParameters(deconvoluteArray, sizeof(deconvoluteArray)/sizeof(string));
- string collectsingleArray[] = {"freq","line","label","calc","abund"};
+ string collectsingleArray[] = {"freq","line","label","calc","abund","size"};
commandParameters["collect.single"] = addParameters(collectsingleArray, sizeof(collectsingleArray)/sizeof(string));
string collectsharedArray[] = {"freq","line","label","calc","groups"};
string libshuffArray[] = {"iters","groups","step","form","cutoff"};
commandParameters["libshuff"] = addParameters(libshuffArray, sizeof(libshuffArray)/sizeof(string));
- string summarysingleArray[] = {"line","label","calc","abund"};
+ string summarysingleArray[] = {"line","label","calc","abund","size"};
commandParameters["summary.single"] = addParameters(summarysingleArray, sizeof(summarysingleArray)/sizeof(string));
string summarysharedArray[] = {"line","label","calc","groups"};
string softArray[] = {">=","0", "<=","100", "between"};
parameterRanges["soft"] = addParameters(softArray, rangeSize);
+
+ string sizeArray[] = {">=","1", "<","NA", "between"};
+ parameterRanges["size"] = addParameters(sizeArray, rangeSize);
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";