Skip to content

Commit

Permalink
use Invitae examples as bidirectional g↔t tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reece committed Mar 25, 2020
1 parent 0846086 commit ebb9c44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hgvs/variantmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def t_to_g(self, var_t, alt_ac, alt_aln_method=hgvs.global_config.mapping.alt_al
var_t.fill_ref(self.hdp)
mapper = self._fetch_AlignmentMapper(
tx_ac=var_t.ac, alt_ac=alt_ac, alt_aln_method=alt_aln_method)
if mapper.is_coding_transcript:
if var_t.type == "c":
var_out = VariantMapper.c_to_g(
self, var_c=var_t, alt_ac=alt_ac, alt_aln_method=alt_aln_method)
else:
Expand Down
20 changes: 15 additions & 5 deletions tests/issues/test_437.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,38 @@ def test_oob_dup(parser, am37):




def test_invitae_examples(parser, am37):
tests = [
"""bidirectional g↔t tests of out-of-bounds variants provided by Invitae"""
invitae_examples = [
("NC_000009.11:g.35658020C>T", "NR_003051.3:n.-5G>A"),

# ("NC_000009.11:g.35657741A>G", "NR_003051.3:n.*7T>C"),
# See #592: hgvs doesn't support n.* coordinates, so
# rewrite of previous variant with SEQ_START coordinate
("NC_000009.11:g.35657741A>G", "NR_003051.3:n.275T>C"),

# Same position, just testing c-n conversion
("NC_000001.10:g.18807339T>C", "NM_152375.2:n.-85T>C"),
# Broken, probably in c-to-n translation:
#("NC_000001.10:g.18807339T>C", "NM_152375.2:c.-137T>C"),
]

hgvs.global_config.mapping.strict_bounds = False

for hgvs_g, hgvs_t in tests:
for hgvs_g, hgvs_t in invitae_examples:
var_g = parser.parse(hgvs_g)
var_t = parser.parse(hgvs_t)
assert hgvs_t == str(am37.g_to_t(var_g, var_t.ac))
assert hgvs_g == str(am37.t_to_g(var_t))
if var_t.type == "c":
assert hgvs_t == str(am37.g_to_c(var_g, var_t.ac))
else:
assert hgvs_t == str(am37.g_to_n(var_g, var_t.ac))

hgvs.global_config.mapping.strict_bounds = True




if __name__ == "__main__":
from hgvs.easy import *
test_437(parser=parser, am=am37)

0 comments on commit ebb9c44

Please sign in to comment.