From 6530d46398c4f1400205e62ba77e5b09dd85dfc5 Mon Sep 17 00:00:00 2001 From: michael-harper <109899932+michael-harper@users.noreply.github.com> Date: Fri, 26 Jan 2024 15:12:45 +1100 Subject: [PATCH] Added the ability to transfer assay files across during the process. Needed to pass the 'project' variable through various function calls in order to provide copy_files_in_dict the correct project id to create paths to copy files to (#660) --- scripts/create_test_subset.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/create_test_subset.py b/scripts/create_test_subset.py index cc1adf52b..14f8ccd00 100755 --- a/scripts/create_test_subset.py +++ b/scripts/create_test_subset.py @@ -276,7 +276,7 @@ def transfer_samples_sgs_assays( type=sample_type or None, meta=(copy_files_in_dict(s['meta'], project) or {}), participant_id=existing_pid, - sequencing_groups=upsert_sequencing_groups(s, existing_data), + sequencing_groups=upsert_sequencing_groups(s, existing_data, project), id=existing_sid, ) @@ -289,7 +289,7 @@ def transfer_samples_sgs_assays( def upsert_sequencing_groups( - sample: dict, existing_data: dict + sample: dict, existing_data: dict, project: str ) -> list[SequencingGroupUpsert]: """Create SG Upsert Objects for a sample""" sgs_to_upsert: list[SequencingGroupUpsert] = [] @@ -306,7 +306,7 @@ def upsert_sequencing_groups( technology=sg.get('technology'), type=sg.get('type'), assays=upsert_assays( - sg, existing_sgid, existing_data, sample.get('externalId') + sg, existing_sgid, existing_data, sample.get('externalId'), project ), ) sgs_to_upsert.append(sg_upsert) @@ -315,7 +315,11 @@ def upsert_sequencing_groups( def upsert_assays( - sg: dict, existing_sgid: str | None, existing_data: dict, sample_external_id + sg: dict, + existing_sgid: str | None, + existing_data: dict, + sample_external_id, + project: str, ) -> list[AssayUpsert]: """Create Assay Upsert Objects for a sequencing group""" print(sg) @@ -325,17 +329,14 @@ def upsert_assays( # Check if assay exists if existing_sgid: _existing_assay = get_existing_assay( - existing_data, - sample_external_id, - existing_sgid, - assay + existing_data, sample_external_id, existing_sgid, assay ) existing_assay_id = _existing_assay.get('id') if _existing_assay else None assay_upsert = AssayUpsert( type=assay.get('type'), id=existing_assay_id, external_ids=assay.get('externalIds') or {}, - meta=assay.get('meta'), + meta=copy_files_in_dict(assay.get('meta'), project), ) assays_to_upsert.append(assay_upsert)