- int pid = fork();
- if(pid > 0){
- driver(distCalculator, seqDB, 0, (numSeqs/sqrt(2)), distFile + "tempa", phylipFile + "tempPhylipA", cutoff);
- appendFiles((distFile+"tempa"), distFile);
- remove((distFile + "tempa").c_str());
- appendFiles((phylipFile + "tempPhylipA"), phylipFile);
- remove((phylipFile + "tempPhylipA").c_str());
- }
- else{
- driver(distCalculator, seqDB, (numSeqs/sqrt(2)), numSeqs, distFile + "tempb", phylipFile + "tempPhylipB", cutoff);
- appendFiles((distFile+"tempb"), distFile);
- remove((distFile + "tempb").c_str());
- appendFiles((phylipFile + "tempPhylipB"), phylipFile);
- remove((phylipFile + "tempPhylipB").c_str());
- }
- wait(NULL);
-
- }
- else if(processors == 3){
- int pid1 = fork();
- if(pid1 > 0){
- int pid2 = fork();
- if(pid2 > 0){
- driver(distCalculator, seqDB, 0, sqrt(3) * numSeqs / 3, distFile + "tempa", phylipFile + "tempPhylipA", cutoff);
- appendFiles(distFile+"tempa", distFile);
- appendFiles((phylipFile + "tempPhylipA"), phylipFile);
- remove((distFile + "tempa").c_str());
- remove((phylipFile + "tempPhylipA").c_str());
- }
- else{
- driver(distCalculator, seqDB, sqrt(3) * numSeqs / 3, sqrt(6) * numSeqs / 3, distFile + "tempb", phylipFile + "tempPhylipB", cutoff);
- appendFiles(distFile+"tempb", distFile);
- appendFiles((phylipFile + "tempPhylipB"), phylipFile);
- remove((distFile + "tempb").c_str());
- remove((phylipFile + "tempPhylipB").c_str());
- }
- wait(NULL);
- }
- else{
- driver(distCalculator, seqDB, sqrt(6) * numSeqs / 3, numSeqs, distFile + "tempc", phylipFile + "tempPhylipC", cutoff);
- appendFiles(distFile+"tempc", distFile);
- appendFiles((phylipFile + "tempPhylipC"), phylipFile);
- remove((distFile + "tempc").c_str());
- remove((phylipFile + "tempPhylipC").c_str());
- }
- wait(NULL);
- }
- else if(processors == 4){
- int pid1 = fork();
- if(pid1 > 0){
- int pid2 = fork();
- if(pid2 > 0){
- driver(distCalculator, seqDB, 0, numSeqs / 2, distFile + "tempa", phylipFile + "tempPhylipA", cutoff);
- appendFiles(distFile+"tempa", distFile);
- appendFiles((phylipFile + "tempPhylipA"), phylipFile);
- remove((distFile + "tempa").c_str());
- remove((phylipFile + "tempPhylipA").c_str());
- }
- else{
- driver(distCalculator, seqDB, numSeqs / 2, (numSeqs/sqrt(2)), distFile + "tempb", phylipFile + "tempPhylipB", cutoff);
- appendFiles(distFile+"tempb", distFile);
- appendFiles((phylipFile + "tempPhylipB"), phylipFile);
- remove((distFile + "tempb").c_str());
- remove((phylipFile + "tempPhylipB").c_str());
- }
- wait(NULL);