outputTypes["list"] = tempOutNames;
outputTypes["rabund"] = tempOutNames;
outputTypes["sabund"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
outputTypes["list"] = tempOutNames;
outputTypes["rabund"] = tempOutNames;
outputTypes["sabund"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
globaldata->newRead();
vector< map<string, string> > distName = split->getDistanceFiles(); //returns map of distance files -> namefile sorted by distance file size
delete split;
+ //output a merged distance file
+ if (splitmethod == "fasta") { createMergedDistanceFile(distName); }
+
+
if (m->control_pressed) { return 0; }
m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to split the distance file."); m->mothurOutEndLine();
outLabels.close();
exit(0);
- }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
+ }else {
+ m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine();
+ for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
+ exit(0);
+ }
}
//force parent to wait until all the processes are done
}
+//**********************************************************************************************************************
+int ClusterSplitCommand::createMergedDistanceFile(vector< map<string, string> > distNames) {
+ try{
+
+#ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+
+ if (pid != 0) {
+#endif
+
+ string thisOutputDir = outputDir;
+ if (outputDir == "") { thisOutputDir = m->hasPath(fastafile); }
+ string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist";
+ remove(outputFileName.c_str());
+
+
+ for (int i = 0; i < distNames.size(); i++) {
+ if (m->control_pressed) { return 0; }
+
+ string thisDistFile = distNames[i].begin()->first;
+
+ m->appendFiles(thisDistFile, outputFileName);
+ }
+
+ outputTypes["column"].push_back(outputFileName); outputNames.push_back(outputFileName);
+
+#ifdef USE_MPI
+ }
+#endif
+
+
+
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "ClusterSplitCommand", "createMergedDistanceFile");
+ exit(1);
+ }
+}
//**********************************************************************************************************************