]> git.donarmstrong.com Git - mothur.git/blob - clustercommand.cpp
changed random forest output filename
[mothur.git] / clustercommand.cpp
1 /*
2  *  clustercommand.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/2/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "clustercommand.h"
11 #include "readphylip.h"
12 #include "readcolumn.h"
13 #include "readmatrix.hpp"
14 #include "clusterdoturcommand.h"
15
16
17 //**********************************************************************************************************************
18 vector<string> ClusterCommand::setParameters(){ 
19         try {
20                 CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none","list",false,false,true); parameters.push_back(pphylip);
21                 CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName","rabund-sabund",false,false,true); parameters.push_back(pname);
22                 CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pcount);
23         CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName","list",false,false,true); parameters.push_back(pcolumn);          
24                 CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "","",false,false,true); parameters.push_back(pcutoff);
25                 CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
26                 CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "","",false,false,true); parameters.push_back(pmethod);
27                 CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
28                 CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
29                 CommandParameter psim("sim", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(psim);
30                 CommandParameter phard("hard", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(phard);
31                 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
32         //CommandParameter padjust("adjust", "String", "", "F", "", "", "","",false,false); parameters.push_back(padjust);
33                 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
34                 
35                 vector<string> myArray;
36                 for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
37                 return myArray;
38         }
39         catch(exception& e) {
40                 m->errorOut(e, "ClusterCommand", "setParameters");
41                 exit(1);
42         }
43 }
44 //**********************************************************************************************************************
45 string ClusterCommand::getHelpString(){ 
46         try {
47                 string helpString = "";
48                 helpString += "The cluster command parameter options are phylip, column, name, count, method, cuttoff, hard, precision, sim, showabund and timing. Phylip or column and name are required, unless you have a valid current file.\n";
49                 //helpString += "The adjust parameter is used to handle missing distances.  If you set a cutoff, adjust=f by default.  If not, adjust=t by default. Adjust=f, means ignore missing distances and adjust cutoff as needed with the average neighbor method.  Adjust=t, will treat missing distances as 1.0. You can also set the value the missing distances should be set to, adjust=0.5 would give missing distances a value of 0.5.\n";
50         helpString += "The cluster command should be in the following format: \n";
51                 helpString += "cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n";
52                 helpString += "The acceptable cluster methods are furthest, nearest, average and weighted.  If no method is provided then average is assumed.\n";       
53                 return helpString;
54         }
55         catch(exception& e) {
56                 m->errorOut(e, "ClusterCommand", "getHelpString");
57                 exit(1);
58         }
59 }
60 //**********************************************************************************************************************
61 string ClusterCommand::getOutputPattern(string type) {
62     try {
63         string pattern = "";
64         
65         if (type == "list") {  pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; } 
66         else if (type == "rabund") {  pattern = "[filename],[clustertag],rabund"; } 
67         else if (type == "sabund") {  pattern = "[filename],[clustertag],sabund"; }
68         else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
69         
70         return pattern;
71     }
72     catch(exception& e) {
73         m->errorOut(e, "ClusterCommand", "getOutputPattern");
74         exit(1);
75     }
76 }
77 //**********************************************************************************************************************
78 ClusterCommand::ClusterCommand(){       
79         try {
80                 abort = true; calledHelp = true; 
81                 setParameters();
82                 vector<string> tempOutNames;
83                 outputTypes["list"] = tempOutNames;
84                 outputTypes["rabund"] = tempOutNames;
85                 outputTypes["sabund"] = tempOutNames;
86         }
87         catch(exception& e) {
88                 m->errorOut(e, "ClusterCommand", "ClusterCommand");
89                 exit(1);
90         }
91 }
92 //**********************************************************************************************************************
93 //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
94 ClusterCommand::ClusterCommand(string option)  {
95         try{
96                 abort = false; calledHelp = false;   
97                 
98                 //allow user to run help
99                 if(option == "help") { help(); abort = true; calledHelp = true; }
100                 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
101                 
102                 else {
103                         vector<string> myArray = setParameters();
104                         
105                         OptionParser parser(option);
106                         map<string,string> parameters = parser.getParameters();
107                         map<string,string>::iterator it;
108                         
109                         ValidParameters validParameter;
110                 
111                         //check to make sure all parameters are valid for command
112                         for (it = parameters.begin(); it != parameters.end(); it++) { 
113                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
114                                         abort = true;
115                                 }
116                         }
117                         
118                         //initialize outputTypes
119                         vector<string> tempOutNames;
120                         outputTypes["list"] = tempOutNames;
121                         outputTypes["rabund"] = tempOutNames;
122                         outputTypes["sabund"] = tempOutNames;
123                 
124                         //if the user changes the output directory command factory will send this info to us in the output parameter 
125                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
126                         
127                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
128                         if (inputDir == "not found"){   inputDir = "";          }
129                         else {
130                                 string path;
131                                 it = parameters.find("phylip");
132                                 //user has given a template file
133                                 if(it != parameters.end()){ 
134                                         path = m->hasPath(it->second);
135                                         //if the user has not given a path then, add inputdir. else leave path alone.
136                                         if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
137                                 }
138                                 
139                                 it = parameters.find("column");
140                                 //user has given a template file
141                                 if(it != parameters.end()){ 
142                                         path = m->hasPath(it->second);
143                                         //if the user has not given a path then, add inputdir. else leave path alone.
144                                         if (path == "") {       parameters["column"] = inputDir + it->second;           }
145                                 }
146                                 
147                                 it = parameters.find("name");
148                                 //user has given a template file
149                                 if(it != parameters.end()){ 
150                                         path = m->hasPath(it->second);
151                                         //if the user has not given a path then, add inputdir. else leave path alone.
152                                         if (path == "") {       parameters["name"] = inputDir + it->second;             }
153                                 }
154                 
155                 it = parameters.find("count");
156                                 //user has given a template file
157                                 if(it != parameters.end()){ 
158                                         path = m->hasPath(it->second);
159                                         //if the user has not given a path then, add inputdir. else leave path alone.
160                                         if (path == "") {       parameters["count"] = inputDir + it->second;            }
161                                 }
162                         }
163                         
164                         //check for required parameters
165                         phylipfile = validParameter.validFile(parameters, "phylip", true);
166                         if (phylipfile == "not open") { phylipfile = ""; abort = true; }
167                         else if (phylipfile == "not found") { phylipfile = ""; }        
168                         else {  distfile = phylipfile;  format = "phylip";      m->setPhylipFile(phylipfile); }
169                         
170                         columnfile = validParameter.validFile(parameters, "column", true);
171                         if (columnfile == "not open") { columnfile = ""; abort = true; }        
172                         else if (columnfile == "not found") { columnfile = ""; }
173                         else {  distfile = columnfile; format = "column"; m->setColumnFile(columnfile); }
174                         
175                         namefile = validParameter.validFile(parameters, "name", true);
176                         if (namefile == "not open") { abort = true; }   
177                         else if (namefile == "not found") { namefile = ""; }
178                         else { m->setNameFile(namefile); }
179             
180             countfile = validParameter.validFile(parameters, "count", true);
181                         if (countfile == "not open") { abort = true; countfile = ""; }  
182                         else if (countfile == "not found") { countfile = ""; }
183                         else { m->setCountTableFile(countfile); }
184                         
185                         if ((phylipfile == "") && (columnfile == "")) { 
186                                 //is there are current file available for either of these?
187                                 //give priority to column, then phylip
188                                 columnfile = m->getColumnFile(); 
189                                 if (columnfile != "") {  distfile = columnfile; format = "column"; m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
190                                 else { 
191                                         phylipfile = m->getPhylipFile(); 
192                                         if (phylipfile != "") { distfile = phylipfile;  format = "phylip"; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
193                                         else { 
194                                                 m->mothurOut("No valid current files. You must provide a phylip or column file before you can use the cluster command."); m->mothurOutEndLine(); 
195                                                 abort = true;
196                                         }
197                                 }
198                         }
199                         else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a cluster command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
200                         
201                         if (columnfile != "") {
202                                 if ((namefile == "") && (countfile == "")){ 
203                                         namefile = m->getNameFile(); 
204                                         if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
205                                         else { 
206                                                 countfile = m->getCountTableFile();
207                         if (countfile != "") {  m->mothurOut("Using " + countfile + " as input file for the count parameter."); m->mothurOutEndLine(); }
208                         else { 
209                             m->mothurOut("You need to provide a namefile or countfile if you are going to use the column format."); m->mothurOutEndLine(); 
210                             abort = true; 
211                         }       
212                                         }       
213                                 }
214                         }
215                         
216             if ((countfile != "") && (namefile != "")) { m->mothurOut("When executing a cluster command you must enter ONLY ONE of the following: count or name."); m->mothurOutEndLine(); abort = true; }
217             
218                         //check for optional parameter and set defaults
219                         // ...at some point should added some additional type checking...
220                         //get user cutoff and precision or use defaults
221                         string temp;
222                         temp = validParameter.validFile(parameters, "precision", false);
223                         if (temp == "not found") { temp = "100"; }
224                         //saves precision legnth for formatting below
225                         length = temp.length();
226                         m->mothurConvert(temp, precision); 
227                         
228                         temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
229                         hard = m->isTrue(temp);
230                         
231                         temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
232                         sim = m->isTrue(temp); 
233                         
234             //bool cutoffSet = false;
235                         temp = validParameter.validFile(parameters, "cutoff", false);
236                         if (temp == "not found") { temp = "10"; }
237             //else { cutoffSet = true; }
238                         m->mothurConvert(temp, cutoff); 
239                         cutoff += (5 / (precision * 10.0));
240             
241             //temp = validParameter.validFile(parameters, "adjust", false);                             if (temp == "not found") { temp = "F"; }
242             //if (m->isNumeric1(temp))    { m->mothurConvert(temp, adjust);   }
243             //else if (m->isTrue(temp))   { adjust = 1.0;                     }
244             //else                        { adjust = -1.0;                    }
245             adjust=-1.0;
246                         
247                         method = validParameter.validFile(parameters, "method", false);
248                         if (method == "not found") { method = "average"; }
249                         
250                         if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
251                         else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average, and weighted."); m->mothurOutEndLine(); abort = true; }
252
253                         showabund = validParameter.validFile(parameters, "showabund", false);
254                         if (showabund == "not found") { showabund = "T"; }
255
256                         timing = validParameter.validFile(parameters, "timing", false);
257                         if (timing == "not found") { timing = "F"; }
258                         
259                 }
260         }
261         catch(exception& e) {
262                 m->errorOut(e, "ClusterCommand", "ClusterCommand");
263                 exit(1);
264         }
265 }
266 //**********************************************************************************************************************
267 ClusterCommand::~ClusterCommand(){}
268 //**********************************************************************************************************************
269
270 int ClusterCommand::execute(){
271         try {
272         
273                 if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
274                 
275                 //phylip file given and cutoff not given - use cluster.classic because it uses less memory and is faster
276                 if ((format == "phylip") && (cutoff > 10.0)) {
277                         m->mothurOutEndLine(); m->mothurOut("You are using a phylip file and no cutoff.  I will run cluster.classic to save memory and time."); m->mothurOutEndLine();
278                         
279                         //run unique.seqs for deconvolute results
280                         string inputString = "phylip=" + distfile;
281                         if (namefile != "") { inputString += ", name=" + namefile; }
282             else if (countfile != "") { inputString += ", count=" + countfile; }
283                         inputString += ", precision=" + toString(precision);
284                         inputString += ", method=" + method;
285                         if (hard)       { inputString += ", hard=T";    }
286                         else            { inputString += ", hard=F";    }
287                         if (sim)        { inputString += ", sim=T";             }
288                         else            { inputString += ", sim=F";             }
289
290                         
291                         m->mothurOutEndLine(); 
292                         m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine(); 
293                         m->mothurOut("Running command: cluster.classic(" + inputString + ")"); m->mothurOutEndLine(); 
294                         
295                         Command* clusterClassicCommand = new ClusterDoturCommand(inputString);
296                         clusterClassicCommand->execute();
297                         delete clusterClassicCommand;
298                         
299                         m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine();  
300
301                         return 0;
302                 }
303                 
304                 ReadMatrix* read;
305                 if (format == "column") { read = new ReadColumnMatrix(columnfile, sim); }       //sim indicates whether its a similarity matrix
306                 else if (format == "phylip") { read = new ReadPhylipMatrix(phylipfile, sim); }
307                 
308                 read->setCutoff(cutoff);
309                 
310                 NameAssignment* nameMap = NULL;
311         CountTable* ct = NULL;
312                 if(namefile != ""){     
313                         nameMap = new NameAssignment(namefile);
314                         nameMap->readMap();
315             read->read(nameMap);
316                 }else if (countfile != "") {
317             ct = new CountTable();
318             ct->readTable(countfile, false);
319             read->read(ct);
320         }else { read->read(nameMap); }
321                 
322                 list = read->getListVector();
323                 matrix = read->getDMatrix();
324         
325                 if(countfile != "") {
326             rabund = new RAbundVector();
327             createRabund(ct, list, rabund); //creates an rabund that includes the counts for the unique list
328             delete ct;
329         }else { rabund = new RAbundVector(list->getRAbundVector()); }
330                 delete read;
331                 
332                 if (m->control_pressed) { //clean up
333                         delete list; delete matrix; delete rabund; if(countfile == ""){rabundFile.close(); sabundFile.close();  m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); }
334                         listFile.close(); m->mothurRemove((fileroot+ tag + ".list")); outputTypes.clear(); return 0;
335                 }
336                 
337                 //create cluster
338                 if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method, adjust); }
339                 else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff, method, adjust); }
340                 else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff, method, adjust);     }
341                 else if(method == "weighted"){  cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method, adjust);    }
342                 tag = cluster->getTag();
343                 
344                 if (outputDir == "") { outputDir += m->hasPath(distfile); }
345                 fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
346                 
347         map<string, string> variables; 
348         variables["[filename]"] = fileroot;
349         variables["[clustertag]"] = tag;
350         string sabundFileName = getOutputFileName("sabund", variables);
351         string rabundFileName = getOutputFileName("rabund", variables);
352         if (countfile != "") { variables["[tag2]"] = "unique_list"; }
353         string listFileName = getOutputFileName("list", variables);
354         
355         if (countfile == "") {
356             m->openOutputFile(sabundFileName,   sabundFile);
357             m->openOutputFile(rabundFileName,   rabundFile);
358             outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
359             outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
360
361         }
362                 m->openOutputFile(listFileName, listFile);
363         outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
364                 
365                 
366                 time_t estart = time(NULL);
367                 float previousDist = 0.00000;
368                 float rndPreviousDist = 0.00000;
369                 oldRAbund = *rabund;
370                 oldList = *list;
371
372                 print_start = true;
373                 start = time(NULL);
374                 loops = 0;
375                 double saveCutoff = cutoff;
376                 
377                 while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){  
378                 
379                         if (m->control_pressed) { //clean up
380                                 delete list; delete matrix; delete rabund; delete cluster;
381                                 if(countfile == "") {rabundFile.close(); sabundFile.close();  m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); }
382                 listFile.close(); m->mothurRemove((fileroot+ tag + ".list")); outputTypes.clear(); return 0;
383                         }
384                 
385                         if (print_start && m->isTrue(timing)) {
386                                 m->mothurOut("Clustering (" + tag + ") dist " + toString(matrix->getSmallDist()) + "/" 
387                                         + toString(m->roundDist(matrix->getSmallDist(), precision)) 
388                                         + "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
389                                 cout.flush();
390                                 print_start = false;
391                         }
392
393                         loops++;
394
395                         cluster->update(cutoff);
396             
397             float dist = matrix->getSmallDist();
398                         float rndDist;
399                         if (hard) {
400                                 rndDist = m->ceilDist(dist, precision); 
401                         }else{
402                                 rndDist = m->roundDist(dist, precision); 
403                         }
404
405                         if(previousDist <= 0.0000 && dist != previousDist){
406                                 printData("unique");
407                         }
408                         else if(rndDist != rndPreviousDist){
409                                 printData(toString(rndPreviousDist,  length-1));
410                         }
411                 
412                         previousDist = dist;
413                         rndPreviousDist = rndDist;
414                         oldRAbund = *rabund;
415                         oldList = *list;
416                 }
417
418                 if (print_start && m->isTrue(timing)) {
419                         m->mothurOut("Clustering (" + tag + ") for distance " + toString(previousDist) + "/" + toString(rndPreviousDist) 
420                                          + "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
421                         cout.flush();
422                         print_start = false;
423                 }
424                 
425                 if(previousDist <= 0.0000){
426                         printData("unique");
427                 }
428                 else if(rndPreviousDist<cutoff){
429                         printData(toString(rndPreviousDist, length-1));
430                 }
431                 
432                 delete matrix;
433                 delete list;
434                 delete rabund;
435                 delete cluster;
436         if (countfile == "") {
437             sabundFile.close();
438             rabundFile.close();
439         }
440                 listFile.close();
441         
442                 if (saveCutoff != cutoff) { 
443                         if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
444                         else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
445
446                         m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
447                 }
448                 
449                 //set list file as new current listfile
450                 string current = "";
451                 itTypes = outputTypes.find("list");
452                 if (itTypes != outputTypes.end()) {
453                         if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
454                 }
455                 
456                 //set rabund file as new current rabundfile
457                 itTypes = outputTypes.find("rabund");
458                 if (itTypes != outputTypes.end()) {
459                         if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
460                 }
461                 
462                 //set sabund file as new current sabundfile
463                 itTypes = outputTypes.find("sabund");
464                 if (itTypes != outputTypes.end()) {
465                         if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
466                 }
467                 
468                 m->mothurOutEndLine();
469                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
470                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
471                 m->mothurOutEndLine();
472
473                 
474                 //if (m->isTrue(timing)) {
475                         m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
476                 //}
477                 
478                 
479                 return 0;
480         }
481         catch(exception& e) {
482                 m->errorOut(e, "ClusterCommand", "execute");
483                 exit(1);
484         }
485 }
486
487 //**********************************************************************************************************************
488
489 void ClusterCommand::printData(string label){
490         try {
491                 if (m->isTrue(timing)) {
492                         m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins()) 
493                      + "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
494                 }
495                 print_start = true;
496                 loops = 0;
497                 start = time(NULL);
498         
499         oldRAbund.setLabel(label);
500         if (countfile == "") {
501             oldRAbund.print(rabundFile);
502             oldRAbund.getSAbundVector().print(sabundFile);
503         }
504        
505         if (m->isTrue(showabund)) {
506             oldRAbund.getSAbundVector().print(cout);
507         }
508         
509                 oldList.setLabel(label);
510                 oldList.print(listFile);
511         }
512         catch(exception& e) {
513                 m->errorOut(e, "ClusterCommand", "printData");
514                 exit(1);
515         }
516
517
518 }
519 //**********************************************************************************************************************
520
521 int ClusterCommand::createRabund(CountTable*& ct, ListVector*& list, RAbundVector*& rabund){
522     try {
523         rabund->setLabel(list->getLabel());        
524         for(int i = 0; i < list->getNumBins(); i++) { 
525             if (m->control_pressed) { break; }
526             vector<string> binNames;
527             string bin = list->get(i);
528             m->splitAtComma(bin, binNames);
529             int total = 0;
530             for (int j = 0; j < binNames.size(); j++) { total += ct->getNumSeqs(binNames[j]);  }
531             rabund->push_back(total);   
532         }
533         return 0;
534     }
535     catch(exception& e) {
536                 m->errorOut(e, "ClusterCommand", "createRabund");
537                 exit(1);
538         }
539     
540 }
541 //**********************************************************************************************************************