Skip to content

Fix #242: expose annotation versions on Gene/Transcript/Exon/Protein#341

Merged
iskandr merged 1 commit into
mainfrom
fix-242-version-and-versioned-id
May 12, 2026
Merged

Fix #242: expose annotation versions on Gene/Transcript/Exon/Protein#341
iskandr merged 1 commit into
mainfrom
fix-242-version-and-versioned-id

Conversation

@iskandr

@iskandr iskandr commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #242 by surfacing the Ensembl annotation version columns (already loaded into the sqlite DB) on Gene, Transcript, Exon, and a new Protein view object accessed via Transcript.protein.

Each type has a prefixed canonical accessor plus a generic alias:

Entity Canonical Alias
Gene gene_version, versioned_gene_id version, versioned_id
Transcript transcript_version, versioned_transcript_id version, versioned_id
Exon exon_version, versioned_exon_id version, versioned_id
Protein (via t.protein) protein_id, protein_version, versioned_protein_id id, version, versioned_id

Example:

t = ensembl.transcript_by_id("ENSMUST00000103109")
t.transcript_version       # 3
t.versioned_transcript_id  # "ENSMUST00000103109.3"
t.version                  # 3  (alias)
t.versioned_id             # "ENSMUST00000103109.3"  (alias)
t.protein.id               # "ENSMUSP00000099398"
t.protein.versioned_id     # "ENSMUSP00000099398.3"

When the GTF omits version attributes (e.g. TAIR), every *_version returns None and versioned_* falls back to the unversioned id.

Compatibility

  • Exon.__init__ gains a keyword-only exon_version=None (default preserves the old signature for positional callers).
  • Transcript.protein_id and Transcript.protein_sequence stay; the new Transcript.protein is purely additive.
  • Pyensembl's existing .N-stripping of FASTA IDs is unchanged — those strips are needed for sequence lookup and are orthogonal to surfacing the version on the metadata objects.
  • Bumps version to 2.7.0 (additive features, no breakage).

Test plan

  • tests/test_versions.py covers Gene/Transcript/Exon/Protein versions on mouse Ensembl 81 partial data (versions present) and on TAIR partial data (versions absent)
  • pytest tests/test_versions.py tests/test_mouse.py tests/test_tair10_complete.py tests/test_serialization.py tests/test_missing_genome_sources.py tests/test_exon_object.py tests/test_locus.py tests/test_shell.py
  • ./lint.sh
  • CI on PR

…Protein

The transcript_version, gene_version, exon_version, and protein_version
columns were already loaded into the sqlite database from modern Ensembl
GTFs; they were just never surfaced on the Python objects.

Each entity now has a prefixed canonical accessor and a generic alias:

  Gene       gene_version       / versioned_gene_id
              version            / versioned_id  (aliases)

  Transcript transcript_version / versioned_transcript_id
              version            / versioned_id  (aliases)
              protein            -> new Protein view (or None for noncoding)

  Exon       exon_version       / versioned_exon_id
              version            / versioned_id  (aliases)
              exon_version is now a constructor kwarg (default None)

  Protein    protein_id, protein_version (primary)
              id, version, versioned_protein_id, versioned_id (aliases)

All version accessors return None when the GTF omits the corresponding
attribute (e.g. TAIR), and versioned_id falls back to the unversioned id
in that case.

Bump version to 2.7.0.
@iskandr iskandr merged commit ca51c48 into main May 12, 2026
10 checks passed
@iskandr iskandr deleted the fix-242-version-and-versioned-id branch May 12, 2026 16:52
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 84.129% (+0.6%) from 83.547% — fix-242-version-and-versioned-id into main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensemble version of transcript in python API?

2 participants