]> git.donarmstrong.com Git - mothur.git/blobdiff - bellerophon.cpp
changes while testing
[mothur.git] / bellerophon.cpp
index 4f48d9ce03b64ec2a5c1f52d4d3ef2feaab9d8a5..833cfb907d6d4bd2aed8acb3d8522932ac3b2e7d 100644 (file)
@@ -75,7 +75,7 @@ Bellerophon::Bellerophon(string name, bool filterSeqs,  bool c, int win, int inc
 }
 
 //***************************************************************************************************************
-int Bellerophon::print(ostream& out, ostream& outAcc) {
+int Bellerophon::print(ostream& out, ostream& outAcc, string s) {
        try {
                int above1 = 0;
                
@@ -130,7 +130,7 @@ int Bellerophon::print(ostream& out, ostream& outAcc) {
 }
 #ifdef USE_MPI
 //***************************************************************************************************************
-int Bellerophon::print(MPI_File& out, MPI_File& outAcc) {
+int Bellerophon::print(MPI_File& out, MPI_File& outAcc, string s) {
        try {
        
                int pid;
@@ -246,7 +246,7 @@ int Bellerophon::getChimeras() {
                numSeqsPerProcessor = iters / processors;
                
                //each process hits this only once
-               unsigned long int startPos = pid * numSeqsPerProcessor;
+               unsigned long long startPos = pid * numSeqsPerProcessor;
                if(pid == processors - 1){
                                numSeqsPerProcessor = iters - pid * numSeqsPerProcessor;
                }
@@ -274,7 +274,7 @@ int Bellerophon::getChimeras() {
                                        MPI_Recv(&length, 1, MPI_INT, j, 2001, MPI_COMM_WORLD, &status);
                                        
                                        char* buf = new char[length];
-                                       MPI_Recv(&buf, length, MPI_CHAR, j, 2001, MPI_COMM_WORLD, &status);
+                                       MPI_Recv(&buf[0], length, MPI_CHAR, j, 2001, MPI_COMM_WORLD, &status);
                                        
                                        string temp = buf;
                                        if (temp.length() > length) { temp = temp.substr(0, length); }
@@ -293,7 +293,7 @@ int Bellerophon::getChimeras() {
                        //played with this a bit, but it may be better to try user-defined datatypes with set string lengths??
                        vector<string> MPIBestSend = getBestWindow(lines[0]);
                        pref.clear();
-                       
+                               
                        //send your result to parent
                        for (int i = 0; i < numSeqs; i++) {
                                
@@ -314,7 +314,7 @@ int Bellerophon::getChimeras() {
        #else
        
                //divide breakpoints between processors
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                        if(processors == 1){ 
                                lines.push_back(linePair(0, iters));    
                                
@@ -326,7 +326,7 @@ int Bellerophon::getChimeras() {
                                int numSeqsPerProcessor = iters / processors;
                                
                                for (int i = 0; i < processors; i++) {
-                                       unsigned long int startPos = i * numSeqsPerProcessor;
+                                       unsigned long long startPos = i * numSeqsPerProcessor;
                                        if(i == processors - 1){
                                                numSeqsPerProcessor = iters - i * numSeqsPerProcessor;
                                        }
@@ -356,7 +356,7 @@ int Bellerophon::getChimeras() {
 
 int Bellerophon::createProcesses(vector<int> mid) {
        try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                int process = 0;
                int exitCommand = 1;
                vector<int> processIDS;
@@ -373,7 +373,11 @@ int Bellerophon::createProcesses(vector<int> mid) {
                                string tempOut = outputDir + toString(getpid()) + ".temp";
                                writePrefs(tempOut, lines[process]);
                                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
@@ -531,7 +535,6 @@ int Bellerophon::createSparseMatrix(int startSeq, int endSeq, SparseMatrix* spar
 int Bellerophon::generatePreferences(vector<SeqMap> left, vector<SeqMap> right, int mid){
        try {
                
-               float dme = 0.0;
                SeqMap::iterator itR;
                SeqMap::iterator itL;
                
@@ -674,7 +677,7 @@ int Bellerophon::writePrefs(string file, linePair tempLine) {
                        
                        for (int j = 0; j < numSeqs; j++) {
                                
-                               if (m->control_pressed) { outTemp.close(); remove(file.c_str()); return 0; }
+                               if (m->control_pressed) { outTemp.close(); m->mothurRemove(file); return 0; }
                                
                                outTemp << pref[i][j].name << '\t' << pref[i][j].leftParent << '\t' << pref[i][j].rightParent << '\t';
                                outTemp << pref[i][j].score << '\t' << pref[i][j].closestLeft << '\t' << pref[i][j].closestRight << '\t' << pref[i][j].midpoint <<  endl;
@@ -706,7 +709,7 @@ int Bellerophon::readPrefs(string file) {
                        
                        for (int j = 0; j < numSeqs; j++) {
                                
-                               if (m->control_pressed) { inTemp.close(); remove(file.c_str()); return 0; }
+                               if (m->control_pressed) { inTemp.close(); m->mothurRemove(file); return 0; }
                        
                                inTemp >> pref[i][j].name >> pref[i][j].leftParent >> pref[i][j].rightParent;
                                inTemp >> pref[i][j].score >> pref[i][j].closestLeft >> pref[i][j].closestRight >> pref[i][j].midpoint;
@@ -716,7 +719,7 @@ int Bellerophon::readPrefs(string file) {
                
                inTemp.close();
                
-               remove(file.c_str());
+               m->mothurRemove(file);
                
                return 0;
        }