Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:populationgenomics/metamist into our…
Browse files Browse the repository at this point in the history
…dna/update-table-view-and-filtering
  • Loading branch information
illusional committed Jun 19, 2024
2 parents 963da38 + 6a0c58a commit f01fb12
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 7.1.0
current_version = 7.1.1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>[A-z0-9-]+)
Expand Down
2 changes: 1 addition & 1 deletion api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from db.python.utils import get_logger

# This tag is automatically updated by bump2version
_VERSION = '7.1.0'
_VERSION = '7.1.1'


logger = get_logger()
Expand Down
12 changes: 7 additions & 5 deletions db/python/tables/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from db.python.tables.base import DbBase
from db.python.utils import NotFoundError, to_db_json
from models.enums import AnalysisStatus
from models.models import PRIMARY_EXTERNAL_ORG
from models.models.analysis import AnalysisInternal
from models.models.audit_log import AuditLogInternal
from models.models.project import ProjectId
Expand Down Expand Up @@ -408,12 +409,13 @@ async def get_sample_cram_path_map_for_seqr(
) -> List[dict[str, str]]:
"""Get (ext_sample_id, cram_path, internal_id) map"""

values: dict[str, Any] = {'project': project}
values: dict[str, Any] = {'project': project, 'PRIMARY_EXTERNAL_ORG': PRIMARY_EXTERNAL_ORG}
filters = [
'a.active',
'a.type = "cram"',
'a.status = "completed"',
'p.project = :project',
'peid.project = :project',
'peid.name = :PRIMARY_EXTERNAL_ORG',
]
if sequencing_types:
if len(sequencing_types) == 1:
Expand All @@ -426,16 +428,16 @@ async def get_sample_cram_path_map_for_seqr(
filters.append('JSON_VALUE(a.meta, "$.sequencing_type") ' + seq_check)

if participant_ids:
filters.append('p.id IN :pids')
filters.append('peid.participant_id IN :pids')
values['pids'] = list(participant_ids)

_query = f"""
SELECT p.external_id as participant_id, a.output as output, sg.id as sequencing_group_id
SELECT peid.external_id as participant_id, a.output as output, sg.id as sequencing_group_id
FROM analysis a
INNER JOIN analysis_sequencing_group a_sg ON a_sg.analysis_id = a.id
INNER JOIN sequencing_group sg ON a_sg.sequencing_group_id = sg.id
INNER JOIN sample s ON sg.sample_id = s.id
INNER JOIN participant p ON s.participant_id = p.id
INNER JOIN participant_external_id peid ON s.participant_id = peid.participant_id
WHERE
{' AND '.join(filters)}
ORDER BY a.timestamp_completed DESC;
Expand Down
2 changes: 1 addition & 1 deletion deploy/python/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0
7.1.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
setup(
name=PKG,
# This tag is automatically updated by bump2version
version='7.1.0',
version='7.1.1',
description='Python API for interacting with the Sample API system',
long_description=readme,
long_description_content_type='text/markdown',
Expand Down
24 changes: 24 additions & 0 deletions test/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from db.python.filters import GenericFilter
from db.python.layers.analysis import AnalysisLayer
from db.python.layers.assay import AssayLayer
from db.python.layers.participant import ParticipantLayer
from db.python.layers.sample import SampleLayer
from db.python.layers.sequencing_group import SequencingGroupLayer
from db.python.tables.analysis import AnalysisFilter
Expand All @@ -12,6 +13,7 @@
PRIMARY_EXTERNAL_ORG,
AnalysisInternal,
AssayUpsertInternal,
ParticipantUpsertInternal,
SampleUpsertInternal,
SequencingGroupUpsertInternal,
)
Expand All @@ -20,6 +22,8 @@
class TestAnalysis(DbIsolatedTest):
"""Test sample class"""

# pylint: disable=too-many-instance-attributes

@run_as_sync
async def setUp(self) -> None:
# don't need to await because it's tagged @run_as_sync
Expand All @@ -28,6 +32,7 @@ async def setUp(self) -> None:
self.sgl = SequencingGroupLayer(self.connection)
self.asl = AssayLayer(self.connection)
self.al = AnalysisLayer(self.connection)
self.pl = ParticipantLayer(self.connection)

sample = await self.sl.upsert_sample(
SampleUpsertInternal(
Expand Down Expand Up @@ -167,3 +172,22 @@ async def test_get_analysis(self):
]

self.assertEqual(analyses, expected)

@run_as_sync
async def test_get_sample_cram_path_map_for_seqr(self):
"""
Exercise get_sample_cram_path_map_for_seqr()
"""

part = await self.pl.upsert_participants(
[
ParticipantUpsertInternal(
external_ids={PRIMARY_EXTERNAL_ORG: 'PEXT1'},
meta={},
samples=[SampleUpsertInternal(id=self.sample_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)
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamist",
"version": "7.1.0",
"version": "7.1.1",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.3",
Expand Down

0 comments on commit f01fb12

Please sign in to comment.