From 51f1077ca8b5f9d05ce85538e8d511b51b2a4ffc Mon Sep 17 00:00:00 2001 From: _ <4256466+leehart@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:10:57 +0100 Subject: [PATCH] Skip sets with missing CNV DRCs rather than FileNotFoundError. Raise ValueError when no given sets have DRCs. --- malariagen_data/anoph/cnv_data.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/cnv_data.py b/malariagen_data/anoph/cnv_data.py index 38e389939..f9e6d474c 100644 --- a/malariagen_data/anoph/cnv_data.py +++ b/malariagen_data/anoph/cnv_data.py @@ -454,7 +454,11 @@ def _cnv_discordant_read_calls_dataset( data_vars = dict() debug("open zarr") - root = self.open_cnv_discordant_read_calls(sample_set=sample_set) + + try: + root = self.open_cnv_discordant_read_calls(sample_set=sample_set) + except FileNotFoundError: + return None # not all contigs have CNVs, need to check # TODO consider returning dataset with zero length variants dimension, would @@ -556,8 +560,17 @@ def cnv_discordant_read_calls( inline_array=inline_array, chunks=chunks, ) + + # If no CNV DRCs dataset was found then skip + if y is None: + continue + ly.append(y) + if len(ly) == 0: + # Bail out, no data for given sample sets and analysis. + raise ValueError("No data found for requested sample sets.") + x = simple_xarray_concat(ly, dim=DIM_SAMPLE) lx.append(x)