Skip to content

Commit

Permalink
Merge pull request #117 from bcgsc/task/KBDEV-1163-tests-ensembl-protein
Browse files Browse the repository at this point in the history
Task/kbdev 1163 tests ensembl protein
  • Loading branch information
mathieulemieux authored Mar 2, 2024
2 parents 15180c6 + 16195a0 commit 73473c6
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 7 deletions.
1 change: 1 addition & 0 deletions graphkb/genes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Methods for retrieving gene annotation lists from GraphKB."""

from typing import Any, Dict, List, Sequence, Set, Tuple, cast

from . import GraphKBConnection
Expand Down
17 changes: 11 additions & 6 deletions graphkb/match.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions which return Variants from GraphKB which match some input variant definition
"""

from typing import Dict, List, Optional, Set, Union, cast

from . import GraphKBConnection
Expand Down Expand Up @@ -303,9 +304,11 @@ def compare_positional_variants(
if not positions_overlap(
cast(BasicPosition, variant["break1Start"]),
cast(BasicPosition, reference_variant["break1Start"]),
None
if "break1End" not in reference_variant
else cast(BasicPosition, reference_variant["break1End"]),
(
None
if "break1End" not in reference_variant
else cast(BasicPosition, reference_variant["break1End"])
),
):
return False

Expand All @@ -318,9 +321,11 @@ def compare_positional_variants(
if not positions_overlap(
cast(BasicPosition, variant["break2Start"]),
cast(BasicPosition, reference_variant["break2Start"]),
None
if "break2End" not in reference_variant
else cast(BasicPosition, reference_variant["break2End"]),
(
None
if "break2End" not in reference_variant
else cast(BasicPosition, reference_variant["break2End"])
),
):
return False

Expand Down
1 change: 0 additions & 1 deletion tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Array of variants (diplayName and type) that MUST NOT be matching, but not restricted to
"""


# Screening structural variant to rule out small events [KBDEV_1056]
structuralVariants = {
# Unambiguous structural variations
Expand Down
1 change: 1 addition & 0 deletions tests/test_genes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests here depend on specific data in GraphKB which can change. To avoid this, expected/stable values are chosen
"""

import os

import pytest
Expand Down
129 changes: 129 additions & 0 deletions tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,135 @@ def test_checks_by_source_id_kras(self, conn):
]
assert "KRAS" in kras

# KBDEV-1163
# Testing if the addition of Ensembl protein Features are limiting results
# returned by get_equivalent_features() since SimilatTo queryType queries
# aren't traversing the graph to it's whole depth.
@pytest.mark.skipif(EXCLUDE_INTEGRATION_TESTS, reason="excluding data-specific test")
def test_ensembl_protein(self, conn):
for feature, expected in [
# Sample
(
'EGFR',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'ENST00000275493',
'ENST00000275493.6',
'NM_001346897',
'NM_001346897.2',
'NP_001333826',
'NP_001333826.1',
],
),
(
'NM_001346897',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'NM_001346897',
'NM_001346897.2',
'NP_001333826',
'NP_001333826.1',
],
),
(
'NM_001346897.2',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'NM_001346897',
'NM_001346897.2',
'NP_001333826',
'NP_001333826.1',
],
),
(
'NP_001333826',
[
'EGFR',
'ERBB',
'ENSG00000146648', # Warn: Versionized ENSG won't be returned due to API limitations
'NM_001346897',
'NM_001346897.2',
'NP_001333826',
'NP_001333826.1',
],
),
(
'NP_001333826.1',
[
'EGFR',
'ERBB',
'ENSG00000146648', # Warn: Versionized ENSG won't be returned due to API limitations
'NM_001346897',
'NM_001346897.2',
'NP_001333826',
'NP_001333826.1',
],
),
(
'ENSG00000146648',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'ENST00000275493',
'ENST00000275493.6',
'NM_001346897',
'NM_001346897.2',
'NP_001333826', # Warn: Versionized NP won't be returned due to API limitations
],
),
(
'ENSG00000146648.17',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'ENST00000275493',
'ENST00000275493.6',
'NM_001346897',
'NM_001346897.2',
'NP_001333826', # Warn: Versionized NP won't be returned due to API limitations
],
),
(
'ENST00000275493',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'ENST00000275493',
'ENST00000275493.6',
],
),
(
'ENST00000275493.6',
[
'EGFR',
'ERBB',
'ENSG00000146648',
'ENSG00000146648.17',
'ENST00000275493',
'ENST00000275493.6',
],
),
]:
equivalent_features = match.get_equivalent_features(conn, feature)
equivalent_features = [el['displayName'] for el in equivalent_features]
for equivalent_feature in expected:
assert equivalent_feature in equivalent_features


class TestMatchCopyVariant:
def test_bad_category(self, conn):
Expand Down
1 change: 1 addition & 0 deletions tests/test_vocab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests here depend on specific data in GraphKB which can change. To avoid this, expected/stable values are chosen
"""

import os

import pytest
Expand Down

0 comments on commit 73473c6

Please sign in to comment.