Skip to content

Commit

Permalink
Add sample name to the pool stats table.
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdstrike committed Jul 30, 2024
1 parent b70126f commit 21ee7b8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions frontend/src/components/PoolStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const active = ref([])
</el-tooltip>
<table>
<tr>
<th>Sample</th>
<th>Tag 1</th>
<th>Tag 2</th>
<th>Deplexing barcode ID</th>
Expand All @@ -28,6 +29,7 @@ const active = ref([])
<th>Percentage of total reads</th>
</tr>
<tr :key="library.id_product" v-for="library in props.pool.products">
<td>{{ library.sample_name }}</td>
<td>{{ library.tag1_name }}</td>
<td>{{ library.tag2_name }}</td>
<td>{{ library.deplexing_barcode }}</td>
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/__tests__/PoolStats.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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('')
})
})
4 changes: 4 additions & 0 deletions lang_qc/models/pacbio/qc_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions tests/fixtures/sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
13 changes: 12 additions & 1 deletion tests/test_pac_bio_qc_data_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):

Expand Down

0 comments on commit 21ee7b8

Please sign in to comment.