Skip to content

Commit

Permalink
Fix get sequencing groups by analysis IDs (#850)
Browse files Browse the repository at this point in the history
* Commit failing test

* Change inner to left join to fix test

---------

Co-authored-by: Michael Franklin <[email protected]>
  • Loading branch information
illusional and illusional authored Jul 1, 2024
1 parent 1162776 commit bcc6392
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db/python/tables/sequencing_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async def get_sequencing_groups_by_analysis_ids(
FROM analysis_sequencing_group asg
INNER JOIN sequencing_group sg ON sg.id = asg.sequencing_group_id
INNER JOIN sample s ON s.id = sg.sample_id
INNER JOIN sequencing_group_external_id sgexid ON sg.id = sgexid.sequencing_group_id
LEFT JOIN sequencing_group_external_id sgexid ON sg.id = sgexid.sequencing_group_id
WHERE asg.analysis_id IN :aids
GROUP BY sg.id, asg.analysis_id
"""
Expand Down
68 changes: 67 additions & 1 deletion test/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,71 @@ async def test_get_sample_cram_path_map_for_seqr(self):
],
)

id_map = await self.al.get_sample_cram_path_map_for_seqr(self.project_id, ['blood'], [part[0].id])
id_map = await self.al.get_sample_cram_path_map_for_seqr(
self.project_id, ['blood'], [part[0].id]
)
self.assertIsInstance(id_map, list)

@run_as_sync
async def test_get_sgs_by_analysis_id_with_no_eids(self):
"""
Test get_sgs_by_analysis_id()
"""

# duplicate here to ensure sgs don't have any external ids
assay_meta = {
'sequencing_type': 'genome',
'sequencing_technology': 'short-read',
'sequencing_platform': 'illumina',
}
sample = await self.sl.upsert_sample(
SampleUpsertInternal(
external_ids={PRIMARY_EXTERNAL_ORG: 'test_sgs_aid'},
type='blood',
meta={},
active=True,
sequencing_groups=[
SequencingGroupUpsertInternal(
type='genome',
technology='short-read',
platform='illumina',
assays=[
AssayUpsertInternal(
type='sequencing',
meta=assay_meta,
)
],
),
SequencingGroupUpsertInternal(
type='exome',
technology='short-read',
platform='illumina',
assays=[
AssayUpsertInternal(
type='sequencing',
meta=assay_meta,
)
],
),
],
)
)

genome_id = sample.sequencing_groups[0].id
exome_id = sample.sequencing_groups[1].id

a_id = await self.al.create_analysis(
AnalysisInternal(
type='analysis-runner',
status=AnalysisStatus.UNKNOWN,
sequencing_group_ids=[genome_id, exome_id],
meta={},
)
)

sgs_by_aid = await self.sgl.get_sequencing_groups_by_analysis_ids([a_id])
self.assertIn(a_id, sgs_by_aid)
sgs = sorted(sgs_by_aid[a_id], key=lambda sg: sg.id)

self.assertEqual(sgs[0].id, genome_id)
self.assertEqual(sgs[1].id, exome_id)

0 comments on commit bcc6392

Please sign in to comment.