]> git.donarmstrong.com Git - mothur.git/blob - clustersplitcommand.cpp
added cluster.split command
[mothur.git] / clustersplitcommand.cpp
1 /*
2  *  clustersplitcommand.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 5/19/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "clustersplitcommand.h"
11 #include "readcluster.h"
12 #include "splitmatrix.h"
13 #include "readphylip.h"
14 #include "readcolumn.h"
15 #include "readmatrix.hpp"
16 #include "inputdata.h"
17
18 //**********************************************************************************************************************
19 //This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
20 ClusterSplitCommand::ClusterSplitCommand(string option)  {
21         try{
22                 globaldata = GlobalData::getInstance();
23                 abort = false;
24                 
25                 //allow user to run help
26                 if(option == "help") { help(); abort = true; }
27                 
28                 else {
29                         //valid paramters for this command
30                         string Array[] =  {"phylip","column","name","cutoff","precision","method","showabund","timing","hard","processors","splitcutoff","outputdir","inputdir"};
31                         vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
32                         
33                         OptionParser parser(option);
34                         map<string,string> parameters = parser.getParameters();
35                         
36                         ValidParameters validParameter;
37                 
38                         //check to make sure all parameters are valid for command
39                         map<string,string>::iterator it;
40                         for (it = parameters.begin(); it != parameters.end(); it++) { 
41                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
42                                         abort = true;
43                                 }
44                         }
45                         
46                         globaldata->newRead();
47                         
48                         //if the user changes the output directory command factory will send this info to us in the output parameter 
49                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
50                         
51                                 //if the user changes the input directory command factory will send this info to us in the output parameter 
52                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
53                         if (inputDir == "not found"){   inputDir = "";          }
54                         else {
55                                 string path;
56                                 it = parameters.find("phylip");
57                                 //user has given a template file
58                                 if(it != parameters.end()){ 
59                                         path = hasPath(it->second);
60                                         //if the user has not given a path then, add inputdir. else leave path alone.
61                                         if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
62                                 }
63                                 
64                                 it = parameters.find("column");
65                                 //user has given a template file
66                                 if(it != parameters.end()){ 
67                                         path = hasPath(it->second);
68                                         //if the user has not given a path then, add inputdir. else leave path alone.
69                                         if (path == "") {       parameters["column"] = inputDir + it->second;           }
70                                 }
71                                 
72                                 it = parameters.find("name");
73                                 //user has given a template file
74                                 if(it != parameters.end()){ 
75                                         path = hasPath(it->second);
76                                         //if the user has not given a path then, add inputdir. else leave path alone.
77                                         if (path == "") {       parameters["name"] = inputDir + it->second;             }
78                                 }
79                         }
80                         
81                         //check for required parameters
82                         phylipfile = validParameter.validFile(parameters, "phylip", true);
83                         if (phylipfile == "not open") { abort = true; }
84                         else if (phylipfile == "not found") { phylipfile = ""; }        
85                         else {  distfile = phylipfile;  format = "phylip";      }
86                         
87                         columnfile = validParameter.validFile(parameters, "column", true);
88                         if (columnfile == "not open") { abort = true; } 
89                         else if (columnfile == "not found") { columnfile = ""; }
90                         else {  distfile = columnfile; format = "column";       }
91                         
92                         namefile = validParameter.validFile(parameters, "name", true);
93                         if (namefile == "not open") { abort = true; }   
94                         else if (namefile == "not found") { namefile = ""; }
95                         
96                         if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a hcluster command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
97                         else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a hcluster command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
98                 
99                         if (columnfile != "") {
100                                 if (namefile == "") {  cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
101                         }
102                                         
103                         //check for optional parameter and set defaults
104                         // ...at some point should added some additional type checking...
105                         //get user cutoff and precision or use defaults
106                         string temp;
107                         temp = validParameter.validFile(parameters, "precision", false);
108                         if (temp == "not found") { temp = "100"; }
109                         //saves precision legnth for formatting below
110                         length = temp.length();
111                         convert(temp, precision); 
112                         
113                         temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "F"; }
114                         hard = isTrue(temp);
115                         
116                         temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = "1";                             }
117                         convert(temp, processors); 
118                         
119                         temp = validParameter.validFile(parameters, "cutoff", false);
120                         if (temp == "not found") { temp = "10"; }
121                         convert(temp, cutoff); 
122                         if (!hard) {    cutoff += (5 / (precision * 10.0));  }
123                         
124                         temp = validParameter.validFile(parameters, "splitcutoff", false);
125                         if (temp == "not found") { temp = "0.10"; }
126                         convert(temp, splitcutoff); 
127                         if (!hard) {    splitcutoff += (5 / (precision * 10.0));  }
128                         
129                         method = validParameter.validFile(parameters, "method", false);
130                         if (method == "not found") { method = "furthest"; }
131                         
132                         if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
133                         else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
134
135                         showabund = validParameter.validFile(parameters, "showabund", false);
136                         if (showabund == "not found") { showabund = "T"; }
137
138                         timing = validParameter.validFile(parameters, "timing", false);
139                         if (timing == "not found") { timing = "F"; }
140                         
141                 }
142         }
143         catch(exception& e) {
144                 m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
145                 exit(1);
146         }
147 }
148
149 //**********************************************************************************************************************
150
151 void ClusterSplitCommand::help(){
152         try {
153                 m->mothurOut("The cluster command can only be executed after a successful read.dist command.\n");
154                 m->mothurOut("The cluster command parameter options are method, cuttoff, hard, precision, showabund and timing. No parameters are required.\n");
155                 m->mothurOut("The cluster command should be in the following format: \n");
156                 m->mothurOut("cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n");
157                 m->mothurOut("The acceptable cluster methods are furthest, nearest and average.  If no method is provided then furthest is assumed.\n\n");      
158         }
159         catch(exception& e) {
160                 m->errorOut(e, "ClusterSplitCommand", "help");
161                 exit(1);
162         }
163 }
164
165 //**********************************************************************************************************************
166
167 ClusterSplitCommand::~ClusterSplitCommand(){}
168
169 //**********************************************************************************************************************
170
171 int ClusterSplitCommand::execute(){
172         try {
173         
174                 if (abort == true) {    return 0;       }
175                 
176                 //****************** file prep work ******************************//
177                 
178                 //if user gave a phylip file convert to column file
179                 if (format == "phylip") {
180                         ReadCluster* convert = new ReadCluster(distfile, cutoff, outputDir, false);
181                         
182                         NameAssignment* nameMap = NULL;
183                         convert->read(nameMap);
184                         
185                         if (m->control_pressed) {  delete convert;  return 0;  }
186                         
187                         string distfile = convert->getOutputFile();
188                         
189                         //if no names file given with phylip file, create it
190                         ListVector* listToMakeNameFile =  convert->getListVector();
191                         if (namefile == "") {  //you need to make a namefile for split matrix
192                                 ofstream out;
193                                 namefile = phylipfile + ".names";
194                                 openOutputFile(namefile, out);
195                                 for (int i = 0; i < listToMakeNameFile->getNumBins(); i++) {
196                                         string bin = listToMakeNameFile->get(i);
197                                         out << bin << '\t' << bin << endl;
198                                 }
199                                 out.close();
200                         }
201                         delete listToMakeNameFile;
202                         delete convert;
203                 }
204                 
205                 if (m->control_pressed) { return 0; }
206                 
207                 time_t estart = time(NULL);
208                 
209                 //split matrix into non-overlapping groups
210                 SplitMatrix* split = new SplitMatrix(distfile, namefile, splitcutoff);
211                 split->split();
212                 
213                 if (m->control_pressed) { delete split; return 0; }
214                 
215                 string singletonName = split->getSingletonNames();
216                 vector< map<string, string> > distName = split->getDistanceFiles();  //returns map of distance files -> namefile sorted by distance file size
217                 delete split;
218                 
219                 m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to split the distance file."); m->mothurOutEndLine();
220                 estart = time(NULL);
221                 
222                 if (m->control_pressed) { return 0; }
223                 
224                 //****************** break up files between processes and cluster each file set ******************************//
225                 vector<string> listFileNames;
226                 set<string> labels;
227                 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
228                                 if(processors == 1){
229                                         listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files
230                                 }else{
231                                         vector < vector < map<string, string> > > dividedNames; //distNames[1] = vector of filenames for process 1...
232                                         dividedNames.resize(processors);
233                                         
234                                         //for each file group figure out which process will complete it
235                                         //want to divide the load intelligently so the big files are spread between processes
236                                         int count = 1;
237                                         for (int i = 0; i < distName.size(); i++) { 
238                                                 int processToAssign = (i+1) % processors; 
239                                                 if (processToAssign == 0) { processToAssign = processors; }
240                                                 
241                                                 dividedNames[(processToAssign-1)].push_back(distName[i]);
242                                         }
243                                         
244                                         createProcesses(dividedNames);
245                                                         
246                                         if (m->control_pressed) { return 0; }
247
248                                         //get list of list file names from each process
249                                         for(int i=0;i<processors;i++){
250                                                 string filename = toString(processIDS[i]) + ".temp";
251                                                 ifstream in;
252                                                 openInputFile(filename, in);
253                                                 
254                                                 while(!in.eof()) {
255                                                         string tempName;
256                                                         in >> tempName; gobble(in);
257                                                         listFileNames.push_back(tempName);
258                                                 }
259                                                 in.close();
260                                                 remove((toString(processIDS[i]) + ".temp").c_str());
261                                                 
262                                                 //get labels
263                                                 filename = toString(processIDS[i]) + ".temp.labels";
264                                                 ifstream in2;
265                                                 openInputFile(filename, in2);
266                                                 
267                                                 while(!in2.eof()) {
268                                                         string tempName;
269                                                         in2 >> tempName; gobble(in);
270                                                         if (labels.count(tempName) == 0) { labels.insert(tempName); }
271                                                 }
272                                                 in2.close();
273                                                 remove((toString(processIDS[i]) + ".temp.labels").c_str());
274                                         }
275                                 }
276                 #else
277                                 listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files
278                 #endif
279                 
280                 if (m->control_pressed) { for (int i = 0; i < listFileNames.size(); i++) { remove(listFileNames[i].c_str()); } return 0; }
281                 
282                 //****************** merge list file and create rabund and sabund files ******************************//
283                                 
284                 mergeLists(listFileNames, singletonName, labels);
285
286                 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
287                 
288                 m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
289                 
290                 m->mothurOutEndLine();
291                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
292                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
293                 m->mothurOutEndLine();
294
295                 return 0;
296         }
297         catch(exception& e) {
298                 m->errorOut(e, "ClusterSplitCommand", "execute");
299                 exit(1);
300         }
301 }
302 //**********************************************************************************************************************
303 int ClusterSplitCommand::mergeLists(vector<string> listNames, string singleton, set<string> userLabels){
304         try {
305                 if (outputDir == "") { outputDir += hasPath(distfile); }
306                 fileroot = outputDir + getRootName(getSimpleName(distfile));
307                 
308                 openOutputFile(fileroot+ tag + ".sabund",       outSabund);
309                 openOutputFile(fileroot+ tag + ".rabund",       outRabund);
310                 openOutputFile(fileroot+ tag + ".list",         outList);
311                                 
312                 outputNames.push_back(fileroot+ tag + ".sabund");
313                 outputNames.push_back(fileroot+ tag + ".rabund");
314                 outputNames.push_back(fileroot+ tag + ".list");
315                         
316                 //read in singletons
317                 ListVector* listSingle = NULL;
318                 if (singleton != "none") {
319                         ifstream in;
320                         openInputFile(singleton, in);
321                                 
322                         string firstCol, secondCol;
323                         listSingle = new ListVector();
324                         while (!in.eof()) {
325                                 in >> firstCol >> secondCol; gobble(in);
326                                 listSingle->push_back(secondCol);
327                         }
328                         in.close();
329                 }
330                 
331                 vector<float> orderFloat;
332         
333                 //go through users set and make them floats so we can sort them 
334                 for(set<string>::iterator it = userLabels.begin(); it != userLabels.end(); ++it) {
335                         float temp;
336
337                         if ((*it != "unique") && (convertTestFloat(*it, temp) == true)){
338                                 convert(*it, temp);
339                                 orderFloat.push_back(temp);
340                         }else if (*it == "unique") { orderFloat.push_back(-1.0); }
341                         else {
342                                 userLabels.erase(*it); 
343                                 it--;
344                         }
345                 }
346                 
347                 //sort order
348                 sort(orderFloat.begin(), orderFloat.end());
349
350                 vector<InputData*> inputs;
351                 vector<string> lastLabels;
352                 for (int i = 0; i < listNames.size(); i++) {
353                         InputData* input = new InputData(listNames[i], "list");
354                         inputs.push_back(input);
355                         
356                         ifstream in;
357                         openInputFile(listNames[i], in);
358                         ListVector tempList(in);
359                         lastLabels.push_back(tempList.getLabel());
360                         in.close();
361                 }
362                 
363                 ListVector* merged = NULL;
364                                 
365                 //for each label needed
366                 for(int l = 0; l < orderFloat.size(); l++){
367                         
368                         string thisLabel;
369                         if (orderFloat[l] == -1) { thisLabel = "unique"; }
370                         else { thisLabel = toString(orderFloat[l],  length-1);  } 
371         
372                         //get the list info from each file
373                         for (int k = 0; k < listNames.size(); k++) {
374         
375                                 ListVector* list = inputs[k]->getListVector();
376                                 
377                                 //this file has reached the end
378                                 if (list == NULL) { list = inputs[k]->getListVector(lastLabels[k], true); }     
379                                                 
380                                 float labelFloat;
381                                 if (list->getLabel() == "unique") {  labelFloat = -1.0;  }
382                                 else { convert(list->getLabel(), labelFloat); }
383
384                                 //check for missing labels
385                                 if (labelFloat > orderFloat[l]) { //you are missing the label, get the next smallest one
386                                         //if its bigger get last label, otherwise keep it
387                                         delete list;
388                                         list = inputs[k]->getListVector(lastLabels[k], true); //get last list vector to use, you actually want to move back in the file
389                                 }
390                                 lastLabels[k] = list->getLabel();
391
392                                 //is this the first file
393                                 if (merged == NULL) {  merged = new ListVector();  merged->setLabel(thisLabel); }
394                                 
395                                 for (int j = 0; j < list->getNumBins(); j++) {
396                                         merged->push_back(list->get(j));
397                                 }
398                                 
399                                 delete list;
400                         }
401                         
402                         //add in singletons
403                         for (int j = 0; j < listSingle->getNumBins(); j++) {
404                                 merged->push_back(listSingle->get(j));
405                         }
406
407                         //print to files
408                         printData(merged);
409                         
410                         delete merged; merged = NULL;
411                 }
412                 
413                 if (listSingle != NULL) { delete listSingle; remove(singleton.c_str());  }
414                 
415                 for (int i = 0; i < listNames.size(); i++) {  delete inputs[i];  remove(listNames[i].c_str());  }
416         }
417         catch(exception& e) {
418                 m->errorOut(e, "ClusterSplitCommand", "mergeLists");
419                 exit(1);
420         }
421 }
422 //**********************************************************************************************************************
423
424 void ClusterSplitCommand::printData(ListVector* oldList){
425         try {
426                 string label = oldList->getLabel();
427                 RAbundVector oldRAbund = oldList->getRAbundVector();
428                 
429                 oldRAbund.setLabel(label);
430                 if (isTrue(showabund)) {
431                         oldRAbund.getSAbundVector().print(cout);
432                 }
433                 oldRAbund.print(outRabund);
434                 oldRAbund.getSAbundVector().print(outSabund);
435         
436                 oldList->print(outList);
437         }
438         catch(exception& e) {
439                 m->errorOut(e, "ClusterSplitCommand", "printData");
440                 exit(1);
441         }
442 }
443 //**********************************************************************************************************************
444 int ClusterSplitCommand::createProcesses(vector < vector < map<string, string> > > dividedNames){
445         try {
446         
447         #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
448                 int process = 0;
449                 int exitCommand = 1;
450                 processIDS.clear();
451                 
452                 //loop through and create all the processes you want
453                 while (process != processors) {
454                         int pid = fork();
455                         
456                         if (pid > 0) {
457                                 processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
458                                 process++;
459                         }else if (pid == 0){
460                                 set<string> labels;
461                                 vector<string> listFileNames = cluster(dividedNames[process], labels);
462                                 
463                                 //write out names to file
464                                 string filename = toString(getpid()) + ".temp";
465                                 ofstream out;
466                                 openOutputFile(filename, out);
467                                 for (int j = 0; j < listFileNames.size(); j++) { out << listFileNames[j] << endl;  }
468                                 out.close();
469                                 
470                                 //print out labels
471                                 ofstream outLabels;
472                                 filename = toString(getpid()) + ".temp.labels";
473                                 openOutputFile(filename, outLabels);
474                 
475                                 for (set<string>::iterator it = labels.begin(); it != labels.end(); it++) {
476                                         outLabels << (*it) << endl;
477                                 }
478                                 outLabels.close();
479
480                                 exit(0);
481                         }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); }
482                 }
483                 
484                 //force parent to wait until all the processes are done
485                 for (int i=0;i<processors;i++) { 
486                         int temp = processIDS[i];
487                         wait(&temp);
488                 }
489                 
490                 return exitCommand;
491         #endif          
492         
493         }
494         catch(exception& e) {
495                 m->errorOut(e, "ClusterSplitCommand", "createProcesses");
496                 exit(1);
497         }
498 }
499 //**********************************************************************************************************************
500
501 vector<string> ClusterSplitCommand::cluster(vector< map<string, string> > distNames, set<string>& labels){
502         try {
503                 Cluster* cluster;
504                 SparseMatrix* matrix;
505                 ListVector* list;
506                 ListVector oldList;
507                 RAbundVector* rabund;
508                 
509                 vector<string> listFileNames;
510                 
511                 //cluster each distance file
512                 for (int i = 0; i < distNames.size(); i++) {
513                         
514                         string thisNamefile = distNames[i].begin()->second;
515                         string thisDistFile = distNames[i].begin()->first;
516                         
517                         //read in distance file
518                         globaldata->setNameFile(thisNamefile);
519                         globaldata->setColumnFile(thisDistFile); globaldata->setFormat("column");
520                         
521                         ReadMatrix* read = new ReadColumnMatrix(thisDistFile);  
522                         read->setCutoff(cutoff);
523
524                         NameAssignment* nameMap = new NameAssignment(thisNamefile);
525                         nameMap->readMap();
526                         read->read(nameMap);
527                         
528                         if (m->control_pressed) {  delete read; delete nameMap; return listFileNames; }
529                         
530                         list = read->getListVector();
531                         oldList = *list;
532                         matrix = read->getMatrix();
533                         
534                         delete read; 
535                         delete nameMap; 
536                         
537                         m->mothurOutEndLine(); m->mothurOut("Clustering " + thisDistFile); m->mothurOutEndLine();
538                 
539                         rabund = new RAbundVector(list->getRAbundVector());
540                         
541                         //create cluster
542                         if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
543                         else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
544                         else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff, method);     }
545                         tag = cluster->getTag();
546                 
547                         if (outputDir == "") { outputDir += hasPath(thisDistFile); }
548                         fileroot = outputDir + getRootName(getSimpleName(thisDistFile));
549                         
550                         ofstream listFile;
551                         openOutputFile(fileroot+ tag + ".list", listFile);
552                 
553                         listFileNames.push_back(fileroot+ tag + ".list");
554                 
555                         time_t estart = time(NULL);
556                         
557                         float previousDist = 0.00000;
558                         float rndPreviousDist = 0.00000;
559                         
560                         oldList = *list;
561
562                         print_start = true;
563                         start = time(NULL);
564                         double saveCutoff = cutoff;
565                 
566                         while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){
567                 
568                                 if (m->control_pressed) { //clean up
569                                         delete matrix; delete list;     delete cluster; delete rabund;
570                                         listFile.close();
571                                         for (int i = 0; i < listFileNames.size(); i++) {        remove(listFileNames[i].c_str());       }
572                                         listFileNames.clear(); return listFileNames;
573                                 }
574                 
575                                 cluster->update(cutoff);
576         
577                                 float dist = matrix->getSmallDist();
578                                 float rndDist = roundDist(dist, precision);
579
580                                 if(previousDist <= 0.0000 && dist != previousDist){
581                                         oldList.setLabel("unique");
582                                         oldList.print(listFile);
583                                         if (labels.count("unique") == 0) {  labels.insert("unique");  }
584                                 }
585                                 else if(rndDist != rndPreviousDist){
586                                         oldList.setLabel(toString(rndPreviousDist,  length-1));
587                                         oldList.print(listFile);
588                                         if (labels.count(toString(rndPreviousDist,  length-1)) == 0) { labels.insert(toString(rndPreviousDist,  length-1)); }
589                                 }
590                 
591                                 previousDist = dist;
592                                 rndPreviousDist = rndDist;
593                                 oldList = *list;
594                         }
595
596                 
597                         if(previousDist <= 0.0000){
598                                 oldList.setLabel("unique");
599                                 oldList.print(listFile);
600                                 if (labels.count("unique") == 0) { labels.insert("unique"); }
601                         }
602                         else if(rndPreviousDist<cutoff){
603                                 oldList.setLabel(toString(rndPreviousDist,  length-1));
604                                 oldList.print(listFile);
605                                 if (labels.count(toString(rndPreviousDist,  length-1)) == 0) { labels.insert(toString(rndPreviousDist,  length-1)); }
606                         }
607                 
608                         delete matrix; delete list;     delete cluster; delete rabund; 
609                         listFile.close();
610                         
611                         if (m->control_pressed) { //clean up
612                                 for (int i = 0; i < listFileNames.size(); i++) {        remove(listFileNames[i].c_str());       }
613                                 listFileNames.clear(); return listFileNames;
614                         }
615                         
616                         remove(thisDistFile.c_str());
617                         remove(thisNamefile.c_str());
618                 }
619                 
620                                 
621                 return listFileNames;
622         
623         }
624         catch(exception& e) {
625                 m->errorOut(e, "ClusterSplitCommand", "cluster");
626                 exit(1);
627         }
628
629
630 }
631
632 //**********************************************************************************************************************