Skip to content

Commit 3d14a1a

Browse files
committed
draft change for test
1 parent e4689df commit 3d14a1a

File tree

1 file changed

+61
-20
lines changed

1 file changed

+61
-20
lines changed

pori_python/ipr/annotate.py

+61-20
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,22 @@ def annotate_expression_variants(
122122
continue
123123
try:
124124
matches = gkb_match.match_expression_variant(graphkb_conn, gene, variant)
125-
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
126-
ipr_row["variant"] = row["key"]
127-
ipr_row["variantType"] = row.get("variantType", "exp")
125+
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
126+
ipr_row = {
127+
'variant': row['key'],
128+
'variantType': row.get('variantType', 'exp'),
129+
'kbVariant': matched_stmt['kbVariant'],
130+
'kbMatchedStatements': [matched_stmt]
131+
}
132+
#ipr_row["variant"] = row["key"]
133+
#ipr_row["variantType"] = row.get("variantType", "exp")
128134
alterations.append(ipr_row)
129135
except FeatureNotFoundError as err:
130136
problem_genes.add(gene)
131137
logger.debug(f"Unrecognized gene ({gene} {variant}): {err}")
132138
except ValueError as err:
133139
logger.error(f"failed to match variants ({gene} {variant}): {err}")
140+
import pdb; pdb.set_trace()
134141

135142
if skipped:
136143
logger.info(f"skipped matching {skipped} expression information rows")
@@ -140,6 +147,7 @@ def annotate_expression_variants(
140147
logger.info(
141148
f"matched {len(variants)} expression variants to {len(alterations)} graphkb annotations"
142149
)
150+
import pdb; pdb.set_trace()
143151
return alterations
144152

145153

@@ -175,10 +183,20 @@ def annotate_copy_variants(
175183
continue
176184
try:
177185
matches = gkb_match.match_copy_variant(graphkb_conn, gene, variant)
178-
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
179-
ipr_row["variant"] = row["key"]
180-
ipr_row["variantType"] = row.get("variantType", "cnv")
186+
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
187+
# ipr_row["variant"] = row["key"]
188+
# ipr_row["variantType"] = row.get("variantType", "cnv")
189+
# alterations.append(ipr_row)
190+
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
191+
ipr_row = {
192+
'variant': row['key'],
193+
'variantType': row.get('variantType', 'cnv'),
194+
'kbVariant': matched_stmt['kbVariant'],
195+
'kbMatchedStatements': [matched_stmt]
196+
}
181197
alterations.append(ipr_row)
198+
#ipr_row["variant"] = row["key"]
199+
#ipr_row["variantType"] = row.get("variantType", "exp")
182200
except FeatureNotFoundError as err:
183201
problem_genes.add(gene)
184202
logger.debug(f"Unrecognized gene ({gene} {variant}): {err}")
@@ -252,15 +270,22 @@ def annotate_positional_variants(
252270
matches = gkb_match.match_positional_variant(graphkb_conn, variant)
253271
else:
254272
raise parse_err
255-
256-
for ipr_row in get_ipr_statements_from_variants(
257-
graphkb_conn, matches, disease_name
258-
):
259-
ipr_row["variant"] = row["key"]
260-
ipr_row["variantType"] = row.get(
261-
"variantType", "mut" if row.get("gene") else "sv"
262-
)
273+
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, matches, disease_name):
274+
ipr_row = {
275+
'variant': row['key'],
276+
'variantType': row.get("variantType", "mut" if row.get("gene") else "sv"),
277+
'kbVariant': matched_stmt['kbVariant'],
278+
'kbMatchedStatements': [matched_stmt]
279+
}
263280
alterations.append(Hashabledict(ipr_row))
281+
#for ipr_row in get_ipr_statements_from_variants(
282+
# graphkb_conn, matches, disease_name
283+
#):
284+
# ipr_row["variant"] = row["key"]
285+
# ipr_row["variantType"] = row.get(
286+
# "variantType", "mut" if row.get("gene") else "sv"
287+
# )
288+
# alterations.append(Hashabledict(ipr_row))
264289

265290
except FeatureNotFoundError as err:
266291
logger.debug(f"failed to match positional variants ({variant}): {err}")
@@ -327,10 +352,18 @@ def annotate_msi(
327352
)
328353
if msi_categories:
329354
msi_variants = [cast(Variant, var) for var in msi_categories]
330-
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
331-
ipr_row["variant"] = msi_category
332-
ipr_row["variantType"] = "msi"
355+
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
356+
ipr_row = {
357+
'variant': msi_category,
358+
'variantType': 'msi',
359+
'kbVariant': matched_stmt['kbVariant'],
360+
'kbMatchedStatements': [matched_stmt]
361+
}
333362
gkb_matches.append(ipr_row)
363+
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, msi_variants, disease_name):
364+
# ipr_row["variant"] = msi_category
365+
# ipr_row["variantType"] = "msi"
366+
# gkb_matches.append(ipr_row)
334367
return gkb_matches
335368

336369

@@ -366,8 +399,16 @@ def annotate_tmb(
366399
)
367400
if categories:
368401
cat_variants = [cast(Variant, var) for var in categories]
369-
for ipr_row in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
370-
ipr_row["variant"] = category
371-
ipr_row["variantType"] = "tmb"
402+
for matched_stmt in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
403+
ipr_row = {
404+
'variant': category,
405+
'variantType': 'tmb',
406+
'kbVariant': matched_stmt['kbVariant'],
407+
'kbMatchedStatements': [matched_stmt]
408+
}
372409
gkb_matches.append(ipr_row)
410+
#for ipr_row in get_ipr_statements_from_variants(graphkb_conn, cat_variants, disease_name):
411+
# ipr_row["variant"] = category
412+
# ipr_row["variantType"] = "tmb"
413+
# gkb_matches.append(ipr_row)
373414
return gkb_matches

0 commit comments

Comments
 (0)