Skip to content

Commit

Permalink
test_dfe_no_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
petrelharp committed Jul 6, 2024
1 parent e537b27 commit 5080101
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_slim_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
import collections
import re
import contextlib

import pytest
import tskit
Expand Down Expand Up @@ -443,14 +444,24 @@ def test_dfe_no_demography(self, tmp_path):

@pytest.mark.filterwarnings("ignore::stdpopsim.SLiMScalingFactorWarning")
def test_dfe_no_interval(self):
with tempfile.NamedTemporaryFile(mode="w") as f:
tempdir = tempfile.TemporaryDirectory(prefix="TestCLI_")

@contextlib.contextmanager
def temp_file():
fname = os.path.join(tempdir.name, f"{os.urandom(3).hex()}.slim")
f = open(fname, "w")
yield f, fname
f.close()

with temp_file() as fn:
f, fname = fn
cmd = (
f"-q -e slim --slim-scaling-factor 20 --slim-path {slim_path} "
f"HomSap -c chr22 -l 0.01 -o {f.name} --dfe Gamma_K17 -s 984 "
f"HomSap -c chr22 -l 0.01 -o {fname} --dfe Gamma_K17 -s 984 "
f"pop_0:5"
).split()
capture_output(stdpopsim.cli.stdpopsim_main, cmd)
ts = tskit.load(f.name)
ts = tskit.load(fname)
self.verify_slim_sim(ts, num_samples=10)

@pytest.mark.filterwarnings("ignore::stdpopsim.SLiMScalingFactorWarning")
Expand Down

0 comments on commit 5080101

Please sign in to comment.