From cd04654ad3a805447a686a639867e8cdbb3c0d52 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Wed, 19 Jun 2024 14:43:49 +1200 Subject: [PATCH] Update external_ids in fix_pbmc_sample_participant.py script Expand sample_map_by_external_id to hold all the external_ids for all the samples. For samples with an external_id containing '-PBMC', use next(...) to pick the first such external_id -- generally there'll surely only be one anyway. --- scripts/fix_pbmc_sample_participant.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/fix_pbmc_sample_participant.py b/scripts/fix_pbmc_sample_participant.py index 4d0c84599..c3fe32b08 100644 --- a/scripts/fix_pbmc_sample_participant.py +++ b/scripts/fix_pbmc_sample_participant.py @@ -19,12 +19,12 @@ def main(): ) ) - sample_map_by_external_id = {s['external_id']: s for s in all_samples} + sample_map_by_external_id = {eid: s for s in all_samples for eid in s['external_ids'].values()} - pbmc_samples = [s for s in all_samples if '-PBMC' in s['external_id']] + pbmc_samples = [s for s in all_samples if any('-PBMC' in eid for eid in s['external_ids'].values())] for sample in pbmc_samples: - external_id = sample['external_id'] + external_id = next(eid for eid in sample['external_ids'].values() if '-PBMC' in eid) non_pbmc_id = external_id.strip('-PBMC') non_pbmc_sample = sample_map_by_external_id.get(non_pbmc_id) pbmc_sample = sample_map_by_external_id.get(external_id)