//**********************************************************************************************************************
ClusterSplitCommand::ClusterSplitCommand(){
try {
- abort = true;
- //initialize outputTypes
+ abort = true; calledHelp = true;
vector<string> tempOutNames;
outputTypes["list"] = tempOutNames;
outputTypes["rabund"] = tempOutNames;
outputTypes["sabund"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
ClusterSplitCommand::ClusterSplitCommand(string option) {
try{
globaldata = GlobalData::getInstance();
- abort = false;
+ abort = false; calledHelp = false;
format = "";
//allow user to run help
- if(option == "help") { help(); abort = true; }
+ if(option == "help") { help(); abort = true; calledHelp = true; }
else {
//valid paramters for this command
outputTypes["list"] = tempOutNames;
outputTypes["rabund"] = tempOutNames;
outputTypes["sabund"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
globaldata->newRead();
int ClusterSplitCommand::execute(){
try {
- if (abort == true) { return 0; }
+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
time_t estart;
vector<string> listFileNames;
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();
//for each file group figure out which process will complete it
//want to divide the load intelligently so the big files are spread between processes
- int count = 1;
for (int i = 0; i < distName.size(); i++) {
int processToAssign = (i+1) % processors;
if (processToAssign == 0) { processToAssign = processors; }
//for each file group figure out which process will complete it
//want to divide the load intelligently so the big files are spread between processes
- int count = 1;
for (int i = 0; i < distName.size(); i++) {
int processToAssign = (i+1) % processors;
if (processToAssign == 0) { processToAssign = processors; }
m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to merge."); m->mothurOutEndLine();
+ //set list file as new current listfile
+ string current = "";
+ itTypes = outputTypes.find("list");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
+ }
+
+ //set rabund file as new current rabundfile
+ itTypes = outputTypes.find("rabund");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
+ }
+
+ //set sabund file as new current sabundfile
+ itTypes = outputTypes.find("sabund");
+ if (itTypes != outputTypes.end()) {
+ if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
+ }
+
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
m->openOutputFile(fileroot+ tag + ".list", listFile);
listFileNames.push_back(fileroot+ tag + ".list");
-
- time_t estart = time(NULL);
-
+
float previousDist = 0.00000;
float rndPreviousDist = 0.00000;
}
+//**********************************************************************************************************************
+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
+
+ return 0;
+
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "ClusterSplitCommand", "createMergedDistanceFile");
+ exit(1);
+ }
+}
//**********************************************************************************************************************