*/
#include "treegroupscommand.h"
+#include "sharedsobscollectsummary.h"
+#include "sharedchao1.h"
+#include "sharedace.h"
+#include "sharednseqs.h"
#include "sharedjabund.h"
#include "sharedsorabund.h"
#include "sharedjclass.h"
#include "sharedsorest.h"
#include "sharedthetayc.h"
#include "sharedthetan.h"
+#include "sharedkstest.h"
+#include "whittaker.h"
+#include "sharedochiai.h"
+#include "sharedanderbergs.h"
+#include "sharedkulczynski.h"
+#include "sharedkulczynskicody.h"
+#include "sharedlennon.h"
#include "sharedmorisitahorn.h"
#include "sharedbraycurtis.h"
+#include "sharedjackknife.h"
+#include "whittaker.h"
+#include "odum.h"
+#include "canberra.h"
+#include "structeuclidean.h"
+#include "structchord.h"
+#include "hellinger.h"
+#include "manhattan.h"
+#include "structpearson.h"
+#include "soergel.h"
+#include "spearman.h"
+#include "structkulczynski.h"
+#include "structchi2.h"
+#include "speciesprofile.h"
+#include "hamming.h"
+#include "gower.h"
+#include "memchi2.h"
+#include "memchord.h"
+#include "memeuclidean.h"
+#include "mempearson.h"
-
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getValidParameters(){
+ try {
+ string Array[] = {"label","calc","groups", "phylip", "column", "name", "precision","cutoff","outputdir","inputdir"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "getValidParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+TreeGroupCommand::TreeGroupCommand(){
+ try {
+ abort = true; calledHelp = true;
+ globaldata = GlobalData::getInstance();
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["tree"] = tempOutNames;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getRequiredParameters(){
+ try {
+ vector<string> myArray;
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "getRequiredParameters");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> TreeGroupCommand::getRequiredFiles(){
+ try {
+ string Array[] = {"phylip","column","shared","or"};
+ vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ return myArray;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "getRequiredFiles");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
TreeGroupCommand::TreeGroupCommand(string option) {
try {
globaldata = GlobalData::getInstance();
- abort = false;
+ abort = false; calledHelp = false;
allLines = 1;
labels.clear();
Groups.clear();
Estimators.clear();
//allow user to run help
- if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
+ if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; calledHelp = true; }
else {
//valid paramters for this command
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
}
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["tree"] = tempOutNames;
+
//if the user changes the input directory command factory will send this info to us in the output parameter
string inputDir = validParameter.validFile(parameters, "inputdir", false);
if (inputDir == "not found"){ inputDir = ""; }
int i;
for (i=0; i<Estimators.size(); i++) {
if (validCalculator->isValidCalculator("treegroup", Estimators[i]) == true) {
- if (Estimators[i] == "jabund") {
+ if (Estimators[i] == "sharedsobs") {
+ treeCalculators.push_back(new SharedSobsCS());
+ }else if (Estimators[i] == "sharedchao") {
+ treeCalculators.push_back(new SharedChao1());
+ }else if (Estimators[i] == "sharedace") {
+ treeCalculators.push_back(new SharedAce());
+ }else if (Estimators[i] == "jabund") {
treeCalculators.push_back(new JAbund());
}else if (Estimators[i] == "sorabund") {
treeCalculators.push_back(new SorAbund());
treeCalculators.push_back(new ThetaYC());
}else if (Estimators[i] == "thetan") {
treeCalculators.push_back(new ThetaN());
+ }else if (Estimators[i] == "kstest") {
+ treeCalculators.push_back(new KSTest());
+ }else if (Estimators[i] == "sharednseqs") {
+ treeCalculators.push_back(new SharedNSeqs());
+ }else if (Estimators[i] == "ochiai") {
+ treeCalculators.push_back(new Ochiai());
+ }else if (Estimators[i] == "anderberg") {
+ treeCalculators.push_back(new Anderberg());
+ }else if (Estimators[i] == "kulczynski") {
+ treeCalculators.push_back(new Kulczynski());
+ }else if (Estimators[i] == "kulczynskicody") {
+ treeCalculators.push_back(new KulczynskiCody());
+ }else if (Estimators[i] == "lennon") {
+ treeCalculators.push_back(new Lennon());
}else if (Estimators[i] == "morisitahorn") {
treeCalculators.push_back(new MorHorn());
}else if (Estimators[i] == "braycurtis") {
treeCalculators.push_back(new BrayCurtis());
+ }else if (Estimators[i] == "whittaker") {
+ treeCalculators.push_back(new Whittaker());
+ }else if (Estimators[i] == "odum") {
+ treeCalculators.push_back(new Odum());
+ }else if (Estimators[i] == "canberra") {
+ treeCalculators.push_back(new Canberra());
+ }else if (Estimators[i] == "structeuclidean") {
+ treeCalculators.push_back(new StructEuclidean());
+ }else if (Estimators[i] == "structchord") {
+ treeCalculators.push_back(new StructChord());
+ }else if (Estimators[i] == "hellinger") {
+ treeCalculators.push_back(new Hellinger());
+ }else if (Estimators[i] == "manhattan") {
+ treeCalculators.push_back(new Manhattan());
+ }else if (Estimators[i] == "structpearson") {
+ treeCalculators.push_back(new StructPearson());
+ }else if (Estimators[i] == "soergel") {
+ treeCalculators.push_back(new Soergel());
+ }else if (Estimators[i] == "spearman") {
+ treeCalculators.push_back(new Spearman());
+ }else if (Estimators[i] == "structkulczynski") {
+ treeCalculators.push_back(new StructKulczynski());
+ }else if (Estimators[i] == "speciesprofile") {
+ treeCalculators.push_back(new SpeciesProfile());
+ }else if (Estimators[i] == "hamming") {
+ treeCalculators.push_back(new Hamming());
+ }else if (Estimators[i] == "structchi2") {
+ treeCalculators.push_back(new StructChi2());
+ }else if (Estimators[i] == "gower") {
+ treeCalculators.push_back(new Gower());
+ }else if (Estimators[i] == "memchi2") {
+ treeCalculators.push_back(new MemChi2());
+ }else if (Estimators[i] == "memchord") {
+ treeCalculators.push_back(new MemChord());
+ }else if (Estimators[i] == "memeuclidean") {
+ treeCalculators.push_back(new MemEuclidean());
+ }else if (Estimators[i] == "mempearson") {
+ treeCalculators.push_back(new MemPearson());
}
}
}
int TreeGroupCommand::execute(){
try {
- if (abort == true) { return 0; }
+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
if (format == "sharedfile") {
//if the users entered no valid calculators don't execute command
//create a new filename
outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "tre";
- outputNames.push_back(outputFile);
+ outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
createTree();
//create a new filename
outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
- outputNames.push_back(outputFile);
+ outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
for (int k = 0; k < thisLookup.size(); k++) {
for (int l = k; l < thisLookup.size(); l++) {
//add new pair of sharedrabunds
subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]);
+ //if this calc needs all groups to calculate the pair load all groups
+ if (treeCalculators[i]->getNeedsAll()) {
+ //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+ for (int w = 0; w < thisLookup.size(); w++) {
+ if ((w != k) && (w != l)) { subset.push_back(thisLookup[w]); }
+ }
+ }
+
data = treeCalculators[i]->getValues(subset); //saves the calculator outputs
//cout << thisLookup[k]->getGroup() << '\t' << thisLookup[l]->getGroup() << '\t' << (1.0 - data[0]) << endl;
if (m->control_pressed) { return 1; }
}
}
+ //createdistance file from simMatrix
+ /*string o = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".dist";
+ ofstream outDist;
+ m->openOutputFile(o, outDist);
+ outDist << simMatrix.size() << endl;
+ for (int k = 0; k < simMatrix.size(); k++) {
+ outDist << thisLookup[k]->getGroup() << '\t';
+ for (int l = 0; l < k; l++) {
+ outDist << (1.0-simMatrix[k][l]) << '\t';
+ }
+ outDist << endl;
+ }
+ outDist.close();*/
+
+
if (m->control_pressed) { return 1; }
//creates tree from similarity matrix and write out file
createTree();