From 64b8425ecbc668757a1dbb5465462c2701b0f5c4 Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Mon, 5 Aug 2024 11:12:49 -0400 Subject: [PATCH] sequence util fixes --- server/src/curfu/routers/utilities.py | 10 ++++++---- server/src/curfu/schemas.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/curfu/routers/utilities.py b/server/src/curfu/routers/utilities.py index 91f58cfe..fda2191b 100644 --- a/server/src/curfu/routers/utilities.py +++ b/server/src/curfu/routers/utilities.py @@ -197,7 +197,7 @@ async def get_sequence_id(request: Request, sequence: str) -> SequenceIDResponse :param str sequence_id: user-provided sequence identifier to translate :return: Response object with ga4gh ID and aliases """ - params: dict[str, Any] = {"sequence": sequence, "ga4gh_id": None, "aliases": []} + params: dict[str, Any] = {"sequence": sequence} sr = request.app.state.fusor.cool_seq_tool.seqrepo_access sr_ids, errors = sr.translate_identifier(sequence) @@ -234,8 +234,7 @@ async def get_sequence_id(request: Request, sequence: str) -> SequenceIDResponse @router.get( "/api/utilities/download_sequence", summary="Get sequence for ID", - description="Given a known accession identifier, retrieve sequence data and return" - "as a FASTA file", + description="Given a known accession identifier, retrieve sequence data and return as a FASTA file", response_class=FileResponse, tags=[RouteTag.UTILITIES], ) @@ -247,6 +246,7 @@ async def get_sequence( ), ) -> FileResponse: """Get sequence for requested sequence ID. + \f :param Request request: the HTTP request context, supplied by FastAPI. Use to access FUSOR and UTA-associated tools. @@ -257,7 +257,9 @@ async def get_sequence( """ _, path = tempfile.mkstemp(suffix=".fasta") try: - request.app.state.fusor.cool_seq_tool.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 as ke: resp = ( request.app.state.fusor.cool_seq_tool.seqrepo_access.translate_identifier( diff --git a/server/src/curfu/schemas.py b/server/src/curfu/schemas.py index 736cee73..da05829b 100644 --- a/server/src/curfu/schemas.py +++ b/server/src/curfu/schemas.py @@ -219,9 +219,9 @@ class SequenceIDResponse(Response): """Response model for sequence ID retrieval endpoint.""" sequence: StrictStr - refseq_id: StrictStr | None - ga4gh_id: StrictStr | None - aliases: list[StrictStr] | None + refseq_id: StrictStr | None = None + ga4gh_id: StrictStr | None = None + aliases: list[StrictStr] | None = None class ManeGeneTranscript(BaseModel):