+
+ sharedfile = validParameter.validFile(parameters, "shared", true);
+ if (sharedfile == "not found") {
+ //if there is a current shared file, use it
+ sharedfile = m->getSharedFile();
+ if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
+ else { m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
+ }else if (sharedfile == "not open") { sharedfile = ""; abort = true; }
+ else { m->setSharedFile(sharedfile); }
+
+ //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(sharedfile); //if user entered a file with a path then preserve it
+ }
+
+ //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; }
+ }
+
+ output = validParameter.validFile(parameters, "output", false); if(output == "not found"){ output = "lt"; }
+ if ((output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are lt and square. I will use lt."); m->mothurOutEndLine(); output = "lt"; }
+
+ mode = validParameter.validFile(parameters, "mode", false); if(mode == "not found"){ mode = "average"; }
+ if ((mode != "average") && (mode != "median")) { m->mothurOut(mode + " is not a valid mode. Options are average and medina. I will use average."); m->mothurOutEndLine(); output = "average"; }
+
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; }
+ else {
+ m->splitAtDash(groups, Groups);
+ m->setGroups(Groups);
+ }
+
+ string temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
+ m->setProcessors(temp);
+ m->mothurConvert(temp, processors);
+
+ calc = validParameter.validFile(parameters, "calc", false);
+ if (calc == "not found") { calc = "jclass-thetayc"; }
+ else {
+ if (calc == "default") { calc = "jclass-thetayc"; }
+ }
+ m->splitAtDash(calc, Estimators);
+ if (m->inUsersGroups("citation", Estimators)) {
+ ValidCalculators validCalc; validCalc.printCitations(Estimators);
+ //remove citation from list of calcs
+ for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") { Estimators.erase(Estimators.begin()+i); break; } }
+ }
+
+ temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "1000"; }
+ m->mothurConvert(temp, iters);
+
+ temp = validParameter.validFile(parameters, "subsample", false); if (temp == "not found") { temp = "F"; }
+ if (m->isNumeric1(temp)) { m->mothurConvert(temp, subsampleSize); subsample = true; }
+ else {
+ if (m->isTrue(temp)) { subsample = true; subsampleSize = -1; } //we will set it to smallest group later
+ else { subsample = false; }
+ }
+
+ if (subsample == false) { iters = 0; }
+
+ if (abort == false) {
+
+ ValidCalculators validCalculator;
+
+ int i;
+ for (i=0; i<Estimators.size(); i++) {
+ if (validCalculator.isValidCalculator("matrix", Estimators[i]) == true) {
+ if (Estimators[i] == "sharedsobs") {
+ matrixCalculators.push_back(new SharedSobsCS());
+ }else if (Estimators[i] == "sharedchao") {
+ matrixCalculators.push_back(new SharedChao1());
+ }else if (Estimators[i] == "sharedace") {
+ matrixCalculators.push_back(new SharedAce());
+ }else if (Estimators[i] == "jabund") {
+ matrixCalculators.push_back(new JAbund());
+ }else if (Estimators[i] == "sorabund") {
+ matrixCalculators.push_back(new SorAbund());
+ }else if (Estimators[i] == "jclass") {
+ matrixCalculators.push_back(new Jclass());
+ }else if (Estimators[i] == "sorclass") {
+ matrixCalculators.push_back(new SorClass());
+ }else if (Estimators[i] == "jest") {
+ matrixCalculators.push_back(new Jest());
+ }else if (Estimators[i] == "sorest") {
+ matrixCalculators.push_back(new SorEst());
+ }else if (Estimators[i] == "thetayc") {
+ matrixCalculators.push_back(new ThetaYC());
+ }else if (Estimators[i] == "thetan") {
+ matrixCalculators.push_back(new ThetaN());
+ }else if (Estimators[i] == "kstest") {
+ matrixCalculators.push_back(new KSTest());
+ }else if (Estimators[i] == "sharednseqs") {
+ matrixCalculators.push_back(new SharedNSeqs());
+ }else if (Estimators[i] == "ochiai") {
+ matrixCalculators.push_back(new Ochiai());
+ }else if (Estimators[i] == "anderberg") {
+ matrixCalculators.push_back(new Anderberg());
+ }else if (Estimators[i] == "kulczynski") {
+ matrixCalculators.push_back(new Kulczynski());
+ }else if (Estimators[i] == "kulczynskicody") {
+ matrixCalculators.push_back(new KulczynskiCody());
+ }else if (Estimators[i] == "lennon") {
+ matrixCalculators.push_back(new Lennon());
+ }else if (Estimators[i] == "morisitahorn") {
+ matrixCalculators.push_back(new MorHorn());
+ }else if (Estimators[i] == "braycurtis") {
+ matrixCalculators.push_back(new BrayCurtis());
+ }else if (Estimators[i] == "whittaker") {
+ matrixCalculators.push_back(new Whittaker());
+ }else if (Estimators[i] == "odum") {
+ matrixCalculators.push_back(new Odum());
+ }else if (Estimators[i] == "canberra") {
+ matrixCalculators.push_back(new Canberra());
+ }else if (Estimators[i] == "structeuclidean") {
+ matrixCalculators.push_back(new StructEuclidean());
+ }else if (Estimators[i] == "structchord") {
+ matrixCalculators.push_back(new StructChord());
+ }else if (Estimators[i] == "hellinger") {
+ matrixCalculators.push_back(new Hellinger());
+ }else if (Estimators[i] == "manhattan") {
+ matrixCalculators.push_back(new Manhattan());
+ }else if (Estimators[i] == "structpearson") {
+ matrixCalculators.push_back(new StructPearson());
+ }else if (Estimators[i] == "soergel") {
+ matrixCalculators.push_back(new Soergel());
+ }else if (Estimators[i] == "spearman") {
+ matrixCalculators.push_back(new Spearman());
+ }else if (Estimators[i] == "structkulczynski") {
+ matrixCalculators.push_back(new StructKulczynski());
+ }else if (Estimators[i] == "speciesprofile") {
+ matrixCalculators.push_back(new SpeciesProfile());
+ }else if (Estimators[i] == "hamming") {
+ matrixCalculators.push_back(new Hamming());
+ }else if (Estimators[i] == "structchi2") {
+ matrixCalculators.push_back(new StructChi2());
+ }else if (Estimators[i] == "gower") {
+ matrixCalculators.push_back(new Gower());
+ }else if (Estimators[i] == "memchi2") {
+ matrixCalculators.push_back(new MemChi2());
+ }else if (Estimators[i] == "memchord") {
+ matrixCalculators.push_back(new MemChord());
+ }else if (Estimators[i] == "memeuclidean") {
+ matrixCalculators.push_back(new MemEuclidean());
+ }else if (Estimators[i] == "mempearson") {
+ matrixCalculators.push_back(new MemPearson());
+ }
+ }
+ }
+
+ }