X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=parsimony.cpp;h=6a0485c133b2868670e49e5873186e5d10df474d;hp=4ec5e1ba7d31495ebef7b5efaf2b7e6bbc82ad7c;hb=1a20e24ee786195ab0e1cccd4f5aede7a88f3f4e;hpb=c53ef46b40b97c00e32bfd8c3924ce8c51b5cd7b diff --git a/parsimony.cpp b/parsimony.cpp index 4ec5e1b..6a0485c 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -13,20 +13,21 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { try { - globaldata = GlobalData::getInstance(); processors = p; outputDir = o; + CountTable* ct = t->getCountTable(); //if the users enters no groups then give them the score of all groups - int numGroups = globaldata->Groups.size(); + vector mGroups = m->getGroups(); + int numGroups = mGroups.size(); //calculate number of comparsions int numComp = 0; vector< vector > namesOfGroupCombos; for (int r=0; r groups; groups.push_back(globaldata->Groups[r]); groups.push_back(globaldata->Groups[l]); + vector groups; groups.push_back(mGroups[r]); groups.push_back(mGroups[l]); //cout << globaldata->Groups[r] << '\t' << globaldata->Groups[l] << endl; namesOfGroupCombos.push_back(groups); } @@ -37,25 +38,26 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { vector groups; if (numGroups == 0) { //get score for all users groups - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - groups.push_back(tmap->namesOfGroups[i]); + vector tGroups = ct->getNamesOfGroups(); + for (int i = 0; i < tGroups.size(); i++) { + if (tGroups[i] != "xxx") { + groups.push_back(tGroups[i]); //cout << tmap->namesOfGroups[i] << endl; } } namesOfGroupCombos.push_back(groups); }else { - for (int i = 0; i < globaldata->Groups.size(); i++) { - groups.push_back(globaldata->Groups[i]); + for (int i = 0; i < mGroups.size(); i++) { + groups.push_back(mGroups[i]); //cout << globaldata->Groups[i] << endl; } namesOfGroupCombos.push_back(groups); } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ - data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size()); + data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), ct); }else{ lines.clear(); int numPairs = namesOfGroupCombos.size(); @@ -72,10 +74,10 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { lines.push_back(linePair(startPos, numPairsPerProcessor)); } - data = createProcesses(t, namesOfGroupCombos); + data = createProcesses(t, namesOfGroupCombos, ct); } #else - data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size()); + data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), ct); #endif return data; @@ -88,11 +90,10 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { } /**************************************************************************************************/ -EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGroupCombos) { +EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGroupCombos, CountTable* ct) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; - int num = 0; vector processIDS; EstOutput results; @@ -106,7 +107,7 @@ EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGr process++; }else if (pid == 0){ EstOutput myresults; - myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num); + myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, ct); if (m->control_pressed) { exit(0); } @@ -126,7 +127,7 @@ EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGr } } - results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num); + results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, ct); //force parent to wait until all the processes are done for (int i=0;i > namesOfGr m->gobble(in); } in.close(); - remove(s.c_str()); + m->mothurRemove(s); } return results; @@ -169,12 +170,12 @@ EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGr } } /**************************************************************************************************/ -EstOutput Parsimony::driver(Tree* t, vector< vector > namesOfGroupCombos, int start, int num) { +EstOutput Parsimony::driver(Tree* t, vector< vector > namesOfGroupCombos, int start, int num, CountTable* ct) { try { EstOutput results; results.resize(num); - Tree* copyTree = new Tree(); + Tree* copyTree = new Tree(ct); int count = 0; for (int h = start; h < (start+num); h++) {