Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise error when recording migrants #2199

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions msprime/ancestry.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,18 +866,22 @@ def _parse_sim_ancestry(
" additional_nodes."
)

if is_dtwf:
if additional_nodes.value & NodeType.MIGRANT.value:
if additional_nodes.value & NodeType.MIGRANT.value:
if is_dtwf:
raise ValueError(
"Recording MIGRANT nodes is currently not supported in"
" DTWF simulation."
)
if is_pedigree:
if additional_nodes.value & NodeType.MIGRANT.value:
if is_pedigree:
raise ValueError(
"Recording MIGRANT nodes is not supported in "
"FixedPedigree simulation."
)
if any(isinstance(model, SweepGenicSelection) for model in models):
raise ValueError(
"Recording MIGRANT nodes is not supported in "
"SweepGenicSelection simulation."
)

record_migrations = core._parse_flag(record_migrations, default=False)

Expand Down
27 changes: 27 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,3 +962,30 @@ def test_lots_of_sweeps(self):
random_seed=2,
)
assert all(tree.num_roots == 1 for tree in ts.trees())

def test_sweep_migration_event(self):
models = [
msprime.StandardCoalescent(duration=0.01),
msprime.SweepGenicSelection(
position=5,
start_frequency=0.69,
end_frequency=0.7,
s=0.1,
dt=1e-6,
),
]
with pytest.raises(
ValueError,
match="Recording MIGRANT nodes is not supported in "
"SweepGenicSelection simulation.",
):
msprime.sim_ancestry(
3,
population_size=1000,
sequence_length=10,
recombination_rate=0.2,
model=models,
random_seed=2,
coalescing_segments_only=False,
additional_nodes=msprime.NodeType.MIGRANT,
)
Loading