]> git.donarmstrong.com Git - mothur.git/blobdiff - metastatscommand.cpp
fixes while testing 1.33.0
[mothur.git] / metastatscommand.cpp
index de9e373194b30bc97a2afbeceb49b5303aa66de3..de03dab2a147174384d3e3ffce329c1e16fa07f5 100644 (file)
@@ -256,15 +256,14 @@ int MetaStatsCommand::execute(){
                else if (numGroups < 2) { m->mothurOut("Not enough sets, I need at least 2 valid sets. Unable to complete command."); m->mothurOutEndLine(); m->control_pressed = true; }
 
         if(processors != 1){
-            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;
             }
         }