X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=treegroupscommand.cpp;h=a31c15192f1f27dcc1b84ddf114d0dcf485d41a3;hb=5334a314651228c55fd0f206dec0209bc3148b24;hp=a36e599fb3b04c01d2651423382566a26e7ac6d7;hpb=8bc3e5b38c2317a1715f53be22fa96455868c281;p=mothur.git diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index a36e599..a31c151 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -8,6 +8,10 @@ */ #include "treegroupscommand.h" +#include "sharedsobscollectsummary.h" +#include "sharedchao1.h" +#include "sharedace.h" +#include "sharednseqs.h" #include "sharedjabund.h" #include "sharedsorabund.h" #include "sharedjclass.h" @@ -16,8 +20,35 @@ #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 TreeGroupCommand::getValidParameters(){ @@ -34,6 +65,8 @@ vector TreeGroupCommand::getValidParameters(){ //********************************************************************************************************************** TreeGroupCommand::TreeGroupCommand(){ try { + abort = true; calledHelp = true; + globaldata = GlobalData::getInstance(); //initialize outputTypes vector tempOutNames; outputTypes["tree"] = tempOutNames; @@ -71,14 +104,14 @@ vector TreeGroupCommand::getRequiredFiles(){ 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 @@ -208,7 +241,13 @@ TreeGroupCommand::TreeGroupCommand(string option) { int i; for (i=0; iisValidCalculator("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()); @@ -224,10 +263,62 @@ TreeGroupCommand::TreeGroupCommand(string option) { 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()); } } } @@ -289,7 +380,7 @@ TreeGroupCommand::~TreeGroupCommand(){ 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 @@ -656,6 +747,14 @@ int TreeGroupCommand::process(vector thisLookup) { //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; } @@ -667,6 +766,21 @@ int TreeGroupCommand::process(vector thisLookup) { } } + //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();