@@ -122,15 +122,22 @@ def annotate_expression_variants(
122
122
continue
123
123
try :
124
124
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")
128
134
alterations .append (ipr_row )
129
135
except FeatureNotFoundError as err :
130
136
problem_genes .add (gene )
131
137
logger .debug (f"Unrecognized gene ({ gene } { variant } ): { err } " )
132
138
except ValueError as err :
133
139
logger .error (f"failed to match variants ({ gene } { variant } ): { err } " )
140
+ import pdb ; pdb .set_trace ()
134
141
135
142
if skipped :
136
143
logger .info (f"skipped matching { skipped } expression information rows" )
@@ -140,6 +147,7 @@ def annotate_expression_variants(
140
147
logger .info (
141
148
f"matched { len (variants )} expression variants to { len (alterations )} graphkb annotations"
142
149
)
150
+ import pdb ; pdb .set_trace ()
143
151
return alterations
144
152
145
153
@@ -175,10 +183,20 @@ def annotate_copy_variants(
175
183
continue
176
184
try :
177
185
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
+ }
181
197
alterations .append (ipr_row )
198
+ #ipr_row["variant"] = row["key"]
199
+ #ipr_row["variantType"] = row.get("variantType", "exp")
182
200
except FeatureNotFoundError as err :
183
201
problem_genes .add (gene )
184
202
logger .debug (f"Unrecognized gene ({ gene } { variant } ): { err } " )
@@ -252,15 +270,22 @@ def annotate_positional_variants(
252
270
matches = gkb_match .match_positional_variant (graphkb_conn , variant )
253
271
else :
254
272
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
+ }
263
280
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))
264
289
265
290
except FeatureNotFoundError as err :
266
291
logger .debug (f"failed to match positional variants ({ variant } ): { err } " )
@@ -327,10 +352,18 @@ def annotate_msi(
327
352
)
328
353
if msi_categories :
329
354
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
+ }
333
362
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)
334
367
return gkb_matches
335
368
336
369
@@ -366,8 +399,16 @@ def annotate_tmb(
366
399
)
367
400
if categories :
368
401
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
+ }
372
409
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)
373
414
return gkb_matches
0 commit comments