#include "npshannon.h"
#include "shannon.h"
#include "jackknife.h"
+#include "coverage.h"
//**********************************************************************************************************************
globaldata = GlobalData::getInstance();
string fileNameRoot;
fileNameRoot = getRootName(globaldata->inputFileName);
+ convert(globaldata->getFreq(), freq);
+ convert(globaldata->getIters(), nIters);
validCalculator = new ValidCalculators();
int i;
rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
}else if (globaldata->Estimators[i] == "bootstrap") {
rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+ }else if (globaldata->Estimators[i] == "coverage") {
+ rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
}else if (globaldata->Estimators[i] == "nseqs") {
rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
}
read->read(&*globaldata);
order = globaldata->gorder;
+ OrderVector* lastOrder = order;
input = globaldata->ginput;
-
- while(order != NULL){
+ //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 = globaldata->labels;
+ set<int> userLines = globaldata->lines;
+
+ //as long as you are not at the end of the file or done wih the lines you want
+ while((order != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
+
if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
rCurve = new Rarefact(order, rDisplays);
- convert(globaldata->getFreq(), freq);
- convert(globaldata->getIters(), nIters);
rCurve->getCurve(freq, nIters);
-
delete rCurve;
cout << order->getLabel() << '\t' << count << endl;
+ processedLabels.insert(order->getLabel());
+ userLabels.erase(order->getLabel());
+ userLines.erase(count);
}
-
+
+ if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastOrder->getLabel()) != 1)) {
+ rCurve = new Rarefact(lastOrder, rDisplays);
+ rCurve->getCurve(freq, nIters);
+ delete rCurve;
+
+ cout << lastOrder->getLabel() << '\t' << count << endl;
+ processedLabels.insert(lastOrder->getLabel());
+ userLabels.erase(lastOrder->getLabel());
+ }
+
+ if (count != 1) { delete lastOrder; }
+ lastOrder = order;
+
order = (input->getOrderVector());
count++;
+ }
+ //output error messages about any remaining user labels
+ set<string>::iterator it;
+ bool needToRun = false;
+ for (it = userLabels.begin(); it != userLabels.end(); it++) {
+ cout << "Your file does not include the label "<< *it;
+ if (processedLabels.count(lastOrder->getLabel()) != 1) {
+ cout << ". I will use " << lastOrder->getLabel() << "." << endl;
+ needToRun = true;
+ }else {
+ cout << ". Please refer to " << lastOrder->getLabel() << "." << endl;
+ }
}
-
+
+ //run last line if you need to
+ if (needToRun == true) {
+ rCurve = new Rarefact(lastOrder, rDisplays);
+ rCurve->getCurve(freq, nIters);
+ delete rCurve;
+
+ cout << lastOrder->getLabel() << '\t' << count << endl;
+ }
+
+ delete lastOrder;
+
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
return 0;
}