Skip to content

Commit 19aa795

Browse files
committed
get custom variant text from ipr for comments
1 parent e4689df commit 19aa795

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

pori_python/ipr/main.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
germline_kb_matches,
3838
select_expression_plots,
3939
)
40-
from .summary import auto_analyst_comments
40+
from .summary import auto_analyst_comments, ipr_analyst_comments
4141
from .therapeutic_options import create_therapeutic_options
4242
from .util import LOG_LEVELS, logger, trim_empty_values
4343

@@ -194,6 +194,7 @@ def clean_unsupported_content(upload_content: Dict, ipr_spec: Dict = {}) -> Dict
194194
"copyVariants",
195195
"structuralVariants",
196196
"probeResults",
197+
"signatureVariants",
197198
"msi",
198199
]
199200
for variant_list_section in VARIANT_LIST_KEYS:
@@ -446,12 +447,20 @@ def ipr_report(
446447
targets = []
447448

448449
logger.info("generating analyst comments")
450+
449451
if generate_comments:
450-
comments = {
451-
"comments": auto_analyst_comments(
452+
graphkb_comments = auto_analyst_comments(
452453
graphkb_conn, gkb_matches, disease_name=kb_disease_match, variants=all_variants
453454
)
454-
}
455+
456+
ipr_comments = ipr_analyst_comments(
457+
ipr_conn,
458+
gkb_matches,
459+
disease_name=kb_disease_match,
460+
project_name=content['project'],
461+
report_type=content['template']
462+
)
463+
comments = {"comments": "\n".join([ipr_comments, graphkb_comments])}
455464
else:
456465
comments = {"comments": ""}
457466

pori_python/ipr/summary.py

+34
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,40 @@ def section_statements_by_genes(
342342
return genes
343343

344344

345+
def ipr_analyst_comments(
346+
ipr_conn: IprConnection,
347+
matches: Sequence[KbMatch] | Sequence[Hashabledict],
348+
disease_name: str,
349+
project_name: str,
350+
report_type: str
351+
):
352+
output: List[str] = [
353+
"<h3>The comments below were automatically drawn from curated text stored in IPR for variant matches in this report, and have not been manually reviewed</h3>"
354+
]
355+
356+
items = []
357+
358+
templates = ipr_conn.get(f'templates?name={report_type}')
359+
# if this is genomic expect two results - one 'pharmacogenomic'
360+
template_ident = [item for item in templates if item['name']==report_type][0]['ident']
361+
362+
projects = ipr_conn.get(f'project')
363+
project_ident = [item for item in projects if item['name']==project_name][0]['ident']
364+
365+
match_set = list(set([item['kbVariant'] for item in matches]))
366+
367+
for variant in match_set:
368+
itemlist = ipr_conn.get('variant-text', data={
369+
'variantName': variant,
370+
'template': template_ident,
371+
'project': project_ident
372+
})
373+
if itemlist:
374+
for item in itemlist:
375+
output.append(item['text'])
376+
return "\n".join(output)
377+
378+
345379
def auto_analyst_comments(
346380
graphkb_conn: GraphKBConnection,
347381
matches: Sequence[KbMatch] | Sequence[Hashabledict],

0 commit comments

Comments
 (0)