+ //loop through and create all the processes you want
+ while (process != processors) {
+ int 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){
+ driver(lines[process].start, lines[process].num, thisLookUp);
+ 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);
+ }
+ }
+
+ //do my part
+ driver(lines[0].start, lines[0].num, thisLookUp);
+
+ //force parent to wait until all the processes are done
+ for (int i=0;i<(processors-1);i++) {
+ int temp = processIDS[i];
+ wait(&temp);
+ }
+ }
+ #else
+ driver(0, namesOfGroupCombos.size(), thisLookUp);
+ #endif
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "MetaStatsCommand", "process");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& thisLookUp) {
+ try {
+
+ //for each combo
+ for (int c = start; c < (start+num); c++) {
+
+ //get set names
+ string setA = namesOfGroupCombos[c][0];
+ string setB = namesOfGroupCombos[c][1];
+
+ //get filename
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + ".metastats";
+ outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
+ int nameLength = outputFileName.length();
+ char * output = new char[nameLength];
+ strcpy(output, outputFileName.c_str());
+
+ //build matrix from shared rabunds
+ double** data;
+ data = new double*[thisLookUp[0]->getNumBins()];
+
+ vector<SharedRAbundVector*> subset;
+ int setACount = 0;
+ int setBCount = 0;