Skip to content

Commit

Permalink
Merge pull request #113 from bcgsc/release/v1.15.0_kbStatementRelated…
Browse files Browse the repository at this point in the history
…_genes

Release/v1.15.0 kb statement related genes
  • Loading branch information
dustinbleile authored Dec 4, 2023
2 parents 37f6528 + db08658 commit f3a17ae
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
18 changes: 10 additions & 8 deletions graphkb/genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,16 +392,18 @@ def get_gene_information(
Function is originally from pori_ipr_python::annotate.py
Gene flags (categories) are: ['cancerGene', 'cancerRelated', 'knownFusionPartner', 'knownSmallMutation',
'oncogene', 'therapeuticAssociated', 'tumourSuppressor']
Gene flags (categories) are: [
'cancerGeneListMatch', 'kbStatementRelated', 'knownFusionPartner',
'knownSmallMutation', 'oncogene', 'therapeuticAssociated', 'tumourSuppressor'
]
Args:
graphkb_conn ([type]): [description]
gene_names ([type]): [description]
Returns:
List of gene_info dicts of form [{'name':<gene_str>, <flag>: True}]
Keys of False values are simply omitted from ipr upload to reduce info transfer.
eg. [{'cancerRelated': True,
eg. [{'kbStatementRelated': True,
'knownFusionPartner': True,
'knownSmallMutation': True,
'name': 'TERT',
Expand All @@ -423,7 +425,7 @@ def get_gene_information(
statements = [s for s in statements if s.get("reviewStatus") != FAILED_REVIEW_STATUS]

gene_flags: Dict[str, Set[str]] = {
"cancerRelated": set(),
"kbStatementRelated": set(),
"knownFusionPartner": set(),
"knownSmallMutation": set(),
}
Expand All @@ -432,9 +434,9 @@ def get_gene_information(
for condition in statement["conditions"]:
if not condition.get("reference1"):
continue
gene_flags["cancerRelated"].add(condition["reference1"])
gene_flags["kbStatementRelated"].add(condition["reference1"])
if condition["reference2"]:
gene_flags["cancerRelated"].add(condition["reference2"])
gene_flags["kbStatementRelated"].add(condition["reference2"])
gene_flags["knownFusionPartner"].add(condition["reference1"])
gene_flags["knownFusionPartner"].add(condition["reference2"])
elif condition["@class"] == "PositionalVariant":
Expand All @@ -444,8 +446,8 @@ def get_gene_information(
gene_flags["oncogene"] = convert_to_rid_set(get_oncokb_oncogenes(graphkb_conn))
logger.info("fetching tumour supressors list")
gene_flags["tumourSuppressor"] = convert_to_rid_set(get_oncokb_tumour_supressors(graphkb_conn))
logger.info("fetching cancerGene list")
gene_flags["cancerGene"] = convert_to_rid_set(get_cancer_genes(graphkb_conn))
logger.info("fetching cancerGeneListMatch list")
gene_flags["cancerGeneListMatch"] = convert_to_rid_set(get_cancer_genes(graphkb_conn))

logger.info("fetching therapeutic associated genes lists")
gene_flags["therapeuticAssociated"] = convert_to_rid_set(
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include_trailing_comma = true
[metadata]
name = graphkb
url = https://github.com/bcgsc/pori_graphkb_python
version = 1.14.0
version = 1.15.0
author_email = [email protected]
description = python adapter for interacting with the GraphKB API
long_description = file: README.md
Expand Down
8 changes: 4 additions & 4 deletions tests/test_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ def test_get_gene_information(conn):
+ CANNONICAL_THERAPY_GENES
):
assert gene in [
g["name"] for g in gene_info if g.get("cancerRelated")
], f"Missed cancerRelated {gene}"
g["name"] for g in gene_info if g.get("kbStatementRelated")
], f"Missed kbStatementRelated {gene}"

for gene in CANONICAL_CG:
assert gene in [
g["name"] for g in gene_info if g.get("cancerGene")
], f"Missed cancerGene {gene}"
g["name"] for g in gene_info if g.get("cancerGeneListMatch")
], f"Missed cancerGeneListMatch {gene}"
6 changes: 4 additions & 2 deletions tests/test_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

from graphkb import statement

from .test_match import conn
from .test_match import ( # noqa - 'F401 imported but unused' is being fooled by pytest conventions
conn,
)

EXCLUDE_INTEGRATION_TESTS = os.environ.get("EXCLUDE_INTEGRATION_TESTS") == "1"

Expand Down Expand Up @@ -86,7 +88,7 @@ def test_custom_categories(self, graphkb_conn):

@pytest.mark.skipif(EXCLUDE_INTEGRATION_TESTS, reason="excluding long running integration tests")
class TestStatementMatch:
def test_truncating_categories(self, conn):
def test_truncating_categories(self, conn): # noqa - pytest fixture, not redefinition
variant = {"@class": "CategoryVariant", "@rid": "#161:429", "displayName": "RB1 truncating"}
statements = statement.get_statements_from_variants(conn, [variant])
assert statements

0 comments on commit f3a17ae

Please sign in to comment.