Skip to content

Commit 6a0c58a

Browse files
EddieLFjmarshall
andauthored
Get_cram_paths external IDs fix (#828)
* Fix analysis table get_cram_paths function with external_id changes * Bump version: 7.1.0 → 7.1.1 * Also rename p.id; return only the primary external_id Add a test case that exercises this code. * Rename table alias to the conventional 'peid.' --------- Co-authored-by: John Marshall <[email protected]>
1 parent aa08309 commit 6a0c58a

File tree

7 files changed

+36
-10
lines changed

7 files changed

+36
-10
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 7.1.0
2+
current_version = 7.1.1
33
commit = True
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>[A-z0-9-]+)

api/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from db.python.utils import get_logger
2121

2222
# This tag is automatically updated by bump2version
23-
_VERSION = '7.1.0'
23+
_VERSION = '7.1.1'
2424

2525

2626
logger = get_logger()

db/python/tables/analysis.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
to_db_json,
1414
)
1515
from models.enums import AnalysisStatus
16+
from models.models import PRIMARY_EXTERNAL_ORG
1617
from models.models.analysis import AnalysisInternal
1718
from models.models.audit_log import AuditLogInternal
1819
from models.models.project import ProjectId
@@ -413,12 +414,13 @@ async def get_sample_cram_path_map_for_seqr(
413414
) -> List[dict[str, str]]:
414415
"""Get (ext_sample_id, cram_path, internal_id) map"""
415416

416-
values: dict[str, Any] = {'project': project}
417+
values: dict[str, Any] = {'project': project, 'PRIMARY_EXTERNAL_ORG': PRIMARY_EXTERNAL_ORG}
417418
filters = [
418419
'a.active',
419420
'a.type = "cram"',
420421
'a.status = "completed"',
421-
'p.project = :project',
422+
'peid.project = :project',
423+
'peid.name = :PRIMARY_EXTERNAL_ORG',
422424
]
423425
if sequencing_types:
424426
if len(sequencing_types) == 1:
@@ -431,16 +433,16 @@ async def get_sample_cram_path_map_for_seqr(
431433
filters.append('JSON_VALUE(a.meta, "$.sequencing_type") ' + seq_check)
432434

433435
if participant_ids:
434-
filters.append('p.id IN :pids')
436+
filters.append('peid.participant_id IN :pids')
435437
values['pids'] = list(participant_ids)
436438

437439
_query = f"""
438-
SELECT p.external_id as participant_id, a.output as output, sg.id as sequencing_group_id
440+
SELECT peid.external_id as participant_id, a.output as output, sg.id as sequencing_group_id
439441
FROM analysis a
440442
INNER JOIN analysis_sequencing_group a_sg ON a_sg.analysis_id = a.id
441443
INNER JOIN sequencing_group sg ON a_sg.sequencing_group_id = sg.id
442444
INNER JOIN sample s ON sg.sample_id = s.id
443-
INNER JOIN participant p ON s.participant_id = p.id
445+
INNER JOIN participant_external_id peid ON s.participant_id = peid.participant_id
444446
WHERE
445447
{' AND '.join(filters)}
446448
ORDER BY a.timestamp_completed DESC;

deploy/python/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.1.0
1+
7.1.1

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
setup(
2020
name=PKG,
2121
# This tag is automatically updated by bump2version
22-
version='7.1.0',
22+
version='7.1.1',
2323
description='Python API for interacting with the Sample API system',
2424
long_description=readme,
2525
long_description_content_type='text/markdown',

test/test_analysis.py

+24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from db.python.layers.analysis import AnalysisLayer
55
from db.python.layers.assay import AssayLayer
6+
from db.python.layers.participant import ParticipantLayer
67
from db.python.layers.sample import SampleLayer
78
from db.python.layers.sequencing_group import SequencingGroupLayer
89
from db.python.tables.analysis import AnalysisFilter
@@ -12,6 +13,7 @@
1213
PRIMARY_EXTERNAL_ORG,
1314
AnalysisInternal,
1415
AssayUpsertInternal,
16+
ParticipantUpsertInternal,
1517
SampleUpsertInternal,
1618
SequencingGroupUpsertInternal,
1719
)
@@ -20,6 +22,8 @@
2022
class TestAnalysis(DbIsolatedTest):
2123
"""Test sample class"""
2224

25+
# pylint: disable=too-many-instance-attributes
26+
2327
@run_as_sync
2428
async def setUp(self) -> None:
2529
# don't need to await because it's tagged @run_as_sync
@@ -28,6 +32,7 @@ async def setUp(self) -> None:
2832
self.sgl = SequencingGroupLayer(self.connection)
2933
self.asl = AssayLayer(self.connection)
3034
self.al = AnalysisLayer(self.connection)
35+
self.pl = ParticipantLayer(self.connection)
3136

3237
sample = await self.sl.upsert_sample(
3338
SampleUpsertInternal(
@@ -167,3 +172,22 @@ async def test_get_analysis(self):
167172
]
168173

169174
self.assertEqual(analyses, expected)
175+
176+
@run_as_sync
177+
async def test_get_sample_cram_path_map_for_seqr(self):
178+
"""
179+
Exercise get_sample_cram_path_map_for_seqr()
180+
"""
181+
182+
part = await self.pl.upsert_participants(
183+
[
184+
ParticipantUpsertInternal(
185+
external_ids={PRIMARY_EXTERNAL_ORG: 'PEXT1'},
186+
meta={},
187+
samples=[SampleUpsertInternal(id=self.sample_id)],
188+
),
189+
],
190+
)
191+
192+
id_map = await self.al.get_sample_cram_path_map_for_seqr(self.project_id, ['blood'], [part[0].id])
193+
self.assertIsInstance(id_map, list)

web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "metamist",
3-
"version": "7.1.0",
3+
"version": "7.1.1",
44
"private": true,
55
"dependencies": {
66
"@apollo/client": "^3.7.3",

0 commit comments

Comments
 (0)