create_missing_features: opt-in / configurable strictness for synthesized parent rows

オープン
#65 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python

調査の方向性

gtfparse.create_missing_features から始め、pyensembl の transcript.py にある下流の例を確認します。これには column_exists("exon", "exon_id") のチェックと Transcript.coding_sequence の動作が含まれます。提案されている strict/policy オプションと required_attributes_per_feature の設計を比較し、デフォルトでは best-effort の動作を維持します。合成された parent 属性が不十分な場合に、呼び出し側が例外を発生させるか、警告してスキップするかを選択でき、既存のデフォルトが変更されていなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

Observation

pyensembl calls gtfparse.create_missing_features to backfill transcript and gene rows that the GTF omits (legitimate when the upstream only emits exon / CDS). The synthesizer derives the parent feature from the child rows it sees, which is usually correct — but when the input GTF deviates in ways the synthesizer doesn't anticipate, downstream consumers have to clean up.

Two recent pyensembl issues are downstream of this:

  • openvax/pyensembl#331 / v2.6.4 — older Ensembl releases (e.g. release 54) omit exon_id. create_missing_features synthesizes transcript rows that don't carry exon_id either, and pyensembl's Transcript.exons then crashed with sqlite3.OperationalError: no such column: exon_id. Workaround lives in pyensembl: a column_exists("exon", "exon_id") check at transcript.py:149.
  • openvax/pyensembl#252 / v2.6.4 — TAIR chr_patch_hapl_scaff fragments contain CDS rows without matching start_codon/stop_codon. After feature synthesis the transcript row exists but coding_sequence couldn't compute its endpoints. Workaround in pyensembl: Transcript.coding_sequence returns None rather than raising.

In both cases the inconsistency is structural to the input GTF rather than to gtfparse's logic, but a caller-side knob would help.

Proposal

Add a strict / policy kwarg to create_missing_features:

  • strict="raise" — when a child row lacks attributes the synthesizer would need to faithfully build the parent, raise.
  • strict="warn" — log + skip the synthesized row.
  • strict="best_effort" — current behavior; synthesize whatever we can, fill missing attrs with None.

Or more granularly: a required_attributes_per_feature: dict[str, set[str]] knob so callers can pin "if you're going to synthesize a transcript row, only do so when the child exon carries exon_id".

Why it'd help

The two issues above both look like "pyensembl handles partial GTFs" but the upstream signal that something's off (exon_id missing, start_codon missing) gets eaten by the synthesizer and lives later as a crash at query time.

Scope guard

  • Existing default behavior should stay best-effort. This is purely additive.
  • Bacteria/archaea GFFs with their own synthesis quirks are out of scope for this issue (separate parser ecosystem).
主要言語
Python
スター
130
フォーク
34
平均マージ
23時間 45分
マージ済み PR(30日)
9

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openvax/gtfparse のほかの issue

openvax/gtfparse の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。