]> git.donarmstrong.com Git - mothur.git/blobdiff - distancecommand.cpp
working on sra and get.mimarkspackage commands. added file parameter to cluster...
[mothur.git] / distancecommand.cpp
index 73a38bfe023025be8b5533e20f72d28539a09cde..80ce6e5117799b2dcde34ce537fca421f926fd42 100644 (file)
@@ -534,14 +534,14 @@ void DistanceCommand::createProcesses(string filename) {
                
                //loop through and create all the processes you want
                while (process != processors) {
-                       int pid = fork();
+                       pid_t pid = fork();
                        
                        if (pid > 0) {
                                processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
                                process++;
                        }else if (pid == 0){
-                               if (output != "square") {  driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", cutoff); }
-                               else { driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", "square"); }
+                               if (output != "square") {  driver(lines[process].start, lines[process].end, filename + m->mothurGetpid(process) + ".temp", cutoff); }
+                               else { driver(lines[process].start, lines[process].end, filename + m->mothurGetpid(process) + ".temp", "square"); }
                                exit(0);
                        }else { 
                                m->mothurOut("[ERROR]: unable to spawn the necessary processes. Error code: " + toString(pid)); m->mothurOutEndLine(); 
@@ -594,6 +594,9 @@ void DistanceCommand::createProcesses(string filename) {
                
                //Close all thread handles and free memory allocations.
                for(int i=0; i < pDataArray.size(); i++){
+            if (pDataArray[i]->count != (pDataArray[i]->endLine-pDataArray[i]->startLine)) {
+                m->mothurOut("[ERROR]: process " + toString(i) + " only processed " + toString(pDataArray[i]->count) + " of " + toString(pDataArray[i]->endLine-pDataArray[i]->startLine) + " sequences assigned to it, quitting. \n"); m->control_pressed = true; 
+            }
                        CloseHandle(hThreadArray[i]);
                        delete pDataArray[i];
                }
@@ -672,11 +675,11 @@ int DistanceCommand::driver(int startLine, int endLine, string dFileName, float
                        if (output == "lt") { outFile << endl; }
                        
                        if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
+                               m->mothurOutJustToScreen(toString(i) + "\t" + toString(time(NULL) - startTime)+"\n"); 
                        }
                        
                }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
+               m->mothurOutJustToScreen(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)+"\n");
                
                outFile.close();
                delete distCalculator;
@@ -742,11 +745,11 @@ int DistanceCommand::driver(int startLine, int endLine, string dFileName, string
                        outFile << endl; 
                        
                        if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
+                               m->mothurOutJustToScreen(toString(i) + "\t" + toString(time(NULL) - startTime)+"\n");
                        }
                        
                }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
+               m->mothurOutJustToScreen(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)+"\n");
                
                outFile.close();
                delete distCalculator;
@@ -809,8 +812,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, MPI_File& outMPI, flo
                        }
                        
                        if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
+                               m->mothurOutJustToScreen(toString(i) + "\t" + toString(time(NULL) - startTime)+"\n"); 
                        }
                        
                         
@@ -826,8 +828,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, MPI_File& outMPI, flo
                        
                }
                
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;        
+               m->mothurOutJustToScreen(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)+"\n");
                delete distCalculator;
                return 1;
        }
@@ -904,9 +905,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned
 
                
                        if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
-                       }
+                               m->mothurOutJustToScreen(toString(i) + "\t" + toString(time(NULL) - startTime)+"\n");                   }
                        
                        
                        //send results to parent
@@ -920,8 +919,8 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned
                        delete buf;
                }
                
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;
+               m->mothurOutJustToScreen(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)+"\n");
+               
                MPI_File_close(&outMPI);
                delete distCalculator;
                
@@ -999,8 +998,7 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned
 
                
                        if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
+                               m->mothurOutJustToScreen(toString(i) + "\t" + toString(time(NULL) - startTime)+"\n"); 
                        }
                        
                        
@@ -1015,8 +1013,8 @@ int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned
                        delete buf;
                }
                
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;
+               m->mothurOutJustToScreen(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)+"\n");
+               
                MPI_File_close(&outMPI);
                delete distCalculator;
                return 1;