feat: Gene Info Endpoint#756
Open
bencap wants to merge 3 commits into
Open
Conversation
- 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.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.GeneResponseinsrc/mavedb/view_models/gene.pyto structure the gene data and associated score sets returned by the endpoint.src/mavedb/server_main.py). [1] [2] [3]HGNC REST client and error handling
src/mavedb/lib/hgnc/client.pyto fetch and validate gene information, with custom exceptions for not found and service errors.HGNCGeneNotFoundErrorandHGNCServiceErrorinsrc/mavedb/lib/exceptions.pyfor precise error reporting.Configuration and constants
HGNC_REST_BASE_URLconstant to centralize the HGNC API base URL.Testing
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.