+ if (recalc) {
+ for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear();
+ vector<unsigned long long> positions;
+ positions = m->divideFile(filename, processors);
+ for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); }
+
+ num = 0;
+ processIDS.resize(0);
+ process = 1;
+
+ while (process != processors) {
+ 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){
+ num = driver(lines[process], alignFileName + toString(m->mothurGetpid(process)) + ".temp", reportFileName + toString(m->mothurGetpid(process)) + ".temp", accnosFName + m->mothurGetpid(process) + ".temp", filename);
+
+ //pass numSeqs to parent
+ ofstream out;
+ string tempFile = alignFileName + toString(m->mothurGetpid(process)) + ".num.temp";
+ m->openOutputFile(tempFile, out);
+ out << num << endl;
+ out.close();
+
+ 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);
+ }
+ }
+ }
+