From 28427f199dff87b26410caad0f377c4b9f35196a Mon Sep 17 00:00:00 2001 From: Katie Stahl Date: Thu, 16 Nov 2023 13:44:48 -0500 Subject: [PATCH] feat: add transcript lookup for genes --- server/curfu/routers/utilities.py | 11 +++++++++-- server/curfu/schemas.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/curfu/routers/utilities.py b/server/curfu/routers/utilities.py index 5473812c..ed502364 100644 --- a/server/curfu/routers/utilities.py +++ b/server/curfu/routers/utilities.py @@ -22,6 +22,7 @@ router = APIRouter() + @router.get( "/api/utilities/get_transcripts", operation_id="getMANETranscripts", @@ -50,6 +51,7 @@ def get_mane_transcripts(request: Request, term: str) -> Dict: else: return {"transcripts": transcripts} + @router.get( "/api/utilities/get_transcripts_for_gene", operation_id="getTranscriptsFromGene", @@ -66,13 +68,16 @@ async def get_transcripts_for_gene(request: Request, gene: str) -> Dict: """ normalized = request.app.state.fusor.gene_normalizer.normalize(gene) symbol = normalized.gene_descriptor.label - transcripts = await request.app.state.fusor.cool_seq_tool.uta_db.get_transcripts(gene=symbol) + transcripts = await request.app.state.fusor.cool_seq_tool.uta_db.get_transcripts( + gene=symbol + ) tx_for_gene = list(transcripts.rows_by_key("tx_ac")) if transcripts.is_empty(): return {"warnings": [f"No matching transcripts: {gene}"], "transcripts": []} else: return {"transcripts": tx_for_gene} + @router.get( "/api/utilities/get_genomic", operation_id="getGenomicCoords", @@ -277,7 +282,9 @@ async def get_sequence( """ _, path = tempfile.mkstemp(suffix=".fasta") try: - request.app.state.fusor.cool_seq_tool.seqrepo_access.get_fasta_file(sequence_id, Path(path)) + request.app.state.fusor.cool_seq_tool.seqrepo_access.get_fasta_file( + sequence_id, Path(path) + ) except KeyError: resp = request.app.state.fusor.cool_seq_tool.seqrepo_access.translate_identifier( # noqa: E501 sequence_id, "refseq" diff --git a/server/curfu/schemas.py b/server/curfu/schemas.py index 3eb19be1..3dfd9e5d 100644 --- a/server/curfu/schemas.py +++ b/server/curfu/schemas.py @@ -252,6 +252,7 @@ class GetTranscriptsResponse(Response): transcripts: Optional[List[ManeGeneTranscript]] = None + class GetGeneTranscriptsResponse(Response): """Response model for MANE transcript retrieval endpoint."""