@@ -343,12 +343,22 @@ def section_statements_by_genes(
343343 return genes
344344
345345
346+ def prep_single_ipr_variant_comment (item ):
347+ cancer_type = ',' .join (item ['cancerType' ])
348+ if not cancer_type :
349+ cancer_type = 'no specific cancer types'
350+ cancer_type = f' ({ cancer_type } )'
351+ section = [f"<h2>{ item ['variantName' ]} { cancer_type } </h2>" ]
352+ section .append (f"<p>{ item ['text' ]} </p>" )
353+ return section
354+
355+
346356def ipr_analyst_comments (
347357 ipr_conn : IprConnection ,
348358 matches : Sequence [KbMatch ] | Sequence [Hashabledict ],
349359 disease_name : str ,
350360 project_name : str ,
351- report_type : str
361+ report_type : str ,
352362):
353363 output : List [str ] = [
354364 "<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>"
@@ -358,37 +368,27 @@ def ipr_analyst_comments(
358368
359369 templates = ipr_conn .get (f'templates?name={ report_type } ' )
360370 # if this is genomic expect two results - one 'pharmacogenomic'
361- template_ident = [item for item in templates if item ['name' ]== report_type ][0 ]['ident' ]
371+ template_ident = [item for item in templates if item ['name' ] == report_type ][0 ]['ident' ]
362372
363373 projects = ipr_conn .get (f'project' )
364- project_ident = [item for item in projects if item ['name' ]== project_name ][0 ]['ident' ]
374+ project_ident = [item for item in projects if item ['name' ] == project_name ][0 ]['ident' ]
365375
366376 match_set = list (set ([item ['kbVariant' ] for item in matches ]))
367377
368- def prep_single_variant_comment (item ):
369- cancer_type = ',' .join (item ['cancerType' ])
370- if not cancer_type :
371- cancer_type = 'no specific cancer types'
372- cancer_type = f' ({ cancer_type } )'
373- section = [f"<h2>{ item ['variantName' ]} { cancer_type } </h2>" ]
374- section .append (f"<p>{ item ['text' ]} </p>" )
375- return section
376-
377378 for variant in match_set :
378- itemlist = ipr_conn .get ('variant-text' , data = {
379- 'variantName' : variant ,
380- 'template' : template_ident ,
381- 'project' : project_ident
382- })
379+ itemlist = ipr_conn .get (
380+ 'variant-text' ,
381+ data = {'variantName' : variant , 'template' : template_ident , 'project' : project_ident },
382+ )
383383 if itemlist :
384384 for item in itemlist :
385385 if not item ['cancerType' ] or disease_name in item ['cancerType' ]:
386- section = prep_single_variant_comment (item )
386+ section = prep_single_ipr_variant_comment (item )
387387 output .extend (section )
388388 else :
389389 ipr_conn .get ('variant-text' )
390390 if not output :
391- output = ['No comments found in IPR for these variants' ]
391+ output = ['No comments found in IPR for variants in this report ' ]
392392 return "\n " .join (output )
393393
394394
0 commit comments