@@ -57,7 +57,7 @@ def get_second_pass_variants(
57
57
58
58
59
59
def get_ipr_statements_from_variants (
60
- graphkb_conn : GraphKBConnection , matches : List [Variant ], disease_name : str
60
+ graphkb_conn : GraphKBConnection , matches : List [Variant ], disease_matches : List [ str ]
61
61
) -> List [KbMatch ]:
62
62
"""IPR upload formatted GraphKB statements from the list of variants.
63
63
@@ -72,7 +72,7 @@ def get_ipr_statements_from_variants(
72
72
existing_statements = {s ["@rid" ] for s in statements }
73
73
74
74
for ipr_row in convert_statements_to_alterations (
75
- graphkb_conn , statements , disease_name , convert_to_rid_set (matches )
75
+ graphkb_conn , statements , disease_matches , convert_to_rid_set (matches )
76
76
):
77
77
rows .append (ipr_row )
78
78
@@ -88,7 +88,7 @@ def get_ipr_statements_from_variants(
88
88
for ipr_row in convert_statements_to_alterations (
89
89
graphkb_conn ,
90
90
inferred_statements ,
91
- disease_name ,
91
+ disease_matches ,
92
92
convert_to_rid_set (inferred_matches ),
93
93
):
94
94
ipr_row ["kbData" ]["inferred" ] = True
@@ -99,15 +99,17 @@ def get_ipr_statements_from_variants(
99
99
100
100
def annotate_expression_variants (
101
101
graphkb_conn : GraphKBConnection ,
102
+ disease_matches : List [str ],
102
103
variants : List [IprExprVariant ],
103
- disease_name : str ,
104
104
show_progress : bool = False ,
105
105
) -> List [KbMatch ]:
106
106
"""Annotate expression variants with GraphKB in the IPR alterations format.
107
107
108
108
Args:
109
- graphkb_conn: the graphkb api connection object
110
- variants: list of variants
109
+ graphkb_conn (GraphKBConnection): the graphkb api connection object
110
+ disease_matches (list.str): GraphKB disease RIDs
111
+ variants (list.IprExprVariant): list of variants.
112
+ show_progress (bool): Progressbar displayed for long runs.
111
113
112
114
Returns:
113
115
list of kbMatches records for IPR
@@ -127,7 +129,7 @@ def annotate_expression_variants(
127
129
continue
128
130
try :
129
131
matches = gkb_match .match_expression_variant (graphkb_conn , gene , variant )
130
- for ipr_row in get_ipr_statements_from_variants (graphkb_conn , matches , disease_name ):
132
+ for ipr_row in get_ipr_statements_from_variants (graphkb_conn , matches , disease_matches ):
131
133
ipr_row ["variant" ] = row ["key" ]
132
134
ipr_row ["variantType" ] = row .get ("variantType" , "exp" )
133
135
alterations .append (ipr_row )
@@ -150,15 +152,17 @@ def annotate_expression_variants(
150
152
151
153
def annotate_copy_variants (
152
154
graphkb_conn : GraphKBConnection ,
155
+ disease_matches : List [str ],
153
156
variants : List [IprCopyVariant ],
154
- disease_name : str ,
155
157
show_progress : bool = False ,
156
158
) -> List [KbMatch ]:
157
159
"""Annotate allowed copy variants with GraphKB in the IPR alterations format.
158
160
159
161
Args:
160
- graphkb_conn: the graphkb api connection object
161
- variants: list of variants
162
+ graphkb_conn (GraphKBConnection): the graphkb api connection object
163
+ disease_matches (list.str): GraphKB disease RIDs
164
+ variants (list.IprCopyVariant): list of variants.
165
+ show_progress (bool): Progressbar displayed for long runs.
162
166
163
167
Returns:
164
168
list of kbMatches records for IPR
@@ -180,7 +184,7 @@ def annotate_copy_variants(
180
184
continue
181
185
try :
182
186
matches = gkb_match .match_copy_variant (graphkb_conn , gene , variant )
183
- for ipr_row in get_ipr_statements_from_variants (graphkb_conn , matches , disease_name ):
187
+ for ipr_row in get_ipr_statements_from_variants (graphkb_conn , matches , disease_matches ):
184
188
ipr_row ["variant" ] = row ["key" ]
185
189
ipr_row ["variantType" ] = row .get ("variantType" , "cnv" )
186
190
alterations .append (ipr_row )
@@ -206,16 +210,16 @@ def annotate_copy_variants(
206
210
def annotate_positional_variants (
207
211
graphkb_conn : GraphKBConnection ,
208
212
variants : Sequence [IprStructuralVariant ] | Sequence [Hashabledict ],
209
- disease_name : str ,
213
+ disease_matches : List [ str ] ,
210
214
show_progress : bool = False ,
211
215
) -> List [Hashabledict ]:
212
216
"""Annotate SNP, INDEL or fusion variant calls with GraphKB and return in IPR match format.
213
217
214
218
Hashable type is required to turn lists into sets.
215
219
Args:
216
220
graphkb_conn (GraphKBConnection): the graphkb api connection object
217
- variants (list.<dict> ): list of variants. Defaults to [] .
218
- disease_name ( str): GraphKB disease name for statement matching. 'cancer' is most general
221
+ variants (Sequence ): list of variants.
222
+ disease_matches (list. str): GraphKB disease RIDs
219
223
show_progress (bool): Progressbar displayed for long runs.
220
224
221
225
Returns:
@@ -259,7 +263,9 @@ def annotate_positional_variants(
259
263
raise parse_err
260
264
261
265
for ipr_row in get_ipr_statements_from_variants (
262
- graphkb_conn , matches , disease_name
266
+ graphkb_conn ,
267
+ matches ,
268
+ disease_matches ,
263
269
):
264
270
ipr_row ["variant" ] = row ["key" ]
265
271
ipr_row ["variantType" ] = row .get (
@@ -304,15 +310,16 @@ def annotate_positional_variants(
304
310
305
311
def annotate_msi (
306
312
graphkb_conn : GraphKBConnection ,
307
- disease_name : str = "cancer" ,
313
+ disease_matches : List [ str ] ,
308
314
msi_category : str = "microsatellite instability" ,
309
315
) -> List [KbMatch ]:
310
316
"""Annotate microsatellite instablity from GraphKB in the IPR alterations format.
311
317
312
318
Match to GraphKb Category variants with similar names
313
319
Args:
314
- graphkb_conn: the graphkb api connection object
315
- msi_category: such as 'microsatellite instability'
320
+ graphkb_conn (GraphKBConnection): the graphkb api connection object
321
+ disease_matches (list.str): GraphKB disease RIDs
322
+ msi_category (str): such as 'microsatellite instability'
316
323
317
324
Returns:
318
325
list of kbMatches records for IPR
@@ -335,7 +342,9 @@ def annotate_msi(
335
342
)
336
343
if msi_categories :
337
344
msi_variants = [cast (Variant , var ) for var in msi_categories ]
338
- for ipr_row in get_ipr_statements_from_variants (graphkb_conn , msi_variants , disease_name ):
345
+ for ipr_row in get_ipr_statements_from_variants (
346
+ graphkb_conn , msi_variants , disease_matches
347
+ ):
339
348
ipr_row ["variant" ] = msi_category
340
349
ipr_row ["variantType" ] = "msi"
341
350
gkb_matches .append (ipr_row )
@@ -344,15 +353,15 @@ def annotate_msi(
344
353
345
354
def annotate_tmb (
346
355
graphkb_conn : GraphKBConnection ,
347
- disease_name : str = "cancer" ,
356
+ disease_matches : List [ str ] ,
348
357
category : str = TMB_HIGH_CATEGORY ,
349
358
) -> List [KbMatch ]:
350
359
"""Annotate Tumour Mutation Burden (tmb) categories from GraphKB in the IPR alterations format.
351
360
352
361
Match to GraphKb Category variants with similar names
353
362
Args:
354
- graphkb_conn: the graphkb api connection object
355
- disease_name: oncotree disease name for graphkb matching.
363
+ graphkb_conn (GraphKBConnection) : the graphkb api connection object
364
+ disease_matches (list.str): GraphKB disease RIDs
356
365
category: such as 'high mutation burden'
357
366
358
367
Returns:
@@ -376,7 +385,9 @@ def annotate_tmb(
376
385
)
377
386
if categories :
378
387
cat_variants = [cast (Variant , var ) for var in categories ]
379
- for ipr_row in get_ipr_statements_from_variants (graphkb_conn , cat_variants , disease_name ):
388
+ for ipr_row in get_ipr_statements_from_variants (
389
+ graphkb_conn , cat_variants , disease_matches
390
+ ):
380
391
ipr_row ["variant" ] = category
381
392
ipr_row ["variantType" ] = "tmb"
382
393
gkb_matches .append (ipr_row )
@@ -385,19 +396,19 @@ def annotate_tmb(
385
396
386
397
def annotate_signature_variants (
387
398
graphkb_conn : GraphKBConnection ,
399
+ disease_matches : List [str ],
388
400
variants : List [IprSignatureVariant ] = [],
389
- disease_name : str = "cancer" ,
390
401
show_progress : bool = False ,
391
402
) -> List [KbMatch ]:
392
403
"""Annotate Signature variants with GraphKB in the IPR alterations format.
393
404
394
405
Match to corresponding GraphKB Variants, then to linked GraphKB Statements
395
406
396
407
Args:
397
- graphkb_conn: the graphkb api connection object
398
- variants: list of signature variants
399
- disease_name: oncotree disease name for graphkb matching
400
- show_progress: progressbar displayed for long runs; default to False
408
+ graphkb_conn (GraphKBConnection) : the graphkb api connection object
409
+ disease_matches ( list.str): GraphKB disease RIDs
410
+ variants (list.IprSignatureVariant): list of signature variants
411
+ show_progress (bool) : progressbar displayed for long runs; default to False
401
412
402
413
Returns:
403
414
list of kbMatches records for IPR
@@ -416,7 +427,7 @@ def annotate_signature_variants(
416
427
)
417
428
# Matching GKB Variants to GKB Statements
418
429
for ipr_row in get_ipr_statements_from_variants (
419
- graphkb_conn , matched_variants , disease_name
430
+ graphkb_conn , matched_variants , disease_matches
420
431
):
421
432
ipr_row ["variant" ] = variant ["key" ]
422
433
ipr_row ["variantType" ] = "sigv"
0 commit comments