+ //close files
+ MPI_File_close(&inMPI);
+ MPI_File_close(&outMPIGood);
+ MPI_File_close(&outMPIBadAccnos);
+ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
+
+#else
+
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ if(processors == 1){
+ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames);
+
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
+
+ }else{
+ processIDS.resize(0);
+
+ numFastaSeqs = createProcesses(goodSeqFile, badAccnosFile, fastafile, badSeqNames);
+
+ rename((goodSeqFile + toString(processIDS[0]) + ".temp").c_str(), goodSeqFile.c_str());
+ rename((badAccnosFile + toString(processIDS[0]) + ".temp").c_str(), badAccnosFile.c_str());
+
+ //append alignment and report files
+ for(int i=1;i<processors;i++){
+ m->appendFiles((goodSeqFile + toString(processIDS[i]) + ".temp"), goodSeqFile);
+ remove((goodSeqFile + toString(processIDS[i]) + ".temp").c_str());
+
+ m->appendFiles((badAccnosFile + toString(processIDS[i]) + ".temp"), badAccnosFile);
+ remove((badAccnosFile + toString(processIDS[i]) + ".temp").c_str());
+ }
+
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
+
+ //read badSeqs in because root process doesnt know what other "bad" seqs the children found
+ ifstream inBad;
+ int ableToOpen = m->openInputFile(badAccnosFile, inBad, "no error");
+
+ if (ableToOpen == 0) {
+ badSeqNames.clear();
+ string tempName;
+ while (!inBad.eof()) {
+ inBad >> tempName; m->gobble(inBad);
+ badSeqNames.insert(tempName);
+ }
+ inBad.close();
+ }
+ }
+ #else
+ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames);
+
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
+
+ #endif
+
+#endif
+
+ #ifdef USE_MPI
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should fix files
+
+ //read accnos file with all names in it, process 0 just has its names
+ MPI_File inMPIAccnos;
+ MPI_Offset size;
+
+ char inFileName[1024];
+ strcpy(inFileName, badAccnosFile.c_str());
+
+ MPI_File_open(MPI_COMM_SELF, inFileName, inMode, MPI_INFO_NULL, &inMPIAccnos); //comm, filename, mode, info, filepointer
+ MPI_File_get_size(inMPIAccnos, &size);
+
+ char* buffer = new char[size];
+ MPI_File_read(inMPIAccnos, buffer, size, MPI_CHAR, &status);
+
+ string tempBuf = buffer;
+ if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size); }
+ istringstream iss (tempBuf,istringstream::in);
+
+ delete buffer;
+ MPI_File_close(&inMPIAccnos);
+
+ badSeqNames.clear();
+ string tempName;
+ while (!iss.eof()) {
+ iss >> tempName; m->gobble(iss);
+ badSeqNames.insert(tempName);
+ }
+ #endif
+