Skip to content

Commit

Permalink
make verfication.py compatible with latest pyslim
Browse files Browse the repository at this point in the history
  • Loading branch information
GertjanBisschop authored and mergify[bot] committed Dec 7, 2023
1 parent 11615e0 commit 71cdb16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements/verification.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ seaborn
tqdm
argparse
daiquiri
pyslim
pyslim>=1.0
13 changes: 6 additions & 7 deletions verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,18 +961,17 @@ def sample_recap_simplify(slim_ts, sample_size, Ne, r, mu):
# TODO is this needed now? Shouldn't be, right?
start_time=slim_ts.metadata["SLiM"]["generation"],
)
rts = pyslim.SlimTreeSequence(recap)
logging.debug(f"pyslim: slim generation:{slim_ts.metadata['SLiM']['generation']}")
alive_inds = rts.individuals_alive_at(0)
alive_inds = pyslim.individuals_alive_at(recap, 0)
keep_indivs = np.random.choice(alive_inds, sample_size, replace=False)
keep_nodes = []
for i in keep_indivs:
keep_nodes.extend(rts.individual(i).nodes)
logging.debug(f"before simplify {rts.num_nodes} nodes")
sts = rts.simplify(keep_nodes)
keep_nodes.extend(recap.individual(i).nodes)
logging.debug(f"before simplify {recap.num_nodes} nodes")
sts = recap.simplify(keep_nodes)
logging.debug(f"after simplify {sts.num_nodes} nodes")
logging.debug(f"after simplify {sts.num_trees} trees")
return pyslim.SlimTreeSequence(msprime.mutate(sts, rate=mu))
return msprime.mutate(sts, rate=mu)


class SweepVsSlim(Test):
Expand Down Expand Up @@ -1033,7 +1032,7 @@ def run_sweep_slim_comparison(self, slim_args, **kwargs):
cmd = _slim_executable + [slim_script]
for _ in range(kwargs["num_replicates"]):
subprocess.check_output(cmd)
ts = pyslim.load(outfile)
ts = tskit.load(outfile)
rts = sample_recap_simplify(
ts, sample_size, pop_size, recombination_rate, 1e-8
)
Expand Down

0 comments on commit 71cdb16

Please sign in to comment.