From 21ee7b8124c1dc76efc70b3bf8d27bf83a36537d Mon Sep 17 00:00:00 2001 From: Kieron Taylor Date: Tue, 30 Jul 2024 07:23:27 +0000 Subject: [PATCH 1/2] Add sample name to the pool stats table. --- frontend/src/components/PoolStats.vue | 2 ++ frontend/src/components/__tests__/PoolStats.spec.js | 10 ++++++++-- lang_qc/models/pacbio/qc_data.py | 4 ++++ tests/fixtures/sample_data.py | 5 +---- tests/test_pac_bio_qc_data_well.py | 13 ++++++++++++- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/PoolStats.vue b/frontend/src/components/PoolStats.vue index 3f853a8..28d61e6 100644 --- a/frontend/src/components/PoolStats.vue +++ b/frontend/src/components/PoolStats.vue @@ -18,6 +18,7 @@ const active = ref([]) + @@ -28,6 +29,7 @@ const active = ref([]) + diff --git a/frontend/src/components/__tests__/PoolStats.spec.js b/frontend/src/components/__tests__/PoolStats.spec.js index fe8d33d..11123ef 100644 --- a/frontend/src/components/__tests__/PoolStats.spec.js +++ b/frontend/src/components/__tests__/PoolStats.spec.js @@ -13,6 +13,7 @@ const wrapper = mount(PoolStats, { pool_coeff_of_variance: 47.2, products: [{ id_product: 'A'.repeat(64), + sample_name: 'allthets', tag1_name: 'TTTTTTTT', tag2_name: null, deplexing_barcode: 'bc10--bc10', @@ -23,6 +24,7 @@ const wrapper = mount(PoolStats, { percentage_total_reads: 66.6 },{ id_product: 'B'.repeat(64), + sample_name: null, tag1_name: 'GGGGGGGG', tag2_name: null, deplexing_barcode: 'bc11--bc11', @@ -54,7 +56,11 @@ describe('Create poolstats table with good data', () => { expect(rows.length).toEqual(3) // Check tag 1 has been set - expect(rows[1].find('td').text()).toEqual('TTTTTTTT') - expect(rows[2].find('td').text()).toEqual('GGGGGGGG') + expect(rows[1].findAll('td')[1].text()).toEqual('TTTTTTTT') + expect(rows[2].findAll('td')[1].text()).toEqual('GGGGGGGG') + + // Sample name column set appropriately + expect(rows[1].find('td').text()).toEqual('allthets') + expect(rows[2].find('td').text()).toEqual('') }) }) \ No newline at end of file diff --git a/lang_qc/models/pacbio/qc_data.py b/lang_qc/models/pacbio/qc_data.py index cbfad6c..ba3a938 100644 --- a/lang_qc/models/pacbio/qc_data.py +++ b/lang_qc/models/pacbio/qc_data.py @@ -170,6 +170,7 @@ class SampleDeplexingStats(BaseModel): """ id_product: PacBioProductSHA256 + sample_name: str | None tag1_name: str | None tag2_name: str | None deplexing_barcode: str | None @@ -235,6 +236,9 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]: sample_stats.append( SampleDeplexingStats( id_product=prod.id_pac_bio_product, + sample_name=( + prod.pac_bio_run.sample.name if prod.pac_bio_run else None + ), tag1_name=lib_lims_data[i].tag_identifier, tag2_name=lib_lims_data[i].tag2_identifier, deplexing_barcode=prod.barcode4deplexing, diff --git a/tests/fixtures/sample_data.py b/tests/fixtures/sample_data.py index 436cc67..ed850e1 100644 --- a/tests/fixtures/sample_data.py +++ b/tests/fixtures/sample_data.py @@ -162,10 +162,7 @@ def multiplexed_run(mlwhdb_test_session): well_label=well_label, plate_number=plate_number, id_pac_bio_run_lims=1, - sample=Sample( - id_lims="pooled_id_1", - id_sample_lims="2", - ), + sample=Sample(id_lims="pooled_id_1", id_sample_lims="2", name="It's a test"), study=study, plate_barcode="ABCD", pac_bio_product_metrics=[product_1], diff --git a/tests/test_pac_bio_qc_data_well.py b/tests/test_pac_bio_qc_data_well.py index 60364c4..d498ba3 100644 --- a/tests/test_pac_bio_qc_data_well.py +++ b/tests/test_pac_bio_qc_data_well.py @@ -104,7 +104,11 @@ def test_creating_qc_data_well(mlwhdb_test_session, mlwhdb_load_runs): def test_pool_metrics_from_single_sample_well(mlwhdb_test_session, simplex_run): - + """ + Applies to samples where deplexing was left as an exercise for the user. + Other single-sample wells with requested deplexing will have a single entry + in the products + """ id = PacBioEntity( run_name=simplex_run.pac_bio_run_name, well_label=simplex_run.well_label, @@ -146,6 +150,13 @@ def test_pool_metrics_from_well(mlwhdb_test_session, multiplexed_run): metrics.products[1].percentage_total_reads == 66.67 ), "20Mb of 30Mb reads is 66.67% (2 d.p.)" + assert ( + metrics.products[0].sample_name is None + ), "Sample without name returned successfully" + assert ( + metrics.products[1].sample_name == "It's a test" + ), "Sample name added to products when present" + def test_errors_instantiating_pool_metrics(mlwhdb_test_session): From bd25d0dafdd9d2eff0ec6ceb70b3d745c355e3e9 Mon Sep 17 00:00:00 2001 From: Kieron Taylor Date: Tue, 30 Jul 2024 08:47:32 +0000 Subject: [PATCH 2/2] Rationalise pac_bio_run use in QCPoolMetrics --- lang_qc/models/pacbio/qc_data.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lang_qc/models/pacbio/qc_data.py b/lang_qc/models/pacbio/qc_data.py index ba3a938..f6b083e 100644 --- a/lang_qc/models/pacbio/qc_data.py +++ b/lang_qc/models/pacbio/qc_data.py @@ -236,9 +236,7 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]: sample_stats.append( SampleDeplexingStats( id_product=prod.id_pac_bio_product, - sample_name=( - prod.pac_bio_run.sample.name if prod.pac_bio_run else None - ), + sample_name=lib_lims_data[i].sample.name, tag1_name=lib_lims_data[i].tag_identifier, tag2_name=lib_lims_data[i].tag2_identifier, deplexing_barcode=prod.barcode4deplexing,
Sample Tag 1 Tag 2 Deplexing barcode IDPercentage of total reads
{{ library.sample_name }} {{ library.tag1_name }} {{ library.tag2_name }} {{ library.deplexing_barcode }}