Skip to content

Commit

Permalink
Merge pull request #112 from bcgsc/release/v3.8.0_approved_levels_fro…
Browse files Browse the repository at this point in the history
…m_IPR_A

Release/v3.8.0 approved levels from ipr a
  • Loading branch information
dustinbleile authored Apr 19, 2023
2 parents 6b15562 + 9faf8a8 commit 1494305
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 35 deletions.
17 changes: 1 addition & 16 deletions ipr/constants.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
DEFAULT_URL = 'https://iprstaging-api.bcgsc.ca/api'
GERMLINE_BASE_TERMS = ('pharmacogenomic', 'cancer predisposition') # based on graphkb.constants
VARIANT_CLASSES = {'Variant', 'CategoryVariant', 'PositionalVariant', 'CatalogueVariant'}


APPROVED_EVIDENCE_LEVELS = {
# sourceIds of levels by source name
'oncokb': ['1', 'r1'],
'profyle': ['t1'],
'cancer genome interpreter': [
'cpic guidelines',
'european leukemianet guidelines',
'fda guidelines',
'nccn guidelines',
'nccn/cap guidelines',
],
}

DEFAULT_URL = 'https://iprstaging-api.bcgsc.ca/api'

# all possible values for review status are: ['pending', 'not required', 'passed', 'failed', 'initial']
FAILED_REVIEW_STATUS = 'failed'
64 changes: 64 additions & 0 deletions ipr/content.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@
"integer",
"null"
]
},
"size": {
"description": "size of the copy change segment in the chromosome",
"type": [
"number",
"null"
]
}
},
"required": [
Expand Down Expand Up @@ -511,6 +518,14 @@
"description": "the sequencing protocol used for ths sample",
"example": "DNA",
"type": "string"
},
"library": {
"description": "Library id string",
"example": "P01234",
"type": [
"string",
"null"
]
}
},
"type": "object"
Expand Down Expand Up @@ -993,6 +1008,14 @@
"null"
]
},
"tumourAltCopies": {
"description": "the number of gene copies in the tumour genome supporting the mutation",
"example": 1,
"type": [
"integer",
"null"
]
},
"tumourAltCount": {
"description": "the number of alternate reads in the tumour genome supporting the mutation",
"example": 1,
Expand All @@ -1017,6 +1040,14 @@
"null"
]
},
"tumourRefCopies": {
"description": "the number of wildtype gene copies in tumour genome",
"example": 1,
"type": [
"integer",
"null"
]
},
"zygosity": {
"examples": [
"het",
Expand Down Expand Up @@ -1099,6 +1130,14 @@
"null"
]
},
"frame": {
"description": "Optional descriptive string for in-frame vs frame-shift SV",
"example": "frame-shift",
"type": [
"string",
"null"
]
},
"gene1": {
"description": "the 5' (n-terminal) gene name",
"example": "EWSR1",
Expand Down Expand Up @@ -1149,6 +1188,15 @@
"null"
]
},
"mavis_product_id": {
"default": null,
"description": "mavis product id / other tool description strings",
"example": "MAVIS-2.5.35-RT3556GHTR",
"type": [
"string",
"null"
]
},
"svg": {
"description": "svg image file content for this SV",
"type": [
Expand All @@ -1162,6 +1210,22 @@
"string",
"null"
]
},
"tumourAltCount": {
"description": "the number of alternate reads in the tumour genome supporting the mutation",
"example": 1,
"type": [
"integer",
"null"
]
},
"tumourDepth": {
"description": "the total number of reads at this position in the tumour genome",
"example": 2,
"type": [
"integer",
"null"
]
}
},
"required": [
Expand Down
2 changes: 2 additions & 0 deletions ipr/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
# GERO-307 - tumourAltCount and tumourDepth are available but not rnaAltCount and rnaDepth
'tumourAltCount',
'tumourDepth',
'germline',
'mavis_product_id',
]


Expand Down
22 changes: 4 additions & 18 deletions ipr/ipr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from graphkb.types import Record
from typing import Dict, Iterable, List, Sequence, Set, Tuple

from .constants import APPROVED_EVIDENCE_LEVELS, GERMLINE_BASE_TERMS, VARIANT_CLASSES
from .constants import GERMLINE_BASE_TERMS, VARIANT_CLASSES
from .types import GkbStatement, ImageDefinition, IprFusionVariant, IprGene, IprVariant, KbMatch
from .util import convert_to_rid_set, find_variant, logger

Expand All @@ -23,20 +23,6 @@ def display_evidence_levels(statement: GkbStatement) -> str:
return ';'.join(sorted(result))


def get_approved_evidence_levels(graphkb_conn: GraphKBConnection) -> List[Record]:
filters = []
for source, names in APPROVED_EVIDENCE_LEVELS.items():
filters.append(
{
'AND': [
{'source': {'target': 'Source', 'filters': {'name': source}}},
{'name': names, 'operator': 'IN'},
]
}
)
return graphkb_conn.query({'target': 'EvidenceLevel', 'filters': {'OR': filters}})


def filter_structural_variants(
structural_variants: List[IprFusionVariant],
kb_matches: List[KbMatch],
Expand Down Expand Up @@ -86,7 +72,7 @@ def get_evidencelevel_mapping(graphkb_conn: GraphKBConnection) -> Dict[str, str]

# Filter IPR EvidenceLevel and map each outgoing CrossReferenceOf to displayName
ipr_source_rid = graphkb_conn.get_source("ipr")["@rid"]
ipr_evidence_levels = filter(lambda d: d["source"] == ipr_source_rid, evidence_levels)
ipr_evidence_levels = filter(lambda d: d.get("source") == ipr_source_rid, evidence_levels)
cross_references_mapping: Dict[str, str] = dict()
ipr_rids_to_displayname = dict()
for level in ipr_evidence_levels:
Expand Down Expand Up @@ -141,9 +127,9 @@ def convert_statements_to_alterations(
raise ValueError(f'failed to match disease ({disease_name}) to graphkb')

rows = []

approved = convert_to_rid_set(get_approved_evidence_levels(graphkb_conn))
ev_map = get_evidencelevel_mapping(graphkb_conn)
# GERO-318 - add all IPR-A evidence equivalents to the approvedTherapy flag
approved = set([ev for (ev, ipr) in ev_map.items() if ipr == 'IPR-A'])

for statement in statements:
variants = [c for c in statement['conditions'] if c['@class'] in VARIANT_CLASSES]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ known_standard_library = requests

[metadata]
name = ipr
version = 3.7.1
version = 3.8.0
author_email = [email protected]
author = ipr
maintainer_email = [email protected]
Expand Down

0 comments on commit 1494305

Please sign in to comment.