+ out << simMatrix[m][n] << '\t';
+ }
+ out << endl;
+ }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "printSims");
+ exit(1);
+ }
+}
+/***********************************************************/
+int 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 k = 0; k < simMatrix.size(); k++) {
+ for (int j = 0; j < simMatrix.size(); j++) {
+ simMatrix[k].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);
+
+ if (m->control_pressed) { return 1; }
+
+ }
+
+ return 0;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "TreeGroupCommand", "makeSimsDist");
+ exit(1);
+ }
+}
+
+/***********************************************************/
+int TreeGroupCommand::makeSimsShared() {
+ try {
+ set<string> processedLabels;
+ set<string> userLabels = labels;
+
+ //as long as you are not at the end of the file or done wih the lines you want
+ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
+ if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i = 0 ; i < treeCalculators.size(); i++) { delete treeCalculators[i]; } return 1; }
+
+ if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ process(lookup);
+
+ processedLabels.insert(lookup[0]->getLabel());
+ userLabels.erase(lookup[0]->getLabel());
+ }
+
+ 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]; }
+ lookup = input->getSharedRAbundVectors(lastLabel);
+
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ process(lookup);
+
+ processedLabels.insert(lookup[0]->getLabel());
+ userLabels.erase(lookup[0]->getLabel());
+
+ //restore real lastlabel to save below
+ lookup[0]->setLabel(saveLabel);
+ }
+
+ lastLabel = lookup[0]->getLabel();
+
+ //get next line to process
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ lookup = input->getSharedRAbundVectors();
+ }
+
+ if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for(int i = 0 ; i < treeCalculators.size(); i++) { delete treeCalculators[i]; } return 1; }
+
+ //output error messages about any remaining user labels
+ set<string>::iterator it;
+ bool needToRun = false;
+ for (it = userLabels.begin(); it != userLabels.end(); it++) {
+ m->mothurOut("Your file does not include the label " + *it);
+ if (processedLabels.count(lastLabel) != 1) {
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
+ needToRun = true;
+ }else {
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();