+void TreeGroupCommand::makeSimsDist() {
+ try {
+ numGroups = list->size();
+
+ //initialize index
+ index.clear();
+ for (int g = 0; g < numGroups; g++) { index[g] = g; }
+
+ //initialize simMatrix
+ simMatrix.clear();
+ simMatrix.resize(numGroups);
+ for (int m = 0; m < simMatrix.size(); m++) {
+ for (int j = 0; j < simMatrix.size(); j++) {
+ simMatrix[m].push_back(0.0);
+ }
+ }
+
+ //go through sparse matrix and fill sims
+ //go through each cell in the sparsematrix
+ for(MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++){
+ //similairity = -(distance-1)
+ simMatrix[currentCell->row][currentCell->column] = -(currentCell->dist -1.0);
+ simMatrix[currentCell->column][currentCell->row] = -(currentCell->dist -1.0);
+ }
+
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function makeSimsDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the TreeGroupCommand class function makeSimsDist. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************/
+void TreeGroupCommand::makeSimsShared() {
+ try {
+ int count = 1;
+ EstOutput data;
+ vector<SharedRAbundVector*> subset;
+
+ numGroups = globaldata->Groups.size();
+
+ //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;
+
+ while(lookup[0] != NULL){
+
+ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lookup[0]->getLabel()) == 1){
+
+ cout << lookup[0]->getLabel() << '\t' << count << endl;
+
+ //for each calculator
+ for(int i = 0 ; i < treeCalculators.size(); i++) {
+ //initialize simMatrix
+ simMatrix.clear();
+ simMatrix.resize(numGroups);
+ for (int m = 0; m < simMatrix.size(); m++) {
+ for (int j = 0; j < simMatrix.size(); j++) {
+ simMatrix[m].push_back(0.0);
+ }
+ }
+
+ //initialize index
+ index.clear();
+ for (int g = 0; g < numGroups; g++) { index[g] = g; }
+
+ //create a new filename
+ outputFile = getRootName(globaldata->inputFileName) + treeCalculators[i]->getName() + "." + lookup[0]->getLabel() + ".tre";
+
+ for (int k = 0; k < lookup.size(); k++) {
+ for (int l = k; l < lookup.size(); l++) {
+ if (k != l) { //we dont need to similiarity of a groups to itself
+ //get estimated similarity between 2 groups
+
+ subset.clear(); //clear out old pair of sharedrabunds
+ //add new pair of sharedrabunds
+ subset.push_back(lookup[k]); subset.push_back(lookup[l]);
+
+ data = treeCalculators[i]->getValues(subset); //saves the calculator outputs
+ //save values in similarity matrix
+ simMatrix[k][l] = data[0];
+ simMatrix[l][k] = data[0];
+ }
+ }
+ }
+
+ //creates tree from similarity matrix and write out file
+ createTree();
+ }
+ }
+
+ //prevent memory leak
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+
+ //get next line to process
+ lookup = input->getSharedRAbundVectors();
+ count++;
+ }
+
+ for(int i = 0 ; i < treeCalculators.size(); i++) { delete treeCalculators[i]; }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function makeSimsShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the TreeGroupCommand class function makeSimsShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************/