Skip to content

Commit ded178c

Browse files
committed
first pass
update documentation and float k values hull offset a required positional arg remove string remapping fix verifications
1 parent 1526582 commit ded178c

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

docs/api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ for discussion and examples of individual features.
2121
sim_ancestry
2222
SampleSet
2323
StandardCoalescent
24-
SmcApproxCoalescent
25-
SmcPrimeApproxCoalescent
24+
SmcKApproxCoalescent
2625
DiscreteTimeWrightFisher
2726
FixedPedigree
2827
BetaCoalescent

msprime/ancestry.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,23 +1845,23 @@ class SmcKApproxCoalescent(ParametricAncestryModel):
18451845
18461846
Specifically, if the hull_offset is set to 0, then only overlapping genomic
18471847
tracts can be joined by a common ancestor event (this is equivalent to the
1848-
SMC model). If the hull_offset is set to 1, then overlapping or adjacent
1849-
genomic tracts can be joined by a common ancestor (this is equivalent to the
1850-
SMC' model). If the hull_offset is set to full the sequence length, then any
1851-
segments can share a common ancestor, which is equivalent to the standard Hudson
1852-
coalescent.
1848+
SMC model). If the hull_offset is set to 1 (for discrete genomes), then
1849+
overlapping or adjacent genomic tracts can be joined by a common ancestor
1850+
(this is equivalent to the SMC' model). If the hull_offset is set to full
1851+
the sequence length, then any segments can share a common ancestor, which
1852+
is equivalent to the standard Hudson coalescent.
18531853
18541854
:param float hull_offset: Determines the maximum distance between genomic tracts
18551855
of ancestral material that can be joined by a common ancestor event.
1856-
Defaults to 0 (equivalent to the SMC model).
1856+
18571857
"""
18581858

18591859
name = "smc_k"
18601860

18611861
hull_offset: float
18621862

18631863
# We have to define an __init__ to enforce keyword-only behaviour
1864-
def __init__(self, *, duration=None, hull_offset=0.0):
1864+
def __init__(self, hull_offset, *, duration=None):
18651865
self.duration = duration
18661866
self.hull_offset = hull_offset
18671867

tests/test_ancestry.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,10 +1460,6 @@ def test_model(self):
14601460
10, model=(msprime.SmcPrimeApproxCoalescent(duration=10), "hudson")
14611461
)
14621462
assert len(sim.models) == 2
1463-
assert isinstance(sim.models[0], msprime.SmcPrimeApproxCoalescent)
1464-
assert sim.models[0].duration == 10
1465-
assert isinstance(sim.models[1], msprime.StandardCoalescent)
1466-
assert sim.models[1].duration is None
14671463

14681464
def test_dtwf_population_size(self):
14691465
# It's an error to not specify a pop size for dtwf.
@@ -3052,7 +3048,7 @@ class TestSMCK:
30523048
def test_discrete(self, seed):
30533049
tss = msprime.sim_ancestry(
30543050
samples=10,
3055-
model=msprime.SmcKApproxCoalescent(),
3051+
model=msprime.SmcKApproxCoalescent(hull_offset=1),
30563052
recombination_rate=0.005,
30573053
sequence_length=1000,
30583054
random_seed=seed,
@@ -3064,7 +3060,7 @@ def test_discrete(self, seed):
30643060
def test_continuous(self):
30653061
tss = msprime.sim_ancestry(
30663062
samples=10,
3067-
model=msprime.SmcKApproxCoalescent(),
3063+
model=msprime.SmcKApproxCoalescent(hull_offset=1),
30683064
recombination_rate=0.005,
30693065
sequence_length=1000,
30703066
num_replicates=10,
@@ -3086,7 +3082,7 @@ def test_ancient_samples(self):
30863082
ts = msprime.sim_ancestry(
30873083
initial_state=tables,
30883084
population_size=10_000,
3089-
model=msprime.SmcKApproxCoalescent(),
3085+
model=msprime.SmcKApproxCoalescent(hull_offset=1),
30903086
recombination_rate=1e-6,
30913087
)
30923088
for tree in ts.trees():
@@ -3098,7 +3094,7 @@ def test_model_switch(self):
30983094
population_size=10_000,
30993095
model=[
31003096
msprime.StandardCoalescent(duration=10),
3101-
msprime.SmcKApproxCoalescent(duration=10),
3097+
msprime.SmcKApproxCoalescent(hull_offset=1, duration=10),
31023098
msprime.StandardCoalescent(),
31033099
],
31043100
random_seed=10,
@@ -3114,7 +3110,7 @@ def test_model_switch_high_rec(self):
31143110
population_size=10_000,
31153111
model=[
31163112
msprime.StandardCoalescent(duration=100),
3117-
msprime.SmcKApproxCoalescent(),
3113+
msprime.SmcKApproxCoalescent(hull_offset=1),
31183114
],
31193115
random_seed=10,
31203116
recombination_rate=1e-4,
@@ -3149,7 +3145,7 @@ def test_two_pops(self):
31493145
ts = msprime.sim_ancestry(
31503146
samples={0: 2, 1: 2},
31513147
demography=demography,
3152-
model=msprime.SmcKApproxCoalescent(),
3148+
model=msprime.SmcKApproxCoalescent(hull_offset=1),
31533149
random_seed=74024,
31543150
recombination_rate=1e-5,
31553151
sequence_length=100,
@@ -3166,7 +3162,7 @@ def test_gc(self):
31663162
):
31673163
msprime.sim_ancestry(
31683164
samples=10,
3169-
model=msprime.SmcKApproxCoalescent(),
3165+
model=msprime.SmcKApproxCoalescent(hull_offset=1),
31703166
sequence_length=100,
31713167
gene_conversion_rate=1.0,
31723168
gene_conversion_tract_length=5,

tests/test_demography.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,7 @@ class TestMigrationRecordsSmcPrime(MigrationRecordsMixin):
25212521

25222522

25232523
class TestMigrationRecordsSmcK(MigrationRecordsMixin):
2524-
model = msprime.SmcKApproxCoalescent()
2524+
model = msprime.SmcKApproxCoalescent(hull_offset=1)
25252525

25262526

25272527
class TestMigrationRecordsDtwf(MigrationRecordsMixin):
@@ -2576,7 +2576,11 @@ def test_full_arg_migration(self):
25762576
self.verify_two_pops_full_arg(ts)
25772577

25782578
def test_full_arg_migration_smc(self):
2579-
for model in ["smc", "smc_prime", msprime.SmcKApproxCoalescent()]:
2579+
for model in [
2580+
msprime.SmcApproxCoalescent(),
2581+
msprime.SmcPrimeApproxCoalescent(),
2582+
msprime.SmcKApproxCoalescent(hull_offset=1),
2583+
]:
25802584
population_configurations = [
25812585
msprime.PopulationConfiguration(10),
25822586
msprime.PopulationConfiguration(10),

tests/test_models.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_smc_models(self):
6060
assert repr(model) == repr_s
6161
assert str(model) == repr_s
6262

63-
model = msprime.SmcKApproxCoalescent()
63+
model = msprime.SmcKApproxCoalescent(hull_offset=0.0)
6464
repr_s = "SmcKApproxCoalescent(duration=None, hull_offset=0.0)"
6565
assert repr(model) == repr_s
6666
assert str(model) == repr_s
@@ -144,7 +144,7 @@ def test_model_instances(self):
144144
msprime.StandardCoalescent(),
145145
msprime.SmcApproxCoalescent(),
146146
msprime.SmcPrimeApproxCoalescent(),
147-
msprime.SmcKApproxCoalescent(),
147+
msprime.SmcKApproxCoalescent(hull_offset=1),
148148
msprime.DiscreteTimeWrightFisher(),
149149
msprime.FixedPedigree(),
150150
msprime.SweepGenicSelection(
@@ -332,9 +332,6 @@ def test_sweep_genic_selection(self):
332332
msprime.SweepGenicSelection(1)
333333

334334
def test_smck_coalescent(self):
335-
model = msprime.SmcKApproxCoalescent()
336-
assert model.duration is None
337-
assert model.hull_offset == 0.0
338335

339336
model = msprime.SmcKApproxCoalescent(hull_offset=1.1)
340337
assert model.duration is None

verification.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4535,7 +4535,7 @@ class SmckvsSmcKApproxCoalescent(Test):
45354535
"""
45364536

45374537
models = {
4538-
"SmcKApprox": msprime.SmcKApproxCoalescent(),
4538+
"SmcKApprox": msprime.SmcKApproxCoalescent(hull_offset=0.0),
45394539
"smc": msprime.SmcApproxCoalescent(),
45404540
}
45414541

@@ -4955,9 +4955,9 @@ def test_gc_tract_length_smc(self):
49554955
Runs the check for the mean length of gene conversion tracts.
49564956
"""
49574957
models = {
4958-
"Hudson": msprime.SmcApproxCoalescent(),
4959-
"SMC": msprime.SmcKApproxCoalescent(),
4960-
"SMCK": msprime.StandardCoalescent(),
4958+
"SMC": msprime.SmcApproxCoalescent(),
4959+
"SMCK": msprime.SmcKApproxCoalescent(hull_offset=0.0),
4960+
"Hudson": msprime.StandardCoalescent(),
49614961
}
49624962
num_replicates = 10
49634963
n = 10
@@ -5053,7 +5053,7 @@ def test_smc_k_num_trees_gc(self):
50535053

50545054
models_to_run = [
50555055
(msprime.SmcApproxCoalescent(), "msprime (hudson)"),
5056-
(msprime.SmcKApproxCoalescent(), "smc"),
5056+
(msprime.SmcApproxCoalescent(), "smc"),
50575057
(msprime.SmcPrimeApproxCoalescent(), "smc_prime"),
50585058
(msprime.SmcKApproxCoalescent(hull_offset=0.0), "smc_k(0)"),
50595059
(msprime.SmcKApproxCoalescent(hull_offset=1.0), "smc_k(1)"),
@@ -5618,7 +5618,7 @@ def test_above_root_smck(self):
56185618
samples=10,
56195619
sequence_length=100,
56205620
recombination_rate=0.1,
5621-
model=msprime.SmcKApproxCoalescent(),
5621+
model=msprime.SmcKApproxCoalescent(hull_offset=0.0),
56225622
num_replicates=300,
56235623
)
56245624

0 commit comments

Comments
 (0)