Skip to content

feat(reactome): add gget reactome module to query the Reactome pathway database (#114)#236

Open
Elarwei001 wants to merge 5 commits into
scverse:devfrom
Elarwei001:feature/reactome-114
Open

feat(reactome): add gget reactome module to query the Reactome pathway database (#114)#236
Elarwei001 wants to merge 5 commits into
scverse:devfrom
Elarwei001:feature/reactome-114

Conversation

@Elarwei001

@Elarwei001 Elarwei001 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Resolves #114

What this adds

A new gget reactome module that queries the Reactome pathway knowledgebase via its ContentService REST API, returning gget-ified data frames (or list-of-dicts with json=True). The query type is selected with the resource argument:

resource Returns query is
pathways (default) the pathways an identifier participates in an identifier (e.g. UniProt P04637)
search full-text search of the knowledgebase a search term (e.g. TP53)
entity details for a Reactome stable ID a stable ID (e.g. R-HSA-6804754)
interactors molecular interactors (IntAct static) a molecule accession
orthology project a stable ID to another species a stable ID (needs --species)
event-hierarchy the full pathway/reaction hierarchy for a species a species name or taxon ID
gget reactome P04637 --species "Homo sapiens"                 # pathways
gget reactome TP53 -r search -t Pathway                       # search
gget reactome R-HSA-6804754 -r entity                         # entity
gget reactome P04637 -r interactors                           # interactors
gget reactome R-HSA-6804754 -r orthology -sp "Mus musculus"   # orthology
gget reactome "Homo sapiens" -r event-hierarchy               # event hierarchy
  • source selects the identifier database for pathways (UniProt default, Ensembl, ChEBI, NCBI); species / types filter where applicable.
  • Names from the search endpoint have Reactome's HTML highlight tags stripped; the returned data frame carries the Reactome release in .attrs["reactome_release"] for reproducibility.
  • CLI format follows gget's convention: JSON by default, --csv for CSV.

Robustness

http_json now raises HTTPStatusError (a RuntimeError subclass carrying .status_code), so reactome branches on the status code (e.g. 404 → empty result / clear ValueError) instead of string-matching the error message. Backward-compatible: existing except RuntimeError callers are unaffected.

Testing

  • Network-free unit tests (TestReactomeOffline): parsing and error branches for every resource, HTML stripping, name/summation fallbacks, species resolution, and argument validation.
  • Network tests (TestReactome) that assert structural invariants (columns, identifier shape, species honored, a stable well-known entry) rather than drift-prone exact lists, and skip when Reactome is unreachable. Includes a species-by-name case.

@codecov-commenter

codecov-commenter commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.94118% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.56%. Comparing base (e43a804) to head (5e3b536).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
gget/gget_reactome.py 93.25% 11 Missing ⚠️
gget/utils.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #236      +/-   ##
==========================================
+ Coverage   56.70%   57.56%   +0.85%     
==========================================
  Files          29       30       +1     
  Lines        9392     9560     +168     
==========================================
+ Hits         5326     5503     +177     
+ Misses       4066     4057       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Elarwei001 Elarwei001 marked this pull request as draft June 25, 2026 03:44
@lauraluebbert lauraluebbert deleted the branch scverse:dev June 28, 2026 20:31
@lauraluebbert lauraluebbert reopened this Jun 28, 2026
Elarwei001 and others added 3 commits June 28, 2026 19:51
…y database (scverse#114)

New module `gget reactome` (Python API + CLI) querying the Reactome
ContentService REST API (https://reactome.org/). Supports three query
types via the `resource` argument:
  - pathways (default): the Reactome pathways an identifier (e.g. a
    UniProt accession) participates in
  - search: full-text search of the Reactome knowledgebase
  - entity: details for a Reactome stable ID

Returns a pandas DataFrame (or JSON with json=True / --csv on the CLI).
Reuses the shared http_json helper for retries/error handling, strips
HTML highlight tags from search results, and maps Reactome 404s to empty
results (pathways/search) or a clear ValueError (entity).

Adds unit tests (offline argument validation via fixture + release-robust
network smoke tests that skip when Reactome is unreachable), docs page
docs/src/en/reactome.md, a SUMMARY.md entry, and an updates.md note.

Resolves scverse#114.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a network-free TestReactomeOffline class that mocks http_json to
cover _strip_html passthrough, the pathways/search/entity parsing,
verbose logging, 404 and non-404 error branches, the entity name
fallback/summation, and resource/query validation. gget_reactome.py now
98% (only the import-time PackageNotFoundError version fallback, lines
16-17, remains, which is un-coverable in an installed environment).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lauraluebbert lauraluebbert force-pushed the feature/reactome-114 branch from 400a044 to 3ef868a Compare June 28, 2026 23:55
Elarwei001 added a commit to Elarwei001/gget_issues that referenced this pull request Jul 6, 2026
Bilingual (ZH/EN) analysis of scverse/gget#236 (new gget reactome module:
pathways/search/entity queries over Reactome's ContentService REST API).
Verified all three endpoints live; covers platform fit (strong, query-type,
maintainer-requested), the good invariant-based live-test design, and the
pre-commit.ci red root cause (a single mypy annotation at main.py:3923).
Updated README index + index.html card.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Elarwei001 and others added 2 commits July 6, 2026 21:46
…xes (scverse#114)

New resource query types for gget reactome, plus the review follow-ups:

- resource="interactors": molecular interactors of an identifier (IntAct static),
  columns [interactor_acc, interactor_name, score, evidences].
- resource="orthology": project a Reactome stable ID to its ortholog in another
  species (requires species; resolves the species name/taxId to Reactome's dbId).
- resource="event-hierarchy": the full pathway/reaction hierarchy for a species,
  flattened to one row per event with parent_id and nesting level.

Review fixes:
- Fix the CLI type annotation that failed pre-commit.ci (main.py: cast the
  reactome() result, which is a DataFrame in the CLI path).
- Structured 404 detection: http_json now raises HTTPStatusError (a RuntimeError
  subclass carrying .status_code), and reactome checks the code instead of
  string-matching the message. Backward-compatible for existing http_json callers.
- Record the Reactome release in df.attrs["reactome_release"] for reproducibility.
- Add a network test that passes species as a name (not just a taxon ID).

Tests: offline mocks for the three new resources (+ species resolution and error
branches) and network invariant tests that skip when Reactome is unreachable.
Docs: reactome.md resource list, --resource/--species, examples; changelog.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- References: list the Reactome (data source) citation before gget's own.
- Remove the "Resolves issue 114" text from the changelog entry (doc pages
  don't need the issue link).
- Add docs/src/es/reactome.md (Spanish translation) and its SUMMARY entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Elarwei001

Copy link
Copy Markdown
Contributor Author

Hi @lauraluebbert — this adds the gget reactome module that querying Reactome's ContentService REST API.

Key points:

  1. What it does — one module, six query types via resource (pathways/search/entity/interactors/orthology/event-hierarchy, same pattern as opentargets).

  2. Scope & shape trade-offs — deliberately query/fetch only (left out Reactome's Analysis Service since that's enrichment, which gget enrichr covers); orthology takes a species name/taxon ID (resolved to Reactome's dbId); event-hierarchy is flattened to one row per event (a large table for human).

  3. Robustness + reproducibility — http_json now raises a small HTTPStatusError (RuntimeError subclass with .status_code) so 404s branch on status, not string-matching (backward-compatible); data frames carry the Reactome release in .attrs["reactome_release"].

would appreciate a review whenever you have a moment. Thanks

@Elarwei001 Elarwei001 marked this pull request as ready for review July 6, 2026 14:01
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.

3 participants