+
+ format = globaldata->getFormat();
+
+ //required parameters
+ phylipfile = validParameter.validFile(parameters, "phylip", true);
+ if (phylipfile == "not open") { abort = true; }
+ else if (phylipfile == "not found") { 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 { globaldata->newRead(); format = "column"; globaldata->setColumnFile(columnfile); }
+
+ namefile = validParameter.validFile(parameters, "name", true);
+ if (namefile == "not open") { abort = true; }
+ else if (namefile == "not found") { namefile = ""; }
+ else { globaldata->setNameFile(namefile); }
+
+ //error checking on files
+ if ((globaldata->getSharedFile() == "") && ((phylipfile == "") && (columnfile == ""))) { m->mothurOut("You must run the read.otu command or provide a distance file before running the tree.shared command."); m->mothurOutEndLine(); abort = true; }
+ else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the tree.shared command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
+
+ if (columnfile != "") {
+ if (namefile == "") { m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); abort = true; }
+ }
+
+ //check for optional parameter and set defaults
+ // ...at some point should added some additional type checking...
+ label = validParameter.validFile(parameters, "label", false);
+ if (label == "not found") { label = ""; }
+ else {
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
+ else { allLines = 1; }
+ }
+
+ //if the user has not specified any labels use the ones from read.otu
+ if(label == "") {
+ allLines = globaldata->allLines;
+ labels = globaldata->labels;
+ }
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") { calc = "jclass-thetayc"; }
+ else {
+ if (calc == "default") { calc = "jclass-thetayc"; }
+ }
+ m->splitAtDash(calc, Estimators);
+
+ string temp;
+ temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
+ convert(temp, precision);
+
+ temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; }
+ convert(temp, cutoff);
+ cutoff += (5 / (precision * 10.0));
+
+ //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 += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ }
+
+
+ if (abort == false) {
+
+ validCalculator = new ValidCalculators();
+
+ if (format == "sharedfile") {
+ int i;
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator->isValidCalculator("treegroup", Estimators[i]) == true) {
+ if (Estimators[i] == "jabund") {
+ treeCalculators.push_back(new JAbund());
+ }else if (Estimators[i] == "sorabund") {
+ treeCalculators.push_back(new SorAbund());
+ }else if (Estimators[i] == "jclass") {
+ treeCalculators.push_back(new Jclass());
+ }else if (Estimators[i] == "sorclass") {
+ treeCalculators.push_back(new SorClass());
+ }else if (Estimators[i] == "jest") {
+ treeCalculators.push_back(new Jest());
+ }else if (Estimators[i] == "sorest") {
+ treeCalculators.push_back(new SorEst());
+ }else if (Estimators[i] == "thetayc") {
+ treeCalculators.push_back(new ThetaYC());
+ }else if (Estimators[i] == "thetan") {
+ treeCalculators.push_back(new ThetaN());
+ }else if (Estimators[i] == "morisitahorn") {
+ treeCalculators.push_back(new MorHorn());
+ }else if (Estimators[i] == "braycurtis") {
+ treeCalculators.push_back(new BrayCurtis());
+ }
+ }
+ }
+ }
+ }