Last active
October 31, 2016 23:08
-
-
Save ashander/efe8442d82cf349c74779308cbb445ed to your computer and use it in GitHub Desktop.
Msprime records $\sum_i (l_i - r_i)$ will _not_ sum to `n-1` for `n` samples (unless there is no recombination)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import msprime | |
pop = __import__('random').randint(2, 20000) | |
sum = 0 | |
with open('example.tsv', 'w') as f: | |
msprime.simulate(pop, recombination_rate = 10).write_records(f) | |
with open('example.tsv', 'r') as f: | |
f.readline() | |
l = f.readlines() | |
for line in l: | |
vec = line.split('\t') | |
sum += float(vec[1]) - float(vec[0]) | |
assert int(sum) + 1 == pop, "population size: {}, 'coverage': {}".format(pop, int(sum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment