Skip to content

Commit

Permalink
linting only - 'venv/bin/isort --profile black --atomic -l 100 graphk…
Browse files Browse the repository at this point in the history
…b/ tests/ *.py & venv/bin/black -C --line-length 100 graphkb/ tests/ *.py'
  • Loading branch information
dustinbleile committed Dec 2, 2023
1 parent 0981021 commit 4be9cdd
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 230 deletions.
2 changes: 1 addition & 1 deletion graphkb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __getitem__(self, key):
}

# For match.type_screening() [KBDEV-1056]
DEFAULT_NON_STRUCTURAL_VARIANT_TYPE = 'mutation'
DEFAULT_NON_STRUCTURAL_VARIANT_TYPE = "mutation"
STRUCTURAL_VARIANT_SIZE_THRESHOLD = 48 # bp
STRUCTURAL_VARIANT_TYPES = [
"structural variant",
Expand Down
13 changes: 4 additions & 9 deletions graphkb/genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@


def _get_tumourigenesis_genes_list(
conn: GraphKBConnection,
relevance: str,
sources: List[str],
ignore_cache: bool = False,
conn: GraphKBConnection, relevance: str, sources: List[str], ignore_cache: bool = False
) -> List[Ontology]:
statements = cast(
List[Statement],
Expand Down Expand Up @@ -259,12 +256,10 @@ def get_cancer_predisposition_info(conn: GraphKBConnection) -> Tuple[List[str],
"evidence": {
"target": "Source",
"filters": {"@rid": get_rid(conn, "Source", "CGL")},
},
},
{
"relevance": {"target": "Vocabulary", "filters": {"@rid": relevance_rids}},
}
},
],
{"relevance": {"target": "Vocabulary", "filters": {"@rid": relevance_rids}}},
]
},
"returnProperties": [
"conditions.@class",
Expand Down
42 changes: 20 additions & 22 deletions graphkb/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
looks_like_rid,
stringifyVariant,
)
from .vocab import get_equivalent_terms, get_terms_set, get_term_tree
from .vocab import get_equivalent_terms, get_term_tree, get_terms_set

FEATURES_CACHE: Set[str] = set()

Expand Down Expand Up @@ -369,9 +369,7 @@ def compare_positional_variants(


def type_screening(
conn: GraphKBConnection,
parsed: ParsedVariant,
updateStructuralTypes=False,
conn: GraphKBConnection, parsed: ParsedVariant, updateStructuralTypes=False
) -> str:
"""
[KBDEV-1056]
Expand Down Expand Up @@ -419,40 +417,40 @@ def type_screening(

# Will use either hardcoded type list or an updated list from the API
if updateStructuralTypes:
rids = list(get_terms_set(conn, ['structural variant']))
rids = list(get_terms_set(conn, ["structural variant"]))
records = conn.get_records_by_id(rids)
structuralVariantTypes = [el['name'] for el in records]
structuralVariantTypes = [el["name"] for el in records]

# Unambiguous non-structural variation type
if parsed['type'] not in structuralVariantTypes:
return parsed['type']
if parsed["type"] not in structuralVariantTypes:
return parsed["type"]

# Unambiguous structural variation type
if parsed['type'] in ['fusion', 'translocation']:
return parsed['type']
if parsed.get('reference2', None):
return parsed['type']
prefix = parsed.get('prefix', 'g')
if prefix == 'y': # Assuming all variations using cytoband coordiantes meet the size threshold
return parsed['type']
if parsed["type"] in ["fusion", "translocation"]:
return parsed["type"]
if parsed.get("reference2", None):
return parsed["type"]
prefix = parsed.get("prefix", "g")
if prefix == "y": # Assuming all variations using cytoband coordiantes meet the size threshold
return parsed["type"]

# When size cannot be determined: exonic and intronic coordinates
# e.g. "MET:e.14del" meaning "Any deletion occuring at the 14th exon"
if prefix in ['e', 'i']: # Assuming they don't meet the size threshold
if prefix in ["e", "i"]: # Assuming they don't meet the size threshold
return default_type

# When size is given
if parsed.get('untemplatedSeqSize', 0) >= threshold:
return parsed['type']
if parsed.get("untemplatedSeqSize", 0) >= threshold:
return parsed["type"]

# When size needs to be computed from positions
pos_start = parsed.get('break1Start', {}).get('pos', 1)
pos_end = parsed.get('break2Start', {}).get('pos', pos_start)
pos_start = parsed.get("break1Start", {}).get("pos", 1)
pos_end = parsed.get("break2Start", {}).get("pos", pos_start)
pos_size = 1
if prefix == 'p':
if prefix == "p":
pos_size = 3
if ((pos_end - pos_start) + 1) * pos_size >= threshold:
return parsed['type']
return parsed["type"]

# Default
return default_type
Expand Down
198 changes: 32 additions & 166 deletions tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,203 +11,69 @@
# Unambiguous structural variations
"(FGFR3,BRCA2):fusion(g.1234567,g.1234567)": {
"matches": {
"displayName": [
"FGFR3 fusion",
"FGFR3 rearrangement",
],
"type": [
"fusion",
"rearrangement",
],
},
"displayName": ["FGFR3 fusion", "FGFR3 rearrangement"],
"type": ["fusion", "rearrangement"],
}
},
# ambiguous structural variations -> structural
"FGFR3:c.1200_1300dup": {
"matches": {
"displayName": [
"FGFR3 mutation",
"FGFR3 rearrangement",
],
"type": [
"mutation",
"rearrangement",
],
},
"displayName": ["FGFR3 mutation", "FGFR3 rearrangement"],
"type": ["mutation", "rearrangement"],
}
},
"FGFR3:c.1200_1201insACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT": {
"matches": {
"displayName": [
"FGFR3 mutation",
"FGFR3 rearrangement",
],
"type": [
"mutation",
"rearrangement",
],
},
"displayName": ["FGFR3 mutation", "FGFR3 rearrangement"],
"type": ["mutation", "rearrangement"],
}
},
"FGFR3:g.5000_5100del": {
"matches": {
"displayName": [
"FGFR3 mutation",
"FGFR3 rearrangement",
],
"type": [
"mutation",
"rearrangement",
],
},
"displayName": ["FGFR3 mutation", "FGFR3 rearrangement"],
"type": ["mutation", "rearrangement"],
}
},
"FGFR3:c.1200_1300delinsA": {
"matches": {
"displayName": [
"FGFR3 mutation",
"FGFR3 rearrangement",
],
"type": [
"mutation",
"rearrangement",
],
},
"displayName": ["FGFR3 mutation", "FGFR3 rearrangement"],
"type": ["mutation", "rearrangement"],
}
},
"FGFR3:c.1200delinsACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT": {
"matches": {
"displayName": [
"FGFR3 mutation",
"FGFR3 rearrangement",
],
"type": [
"mutation",
"rearrangement",
],
},
"displayName": ["FGFR3 mutation", "FGFR3 rearrangement"],
"type": ["mutation", "rearrangement"],
}
},
# ambiguous structural variations -> non-structural
"FGFR3:c.1200dup": {
"matches": {
"displayName": [
"FGFR3 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"FGFR3 rearrangement",
],
"type": [
"rearrangement",
],
},
"matches": {"displayName": ["FGFR3 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["FGFR3 rearrangement"], "type": ["rearrangement"]},
},
"FGFR3:c.1200_1201insA": {
"matches": {
"displayName": [
"FGFR3 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"FGFR3 rearrangement",
],
"type": [
"rearrangement",
],
},
"matches": {"displayName": ["FGFR3 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["FGFR3 rearrangement"], "type": ["rearrangement"]},
},
"FGFR3:g.5000del": {
"matches": {
"displayName": [
"FGFR3 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"FGFR3 rearrangement",
],
"type": [
"rearrangement",
],
},
"matches": {"displayName": ["FGFR3 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["FGFR3 rearrangement"], "type": ["rearrangement"]},
},
"FGFR3:c.1200delinsA": {
"matches": {
"displayName": [
"FGFR3 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"FGFR3 rearrangement",
],
"type": [
"rearrangement",
],
},
"matches": {"displayName": ["FGFR3 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["FGFR3 rearrangement"], "type": ["rearrangement"]},
},
"STK11:e.1_100del": {
"matches": {
"displayName": [
"STK11 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"STK11 deletion",
],
"type": [
"deletion",
],
},
"matches": {"displayName": ["STK11 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["STK11 deletion"], "type": ["deletion"]},
},
"STK11:i.1_100del": {
"matches": {
"displayName": [
"STK11 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"STK11 deletion",
],
"type": [
"deletion",
],
},
"matches": {"displayName": ["STK11 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["STK11 deletion"], "type": ["deletion"]},
},
# non-structural variations
"FGFR3:c.1200C>A": {
"matches": {
"displayName": [
"FGFR3 mutation",
],
"type": [
"mutation",
],
},
"does_not_matches": {
"displayName": [
"FGFR3 rearrangement",
],
"type": [
"rearrangement",
],
},
"matches": {"displayName": ["FGFR3 mutation"], "type": ["mutation"]},
"does_not_matches": {"displayName": ["FGFR3 rearrangement"], "type": ["rearrangement"]},
},
}
Loading

0 comments on commit 4be9cdd

Please sign in to comment.