37AD4DBB0F28E2FE00AA2D49 /* tree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DBA0F28E2FE00AA2D49 /* tree.cpp */; };
37AD4DCA0F28F3DD00AA2D49 /* readtree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */; };
37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */; };
+ 37AFC7A30F44703E005F492D /* readsharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC7A20F44703E005F492D /* readsharedcommand.cpp */; };
37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B28F670F27590100808A62 /* deconvolutecommand.cpp */; };
37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; };
37D928560F21331F001D4494 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BA0F21331F001D4494 /* averagelinkage.cpp */; };
37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtree.cpp; sourceTree = "<group>"; };
37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsobscollectsummary.h; sourceTree = "<group>"; };
37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsobscollectsummary.cpp; sourceTree = "<group>"; };
+ 37AFC7A10F44703E005F492D /* readsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readsharedcommand.h; sourceTree = "<group>"; };
+ 37AFC7A20F44703E005F492D /* readsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readsharedcommand.cpp; sourceTree = "<group>"; };
37B28F660F27590100808A62 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deconvolutecommand.h; sourceTree = "<group>"; };
37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = "<group>"; };
37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
372E12950F263D5A0095CF7E /* readdistcommand.cpp */,
372E126E0F26365B0095CF7E /* readotucommand.h */,
372E126F0F26365B0095CF7E /* readotucommand.cpp */,
+ 37AFC7A10F44703E005F492D /* readsharedcommand.h */,
+ 37AFC7A20F44703E005F492D /* readsharedcommand.cpp */,
37E5F4900F2A3DA800F8D827 /* readtreecommand.h */,
37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */,
37D928270F21331F001D4494 /* sharedcommand.h */,
374610830F40652400460C57 /* unweighted.cpp in Sources */,
3746109D0F40657600460C57 /* unifracunweightedcommand.cpp in Sources */,
37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */,
+ 37AFC7A30F44703E005F492D /* readsharedcommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+#ifndef AVERAGE_H
+#define AVERAGE_H
#include "cluster.hpp"
#include "rabundvector.hpp"
}
/***********************************************************************/
+
+#endif
+
+
string fileNameRoot;
fileNameRoot = getRootName(globaldata->inputFileName);
int i;
- for (i=0; i<globaldata->singleEstimators.size(); i++) {
- if (globaldata->singleEstimators[i] == "sobs") {
- cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
- }else if (globaldata->singleEstimators[i] == "chao") {
- cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
- }else if (globaldata->singleEstimators[i] == "ace") {
- cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
- }else if (globaldata->singleEstimators[i] == "jack") {
- cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
- }else if (globaldata->singleEstimators[i] == "shannon") {
- cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
- }else if (globaldata->singleEstimators[i] == "npshannon") {
- cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
- }else if (globaldata->singleEstimators[i] == "simpson") {
- cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
- }else if (globaldata->singleEstimators[i] == "bootstrap") {
- cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+ validCalculator = new ValidCalculators();
+
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("single", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "sobs") {
+ cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
+ }else if (globaldata->Estimators[i] == "chao") {
+ cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
+ }else if (globaldata->Estimators[i] == "ace") {
+ cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace")));
+ }else if (globaldata->Estimators[i] == "jack") {
+ cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
+ }else if (globaldata->Estimators[i] == "shannon") {
+ cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
+ }else if (globaldata->Estimators[i] == "npshannon") {
+ cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"np_shannon")));
+ }else if (globaldata->Estimators[i] == "simpson") {
+ cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
+ }else if (globaldata->Estimators[i] == "bootstrap") {
+ cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
+ }
}
}
+
+ //reset calc for next command
+ globaldata->setCalc("");
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the CollectCommand class Function CollectCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int CollectCommand::execute(){
try {
int count = 1;
+
+ //if the users entered no valid calculators don't execute command
+ if (cDisplays.size() == 0) { return 0; }
+
read = new ReadPhilFile(globaldata->inputFileName);
read->read(&*globaldata);
#include "collect.h"
#include "display.h"
#include "readmatrix.hpp"
+#include "validcalculator.h"
/*The collect() command:
The collect command generates a collector's curve from the given file.
OrderVector* order;
InputData* input;
Collect* cCurve;
+ ValidCalculators* validCalculator;
vector<Display*> cDisplays;
int freq;
globaldata = GlobalData::getInstance();
string fileNameRoot;
fileNameRoot = getRootName(globaldata->inputFileName);
- //groupmap = globaldata->gGroupmap;
+ format = globaldata->getFormat();
+ validCalculator = new ValidCalculators();
int i;
- for (i=0; i<globaldata->sharedEstimators.size(); i++) {
- if (globaldata->sharedEstimators[i] == "sharedChao") {
- cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
- }else if (globaldata->sharedEstimators[i] == "sharedSobs") {
- cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
- }else if (globaldata->sharedEstimators[i] == "sharedAce") {
- cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
- }else if (globaldata->sharedEstimators[i] == "sharedJabund") {
- cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"shared.jabund")));
- }else if (globaldata->sharedEstimators[i] == "sharedSorensonAbund") {
- cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"shared.sorabund")));
- }else if (globaldata->sharedEstimators[i] == "sharedJclass") {
- cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"shared.jclass")));
- }else if (globaldata->sharedEstimators[i] == "sharedSorClass") {
- cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"shared.sorclass")));
- }else if (globaldata->sharedEstimators[i] == "sharedJest") {
- cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"shared.jest")));
- }else if (globaldata->sharedEstimators[i] == "sharedSorEst") {
- cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"shared.sorest")));
- }else if (globaldata->sharedEstimators[i] == "SharedThetaYC") {
- cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc")));
- }else if (globaldata->sharedEstimators[i] == "SharedThetaN") {
- cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan")));
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("shared", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "sharedchao") {
+ cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
+ }else if (globaldata->Estimators[i] == "sharedsobs") {
+ cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
+ }else if (globaldata->Estimators[i] == "sharedace") {
+ cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
+ }else if (globaldata->Estimators[i] == "sharedjabund") {
+ cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"shared.jabund")));
+ }else if (globaldata->Estimators[i] == "sharedsorensonabund") {
+ cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"shared.sorabund")));
+ }else if (globaldata->Estimators[i] == "sharedjclass") {
+ cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"shared.jclass")));
+ }else if (globaldata->Estimators[i] == "sharedsorclass") {
+ cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"shared.sorclass")));
+ }else if (globaldata->Estimators[i] == "sharedjest") {
+ cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"shared.jest")));
+ }else if (globaldata->Estimators[i] == "sharedsorest") {
+ cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"shared.sorest")));
+ }else if (globaldata->Estimators[i] == "sharedthetayc") {
+ cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc")));
+ }else if (globaldata->Estimators[i] == "sharedthetan") {
+ cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan")));
+ }
}
}
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function CollectSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int CollectSharedCommand::execute(){
try {
int count = 1;
- read = new ReadPhilFile(globaldata->inputFileName);
- read->read(&*globaldata);
- input = globaldata->ginput;
- SharedList = globaldata->gSharedList;
- order = SharedList->getSharedOrderVector();
+ //if the users entered no valid calculators don't execute command
+ if (cDisplays.size() == 0) { return 0; }
+
+ if (format == "sharedfile") {
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }
while(order != NULL){
cout << order->getLabel() << '\t' << count << endl;
}
- SharedList = input->getSharedListVector(); //get new list vector to process
- if (SharedList != NULL) {
- order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
- count++;
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
}else {
- break;
+ //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;
+ }
}
-
+
+ count++;
}
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
#include "collect.h"
#include "display.h"
#include "readmatrix.hpp"
+#include "validcalculator.h"
/* The collect.shared() command:
The collect command generates a collector's curve from the given file representing several groups.
ReadMatrix* read;
SharedOrderVector* order;
InputData* input;
+ ValidCalculators* validCalculator;
Collect* cCurve;
vector<Display*> cDisplays;
int freq;
+ string format;
};
#include "command.hpp"
#include "readdistcommand.h"
#include "readtreecommand.h"
+#include "readsharedcommand.h"
#include "readotucommand.h"
#include "clustercommand.h"
#include "parselistcommand.h"
if(commandName == "read.dist") { command = new ReadDistCommand(); }
else if(commandName == "read.otu") { command = new ReadOtuCommand(); }
else if(commandName == "read.tree") { command = new ReadTreeCommand(); }
+ else if(commandName == "read.shared") { command = new ReadSharedCommand(); }
else if(commandName == "cluster") { command = new ClusterCommand(); }
else if(commandName == "deconvolute") { command = new DeconvoluteCommand(); }
else if(commandName == "parsimony") { command = new ParsimonyCommand(); }
globaldata = GlobalData::getInstance();
validCommand = new ValidCommands();
validParameter = new ValidParameters();
- validCalculator = new ValidCalculators();
}
/*******************************************************/
format = globaldata->getFormat();
method = globaldata->getMethod();
randomtree = globaldata->getRandomTree();
+ sharedfile = globaldata->getSharedFile();
}
/*******************************************************/
//reads in parameters and values
if((optionText != "") && (commandName != "help")){
while((optionText.find_first_of(',') != -1) && (errorFree)) { //while there are parameters
- globaldata->splitAtComma(value, optionText);
- globaldata->splitAtEquals(parameter, value);
+ splitAtComma(value, optionText);
+ splitAtEquals(parameter, value);
//is it a valid parameter
if (validParameter->isValidParameter(parameter) != true) { return false; }
if (parameter == "fasta" ) { fastafile = value; }
if (parameter == "tree" ) { treefile = value; }
if (parameter == "group" ) { groupfile = value; }
+ if (parameter == "shared" ) { sharedfile = value; }
if (parameter == "cutoff" ) { cutoff = value; }
if (parameter == "precision" ) { precision = value; }
if (parameter == "iters" ) { iters = value; }
if (parameter == "label" ) { label = value; }
if (parameter == "randomtree" ) { randomtree = value; }
- if (parameter == "single") {//stores estimators in a vector
- singleEsimators.clear(); //clears out old values
- globaldata->splitAtDash(value, singleEsimators);
- for (int i = 0; i < singleEsimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, singleEsimators[i]) != true) { return false; }
- }
- }
- if (parameter == "rarefaction") {//stores estimators in a vector
- rareEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, rareEstimators);
- for (int i = 0; i < rareEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, rareEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "shared") {//stores estimators in a vector
- sharedEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, sharedEstimators);
- for (int i = 0; i < sharedEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, sharedEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "summary") { //stores summaries to be used in a vector
- summaryEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, summaryEstimators);
- for (int i = 0; i < summaryEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, summaryEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "sharedrarefaction") { //stores summaries to be used in a vector
- sharedRareEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, sharedRareEstimators);
- for (int i = 0; i < sharedRareEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, sharedRareEstimators[i]) != true) { return false; }
- }
- }
}
//gets the last parameter and value
if (errorFree) { //gets the last parameter and value
value = optionText;
- globaldata->splitAtEquals(parameter, value);
+ splitAtEquals(parameter, value);
//is it a valid parameter
if (validParameter->isValidParameter(parameter) != true) { return false; }
if (parameter == "name" ) { namefile = value; }
if (parameter == "order" ) { orderfile = value; }
if (parameter == "group" ) { groupfile = value; }
+ if (parameter == "shared" ) { sharedfile = value; }
if (parameter == "fasta" ) { fastafile = value; }
if (parameter == "tree" ) { treefile = value; }
if (parameter == "cutoff" ) { cutoff = value; }
if (parameter == "label" ) { label = value; }
if (parameter == "randomtree" ) { randomtree = value; }
- if (parameter == "single") {//stores estimators in a vector
- singleEsimators.clear(); //clears out old values
- globaldata->splitAtDash(value, singleEsimators);
- for (int i = 0; i < singleEsimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, singleEsimators[i]) != true) { return false; }
- }
- }
- if (parameter == "rarefaction") {//stores estimators in a vector
- rareEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, rareEstimators);
- for (int i = 0; i < rareEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, rareEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "shared") {//stores estimators in a vector
- sharedEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, sharedEstimators);
- for (int i = 0; i < sharedEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, sharedEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "summary") { //stores summaries to be used in a vector
- summaryEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, summaryEstimators);
- for (int i = 0; i < summaryEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, summaryEstimators[i]) != true) { return false; }
- }
- }
- if (parameter == "sharedrarefaction") { //stores summaries to be used in a vector
- sharedRareEstimators.clear(); //clears out old values
- globaldata->splitAtDash(value, sharedRareEstimators);
- for (int i = 0; i < sharedRareEstimators.size(); i++) { //loop through estimators
- //is it a valid calculator
- if (validCalculator->isValidCalculator(parameter, sharedRareEstimators[i]) != true) { return false; }
- }
- }
-
}
}
validateReadFiles();
validateReadPhil();
}
+ }else if (commandName == "read.shared") {
+ //you want to do shared commands with just the shared file
+ validateReadFiles();
}else if (commandName == "read.tree") {
validateTreeFiles(); //checks the treefile and groupfile parameters
}else if (commandName == "deconvolute") {
}
if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") ){
- if (globaldata->getListFile() == "") { cout << "You must read a list and a group before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
- else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+ if (globaldata->getSharedFile() == "") {
+ if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+ else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; }
+ }
}
-
return errorFree;
}
//unable to open
if (ableToOpen == 1) { errorFree = false; }
else { globaldata->inputFileName = fastafile; }
+ }else if (sharedfile != "") {
+ ableToOpen = openInputFile(sharedfile, filehandle);
+ filehandle.close();
+ //unable to open
+ if (ableToOpen == 1) { errorFree = false; }
+ else { globaldata->inputFileName = sharedfile; }
}else{ //no file given
errorFree = false;
}
namefile = "";
groupfile = "";
orderfile = "";
+ sharedfile = "";
line = "";
label = "";
method = "furthest";
#include "globaldata.hpp"
#include "validcommands.h"
#include "validparameter.h"
-#include "validcalculator.h"
+#include "utilities.hpp"
class ErrorCheck {
public:
GlobalData* globaldata;
ValidCommands* validCommand;
ValidParameters* validParameter;
- ValidCalculators* validCalculator;
- void splitAtDash(string&, vector<string>&);
- void splitAtDash(string&, set<int>&);
- void splitAtDash(string&, set<string>&);
void validateReadFiles();
void validateReadDist();
void validateReadPhil();
void validateTreeFiles();
void clear();
void refresh();
- string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, cutoff, format;
+ string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, cutoff, format;
string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree;
string commandName, optionText;
bool errorFree;
- vector<string> singleEsimators, sharedEstimators, rareEstimators, summaryEstimators, sharedRareEstimators;
};
#endif
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <map>
-#include <sstream>
-#include <stdexcept>
-
-using namespace std;
-
#include "globaldata.hpp"
#include "sparsematrix.hpp"
#include "tree.h"
#include "rabundvector.hpp"
#include "sabundvector.hpp"
#include "listvector.hpp"
-#include <exception>
-#include <iostream>
/*******************************************************/
exit(1);
}
}
-
/*******************************************************/
/******************************************************/
cout << "An unknown error has occurred in the GlobalData class function setSparseMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
-
}
/*******************************************************/
allLines = 1;
commandName = commandString; //save command name to be used by other classes
+ //set all non filename paramters to default values
+ reset();
+
//clears out data from previous read
- if ((commandName == "read.dist") || (commandName == "read.otu") || (commandName == "read.tree")) {
+ if ((commandName == "read.dist") || (commandName == "read.otu") || (commandName == "read.tree") || (commandName == "read.shared")) {
clear();
+ gGroupmap = NULL;
}
//saves help request
if (key == "sabund" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
if (key == "fasta" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
if (key == "tree" ) { treefile = value; inputFileName = value; fileroot = value; format = "tree"; }
+ if (key == "shared" ) { sharedfile = value; inputFileName = value; fileroot = value; format = "sharedfile"; }
if (key == "name" ) { namefile = value; }
if (key == "order" ) { orderfile = value; }
if (key == "group" ) { groupfile = value; }
if (key == "fileroot" ) { fileroot = value; }
if (key == "randomtree" ) { randomtree = value; }
if (key == "groups" ) { groups = value; }
+ if (key == "calc") { calc = value; }
- if (key == "single") {//stores estimators in a vector
- singleEstimators.clear(); //clears out old values
- if (value == "default") { value = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction"; }
- splitAtDash(value, singleEstimators);
- }
- if (key == "rarefaction") {//stores estimators in a vector
- rareEstimators.clear(); //clears out old values
- if (value == "default") { value = "rarefraction"; }
- splitAtDash(value, rareEstimators);
- }
- if (key == "shared") {//stores estimators in a vector
- sharedEstimators.clear(); //clears out old values
- if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
- splitAtDash(value, sharedEstimators);
- }
- if (key == "summary") { //stores summaries to be used in a vector
- summaryEstimators.clear();
- if (value == "default") { value = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
- splitAtDash(value, summaryEstimators);
- }
- if (key == "sharedsummary") { //stores sharedSummaries to be used in a vector
- sharedSummaryEstimators.clear();
- if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
- splitAtDash(value, sharedSummaryEstimators);
- }
- if (key == "sharedrarefaction") { //stores sharedrarefaction to be used in a vector
- sharedRareEstimators.clear();
- if (value == "default") { value = "sharedobserved"; }
- splitAtDash(value, sharedRareEstimators);
- }
if (key == "line") {//stores lines to be used in a set
lines.clear();
line = value;
groups = value;
splitAtDash(value, Groups);
}
-
}
//saves the last parameter
if (key == "rabund" ) { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund"; }
if (key == "sabund" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
if (key == "fasta" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
- if (key == "tree" ) { treefile = value; inputFileName = value; fileroot = value; format = "tree"; }
+ if (key == "tree" ) { treefile = value; inputFileName = value; fileroot = value; format = "tree"; }
+ if (key == "shared" ) { sharedfile = value; inputFileName = value; fileroot = value; format = "sharedfile"; }
if (key == "name" ) { namefile = value; }
if (key == "order" ) { orderfile = value; }
if (key == "group" ) { groupfile = value; }
if (key == "fileroot" ) { fileroot = value; }
if (key == "randomtree" ) { randomtree = value; }
if (key == "groups" ) { groups = value; }
+ if (key == "calc") { calc = value; }
+
-
- if (key == "single") {//stores estimators in a vector
- singleEstimators.clear(); //clears out old values
- if (value == "default") { value = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction"; }
- splitAtDash(value, singleEstimators);
- }
- if (key == "rarefaction") {//stores estimators in a vector
- rareEstimators.clear(); //clears out old values
- if (value == "default") { value = "rarefraction"; }
- splitAtDash(value, rareEstimators);
- }
- if (key == "shared") {//stores estimators in a vector
- sharedEstimators.clear(); //clears out old values
- if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
- splitAtDash(value, sharedEstimators);
- }
- if (key == "summary") { //stores summaries to be used in a vector
- summaryEstimators.clear();
- if (value == "default") { value = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
- splitAtDash(value, summaryEstimators);
- }
- if (key == "sharedsummary") { //stores sharedSummaries to be used in a vector
- sharedSummaryEstimators.clear();
- if (value == "default") { value = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN"; }
- splitAtDash(value, sharedSummaryEstimators);
- }
- if (key == "sharedrarefaction") { //stores sharedrarefaction to be used in a vector
- sharedRareEstimators.clear();
- if (value == "default") { value = "sharedobserved"; }
- splitAtDash(value, sharedRareEstimators);
- }
-
if (key == "line") {//stores lines to be used in a vector
lines.clear();
line = value;
groups = value;
splitAtDash(value, Groups);
}
-
}
//set format for shared
if ((listfile != "") && (groupfile != "")) { format = "shared"; }
- //input defaults
+ //input defaults for calculators
if (commandName == "collect.single") {
- if (singleEstimators.size() == 0) { splitAtDash(single, singleEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
if (commandName == "rarefaction.single") {
- if (rareEstimators.size() == 0) { splitAtDash(rarefaction, rareEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sobs"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
if (commandName == "collect.shared") {
- if (sharedEstimators.size() == 0) { splitAtDash(shared, sharedEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sharedsobs-sharedchao-sharedace-sharedjabund-sharedsorensonabund-sharedjclass-sharedsorclass-sharedjest-sharedsorest-sharedthetayc-sharedthetan"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
if (commandName == "summary.single") {
- if (summaryEstimators.size() == 0) { splitAtDash(summary, summaryEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
if (commandName == "summary.shared") {
- if (sharedSummaryEstimators.size() == 0) { splitAtDash(sharedsummary, sharedSummaryEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sharedsobs-sharedchao-sharedace-sharedjabund-sharedsorensonabund-sharedjclass-sharedsorclass-sharedjest-sharedsorest-sharedthetayc-sharedthetan"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
if (commandName == "rarefaction.shared") {
- if (sharedRareEstimators.size() == 0) { splitAtDash(sharedrarefaction, sharedRareEstimators); }
+ if ((calc == "default") || (calc == "")) { calc = "sharedobserved"; }
+ Estimators.clear();
+ splitAtDash(calc, Estimators);
}
-
//if you have done a read.otu with a groupfile but don't want to use it anymore because you want to do single commands
if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single")) {
if (listfile != "") { format = "list"; }
else if (sabundfile != "") { format = "sabund"; }
else if (rabundfile != "") { format = "rabund"; }
}
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function parseGlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
cout << "An unknown error has occurred in the GlobalData class function parseGlobalData. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
-
}
/*******************************************************/
string GlobalData::getGroupFile() { return groupfile; }
string GlobalData::getOrderFile() { return orderfile; }
string GlobalData::getTreeFile() { return treefile; }
+string GlobalData::getSharedFile() { return sharedfile; }
string GlobalData::getFastaFile() { return fastafile; }
string GlobalData::getCutOff() { return cutoff; }
string GlobalData::getFormat() { return format; }
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::setGroupFile(string file) { groupfile = file; }
void GlobalData::setNameFile(string file) { namefile = file; }
void GlobalData::setFormat(string Format) { format = Format; }
void GlobalData::setRandomTree(string Random) { randomtree = Random; }
-
+void GlobalData::setCalc(string Calc) { calc = Calc; }
/*******************************************************/
/******************************************************/
-
GlobalData::GlobalData() {
//option definitions should go here...
helpRequest = "";
/*******************************************************/
/******************************************************/
-
void GlobalData::clear() {
//option definitions should go here...
phylipfile = "";
orderfile = "";
fastafile = "";
treefile = "";
+ sharedfile = "";
cutoff = "10.00";
format = "";
precision = "100";
freq = "100";
method = "furthest";
fileroot = "";
- single = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction";
- rarefaction = "sobs";
- shared = "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
- sharedsummary = "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
- summary = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson";
- sharedrarefaction = "sharedobserved";
+ calc = "";
}
/*******************************************************/
/******************************************************/
+void GlobalData::reset() {
+ cutoff = "10.00";
+ precision = "100";
+ iters = "1000";
+ line = "";
+ label = "";
+ groups = "";
+ jumble = "1"; //0 means don't jumble, 1 means jumble.
+ randomtree = "0"; //0 means user will enter some user trees, 1 means they just want the random tree distribution.
+ freq = "100";
+ method = "furthest";
+ calc = "";
+}
+/*******************************************************/
+/******************************************************/
GlobalData::~GlobalData() {
_uniqueInstance = 0;
if(gListVector != NULL) { delete gListVector; }
}
/*******************************************************/
-/******************************************************/
-//This function parses the estimator options and puts them in a vector
-void GlobalData::splitAtDash(string& estim, vector<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function parses the label options and puts them in a set
-void GlobalData::splitAtDash(string& estim, set<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.insert(individual);
- }
- }
- //get last one
- container.insert(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function parses the line options and puts them in a set
-void GlobalData::splitAtDash(string& estim, set<int>& container) {
- try {
- string individual;
- int lineNum;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- convert(individual, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- }
- //get last one
- convert(estim, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-/*******************************************************/
-
/******************************************************/
-//This function splits up the various option parameters
-void GlobalData::splitAtComma(string& prefix, string& suffix){
- try {
- prefix = suffix.substr(0,suffix.find_first_of(','));
- if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
- suffix = suffix.substr(suffix.find_first_of(',')+2, suffix.length());
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-/*******************************************************/
-
-/******************************************************/
-//This function separates the key value from the option value i.e. dist=96_...
-void GlobalData::splitAtEquals(string& key, string& value){
- try {
- if(value.find_first_of('=') != -1){
- key = value.substr(0,value.find_first_of('='));
- if ((value.find_first_of('=')+1) <= value.length()) {
- value = value.substr(value.find_first_of('=')+1, value.length());
- }
- }else{
- key = value;
- value = 1;
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the GlobalData class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the GlobalData class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-/*******************************************************/
-
-/******************************************************/
#include <string>
#include <vector>
#include <set>
+#include <iostream>
+#include <iomanip>
+#include <map>
+#include <sstream>
+#include <stdexcept>
+#include <exception>
+
#include "groupmap.h"
#include "treemap.h"
TreeMap* gTreemap;
string inputFileName, helpRequest, commandName;
bool allLines;
- vector<string> singleEstimators, summaryEstimators, sharedEstimators, rareEstimators, sharedRareEstimators, sharedSummaryEstimators; //holds estimators to be used
+ vector<string> Estimators; //holds estimators to be used
set<int> lines; //hold lines to be used
set<string> labels; //holds labels to be used
vector<string> Groups;
string getOrderFile();
string getFastaFile();
string getTreeFile();
+ string getSharedFile();
string getCutOff();
string getFormat();
string getPrecision();
void setSabundFile(string);
void setFormat(string);
void setRandomTree(string);
+ void setCalc(string);
void setListVector(ListVector*);
void setSparseMatrix(SparseMatrix*);
- void clear();
-
void parseGlobalData(string, string);
- void splitAtEquals(string&, string&);
- void splitAtComma(string&, string&);
- void splitAtDash(string&, vector<string>&);
- void splitAtDash(string&, set<int>&);
- void splitAtDash(string&, set<string>&);
-
+
private:
- string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, line, label, randomtree, groups;
- string cutoff, format, precision, method, fileroot, iters, jumble, freq, single, rarefaction, shared, summary, sharedsummary, sharedrarefaction;
+ string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups;
+ string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc;
static GlobalData* _uniqueInstance;
GlobalData( const GlobalData& ); // Disable copy constructor
void operator=( const GlobalData& ); // Disable assignment operator
~GlobalData();
ListVector* gListVector;
SparseMatrix* gSparseMatrix;
+ void clear(); //clears all parameters
+ void reset(); //clears all non filename parameters
+
};
-//**********************************************************************************************************************
-
#endif
fileHandle.close();
}
/************************************************************/
-
-int GroupMap::getNumGroups() {
-
- return namesOfGroups.size();
-
-}
+int GroupMap::getNumGroups() { return namesOfGroups.size(); }
/************************************************************/
string GroupMap::getGroup(string sequenceName) {
}else {
return "not found";
}
-
}
/************************************************************/
-
+void GroupMap::setGroup(string sequenceName, string groupN) {
+ groupmap[sequenceName] = groupN;
+}
+/************************************************************/
void GroupMap::setNamesOfGroups(string seqGroup) {
int i, count;
count = 0;
class GroupMap {
public:
+ GroupMap() {};
GroupMap(string);
~GroupMap();
void readMap();
int getNumGroups();
string getGroup(string);
+ void setGroup(string, string);
vector<string> namesOfGroups;
map<string, int> groupIndex; //groupname, vectorIndex in namesOfGroups. - used by collectdisplays.
private:
ifstream fileHandle;
string groupFileName;
- int numGroups, index;
+ int index;
map<string, string>::iterator it;
void setNamesOfGroups(string);
map<string, string> groupmap; //sequence name and groupname
//**********************************************************************************************************************
-HelpCommand::HelpCommand(){}
+HelpCommand::HelpCommand(){
+ globaldata = GlobalData::getInstance();
+ validCommands = new ValidCommands();
+}
//**********************************************************************************************************************
int HelpCommand::execute(){
- globaldata = GlobalData::getInstance();
-
if (globaldata->helpRequest == "read.dist") {
cout << "The read.dist command parameter options are phylip or column, name, cutoff and precision" << "\n";
cout << "The read.dist command should be in the following format: " << "\n";
cout << "It also must be run before using the parsimony command, unless you are using the randomtree parameter." << "\n";
cout << "The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile)." << "\n";
cout << "The tree and group parameters are both required." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile)." << "\n" << "\n";
+ }else if (globaldata->helpRequest == "read.shared") {
+ cout << "The read.shared must be run before you execute a collect.shared, rarefaction.shared or summary.shared command." << "\n";
+ cout << "The read.shared command is used to read a shared file. The read.shared should be entered in the following format:" << "\n";
+ cout << "read.shared(shared=yourSharedFile). The shared parameter is required." << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedfile)." << "\n" << "\n";
}else if (globaldata->helpRequest == "cluster") {
cout << "The cluster command can only be executed after a successful read.dist command." << "\n";
cout << "The cluster command parameter options are method, cuttoff and precision. No parameters are required." << "\n";
}else if (globaldata->helpRequest == "collect.single") {
cout << "The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. " << "\n";
cout << "The collect.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster." << "\n";
- cout << "The collect.single command parameters are label, line, freq, single. No parameters are required, but you may not use " << "\n";
+ cout << "The collect.single command parameters are label, line, freq, calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The collect.single command should be in the following format: " << "\n";
- cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, single=yourEstimators)." << "\n";
- cout << "Example collect(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, single=collect-chao-ace-jack)." << "\n";
- cout << "The default values for freq is 100, and single are sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << "\n";
+ cout << "collect.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
+ cout << "Example collect(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, calc=sobs-chao-ace-jack)." << "\n";
+ cout << "The default values for freq is 100, and calc are sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "collect.shared") {
cout << "The collect.shared command can only be executed after a successful read.otu command." << "\n";
- cout << "The collect.shared command parameters are label, line, freq, jumble, shared. No parameters are required, but you may not use " << "\n";
+ cout << "The collect.shared command parameters are label, line, freq, jumble, calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The collect.shared command should be in the following format: " << "\n";
- cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, shared=yourEstimators)." << "\n";
- cout << "Example collect.shared(label=unique-.01-.03, line=0,5,10, freq=10, jumble=1, shared=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
- cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and shared are sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << "\n";
+ cout << "collect.shared(label=yourLabel, line=yourLines, freq=yourFreq, jumble=yourJumble, calc=yourEstimators)." << "\n";
+ cout << "Example collect.shared(label=unique-.01-.03, line=0,5,10, freq=10, jumble=1, calc=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
+ cout << "The default values for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100 and calc are sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "rarefaction.single") {
cout << "The rarefaction.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
cout << "The rarefaction.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster." << "\n";
- cout << "The rarefaction.single command parameters are label, line, iters, freq, rarefaction. No parameters are required, but you may not use " << "\n";
+ cout << "The rarefaction.single command parameters are label, line, iters, freq, calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The rarefaction.single command should be in the following format: " << "\n";
- cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, rarefaction=yourEstimators)." << "\n";
- cout << "Example rarefaction.single(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, rarefaction=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
- cout << "The default values for iters is 1000, freq is 100, and rarefaction is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
+ cout << "rarefaction.single(label=yourLabel, line=yourLines, iters=yourIters, freq=yourFreq, calc=yourEstimators)." << "\n";
+ cout << "Example rarefaction.single(label=unique-.01-.03, line=0,5,10, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson)." << "\n";
+ cout << "The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness." << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "rarefaction.shared") {
cout << "The rarefaction.shared command can only be executed after a successful read.otu command." << "\n";
- cout << "The rarefaction.shared command parameters are label, line, iters, jumble and sharedrarefaction. No parameters are required, but you may not use " << "\n";
+ cout << "The rarefaction.shared command parameters are label, line, iters, jumble and calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The rarefaction command should be in the following format: " << "\n";
- cout << "rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, jumble=yourJumble, sharedrarefaction=yourEstimators)." << "\n";
- cout << "Example rarefaction.shared(label=unique-.01-.03, line=0,5,10, iters=10000, jumble=1, sharedrarefaction=sharedobserved)." << "\n";
- cout << "The default values for iters is 1000, jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100, and sharedrarefaction is sharedobserved which calculates the shared rarefaction curve for the observed richness." << "\n";
+ cout << "rarefaction.shared(label=yourLabel, line=yourLines, iters=yourIters, jumble=yourJumble, calc=yourEstimators)." << "\n";
+ cout << "Example rarefaction.shared(label=unique-.01-.03, line=0,5,10, iters=10000, jumble=1, calc=sharedobserved)." << "\n";
+ cout << "The default values for iters is 1000, jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble), freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness." << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq)." << "\n" << "\n";
}else if (globaldata->helpRequest == "summary.single") {
cout << "The summary.single command can only be executed after a successful read.otu WTIH ONE EXECEPTION." << "\n";
cout << "The summary.single command can be executed after a successful cluster command. It will use the .list file from the output of the cluster." << "\n";
- cout << "The summary.single command parameters are label, line, summary. No parameters are required, but you may not use " << "\n";
+ cout << "The summary.single command parameters are label, line, calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The summary.single command should be in the following format: " << "\n";
- cout << "summary.single(label=yourLabel, line=yourLines, summary=yourEstimators)." << "\n";
- cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, summary=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
- cout << "The default value summary is sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson" << "\n";
+ cout << "summary.single(label=yourLabel, line=yourLines, calc=yourEstimators)." << "\n";
+ cout << "Example summary.single(label=unique-.01-.03, line=0,5,10, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson)." << "\n";
+ cout << "The default value calc is sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson" << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
}else if (globaldata->helpRequest == "summary.shared") {
cout << "The summary.shared command can only be executed after a successful read.otu command." << "\n";
- cout << "The summary.shared command parameters are label, line, jumble and sharedsummary. No parameters are required, but you may not use " << "\n";
+ cout << "The summary.shared command parameters are label, line, jumble and calc. No parameters are required, but you may not use " << "\n";
cout << "both the line and label parameters at the same time. The summary.shared command should be in the following format: " << "\n";
- cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, sharedsummary=yourEstimators)." << "\n";
- cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, sharedsummary=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
- cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and sharedsummary is sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN" << "\n";
+ cout << "summary.shared(label=yourLabel, line=yourLines, jumble=yourJumble, calc=yourEstimators)." << "\n";
+ cout << "Example summary.shared(label=unique-.01-.03, line=0,5,10, jumble=1, calc=sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN)." << "\n";
+ cout << "The default value for jumble is 1 (meaning jumble, if it’s set to 0 then it will not jumble) and calc is sharedsobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN" << "\n";
cout << "The label and line parameters are used to analyze specific lines in your input." << "\n";
- cout << "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile)." << "\n" << "\n";
+ cout << "Note: No spaces between parameter labels (i.e. line), '=' and parameters (i.e.yourLines)." << "\n" << "\n";
}else if (globaldata->helpRequest == "parsimony") {
cout << "The parsimony command can only be executed after a successful read.tree command, unless you use the randomtree parameter." << "\n";
cout << "The parsimony command parameters are randomtree and iters. No parameters are required." << "\n";
cout << "The quit command will terminate Dotur and should be in the following format: " << "\n";
cout << "quit()" << "\n" << "\n";
}else if (globaldata->helpRequest == "") {
- cout << "Valid commands are read.dist(), read.otu(), read.tree(), cluster(), deconvolute(), collect.single(), rarefaction.single(), summary.single(), collect.shared(), rarefaction.shared(), summary.shared(), parsimony(), unifrac.weighted(), unifrac.unweighted(), quit(), help()." << "\n";
+ validCommands->printCommands(cout);
cout << "For more information about a specific command type 'help(commandName)' i.e. 'help(read.dist)'" << endl;
}else {
cout << globaldata->helpRequest << " is not a valid command" << endl;
#include "command.hpp"
#include "globaldata.hpp"
+#include "validcommands.h"
class HelpCommand : public Command {
int execute();
private:
GlobalData* globaldata;
+ ValidCommands* validCommands;
private:
SharedListVector* InputData::getSharedListVector(){
try {
if(fileHandle){
- if (format == "shared"){
+ if (format == "shared") {
SharedList = new SharedListVector(fileHandle);
}
}
}
+/***********************************************************************/
+
+SharedOrderVector* InputData::getSharedOrderVector(){
+ try {
+ if(fileHandle){
+ if (format == "sharedfile") {
+ SharedOrder = new SharedOrderVector(fileHandle);
+ }
+
+ gobble(fileHandle);
+ return SharedOrder;
+
+ }else{
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the InputData class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+
/***********************************************************************/
if(format == "list") {
input = new ListVector(fileHandle);
}
- else if(format == "shared") {
+ else if (format == "shared") {
input = new SharedListVector(fileHandle);
}
else if(format == "rabund"){
gobble(fileHandle);
output = new OrderVector();
*output = (input->getOrderVector());
- //delete input;
+
return output;
}
else{
if (format == "list") {
input = new ListVector(fileHandle);
}
- else if(format == "shared") {
+ else if (format == "shared") {
input = new SharedListVector(fileHandle);
}
else if(format == "rabund"){
#include <fstream>
#include "ordervector.hpp"
#include "sharedlistvector.h"
+#include "sharedordervector.h"
#include "listvector.hpp"
ListVector* getListVector();
SharedListVector* getSharedListVector();
OrderVector* getOrderVector();
+ SharedOrderVector* getSharedOrderVector();
SAbundVector* getSAbundVector();
private:
ListVector* list;
SharedListVector* SharedList;
OrderVector* output;
+ SharedOrderVector* SharedOrder;
SAbundVector* sabund;
map<string,int> orderMap;
};
globaldata = GlobalData::getInstance();
string fileNameRoot;
fileNameRoot = getRootName(globaldata->inputFileName);
+ validCalculator = new ValidCalculators();
+
int i;
- for (i=0; i<globaldata->rareEstimators.size(); i++) {
- if (globaldata->rareEstimators[i] == "sobs") {
- rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
- }else if (globaldata->rareEstimators[i] == "chao") {
- rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
- }else if (globaldata->rareEstimators[i] == "ace") {
- rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace")));
- }else if (globaldata->rareEstimators[i] == "jack") {
- rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
- }else if (globaldata->rareEstimators[i] == "shannon") {
- rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
- }else if (globaldata->rareEstimators[i] == "npshannon") {
- rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
- }else if (globaldata->rareEstimators[i] == "simpson") {
- rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
- }else if (globaldata->rareEstimators[i] == "bootstrap") {
- rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("rarefaction", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "sobs") {
+ rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
+ }else if (globaldata->Estimators[i] == "chao") {
+ rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
+ }else if (globaldata->Estimators[i] == "ace") {
+ rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace")));
+ }else if (globaldata->Estimators[i] == "jack") {
+ rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
+ }else if (globaldata->Estimators[i] == "shannon") {
+ rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
+ }else if (globaldata->Estimators[i] == "npshannon") {
+ rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
+ }else if (globaldata->Estimators[i] == "simpson") {
+ 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")));
+ }
}
}
-
-
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the RareFactCommand class Function RareFactCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int RareFactCommand::execute(){
try {
int count = 1;
+
+ //if the users entered no valid calculators don't execute command
+ if (rDisplays.size() == 0) { return 0; }
+
read = new ReadPhilFile(globaldata->inputFileName);
read->read(&*globaldata);
#include "rarefact.h"
#include "display.h"
#include "readmatrix.hpp"
+#include "validcalculator.h"
/*The rarefaction() command:
ReadMatrix* read;
OrderVector* order;
InputData* input;
+ ValidCalculators* validCalculator;
Rarefact* rCurve;
int freq, nIters;
};
globaldata = GlobalData::getInstance();
string fileNameRoot;
fileNameRoot = getRootName(globaldata->inputFileName);
+ format = globaldata->getFormat();
+ validCalculator = new ValidCalculators();
int i;
- for (i=0; i<globaldata->sharedRareEstimators.size(); i++) {
- if (globaldata->sharedRareEstimators[i] == "sharedobserved") {
- rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("sharedrarefaction", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "sharedobserved") {
+ rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+ }
}
}
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function RareFactSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int RareFactSharedCommand::execute(){
try {
int count = 1;
- read = new ReadPhilFile(globaldata->inputFileName);
- read->read(&*globaldata);
- input = globaldata->ginput;
- SharedList = globaldata->gSharedList;
- order = SharedList->getSharedOrderVector();
+ //if the users entered no valid calculators don't execute command
+ if (rDisplays.size() == 0) { return 0; }
+
+ if (format == "sharedfile") {
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }
while(order != NULL){
cout << order->getLabel() << '\t' << count << endl;
}
- SharedList = input->getSharedListVector(); //get new list vector to process
- if (SharedList != NULL) {
- order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
- count++;
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
}else {
- break;
+ //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;
+ }
}
-
+
+ count++;
}
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
#include "rarefact.h"
#include "display.h"
#include "readmatrix.hpp"
+#include "validcalculator.h"
/* The rarefaction.shared() command:
The rarefaction command generates a rarefaction curve from a given file representing several groups.
ReadMatrix* read;
SharedOrderVector* order;
InputData* input;
+ ValidCalculators* validCalculator;
Rarefact* rCurve;
vector<Display*> rDisplays;
int freq, nIters;
+ string format;
};
//you have two inputs because in the next if statement if you only have one then it moves ahead in the same file.
//So when you run the collect or summary commands you miss a line.
input = 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.
+ inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund or shared.
}else {//there is an orderfile
input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
}
sabund = inputSabund->getSAbundVector();
globaldata->sabund = sabund; //saving to be used by summary command.
}else if (globaldata->getFormat() == "shared") {
- SharedList = input->getSharedListVector(); //you are reading for parselist command, or shared commands.
+ SharedList = input->getSharedListVector(); //you are reading for collect.shared, rarefaction.shared, summary.shared, parselist command, or shared commands.
globaldata->gSharedList = SharedList;
}
}
--- /dev/null
+/*
+ * readsharedcommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 2/12/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readsharedcommand.h"
+
+//**********************************************************************************************************************
+ReadSharedCommand::ReadSharedCommand(){
+ try {
+ globaldata = GlobalData::getInstance();
+ filename = globaldata->inputFileName;
+ read = new ReadPhilFile(filename);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ReadSharedCommand class Function ReadSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ReadSharedCommand class function ReadSharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+
+ReadSharedCommand::~ReadSharedCommand(){
+ delete read;
+}
+
+//**********************************************************************************************************************
+
+int ReadSharedCommand::execute(){
+ try {
+ read->read(&*globaldata);
+
+ return 0;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ReadSharedCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ReadSharedCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
\ No newline at end of file
--- /dev/null
+#ifndef READSHAREDCOMMAND_H
+#define READSHAREDCOMMAND_H
+/*
+ * readsharedcommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 2/12/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+#include <iostream>
+#include <fstream>
+#include "command.hpp"
+#include "readmatrix.hpp"
+#include "inputdata.h"
+
+/* The read.shared must be run before you execute a collect.shared, rarefaction.shared or summary.shared command.
+The read.shared command is used to read a shared file. The read.shared should be entered in the following format:
+read.shared(shared=yourSharedFile). The shared parameter is required. */
+
+class GlobalData;
+
+class ReadSharedCommand : public Command {
+public:
+ ReadSharedCommand();
+ ~ReadSharedCommand();
+ int execute();
+
+private:
+ GlobalData* globaldata;
+ ReadMatrix* read;
+ InputData* input;
+ string filename;
+};
+
+#endif
+
+
+
+
SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
try {
globaldata = GlobalData::getInstance();
-
+
//set up groupmap for later.
groupmap = new GroupMap(globaldata->getGroupFile());
groupmap->readMap();
int hold;
+ string inputData;
f >> label >> hold;
data.assign(hold, "");
- string inputData = "";
for(int i=0;i<hold;i++){
f >> inputData;
set(i, inputData);
}
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
updateStats();
}
-/***********************************************************************
-
-//does not work since we don't have a shared order file format yet.
+/***********************************************************************/
+//This function is used to read a .shared file for the collect.shared, rarefaction.shared and summary.shared commands
+//if you don't use a list and groupfile.
SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {
try {
- int hold;
-
- f >> label;
- f >> hold;
-
- data.assign(hold, -1);
-
- int inputData;
-
- for(int i=0;i<hold;i++){
+ globaldata = GlobalData::getInstance();
+
+ if (globaldata->gGroupmap == NULL) { groupmap = new GroupMap(); }
+
+ int num, inputData, pos, count;
+ count = 0; numSeqs = 0;
+ string holdLabel, nextLabel, groupN;
+ individual newguy;
+
+ //read in first row since you know there is at least 1 group.
+ f >> label >> groupN >> num;
+ holdLabel = label;
+
+ if (globaldata->gGroupmap == NULL) {
+ //save group in groupmap
+ groupmap->namesOfGroups.push_back(groupN);
+ groupmap->groupIndex[groupN] = 0;
+ }
+
+ for(int i=0;i<num;i++){
f >> inputData;
- set(i, inputData, inputData, group);
+ for (int j = 0; j < inputData; j++) {
+ push_back(i+1, i+1, groupN);
+ numSeqs++;
+ }
}
+
+ //save position in file in case next line is a new label.
+ pos = f.tellg();
+
+ if (f.eof() != true) { f >> nextLabel; }
+
+ //read the rest of the groups info in
+ while ((nextLabel == holdLabel) && (f.eof() != true)) {
+ f >> groupN >> num;
+ count++;
+
+ if (globaldata->gGroupmap == NULL) {
+ //save group in groupmap
+ groupmap->namesOfGroups.push_back(groupN);
+ groupmap->groupIndex[groupN] = count;
+ }
+
+ for(int i=0;i<num;i++){
+ f >> inputData;
+ for (int j = 0; j < inputData; j++) {
+ push_back(i+1, i+1, groupN);
+ numSeqs++;
+ }
+ }
+
+ //save position in file in case next line is a new label.
+ pos = f.tellg();
+
+ if (f.eof() != true) { f >> nextLabel; }
+
+ }
+
+ //put file pointer back since you are now at a new distance label
+ f.seekg(pos, ios::beg);
+
+ if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; }
updateStats();
}
exit(1);
}
}
-
/***********************************************************************/
-
int SharedOrderVector::getNumBins(){
if(needToUpdate == 1){ updateStats(); }
return numBins;
#include "rabundvector.hpp"
#include "sharedrabundvector.h"
#include "sharedsabundvector.h"
+#include "globaldata.hpp"
+#include "groupmap.h"
class SharedOrderVector : public DataVector {
SharedOrderVector(const SharedOrderVector& ov) : DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){ updateStats();}};
SharedOrderVector(string, vector<individual>);
-// SharedOrderVector(ifstream&);
+ SharedOrderVector(ifstream&);
~SharedOrderVector(){};
void set(int, int, int, string); //index, OTU, abundance, group
SharedSAbundVector getSharedSAbundVector(string); //get the sharedSabundvector for a sepecific group
private:
+ GlobalData* globaldata;
+ GroupMap* groupmap;
vector<individual> data;
map< int, vector<individual> >::iterator it;
int maxRank;
SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
try {
- int i, hold;
+ int i, num;
+ string holdLabel, group
individual newGuy;
- f >> label >> hold;
+ f >> label >> group >> num;
//initialize data
for (i=0; i<hold; i++) {
*
*/
+/* This calculator returns the number of shared species between 2 groups. */
#include "calculator.h"
SummaryCommand::SummaryCommand(){
try {
globaldata = GlobalData::getInstance();
+ validCalculator = new ValidCalculators();
int i;
- for (i=0; i<globaldata->summaryEstimators.size(); i++) {
- if(globaldata->summaryEstimators[i] == "sobs"){
- sumCalculators.push_back(new Sobs());
- }else if(globaldata->summaryEstimators[i] == "chao"){
- sumCalculators.push_back(new Chao1());
- }else if(globaldata->summaryEstimators[i] == "ace"){
- sumCalculators.push_back(new Ace());
- }else if(globaldata->summaryEstimators[i] == "jack"){
- sumCalculators.push_back(new Jackknife());
- }else if(globaldata->summaryEstimators[i] == "shannon"){
- sumCalculators.push_back(new Shannon());
- }else if(globaldata->summaryEstimators[i] == "npshannon"){
- sumCalculators.push_back(new NPShannon());
- }else if(globaldata->summaryEstimators[i] == "simpson"){
- sumCalculators.push_back(new Simpson());
- }else if(globaldata->summaryEstimators[i] == "bootstrap"){
- sumCalculators.push_back(new Bootstrap());
+
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("summary", globaldata->Estimators[i]) == true) {
+ if(globaldata->Estimators[i] == "sobs"){
+ sumCalculators.push_back(new Sobs());
+ }else if(globaldata->Estimators[i] == "chao"){
+ sumCalculators.push_back(new Chao1());
+ }else if(globaldata->Estimators[i] == "ace"){
+ sumCalculators.push_back(new Ace());
+ }else if(globaldata->Estimators[i] == "jack"){
+ sumCalculators.push_back(new Jackknife());
+ }else if(globaldata->Estimators[i] == "shannon"){
+ sumCalculators.push_back(new Shannon());
+ }else if(globaldata->Estimators[i] == "npshannon"){
+ sumCalculators.push_back(new NPShannon());
+ }else if(globaldata->Estimators[i] == "simpson"){
+ sumCalculators.push_back(new Simpson());
+ }else if(globaldata->Estimators[i] == "bootstrap"){
+ sumCalculators.push_back(new Bootstrap());
+ }
}
}
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SummaryCommand class Function SummaryCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int SummaryCommand::execute(){
try {
+
+ //if the users entered no valid calculators don't execute command
+ if (sumCalculators.size() == 0) { return 0; }
+
outputFileName = ((getRootName(globaldata->inputFileName)) + "summary");
openOutputFile(outputFileName, outputFileHandle);
outputFileHandle << "label";
#include "inputdata.h"
#include "calculator.h"
#include "readmatrix.hpp"
+#include "validcalculator.h"
/* The summary() command:
The summary command can only be executed after a successful read.list, read.sabund or read.rabund command, with one exception.
ReadMatrix* read;
vector<Calculator*> sumCalculators;
InputData* input;
+ ValidCalculators* validCalculator;
SAbundVector* sabund;
string outputFileName;
ofstream outputFileHandle;
SummarySharedCommand::SummarySharedCommand(){
try {
globaldata = GlobalData::getInstance();
+ outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
+ openOutputFile(outputFileName, outputFileHandle);
+ format = globaldata->getFormat();
+ validCalculator = new ValidCalculators();
int i;
- for (i=0; i<globaldata->sharedSummaryEstimators.size(); i++) {
- if (globaldata->sharedSummaryEstimators[i] == "sharedSobs") {
- sumCalculators.push_back(new SharedSobsCS());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedChao") {
- sumCalculators.push_back(new SharedChao1());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedAce") {
- sumCalculators.push_back(new SharedAce());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedJabund") {
- sumCalculators.push_back(new SharedJAbund());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorensonAbund") {
- sumCalculators.push_back(new SharedSorAbund());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedJclass") {
- sumCalculators.push_back(new SharedJclass());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorClass") {
- sumCalculators.push_back(new SharedSorClass());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedJest") {
- sumCalculators.push_back(new SharedJest());
- }else if (globaldata->sharedSummaryEstimators[i] == "sharedSorEst") {
- sumCalculators.push_back(new SharedSorEst());
- }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaYC") {
- sumCalculators.push_back(new SharedThetaYC());
- }else if (globaldata->sharedSummaryEstimators[i] == "SharedThetaN") {
- sumCalculators.push_back(new SharedThetaN());
+ for (i=0; i<globaldata->Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("sharedsummary", globaldata->Estimators[i]) == true) {
+ if (globaldata->Estimators[i] == "sharedsobs") {
+ sumCalculators.push_back(new SharedSobsCS());
+ }else if (globaldata->Estimators[i] == "sharedchao") {
+ sumCalculators.push_back(new SharedChao1());
+ }else if (globaldata->Estimators[i] == "sharedace") {
+ sumCalculators.push_back(new SharedAce());
+ }else if (globaldata->Estimators[i] == "sharedjabund") {
+ sumCalculators.push_back(new SharedJAbund());
+ }else if (globaldata->Estimators[i] == "sharedsorensonabund") {
+ sumCalculators.push_back(new SharedSorAbund());
+ }else if (globaldata->Estimators[i] == "sharedjclass") {
+ sumCalculators.push_back(new SharedJclass());
+ }else if (globaldata->Estimators[i] == "sharedsorclass") {
+ sumCalculators.push_back(new SharedSorClass());
+ }else if (globaldata->Estimators[i] == "sharedjest") {
+ sumCalculators.push_back(new SharedJest());
+ }else if (globaldata->Estimators[i] == "sharedsorest") {
+ sumCalculators.push_back(new SharedSorEst());
+ }else if (globaldata->Estimators[i] == "sharedthetayc") {
+ sumCalculators.push_back(new SharedThetaYC());
+ }else if (globaldata->Estimators[i] == "sharedthetan") {
+ sumCalculators.push_back(new SharedThetaN());
+ }
}
}
+
+ //reset calc for next command
+ globaldata->setCalc("");
+
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int SummarySharedCommand::execute(){
try {
- outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
- openOutputFile(outputFileName, outputFileHandle);
-
- read = new ReadPhilFile(globaldata->inputFileName);
- read->read(&*globaldata);
+ int count = 1;
+ //if the users entered no valid calculators don't execute command
+ if (sumCalculators.size() == 0) { return 0; }
+
+ if (format == "sharedfile") {
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ order = input->getSharedOrderVector();
+ }else {
+ //you are using a list and a groupfile
+ read = new ReadPhilFile(globaldata->inputFileName);
+ read->read(&*globaldata);
+
+ input = globaldata->ginput;
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
+ }
+
+ //output estimator names as column headers
outputFileHandle << "label" <<'\t' << "comparison" << '\t';
for(int i=0;i<sumCalculators.size();i++){
outputFileHandle << '\t' << sumCalculators[i]->getName();
}
outputFileHandle << endl;
-
- SharedList = globaldata->gSharedList;
- input = globaldata->ginput;
- order = SharedList->getSharedOrderVector();
-
- int count = 1;
+
while(order != NULL){
if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
}
}
- SharedList = input->getSharedListVector(); //get new list vector to process
- if (SharedList != NULL) {
- order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
- count++;
+ //get next line to process
+ if (format == "sharedfile") {
+ order = input->getSharedOrderVector();
}else {
- break;
+ //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;
+ }
}
+ count++;
}
return 0;
#include "calculator.h"
#include "readmatrix.hpp"
#include "sharedlistvector.h"
+#include "validcalculator.h"
/*The summary.shared() command
The summary.shared command can only be executed after a successful read.shared command.
ReadMatrix* read;
vector<Calculator*> sumCalculators;
InputData* input;
+ ValidCalculators* validCalculator;
SharedListVector* SharedList;
SharedOrderVector* order;
vector<SharedRAbundVector*> lookup;
SharedRAbundVector* shared1, shared2;
- string outputFileName;
+ string outputFileName, format;
ofstream outputFileHandle;
};
using namespace std;
-#include <string>
-#include <iostream>
-#include <vector>
-#include <fstream>
-#include <iomanip>
-#include <sstream>
-#include <map>
-
#include "treenode.h"
#include "globaldata.hpp"
#include <cmath>
#include <vector>
#include <stdexcept>
+#include <set>
typedef unsigned long long ull;
/***********************************************************************/
+//This function parses the estimator options and puts them in a vector
+inline void splitAtDash(string& estim, vector<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+
+/***********************************************************************/
+//This function parses the label options and puts them in a set
+inline void splitAtDash(string& estim, set<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ container.insert(individual);
+ }
+ }
+ //get last one
+ container.insert(estim);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+//This function parses the line options and puts them in a set
+inline void splitAtDash(string& estim, set<int>& container) {
+ try {
+ string individual;
+ int lineNum;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ convert(individual, lineNum); //convert the string to int
+ container.insert(lineNum);
+ }
+ }
+ //get last one
+ convert(estim, lineNum); //convert the string to int
+ container.insert(lineNum);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+
+//This function splits up the various option parameters
+inline void splitAtComma(string& prefix, string& suffix){
+ try {
+ prefix = suffix.substr(0,suffix.find_first_of(','));
+ if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
+ suffix = suffix.substr(suffix.find_first_of(',')+2, suffix.length());
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+
+//This function separates the key value from the option value i.e. dist=96_...
+inline void splitAtEquals(string& key, string& value){
+ try {
+ if(value.find_first_of('=') != -1){
+ key = value.substr(0,value.find_first_of('='));
+ if ((value.find_first_of('=')+1) <= value.length()) {
+ value = value.substr(value.find_first_of('=')+1, value.length());
+ }
+ }else{
+ key = value;
+ value = 1;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the utilities class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/*******************************************************/
+
+
+
#endif
//is it valid
if ((single.find(calculator)) != (single.end())) {
return true;
- }else { cout << calculator << " is not a valid single estimator. Valid single estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+ }else {
+ cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
+ for (it = single.begin(); it != single.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//are you looking for a calculator for a shared parameter
}else if (parameter == "shared") {
//is it valid
if ((shared.find(calculator)) != (shared.end())) {
return true;
- }else { cout << calculator << " is not a valid shared estimator. Valid shared estimators are sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
+ }else {
+ cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ";
+ for (it = shared.begin(); it != shared.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//are you looking for a calculator for a rarefaction parameter
}else if (parameter == "rarefaction") {
//is it valid
if ((rarefaction.find(calculator)) != (rarefaction.end())) {
return true;
- }else { cout << calculator << " is not a valid rarefaction estimator. Valid rarefaction estimators are rarefaction-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson." << endl; return false; }
+ }else {
+ cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
+ for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//are you looking for a calculator for a summary parameter
}else if (parameter == "summary") {
//is it valid
if ((summary.find(calculator)) != (summary.end())) {
return true;
- }else { cout << calculator << " is not a valid summary estimator. Valid summary estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
+ }else {
+ cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+ for (it = summary.begin(); it != summary.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//are you looking for a calculator for a sharedsummary parameter
}else if (parameter == "sharedsummary") {
//is it valid
if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
return true;
- }else { cout << calculator << " is not a valid sharedsummary estimator. Valid sharedsummary estimators are: sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
-
+ }else {
+ cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
+ for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
}else if (parameter == "sharedrarefaction") {
//is it valid
if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
return true;
- }else { cout << calculator << " is not a valid sharedrarefaction estimator. Valid sharedrarefaction estimator is sharedobserved." << endl; return false; }
+ }else {
+ cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
+ for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+ return false; }
//not a valid paramter
}else { return false; }
/********************************************************************/
void ValidCalculators::initialShared() {
try {
- shared["sharedSobs"] = "sharedSobs";
- shared["sharedChao"] = "sharedChao";
- shared["sharedAce"] = "sharedAce";
- shared["sharedJabund"] = "sharedJabund";
- shared["sharedSorensonAbund"] = "sharedSorensonAbund";
- shared["sharedJclass"] = "sharedJclass";
- shared["sharedSorClass"] = "sharedSorClass";
- shared["sharedJest"] = "sharedJest";
- shared["sharedSorEst"] = "sharedSorEst";
- shared["SharedThetaYC"] = "SharedThetaYC";
- shared["SharedThetaN"] = "SharedThetaN";
+ shared["sharedsobs"] = "sharedsobs";
+ shared["sharedchao"] = "sharedchao";
+ shared["sharedace"] = "sharedace";
+ shared["sharedjabund"] = "sharedjabund";
+ shared["sharedsorensonabund"] = "sharedsorensonabund";
+ shared["sharedjclass"] = "sharedjclass";
+ shared["sharedsorclass"] = "sharedsorclass";
+ shared["sharedjest"] = "sharedjest";
+ shared["sharedsorest"] = "sharedsorest";
+ shared["sharedthetayc"] = "sharedthetayc";
+ shared["sharedthetan"] = "sharedthetan";
shared["default"] = "default";
}
catch(exception& e) {
/********************************************************************/
void ValidCalculators::initialSharedSummary() {
try {
- sharedsummary["sharedSobs"] = "sharedSobs";
- sharedsummary["sharedChao"] = "sharedChao";
- sharedsummary["sharedAce"] = "sharedAce";
- sharedsummary["sharedJabund"] = "sharedJabund";
- sharedsummary["sharedSorensonAbund"] = "sharedSorensonAbund";
- sharedsummary["sharedJclass"] = "sharedJclass";
- sharedsummary["sharedSorClass"] = "sharedSorClass";
- sharedsummary["sharedJest"] = "sharedJest";
- sharedsummary["sharedSorEst"] = "sharedSorEst";
- sharedsummary["SharedThetaYC"] = "SharedThetaYC";
- sharedsummary["SharedThetaN"] = "SharedThetaN";
+ sharedsummary["sharedsobs"] = "sharedsobs";
+ sharedsummary["sharedchao"] = "sharedchao";
+ sharedsummary["sharedace"] = "sharedace";
+ sharedsummary["sharedjabund"] = "sharedjabund";
+ sharedsummary["sharedsorensonabund"] = "sharedsorensonabund";
+ sharedsummary["sharedjclass"] = "sharedjclass";
+ sharedsummary["sharedsorclass"] = "sharedsorclass";
+ sharedsummary["sharedjest"] = "sharedjest";
+ sharedsummary["sharedsorest"] = "sharedsorest";
+ sharedsummary["sharedthetayc"] = "sharedthetayc";
+ sharedsummary["sharedthetan"] = "sharedthetan";
sharedsummary["default"] = "default";
}
catch(exception& e) {
map<string, string> summary;
map<string, string> sharedrarefaction;
map<string, string> sharedsummary;
+ map<string, string>::iterator it;
+
void initialSingle();
void initialShared();
void initialRarefaction();
commands["read.dist"] = "read.dist";
commands["read.otu"] = "read.otu";
commands["read.tree"] = "read.tree";
+ commands["read.shared"] = "read.shared";
commands["cluster"] = "cluster";
commands["deconvolute"] = "deconvolute";
commands["parsimony"] = "parsimony";
if ((commands.find(command)) != (commands.end())) {
return true;
}else{
- cout << command << " is not a valid command in Mothur. Valid commands are read.dist(), read.otu(), read.tree(), cluster(), deconvolute(), collect.single(), collect.shared(), rarefaction.single(), rarefaction.shared(), summary.single(), summary.shared(), parsimony(), unifrac.weighted(), unifrac.unweighted(), quit(), help()." << endl;
+ cout << command << " is not a valid command in Mothur. Valid commands are ";
+ for (it = commands.begin(); it != commands.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
return false;
}
}
/***********************************************************************/
+void ValidCommands::printCommands(ostream& out) {
+ try {
+ out << "Valid commands are ";
+ for (it = commands.begin(); it != commands.end(); it++) {
+ out << it->first << ", ";
+ }
+ out << endl;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ValidCommands class Function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ValidCommands class function printCommands. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+
+
+
ValidCommands();
~ValidCommands();
bool isValidCommand(string);
+ void printCommands(ostream&);
private:
map<string, string> commands;
+ map<string, string>::iterator it;
};
parameters["sharedsummary"] = "sharedsummary";
parameters["randomtree"] = "randomtree";
parameters["groups"] = "groups";
+ parameters["calc"] = "calc";
}
catch(exception& e) {
if ((parameters.find(parameter)) != (parameters.end())) {
return true;
}else{
- cout << parameter << " is not a valid parameter in Mothur." << endl;
+ cout << parameter << " is not a valid parameter in Mothur. Valid parameters are " << endl;
+ for (it = parameters.begin(); it != parameters.end(); it++) {
+ cout << it->first << ", ";
+ }
+ cout << endl;
+
return false;
}
bool isValidParameter(string);
private:
map<string, string> parameters;
+ map<string, string>::iterator it;
};