From 5debebf1b9ecfd48ef2e1e6084f489447ed06ef1 Mon Sep 17 00:00:00 2001 From: EddieLF <34049565+EddieLF@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:31:50 +1100 Subject: [PATCH] Fix pid sgid map api (#680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix participant to sg_id api bug * Remove sample id format import * Add sequencing type option to endpoint * Bump version: 6.6.2 → 6.7.0 --- .bumpversion.cfg | 2 +- api/routes/participant.py | 24 ++++++++++++++---------- api/server.py | 2 +- deploy/python/version.txt | 2 +- setup.py | 2 +- web/package.json | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9ae63ecc9..6331c36cc 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 6.6.2 +current_version = 6.7.0 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P[A-z0-9-]+) diff --git a/api/routes/participant.py b/api/routes/participant.py index f0b5ca55a..61b3db382 100644 --- a/api/routes/participant.py +++ b/api/routes/participant.py @@ -15,7 +15,7 @@ from api.utils.export import ExportType from db.python.layers.participant import ParticipantLayer from models.models.participant import ParticipantUpsert -from models.models.sample import sample_id_format +from models.models.sequencing_group import sequencing_group_id_format router = APIRouter(prefix='/participant', tags=['participant']) @@ -111,35 +111,37 @@ async def update_many_participant_external_ids( @router.get( - '/{project}/external-pid-to-internal-sample-id', - operation_id='getExternalParticipantIdToInternalSampleId', + '/{project}/external-pid-to-sg-id', + operation_id='getExternalParticipantIdToSequencingGroupId', tags=['seqr'], ) -async def get_external_participant_id_to_internal_sample_id( +async def get_external_participant_id_to_sequencing_group_id( project: str, + sequencing_type: str = None, export_type: ExportType = ExportType.JSON, flip_columns: bool = False, connection: Connection = get_project_readonly_connection, ): """ - Get csv / tsv export of external_participant_id to internal_sample_id + Get csv / tsv export of external_participant_id to sequencing_group_id - Get a map of {external_participant_id} -> {internal_sample_id} - useful to matching joint-called samples in the matrix table to the participant + Get a map of {external_participant_id} -> {sequencing_group_id} + useful to matching joint-called sequencing groups in the matrix table to the participant Return a list not dictionary, because dict could lose participants with multiple samples. + :param sequencing_type: Leave empty to get all sequencing types :param flip_columns: Set to True when exporting for seqr """ player = ParticipantLayer(connection) # this wants project ID (connection.project) assert connection.project m = await player.get_external_participant_id_to_internal_sequencing_group_id_map( - project=connection.project + project=connection.project, sequencing_type=sequencing_type ) - rows = [[pid, sample_id_format(sid)] for pid, sid in m] + rows = [[pid, sequencing_group_id_format(sgid)] for pid, sgid in m] if flip_columns: rows = [r[::-1] for r in rows] @@ -151,7 +153,9 @@ async def get_external_participant_id_to_internal_sample_id( writer.writerows(rows) ext = export_type.get_extension() - filename = f'{project}-participant-to-sample-map-{date.today().isoformat()}{ext}' + filename = f'{project}-participant-to-sequencing-group-map-{date.today().isoformat()}{ext}' + if sequencing_type: + filename = f'{project}-{sequencing_type}-participant-to-sequencing-group-map-{date.today().isoformat()}{ext}' return StreamingResponse( # stream the whole file at once, because it's all in memory anyway iter([output.getvalue()]), diff --git a/api/server.py b/api/server.py index 652aa4322..1879bec50 100644 --- a/api/server.py +++ b/api/server.py @@ -19,7 +19,7 @@ from db.python.utils import get_logger # This tag is automatically updated by bump2version -_VERSION = '6.6.2' +_VERSION = '6.7.0' logger = get_logger() diff --git a/deploy/python/version.txt b/deploy/python/version.txt index 28179fc1f..f0e13c509 100644 --- a/deploy/python/version.txt +++ b/deploy/python/version.txt @@ -1 +1 @@ -6.6.2 +6.7.0 diff --git a/setup.py b/setup.py index 0b812b931..1c1d579c0 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name=PKG, # This tag is automatically updated by bump2version - version='6.6.2', + version='6.7.0', description='Python API for interacting with the Sample API system', long_description=readme, long_description_content_type='text/markdown', diff --git a/web/package.json b/web/package.json index 69ffc33f6..40e260617 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "metamist", - "version": "6.6.2", + "version": "6.7.0", "private": true, "dependencies": { "@apollo/client": "^3.7.3",