Skip to content

feat: Gene Info Endpoint#756

Open
bencap wants to merge 3 commits into
release-2026.2.4from
feature/bencap/gene-page-api-support
Open

feat: Gene Info Endpoint#756
bencap wants to merge 3 commits into
release-2026.2.4from
feature/bencap/gene-page-api-support

Conversation

@bencap
Copy link
Copy Markdown
Collaborator

@bencap bencap commented May 20, 2026

API support for VariantEffect/mavedb-ui#682

This pull request introduces a new /genes/{symbol} API endpoint that provides gene identity and associated published score sets using data from the HGNC REST API. The implementation includes robust error handling, a new client for interacting with HGNC, and comprehensive tests to ensure reliability and correct behavior.

Major features and changes:

New gene endpoint and API integration

  • Added a new FastAPI router (src/mavedb/routers/genes.py) that exposes a /genes/{symbol} endpoint. This endpoint fetches gene information from the HGNC REST API and returns it along with associated public score sets, supporting pagination and error handling.
  • Introduced a new response model GeneResponse in src/mavedb/view_models/gene.py to structure the gene data and associated score sets returned by the endpoint.
  • Registered the new router and its OpenAPI metadata in the main application (src/mavedb/server_main.py). [1] [2] [3]

HGNC REST client and error handling

  • Implemented an HGNC REST client in src/mavedb/lib/hgnc/client.py to fetch and validate gene information, with custom exceptions for not found and service errors.
  • Defined new exceptions HGNCGeneNotFoundError and HGNCServiceError in src/mavedb/lib/exceptions.py for precise error reporting.
  • Added FastAPI exception handlers to return appropriate HTTP status codes (404 for not found, 503 for service errors) and log errors for these new exceptions.

Configuration and constants

  • Added the HGNC_REST_BASE_URL constant to centralize the HGNC API base URL.

Testing

  • Added unit tests (tests/lib/hgnc/test_hgnc_client.py) and network tests (tests/lib/hgnc/network/test_hgnc_client.py) to cover the new client’s behavior, including error cases and integration with the live HGNC REST API. [1] [2]

These changes together enable robust, production-ready gene lookup and score set retrieval by symbol, backed by HGNC’s authoritative gene data and integrated with MaveDB’s public score set system.

bencap added 3 commits May 20, 2026 16:11
- Add `src/mavedb/lib/hgnc/client.py` with `fetch_gene_info()` that
  queries the HGNC REST API and returns a `HGNCGeneInfo` dataclass
  (symbol, name, hgnc_id, locus_group, location, omim_id)
- Add `HGNCGeneNotFoundError` and `HGNCServiceError` domain exceptions
  to `lib/exceptions.py`
- Add `HGNC_REST_BASE_URL` constant and package `__init__` files
- Add unit and network integration tests for the new client
- Add `GET /genes/{symbol}` router that fetches HGNC gene identity
  and returns paginated published score sets targeting that gene
- Add `GeneResponse` view model with gene metadata and score set
  pagination fields (limit, offset, total, total_scored_variants)
- Register the genes router in `server_main.py`
- Add `GeneSymbolConverter` for URL path parameter validation
- Add router tests covering happy path and error cases
Add `pytest.importorskip("starlette")` guard to both HGNC client test
files, since the logging context module depends on starlette and would
cause an ImportError in environments where starlette is absent.
@bencap bencap linked an issue May 20, 2026 that may be closed by this pull request
5 tasks
@bencap bencap changed the title Feature/bencap/gene page api support feat: Gene Info Endpoint May 20, 2026
@bencap bencap changed the base branch from release-2026.2.3 to release-2026.2.4 May 21, 2026 18:10
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.

Gene Level Clinical Page

1 participant