From eb9b7e67dd684ae7f3c0493f3d1b4e3062c3fbee Mon Sep 17 00:00:00 2001 From: vivbak Date: Mon, 10 Jun 2024 17:38:23 +1000 Subject: [PATCH] Move random subset within condition to fix bug attempting to sample empty list --- scripts/create_test_subset.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/create_test_subset.py b/scripts/create_test_subset.py index 6605c2347..757c56cc4 100755 --- a/scripts/create_test_subset.py +++ b/scripts/create_test_subset.py @@ -675,9 +675,9 @@ def get_sids_for_cohorts( for seq_group in seq_groups: sample = seq_group.get('sample') sids_for_cohort.append(sample['id']) - all_cohorts_sample_ids_subset.update( - random.sample(sids_for_cohort, cohort_samples_n) - ) + all_cohorts_sample_ids_subset.update( + random.sample(sids_for_cohort, cohort_samples_n) + ) return all_cohorts_sample_ids_subset @@ -907,12 +907,10 @@ def file_exists(path: str) -> bool: parser.add_argument( '--project', required=True, help='The sample-metadata project ($DATASET)' ) - parser.add_argument( - '-n', type=int, help='# Random Samples to copy', default=DEFAULT_SAMPLES_N - ) + parser.add_argument('-n', type=int, help='# Random Samples to copy', default=0) parser.add_argument('-f', type=int, help='# Random families to copy', default=0) parser.add_argument( - '-nsamples-cohort', + '--nsamples-cohort', type=int, help='# Random samples to copy from each cohort', default=0,