Skip to content

Commit

Permalink
issue biocommons#606 - reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
kayleeyuhas committed Dec 23, 2020
1 parent 5d579a8 commit a84ba97
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
8 changes: 5 additions & 3 deletions hgvs/variantmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import hgvs.sequencevariant
import hgvs.validator

from hgvs.exceptions import HGVSDataNotAvailableError, HGVSUnsupportedOperationError, HGVSInvalidVariantError, \
from hgvs.exceptions import HGVSUnsupportedOperationError, HGVSInvalidVariantError, \
HGVSInvalidIntervalError
from hgvs.decorators.lru_cache import lru_cache
from hgvs.enums import PrevalidationLevel
Expand Down Expand Up @@ -162,7 +162,8 @@ def g_to_n(self, var_g, tx_ac, alt_aln_method=hgvs.global_config.mapping.alt_aln
alt_ac=var_g.ac,
alt_aln_method=alt_aln_method)

if (mapper.strand == -1 and not hgvs.global_config.mapping.strict_bounds
if (mapper.strand == -1
and not hgvs.global_config.mapping.strict_bounds
and not mapper.g_interval_is_inbounds(var_g.posedit.pos)):
_logger.info("Renormalizing out-of-bounds minus strand variant on genomic sequence")
var_g = self.left_normalizer.normalize(var_g)
Expand All @@ -184,7 +185,8 @@ def g_to_n(self, var_g, tx_ac, alt_aln_method=hgvs.global_config.mapping.alt_aln
var_n = hgvs.sequencevariant.SequenceVariant(ac=tx_ac,
type="n",
posedit=hgvs.posedit.PosEdit(pos_n, edit_n))
if (self.replace_reference and var_n.posedit.pos.start.base >= 0
if (self.replace_reference
and var_n.posedit.pos.start.base >= 0
and var_n.posedit.pos.end.base < mapper.tgt_len):
self._replace_reference(var_n)
if self.add_gene_symbol:
Expand Down
17 changes: 9 additions & 8 deletions tests/issues/test_606.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@

class TestIssue606(unittest.TestCase):
def test_606(self):
"""https://github.com/biocommons/hgvs/issues/606"""

from hgvs.easy import am37, parser
"""
https://github.com/biocommons/hgvs/issues/606
Occasionally, an IndexError is thrown by the _get_altered_sequence method. This seems to occur
when there is either inconsistent data for a transcript in UTA or an invalid variant input.
There could be other root causes, but these are two that we have observed and are illustrated in the
There could be other root causes, but these are two that we have observed and are illustrated in the
examples below.
Example 1 (NC_000001.10:g.16890441C>G):
Transcript NM_017940.4 has inconsistent data. 25 exons in the 'transcript' alignment to itself,
but 28 exons in the 'splign' alignment to the reference sequence.
Transcript NM_017940.4 has inconsistent data. 25 exons in the 'transcript' alignment to itself,
but 28 exons in the 'splign' alignment to the reference sequence.
Ends up with an index error in _get_altered_sequence.
Example 2 (NM_001291722.1:c.283-3C>T):
This is invalid input -- according to the transcript in UTA, exon 5 starts at position 286 of the transcript,
not position 283. Ends up with an index error in _get_altered_sequence.
"""

from hgvs.easy import am37, parser

# Example 1
hgvs.global_config.mapping.strict_bounds = False
hgvs_g = 'NC_000001.10:g.16890441C>G'
Expand Down

0 comments on commit a84ba97

Please sign in to comment.