diff --git a/mutalyzer/util.py b/mutalyzer/util.py index a76ad3612e488dd1ad2d4897dda3acb170bd0633..c53d913054f17576e7bcdc40d1a0fc1ed57cda0e 100644 --- a/mutalyzer/util.py +++ b/mutalyzer/util.py @@ -424,7 +424,7 @@ def in_frame_description(s1, s2): >>> in_frame_description('MTAPQQMT*', 'MTAPQQMTMQ*') ('p.(*9Metext*2)', 8, 9, 11) >>> in_frame_description('MTAPQQMT*', 'MTAPQQMTMQ') - ('p.(*9Metext*?)', 8, 8, 10) + ('p.(*9Metext*?)', 8, 9, 10) @arg s1: The original protein. @type s1: unicode @@ -441,6 +441,7 @@ def in_frame_description(s1, s2): @todo: More intelligently handle longest_common_prefix(). @todo: Refactor this code (too many return statements). """ + s2_stop = '*' in s2 s1 = s1.rstrip('*') s2 = s2.rstrip('*') @@ -448,7 +449,6 @@ def in_frame_description(s1, s2): # Nothing happened. return ('p.(=)', 0, 0, 0) - s2_stop = '*' in s2 lcp = len(longest_common_prefix(s1, s2)) lcs = len(longest_common_suffix(s1[lcp:], s2[lcp:])) s1_end = len(s1) - lcs diff --git a/tests/test_util.py b/tests/test_util.py new file mode 100644 index 0000000000000000000000000000000000000000..771830987639710e08debc7af499a7eb7e4e0df5 --- /dev/null +++ b/tests/test_util.py @@ -0,0 +1,37 @@ +""" +Tests for the mutalyzer.util module. +""" + + +from __future__ import unicode_literals + +import pytest + +from mutalyzer import util + + +@pytest.mark.parametrize('ref,var,descr,first,last_ref,last_var', [ + ('MTAPQQMT*', 'MTAQQMT*', 'p.(Pro4del)', 3, 4, 3), + ('MTAPQQMT*', 'MTAQMT*', 'p.(Pro4_Gln5del)', 3, 5, 3), + ('MTAPQQT*', 'MTAQQMT*', 'p.(Pro4_Gln6delinsGlnGlnMet)', 3, 6, 6), + ('MTAPQQMT*', 'MTAPQQMTMQ*', 'p.(*9Metext*2)', 8, 9, 11), + ('MTAPQQMT*', 'MTAPQQMTMQ', 'p.(*9Metext*?)', 8, 9, 10)]) +def test_in_frame_description(ref, var, descr, first, last_ref, last_var): + """ + In-frame description of difference between two proteins. + """ + assert util.in_frame_description(ref, var) == ( + descr, first, last_ref, last_var) + + +@pytest.mark.parametrize('ref,var,descr,first,last_ref,last_var', [ + ('MTAPQQMT*', 'MTAQQMT*', 'p.(Pro4Glnfs*5)', 3, 9, 8), + ('MTAPQQMT*', 'MTAQMT*', 'p.(Pro4Glnfs*4)', 3, 9, 7), + ('MTAPQQT*', 'MTAQQMT*', 'p.(Pro4Glnfs*5)', 3, 8, 8), + ('MTAPQQT*', 'MTAQQMT', 'p.(Pro4Glnfs*?)', 3, 8, 7)]) +def test_out_of_frame_description(ref, var, descr, first, last_ref, last_var): + """ + Out-of-frame description of difference between two proteins. + """ + assert util.out_of_frame_description(ref, var) == ( + descr, first, last_ref, last_var) diff --git a/tests/test_variantchecker.py b/tests/test_variantchecker.py index 897a3e08c9f722d15804eb1dfb004d10a5413c35..0018472ae30d119356aee2ce1ad5d7ad4997876b 100644 --- a/tests/test_variantchecker.py +++ b/tests/test_variantchecker.py @@ -1590,3 +1590,12 @@ def test_legend_mrna_by_construction(output, checker): ['SDHD_v001', None, None, None, 'construction'], ['SDHD_i001', 'BAA81889.1', None, 'small subunit of cytochrome b of succinate dehydrogenase', 'construction'] ] + +@with_references('NM_000143.3') +def test_protein_ext_stop(output, checker): + """ + Variant in stop codon where an alternative stop codon is found downstream + in the RNA should yield `ext*P` where P is a position. + """ + checker('NM_000143.3:c.1531T>G') + assert 'NM_000143.3(FH_i001):p.(*511Glyext*3)' in output.getOutput('protDescriptions')