Skip to content

Commit

Permalink
draft change for test
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed Nov 5, 2024
1 parent e4689df commit 3d14a1a
Showing 1 changed file with 61 additions and 20 deletions.
81 changes: 61 additions & 20 deletions pori_python/ipr/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,22 @@ def annotate_expression_variants(
continue
try:
matches = gkb_match.match_expression_variant(graphkb_conn, gene, variant)
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
ipr_row["variant"] = row["key"]
ipr_row["variantType"] = row.get("variantType", "exp")
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
ipr_row = {
'variant': row['key'],
'variantType': row.get('variantType', 'exp'),
'kbVariant': matched_stmt['kbVariant'],
'kbMatchedStatements': [matched_stmt]
}
#ipr_row["variant"] = row["key"]
#ipr_row["variantType"] = row.get("variantType", "exp")
alterations.append(ipr_row)
except FeatureNotFoundError as err:
problem_genes.add(gene)
logger.debug(f"Unrecognized gene ({gene} {variant}): {err}")
except ValueError as err:
logger.error(f"failed to match variants ({gene} {variant}): {err}")
import pdb; pdb.set_trace()

if skipped:
logger.info(f"skipped matching {skipped} expression information rows")
Expand All @@ -140,6 +147,7 @@ def annotate_expression_variants(
logger.info(
f"matched {len(variants)} expression variants to {len(alterations)} graphkb annotations"
)
import pdb; pdb.set_trace()
return alterations


Expand Down Expand Up @@ -175,10 +183,20 @@ def annotate_copy_variants(
continue
try:
matches = gkb_match.match_copy_variant(graphkb_conn, gene, variant)
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
ipr_row["variant"] = row["key"]
ipr_row["variantType"] = row.get("variantType", "cnv")
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
# ipr_row["variant"] = row["key"]
# ipr_row["variantType"] = row.get("variantType", "cnv")
# alterations.append(ipr_row)
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
ipr_row = {
'variant': row['key'],
'variantType': row.get('variantType', 'cnv'),
'kbVariant': matched_stmt['kbVariant'],
'kbMatchedStatements': [matched_stmt]
}
alterations.append(ipr_row)
#ipr_row["variant"] = row["key"]
#ipr_row["variantType"] = row.get("variantType", "exp")
except FeatureNotFoundError as err:
problem_genes.add(gene)
logger.debug(f"Unrecognized gene ({gene} {variant}): {err}")
Expand Down Expand Up @@ -252,15 +270,22 @@ def annotate_positional_variants(
matches = gkb_match.match_positional_variant(graphkb_conn, variant)
else:
raise parse_err

for ipr_row in get_ipr_statements_from_variants(
graphkb_conn, matches, disease_name
):
ipr_row["variant"] = row["key"]
ipr_row["variantType"] = row.get(
"variantType", "mut" if row.get("gene") else "sv"
)
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
ipr_row = {
'variant': row['key'],
'variantType': row.get("variantType", "mut" if row.get("gene") else "sv"),
'kbVariant': matched_stmt['kbVariant'],
'kbMatchedStatements': [matched_stmt]
}
alterations.append(Hashabledict(ipr_row))
#for ipr_row in get_ipr_statements_from_variants(
# graphkb_conn, matches, disease_name
#):
# ipr_row["variant"] = row["key"]
# ipr_row["variantType"] = row.get(
# "variantType", "mut" if row.get("gene") else "sv"
# )
# alterations.append(Hashabledict(ipr_row))

except FeatureNotFoundError as err:
logger.debug(f"failed to match positional variants ({variant}): {err}")
Expand Down Expand Up @@ -327,10 +352,18 @@ def annotate_msi(
)
if msi_categories:
msi_variants = [cast(Variant, var) for var in msi_categories]
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
ipr_row["variant"] = msi_category
ipr_row["variantType"] = "msi"
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
ipr_row = {
'variant': msi_category,
'variantType': 'msi',
'kbVariant': matched_stmt['kbVariant'],
'kbMatchedStatements': [matched_stmt]
}
gkb_matches.append(ipr_row)
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
# ipr_row["variant"] = msi_category
# ipr_row["variantType"] = "msi"
# gkb_matches.append(ipr_row)
return gkb_matches


Expand Down Expand Up @@ -366,8 +399,16 @@ def annotate_tmb(
)
if categories:
cat_variants = [cast(Variant, var) for var in categories]
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
ipr_row["variant"] = category
ipr_row["variantType"] = "tmb"
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
ipr_row = {
'variant': category,
'variantType': 'tmb',
'kbVariant': matched_stmt['kbVariant'],
'kbMatchedStatements': [matched_stmt]
}
gkb_matches.append(ipr_row)
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
# ipr_row["variant"] = category
# ipr_row["variantType"] = "tmb"
# gkb_matches.append(ipr_row)
return gkb_matches

0 comments on commit 3d14a1a

Please sign in to comment.