+}
+/***********************************************************/
+int BootSharedCommand::process(SharedOrderVector* order) {
+ try{
+ EstOutput data;
+ vector<SharedRAbundVector*> subset;
+
+ //open an ostream for each calc to print to
+ for (int z = 0; z < treeCalculators.size(); z++) {
+ //create a new filename
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
+ m->openOutputFile(outputFile, *(out[z]));
+ outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
+ }
+
+ m->mothurOut("Generating bootstrap trees..."); cout.flush();
+
+ //create a file for each calculator with the 1000 trees in it.
+ for (int p = 0; p < iters; p++) {
+
+ if (m->control_pressed) { return 1; }
+
+ util->getSharedVectorswithReplacement(globaldata->Groups, lookup, order); //fills group vectors from order vector.
+
+
+ //for each calculator
+ for(int i = 0 ; i < treeCalculators.size(); i++) {
+
+ if (m->control_pressed) { return 1; }
+
+ //initialize simMatrix
+ simMatrix.clear();
+ simMatrix.resize(numGroups);
+ for (int o = 0; o < simMatrix.size(); o++) {
+ for (int j = 0; j < simMatrix.size(); j++) {
+ simMatrix[o].push_back(0.0);
+ }
+ }
+
+ //initialize index
+ index.clear();
+ for (int g = 0; g < numGroups; g++) { index[g] = g; }
+
+ for (int k = 0; k < lookup.size(); k++) { // pass cdd each set of groups to commpare
+ for (int l = k; l < lookup.size(); l++) {
+ if (k != l) { //we dont need to similiarity of a groups to itself
+ subset.clear(); //clear out old pair of sharedrabunds
+ //add new pair of sharedrabunds
+ subset.push_back(lookup[k]); subset.push_back(lookup[l]);
+
+ //get estimated similarity between 2 groups
+ data = treeCalculators[i]->getValues(subset); //saves the calculator outputs
+ //save values in similarity matrix
+ simMatrix[k][l] = data[0];
+ simMatrix[l][k] = data[0];
+ }
+ }
+ }
+
+ tempTree = new Tree();
+
+ if (m->control_pressed) { delete tempTree; return 1; }
+
+ //creates tree from similarity matrix and write out file
+ createTree(out[i], tempTree);
+
+ if (m->control_pressed) { delete tempTree; return 1; }
+
+ //save trees for consensus command.
+ trees[i].push_back(tempTree);
+ }
+ }
+
+ m->mothurOut("\tDone."); m->mothurOutEndLine();
+ //delete globaldata's tree
+ //for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
+ //globaldata->gTree.clear();
+
+
+ //create consensus trees for each bootstrapped tree set
+ for (int k = 0; k < trees.size(); k++) {
+
+ m->mothurOut("Generating consensus tree for " + treeCalculators[k]->getName()); m->mothurOutEndLine();
+
+ if (m->control_pressed) { return 1; }
+
+ //set global data to calc trees
+ globaldata->gTree = trees[k];
+
+ string filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
+ consensus = new ConcensusCommand(filename);
+ consensus->execute();
+ delete consensus;
+
+ outputNames.push_back(filename + ".cons.pairs");
+ outputNames.push_back(filename + ".cons.tre");
+
+ //delete globaldata's tree
+ //for (int m = 0; m < globaldata->gTree.size(); m++) { delete globaldata->gTree[m]; }
+ //globaldata->gTree.clear();
+
+ }
+
+
+
+ //close ostream for each calc
+ for (int z = 0; z < treeCalculators.size(); z++) { out[z]->close(); }
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "BootSharedCommand", "process");