Skip to content

Commit

Permalink
Add test_variant_str_no_samples and test_variant_str_no_site
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jul 27, 2022
1 parent 9183954 commit 1fa75c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/tests/test_genotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,33 @@ def test_variant_str(self):
str(v),
)

def test_variant_str_no_samples(self):
tables = tskit.TableCollection(10)
tables.nodes.add_row(flags=tskit.NODE_IS_SAMPLE, time=0)
tables.sites.add_row(position=5, ancestral_state="A")
ts = tables.tree_sequence()
v = next(ts.variants(samples=[]))
for allele in v.alleles:
if allele is not None:
assert (
re.search(
rf"║Samples with allele '{allele}'\s*│\s*0\s*\(nan\%\)║", str(v)
)
is not None
)

def test_variant_str_no_site():
tables = tskit.TableCollection(10)
ts = tables.tree_sequence()
v = tskit.Variant(ts)
s = str(v)
assert len(s.splitlines()) == 3
assert (
"This variant has not yet been decoded at a specific site,"
+ "call Variant.decode to set the site"
in s
)

def test_variant_html_repr(self, ts_fixture):
v = next(ts_fixture.variants())
html = v._repr_html_()
Expand Down

0 comments on commit 1fa75c9

Please sign in to comment.