+}
+/***********************************************************/
+void UnifracWeightedCommand::createPhylipFile() {
+ try {
+ int count = 0;
+ //for each tree
+ for (int i = 0; i < T.size(); i++) {
+
+ string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted.dist";
+ outputNames.push_back(phylipFileName);
+ ofstream out;
+ openOutputFile(phylipFileName, out);
+
+ //output numSeqs
+ out << globaldata->Groups.size() << endl;
+
+ //make matrix with scores in it
+ vector< vector<float> > dists; dists.resize(globaldata->Groups.size());
+ for (int i = 0; i < globaldata->Groups.size(); i++) {
+ dists[i].resize(globaldata->Groups.size(), 0.0);
+ }
+
+ //flip it so you can print it
+ for (int r=0; r<globaldata->Groups.size(); r++) {
+ for (int l = r+1; l < globaldata->Groups.size(); l++) {
+ dists[r][l] = utreeScores[count];
+ dists[l][r] = utreeScores[count];
+ count++;
+ }
+ }
+
+ //output to file
+ for (int r=0; r<globaldata->Groups.size(); r++) {
+ //output name
+ string name = globaldata->Groups[r];
+ if (name.length() < 10) { //pad with spaces to make compatible
+ while (name.length() < 10) { name += " "; }
+ }
+ out << name << '\t';
+
+ //output distances
+ for (int l = 0; l < r; l++) { out << dists[r][l] << '\t'; }
+ out << endl;
+ }
+ out.close();
+ }
+ }
+ catch(exception& e) {
+ m->errorOut(e, "UnifracWeightedCommand", "createPhylipFile");
+ exit(1);
+ }
+}
+/***********************************************************/
+int UnifracWeightedCommand::findIndex(float score, int index) {
+ try{
+ for (int i = 0; i < rScores[index].size(); i++) {
+ if (rScores[index][i] >= score) { return i; }
+ }
+ return rScores[index].size();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "UnifracWeightedCommand", "findIndex");