#include "sharedmorisitahorn.h"
#include "sharedbraycurtis.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;
+ 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) {
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 = ""; }
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
phylipfile = validParameter.validFile(parameters, "phylip", true);
if (phylipfile == "not open") { abort = true; }
else if (phylipfile == "not found") { phylipfile = ""; }
- else { format = "phylip"; globaldata->setPhylipFile(phylipfile); }
+ else { globaldata->newRead(); format = "phylip"; globaldata->setPhylipFile(phylipfile); }
columnfile = validParameter.validFile(parameters, "column", true);
if (columnfile == "not open") { abort = true; }
else if (columnfile == "not found") { columnfile = ""; }
- else { format = "column"; globaldata->setColumnFile(columnfile); }
+ else { globaldata->newRead(); format = "column"; globaldata->setColumnFile(columnfile); }
namefile = validParameter.validFile(parameters, "name", true);
if (namefile == "not open") { abort = true; }
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
else {
if (calc == "default") { calc = "jclass-thetayc"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
//if the user changes the output directory command factory will send this info to us in the output parameter
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
if (format == "sharedfile") {
//if the users entered no valid calculators don't execute command
if (treeCalculators.size() == 0) { m->mothurOut("You have given no valid calculators."); m->mothurOutEndLine(); return 0; }
-
+
+ if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; globaldata->gGroupmap = NULL; }
//you have groups
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
//used in tree constructor
globaldata->runParse = false;
- //clear globaldatas old tree names if any
- globaldata->Treenames.clear();
-
- //fills globaldatas tree names
- globaldata->Treenames = globaldata->Groups;
-
//create treemap class from groupmap for tree class to use
tmap = new TreeMap();
tmap->makeSim(globaldata->gGroupmap);
globaldata->gTreemap = tmap;
+ //clear globaldatas old tree names if any
+ globaldata->Treenames.clear();
+
+ //fills globaldatas tree names
+ globaldata->Treenames = globaldata->Groups;
+
if (m->control_pressed) { return 0; }
//create tree file
if (m->control_pressed) { return 0; }
//create a new filename
- outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "tre";
- outputNames.push_back(outputFile);
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "tre";
+ outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
createTree();
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
for (int g = 0; g < numGroups; g++) { index[g] = g; }
//create a new filename
- outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
- outputNames.push_back(outputFile);
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
+ 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++) {
subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]);
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; }
//save values in similarity matrix