-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
One of the critical speed-bottlenecks in RASCalculator is arguably the double loop that happens for every site of the input file:
Lines 134 to 135 in a9c66c6
| for Lftidx, leftPop in enumerate(LeftPops): | |
| for Tstidx, testPop in enumerate(TestPops): |
Effectively, this means that the algorithm scales quadratically with the number of populations (or individuals, for ungrouped input).
I think we can speed this up to scale effectively linear, as long as the allele frequency is low. The idea is that within the first loop, we first ask whether there is any derived allele frequency in the first population. If not, we just move on to the next outer loop item, because we know that all internal loop items would just add zero.
So I'm proposing to change this
for Lftidx, leftPop in enumerate(LeftPops):
for Tstidx, testPop in enumerate(TestPops):
to this:
for Lftidx, leftPop in enumerate(LeftPops):
if afDict[leftPop] > 0:
for Tstidx, testPop in enumerate(TestPops):
or something to that effect.
Metadata
Metadata
Assignees
Labels
No labels