Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes to pool table #233

Merged
merged 8 commits into from
Jul 25, 2024
34 changes: 18 additions & 16 deletions frontend/src/components/QcView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 }
)
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/focusWell.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const useWellStore = defineStore('focusWell', {
(error) => {
ElMessage({
message: error.message,
type: error,
type: "error",
duration: 5000
})
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/views/WellsByRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function flatten_data(values) {
getUserName((email) => { user.value = email }).then();

watch(() => route.query, (after, before) => {
if (qcQueryChanged(before, after)) {
if (after.idProduct === undefined) {
focusWell.setFocusWell(null)
} else if (qcQueryChanged(before, after)) {
focusWell.loadWellDetail(after.idProduct)
}
},
Expand All @@ -51,6 +53,7 @@ watch(() => props.runName, () => {
Promise.all(promises).then(
(values) => (wellCollection.value = flatten_data(values))
).catch(error => {
console.log(error.message + " when resolving promises in props.runName watcher")
ElMessage({
message: error.message,
type: "warning",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/__tests__/WellsByRun.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ describe('Does it work?', async () => {
// Not providing precisely the right data, but serves for the component
fetch.mockResponses(
[JSON.stringify(secondaryRun)], // well QC data loading
[JSON.stringify({})] // Pool stats loading
)

let buttons = wrapper.findAll('button')
Expand All @@ -165,8 +164,9 @@ describe('Does it work?', async () => {
page_number: 1,
total_number_of_items: 1,
wells: [secondaryRun]
})
]
}),
{ status: 200 }
],
)
await wrapper.setProps({runName: ['TRACTION-RUN-211', 'TRACTION-RUN-210']})
await flushPromises()
Expand Down
3 changes: 2 additions & 1 deletion lang_qc/endpoints/pacbio_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 8 additions & 2 deletions lang_qc/models/pacbio/qc_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -236,7 +238,11 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]:
tag1_name=lib_lims_data[i].tag_identifier,
tag2_name=lib_lims_data[i].tag2_identifier,
deplexing_barcode=prod.barcode4deplexing,
hifi_read_bases=convert_to_gigabase(prod, "hifi_read_bases"),
hifi_read_bases=(
convert_to_gigabase(prod, "hifi_read_bases")
if (prod.hifi_read_bases)
else None
),
hifi_num_reads=prod.hifi_num_reads,
hifi_read_length_mean=prod.hifi_read_length_mean,
hifi_bases_percent=prod.hifi_bases_percent,
Expand Down