`HgvsTools.is_intronic` misses intronic `r.` (RNA) variants
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
src/ga4gh/vrs/utils/hgvs_tools.py の HgvsTools.is_intronic から始め、src/ga4gh/vrs/extras/translator.py の関連するガードを確認してください。tests/test_hgvs_tools.py にネットワーク不要のパラメータ化マトリックスを追加するか実行し、c.、n.、r.、g.、UTR、および不確実なケースを網羅してください。完了の条件は、既存の分類を変更せずに、イントロンの r. 入力が c./n. と同様に拒否されることです。
索引モデルが issue の本文から書いたものです。
説明
Summary
HgvsTools.is_intronic gates on the outer sv.posedit.pos being a hgvs.location.BaseOffsetInterval. The hgvs library (2.0.0a0) emits BaseOffsetInterval for c. and n. variants but wraps r. (RNA) endpoints in a plain Interval, even though the inner positions are still BaseOffsetPositions carrying is_intronic=True. The outer-type gate therefore silently returns False for intronic r. inputs.
Both translator paths (AlleleTranslator._from_hgvs via extract_allele_values, and CnvTranslator._from_hgvs) rely on this check to reject intronic inputs before building a SequenceLocation. When the check is bypassed, downstream code accesses pos.start.base / pos.end.base and drops the intron offset, producing a SequenceLocation whose coordinates point at the exon-boundary position in the mature transcript rather than signaling an unrepresentable variant.
Per VRS 2.0 — Implied Sequence Coordinates, offset positions representing sequence not found on the SequenceReference cannot be encoded as VRS start/end values at all. Intronic HGVS inputs should therefore be rejected — which is what is_intronic is meant to do, and does correctly for c./n. but not r..
Reproducer
from ga4gh.vrs.utils.hgvs_tools import HgvsTools
from ga4gh.vrs.dataproxy import SeqRepoRESTDataProxy
dp = SeqRepoRESTDataProxy(
base_url="http://localhost:5000/seqrepo", disable_healthcheck=True
)
ht = HgvsTools(dp)
for expr in [
"NM_000001.1:c.100+5A>T", # c. intronic — correctly detected
"NR_000001.1:n.100+5A>T", # n. intronic — correctly detected
"NM_000001.1:r.100+5a>u", # r. intronic — silently missed
]:
sv = ht.parse(expr)
print(expr, "→ is_intronic:", ht.is_intronic(sv))
Output (current):
NM_000001.1:c.100+5A>T → is_intronic: True
NR_000001.1:n.100+5A>T → is_intronic: True
NM_000001.1:r.100+5a>u → is_intronic: False ← should be True
Real-world r. examples from ClinVar
The following r. expressions come from ClinVar.
All four parse cleanly under hgvs 2.0.0a0
and exhibit the same Interval + BaseOffsetPosition shape that motivates
this issue. They are all exonic (offset=0), so they are not affected
by the bug — they are correctly classified as non-intronic by both the
current and proposed is_intronic implementations. They are listed here as
representative real-world r. inputs to pin in future regression tests.
| Expression | Outer pos | Inner type | offset |
Intronic? |
|---|---|---|---|---|
NR_001566.1:r.398_399del |
Interval |
BaseOffsetPosition |
0 / 0 | No |
NR_001566.1:r.245del |
Interval |
BaseOffsetPosition |
0 / 0 | No |
NM_001374385.1:r.2843_2931del |
Interval |
BaseOffsetPosition |
0 / 0 | No |
NM_001323289.2:r.2632c>a |
Interval |
BaseOffsetPosition |
0 / 0 | No |
These examples confirm two relevant properties of the parser:
- The
Interval+BaseOffsetPositionwrapping is consistent acrossr.
inputs regardless of edit type (del,>) or accession namespace
(NM_*orNR_*). The proposed per-endpointisinstancecheck will
classify all four as non-intronic and allow them through. - The bug surfaces only when a hypothetical intronic counterpart
(e.g.NM_001374385.1:r.2843+1_2931del) is encountered. No such example
exists in the ClinVar set we inspected, which may be why the gap has not
been reported before.
If someone has a real intronic r. example from a curated source, it
should be added to the regression test matrix below.
Why the outer gate is wrong
Walking the parser's output for each prefix:
| Input | Outer sv.posedit.pos |
Inner .start / .end |
is_intronic(sv) should be |
|---|---|---|---|
g.100_200del |
Interval |
SimplePosition |
False (g. has no intronic concept) |
c.100+5A>T |
BaseOffsetInterval |
BaseOffsetPosition(offset=5) |
True |
c.100A>T |
BaseOffsetInterval |
BaseOffsetPosition(offset=0) |
False |
n.100+5A>T |
BaseOffsetInterval |
BaseOffsetPosition(offset=5) |
True |
r.100+5a>u |
Interval |
BaseOffsetPosition(offset=5) |
True (currently returns False) |
g.(A_B)_(C_D)del |
Interval(uncertain=True) |
nested Interval of SimplePosition |
False (parser forbids uncertain on c./n./r., so no intronic-uncertain combination is reachable) |
The r. row is the only case where the outer-gate check disagrees with the correct answer.
Proposed fix
Replace the container-type gate with per-endpoint isinstance checks on BaseOffsetPosition:
def is_intronic(self, sv: HgvsSequenceVariant) -> bool:
"""Check if the given SequenceVariant is intronic.
Tests each endpoint directly rather than gating on the outer container
type. hgvs 2.0.0a0 wraps the BaseOffsetPosition endpoints of ``r.`` (RNA)
variants in a plain ``Interval`` (not ``BaseOffsetInterval``); a
container-only gate silently misses ``r.`` intronic forms like
``r.100+5a>u``.
Returns:
bool: True if either endpoint is a :class:`BaseOffsetPosition` with
a non-zero (or ``None``) offset.
"""
start = sv.posedit.pos.start
end = sv.posedit.pos.end
return (
isinstance(start, hgvs.location.BaseOffsetPosition) and start.is_intronic
) or (
isinstance(end, hgvs.location.BaseOffsetPosition) and end.is_intronic
)
Behavior preservation across existing cases
g.*inputs:SimplePositionendpoints fail bothisinstancechecks →False(unchanged)c./n.exonic:BaseOffsetPosition(offset=0)→isinstanceTrue,is_intronicFalse →False(unchanged)c./n.intronic (either side):is_intronicTrue on at least one endpoint →True(unchanged)- UTR forms like
c.-10/c.*10:BaseOffsetPosition(offset=0)→False(unchanged) - Uncertain ranges on
g.: inner endpoints are nestedInterval, notBaseOffsetPosition→False(unchanged; correct sinceg.has no intronic concept) r.intronic: now returnsTrue— this is the fix.
Callsites require no changes
Both existing guards — src/ga4gh/vrs/utils/hgvs_tools.py:282-284 and src/ga4gh/vrs/extras/translator.py:491-493 — consume only the boolean return and raise ValueError("Intronic HGVS variants are not supported") when True. Behavior for previously-rejected inputs is unchanged.
Test case
Add a network-free parametrized test to tests/test_hgvs_tools.py. No data-proxy or cassette needed — the check operates purely on the parsed hgvs object. Suggested parametrization covers every row of the matrix above.
import hgvs.parser
import pytest
from ga4gh.vrs.utils.hgvs_tools import HgvsTools
@pytest.fixture(scope="module")
def hgvs_tools():
# is_intronic doesn't touch the data_proxy; pass None to avoid wiring
# up seqrepo/UTA for a pure shape test.
return HgvsTools(data_proxy=None)
class TestIsIntronic:
"""Pins the behavior of :meth:`HgvsTools.is_intronic` across every
HGVS prefix and endpoint-shape combination the hgvs parser can produce.
"""
@pytest.mark.parametrize(
("hgvs_expr", "expected"),
[
# Genomic: no intronic concept
("NC_000001.11:g.100_200del", False),
# Coding: exonic, 5' UTR, 3' UTR
("NM_000001.1:c.100A>T", False),
("NM_000001.1:c.-10A>T", False),
("NM_000001.1:c.*10A>T", False),
# Coding: intronic
("NM_000001.1:c.100+5A>T", True),
("NM_000001.1:c.100-3A>T", True),
# Coding: mixed intronic / exonic endpoints
("NM_000001.1:c.100+5_200del", True),
("NM_000001.1:c.100_200+5del", True),
# Non-coding transcript
("NR_000001.1:n.100A>T", False),
("NR_000001.1:n.100+5A>T", True),
# RNA — the gap this issue addresses
("NM_000001.1:r.100a>u", False),
("NM_000001.1:r.100+5a>u", True),
# ClinVar-derived real-world r. examples (all exonic; confirm
# the proposed per-endpoint check correctly classifies them)
("NR_001566.1:r.398_399del", False),
("NR_001566.1:r.245del", False),
("NM_001374385.1:r.2843_2931del", False),
("NM_001323289.2:r.2632c>a", False),
# Genomic uncertain range (structural form #609 uses)
("NC_000001.11:g.(100_200)_(300_400)del", False),
],
)
def test_is_intronic_matrix(self, hgvs_tools, hgvs_expr, expected):
sv = hgvs_tools.parse(hgvs_expr)
assert hgvs_tools.is_intronic(sv) is expected
Note: HgvsTools.__init__ currently opens a UTA connection unconditionally. For this test to be truly network-free, the fixture may need HgvsTools.is_intronic to tolerate data_proxy=None at construction — if that's not already the case, either lazy-init the UTA connection or move is_intronic to a free-function helper that doesn't take self. Either shape is a small refactor, scope-adjacent to this issue.
Scope and impact
- Pre-existing gap; not introduced by or related to issue #609.
- Impact for consumers: any
r.100+5a>u-style intronic RNA input that made it throughAlleleTranslator._from_hgvson the current v3 code would have produced aSequenceLocationwith coordinates that don't reflect the intronic offset (off by the offset's magnitude). After the fix, the same input raisesValueError("Intronic HGVS variants are not supported"), matching thec./n.behavior. - No
r.test cases exist in the current test suite, consistent withr.being a less commonly used HGVS prefix for vrs-python's consumers. Opening this issue separately (rather than bundling into the #609 PR) keeps the scope clean and lets a maintainer decide whetherr.support is in-scope to harden or out-of-scope to reject upstream.
Alternative: reject r. outright
If r. is deemed out of scope for vrs-python, a simpler fix is to reject all r. inputs (the way p. protein inputs are rejected at src/ga4gh/vrs/utils/hgvs_tools.py:397-399 on the reverse path). That is a stricter but less surgical change and should be decided separately by the project maintainers.
- 主要言語
- Python
- スター
- 64
- フォーク
- 45
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ga4gh/vrs-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ga4gh/vrs-python#540 · コメント 8 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
ga4gh/vrs-python#673 ·
メンテナーはふだん 2 日以内に返信
-
Merge `vrs/2.1` into `v3`対応中かも @korikuzma が 2 日前に担当しました。 オープンv3
ga4gh/vrs-python#672 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
ga4gh/vrs-python#669 ·
メンテナーはふだん 2 日以内に返信
-
test(ci): dont make live network requests対応中かも @theferrit32 が 16 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
ga4gh/vrs-python#659 · コメント 1 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
ga4gh/vrs-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
zach-blumenfeld/aip#13 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
nathanmarlor/foxess_modbus#1287 ·
メンテナーはふだん 4 日以内に返信
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
OpenLakeForge/openlakeforge#498 ·
メンテナーはふだん 1 日以内に返信
-
good first issue hacktoberfest help wanted python
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
pollen-robotics/reachy_mini#1493 ·
メンテナーはふだん 1 日以内に返信