EstOutput Parsimony::getValues(Tree* t, int p, string o) {
try {
- globaldata = GlobalData::getInstance();
processors = p;
outputDir = o;
+ TreeMap* tmap = t->getTreeMap();
//if the users enters no groups then give them the score of all groups
- int numGroups = globaldata->Groups.size();
+ vector<string> mGroups = m->getGroups();
+ int numGroups = mGroups.size();
//calculate number of comparsions
int numComp = 0;
vector< vector<string> > namesOfGroupCombos;
for (int r=0; r<numGroups; r++) {
- for (int l = r+1; l < numGroups; l++) {
+ for (int l = 0; l < r; l++) {
numComp++;
- vector<string> groups; groups.push_back(globaldata->Groups[r]); groups.push_back(globaldata->Groups[l]);
+ vector<string> groups; groups.push_back(mGroups[r]); groups.push_back(mGroups[l]);
//cout << globaldata->Groups[r] << '\t' << globaldata->Groups[l] << endl;
namesOfGroupCombos.push_back(groups);
}
vector<string> 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<string> tGroups = tmap->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(), tmap);
}else{
lines.clear();
int numPairs = namesOfGroupCombos.size();
lines.push_back(linePair(startPos, numPairsPerProcessor));
}
- data = createProcesses(t, namesOfGroupCombos);
+ data = createProcesses(t, namesOfGroupCombos, tmap);
}
#else
- data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size());
+ data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
#endif
return data;
}
/**************************************************************************************************/
-EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos) {
+EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, TreeMap* tmap) {
try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
int process = 1;
- int num = 0;
vector<int> processIDS;
EstOutput results;
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, tmap);
if (m->control_pressed) { exit(0); }
}
}
- results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num);
+ results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, tmap);
//force parent to wait until all the processes are done
for (int i=0;i<processIDS.size();i++) {
m->gobble(in);
}
in.close();
- remove(s.c_str());
+ m->mothurRemove(s);
}
return results;
}
}
/**************************************************************************************************/
-EstOutput Parsimony::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num) {
+EstOutput Parsimony::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, TreeMap* tmap) {
try {
EstOutput results; results.resize(num);
- Tree* copyTree = new Tree();
+ Tree* copyTree = new Tree(tmap);
int count = 0;
for (int h = start; h < (start+num); h++) {