X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=unifracweightedcommand.cpp;h=1c146ac4d1b1168093cc6df20a8d37a930e1d56b;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=3b0c53b7437111cfe5045663a8c78370274b939e;hpb=c48d91112209b841444923670dca5454da0e2a4d;p=mothur.git diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 3b0c53b..1c146ac 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -359,7 +359,7 @@ int UnifracWeightedCommand::execute() { variables["[tag]"] = toString(i+1); string wFileName = getOutputFileName("weighted", variables); output = new ColumnFile(wFileName, itersString); - outputNames.push_back(wFileName); outputTypes["wweighted"].push_back(wFileName); + outputNames.push_back(wFileName); outputTypes["weighted"].push_back(wFileName); } userData = weighted.getValues(T[i], processors, outputDir); //userData[0] = weightedscore @@ -699,14 +699,16 @@ int UnifracWeightedCommand::runRandomCalcs(Tree* thisTree, vector usersS lines.clear(); //breakdown work between processors - int numPairs = namesOfGroupCombos.size(); - int numPairsPerProcessor = numPairs / processors; - - for (int i = 0; i < processors; i++) { - int startPos = i * numPairsPerProcessor; - if(i == processors - 1){ numPairsPerProcessor = numPairs - i * numPairsPerProcessor; } - lines.push_back(linePair(startPos, numPairsPerProcessor)); + int remainingPairs = namesOfGroupCombos.size(); + int startIndex = 0; + for (int remainingProcessors = processors; remainingProcessors > 0; remainingProcessors--) { + int numPairs = remainingPairs; //case for last processor + if (remainingProcessors != 1) { numPairs = ceil(remainingPairs / remainingProcessors); } + lines.push_back(linePair(startIndex, numPairs)); //startIndex, numPairs + startIndex = startIndex + numPairs; + remainingPairs = remainingPairs - numPairs; } + //get scores for random trees @@ -915,7 +917,7 @@ void UnifracWeightedCommand::printWeightedFile() { for(int a = 0; a < numComp; a++) { output->initFile(groupComb[a], tags); //print each line - for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { + for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { data.push_back(it->first); data.push_back(rScoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); output->output(data); data.clear(); @@ -1085,7 +1087,7 @@ void UnifracWeightedCommand::calculateFreqsCumuls() { for (int f = 0; f < numComp; f++) { for (int i = 0; i < rScores[f].size(); i++) { //looks like 0,0,1,1,1,2,4,7... you want to make a map that say rScoreFreq[0] = 2, rScoreFreq[1] = 3... validScores[rScores[f][i]] = rScores[f][i]; - map::iterator it = rScoreFreq[f].find(rScores[f][i]); + map::iterator it = rScoreFreq[f].find(rScores[f][i]); if (it != rScoreFreq[f].end()) { rScoreFreq[f][rScores[f][i]]++; }else{ @@ -1098,9 +1100,9 @@ void UnifracWeightedCommand::calculateFreqsCumuls() { for(int a = 0; a < numComp; a++) { float rcumul = 1.0000; //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print. - for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { + for (map::iterator it = validScores.begin(); it != validScores.end(); it++) { //make rscoreFreq map and rCumul - map::iterator it2 = rScoreFreq[a].find(it->first); + map::iterator it2 = rScoreFreq[a].find(it->first); rCumul[a][it->first] = rcumul; //get percentage of random trees with that info if (it2 != rScoreFreq[a].end()) { rScoreFreq[a][it->first] /= iters; rcumul-= it2->second; }