From 72c1367f4fa246c167ea986b71dc35740bdc43ad Mon Sep 17 00:00:00 2001 From: Kieron Taylor Date: Mon, 22 Jul 2024 16:31:15 +0000 Subject: [PATCH 1/8] Fix stdev function throwing when n=1 for a pool --- lang_qc/models/pacbio/qc_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lang_qc/models/pacbio/qc_data.py b/lang_qc/models/pacbio/qc_data.py index ca29192..a61c57f 100644 --- a/lang_qc/models/pacbio/qc_data.py +++ b/lang_qc/models/pacbio/qc_data.py @@ -227,7 +227,9 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]: cov = None else: hifi_reads = [prod.hifi_num_reads for prod in product_metrics] - cov = round(stdev(hifi_reads) / mean(hifi_reads) * 100, 2) + if len(hifi_reads) > 1: + # stdev throws on n=1 + cov = round(stdev(hifi_reads) / mean(hifi_reads) * 100, 2) for i, prod in enumerate(product_metrics): sample_stats.append( From 9203da1c7244bbf8db79f59fd758cab2d298c6ac Mon Sep 17 00:00:00 2001 From: Kieron Taylor Date: Mon, 22 Jul 2024 17:17:37 +0000 Subject: [PATCH 2/8] Give no data when pool size is zero, rather than sparse dict. --- lang_qc/endpoints/pacbio_well.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang_qc/endpoints/pacbio_well.py b/lang_qc/endpoints/pacbio_well.py index e72e7c9..93ebdab 100644 --- a/lang_qc/endpoints/pacbio_well.py +++ b/lang_qc/endpoints/pacbio_well.py @@ -236,7 +236,8 @@ def get_product_metrics( metrics = QCPoolMetrics(db_well=mlwh_well) except MissingLimsDataError: return - + if len(metrics.products) == 0: + return return metrics From 06eb2da6c747c4527e9d9dea0c937a91cbbe4e2f Mon Sep 17 00:00:00 2001 From: Kieron Taylor Date: Mon, 22 Jul 2024 17:31:55 +0000 Subject: [PATCH 3/8] Skip pool stats fetch if sample size is 0. Nothing useful happens --- frontend/src/components/QcView.vue | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/QcView.vue b/frontend/src/components/QcView.vue index ce0a84c..2f70161 100644 --- a/frontend/src/components/QcView.vue +++ b/frontend/src/components/QcView.vue @@ -18,22 +18,6 @@ well: Object, }) - const poolStats = ref(null) - watch(() => props.well, () => { - poolStats.value = null // empty in case next well doesn't have a pool - dataClient.getPoolMetrics(props.well.id_product).then( - (response) => { poolStats.value = response } - ).catch((error) => { - if (error.message.match("Conflict")) { - // Nothing to do - } else { - console.log(error) - // make a banner show this error? - } - }) - }, { immediate: true} - ) - const slURL = computed(() => { let hostname = props.well.metrics.smrt_link.hostname let url = '' @@ -118,6 +102,24 @@ } return '' }) + + const poolStats = ref(null) + watch(() => props.well, () => { + poolStats.value = null // empty in case next well doesn't have a pool + if (ssLimsNumSamples.value > 0) { + dataClient.getPoolMetrics(props.well.id_product).then( + (response) => { poolStats.value = response } + ).catch((error) => { + if (error.message.match("Conflict")) { + // Nothing to do + } else { + console.log(error) + // make a banner show this error? + } + }) + } + }, { immediate: true } + )