Skip to content

Commit f5c89e0

Browse files
committed
Extra test for node extent
1 parent ef50286 commit f5c89e0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

python/tests/test_genotypes.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,33 @@ def test_nexus_impute_missing(self):
18351835
)
18361836

18371837

1838+
class TestAlignmentsPartialIsolation:
1839+
def build_ts(self):
1840+
# sequence length 10, sample node covers only [3,7)
1841+
tables = tskit.TableCollection(10)
1842+
parent = tables.nodes.add_row(time=1)
1843+
child = tables.nodes.add_row(flags=tskit.NODE_IS_SAMPLE, time=0)
1844+
tables.edges.add_row(left=3, right=7, parent=parent, child=child)
1845+
# Add a site inside the covered region with a mutation on the child
1846+
site_id = tables.sites.add_row(position=5, ancestral_state="A")
1847+
tables.mutations.add_row(site=site_id, node=child, derived_state="G")
1848+
tables.sort()
1849+
return tables.tree_sequence()
1850+
1851+
def test_whole_window_missing_at_ends(self):
1852+
ts = self.build_ts()
1853+
ref = "0123456789"
1854+
# Node is isolated outside [3,7): expect missing there; inside use ref, with site overlay at 5
1855+
got = list(ts.alignments(samples=[1], reference_sequence=ref))
1856+
assert got == ["NNN34G6NNN"]
1857+
1858+
def test_subwindow(self):
1859+
ts = self.build_ts()
1860+
ref = "0123456789"
1861+
# Request [2,8): expect missing at 2 and 7, ref inside, site overlay at 5
1862+
got = list(ts.alignments(samples=[1], reference_sequence=ref[2:8], left=2, right=8))
1863+
assert got == ["N34G6N"]
1864+
18381865
class TestMultiRootExample:
18391866
# 1.00┊ 4 5 ┊
18401867
# ┊ ┏┻┓ ┏┻┓ ┊

0 commit comments

Comments
 (0)