1111 get_kb_statement_matched_conditions ,
1212 get_kb_variants ,
1313 get_kb_matches_sections ,
14+ create_key_alterations ,
1415)
1516from pori_python .types import Statement
1617
@@ -484,9 +485,9 @@ def test_germline_kb_matches(self):
484485 "kbContextId" : "#135:8764" ,
485486 "kbRelevanceId" : "#147:32" ,
486487 "kbStatementId" : "#155:13511" ,
487- "requiredKbMatches" : ["#159:5426 " , "#161:938 " ],
488+ "requiredKbMatches" : ["#159:54261 " , "#161:9381 " ],
488489 "kbVariant" : "BRCA1 mutation" ,
489- "kbVariantId" : "#161:938 " ,
490+ "kbVariantId" : "#161:9381 " ,
490491 "matchedCancer" : False ,
491492 "reference" : "MOAlmanac FDA-56" ,
492493 "relevance" : "therapy" ,
@@ -495,6 +496,13 @@ def test_germline_kb_matches(self):
495496 },
496497]
497498
499+ ALL_VARIANTS = [
500+ {"variant" : "var1" , "key" : '1' , "variantType" : 'mut' },
501+ {"variant" : "var2" , "key" : '2' , "variantType" : 'mut' },
502+ {"variant" : "var3" , "key" : '3' , "variantType" : 'mut' },
503+ {"variant" : "var4" , "key" : '4' , "variantType" : 'mut' },
504+ ]
505+
498506BASIC_GKB_MATCH = {
499507 "approvedTherapy" : False ,
500508 "category" : "test" ,
@@ -830,3 +838,21 @@ def test_partial_matches_included(self):
830838 kbcs = get_kb_statement_matched_conditions (gkb_matches , allow_partial_matches = True )
831839 assert len (stmts ) == 2 # X and Y
832840 assert len (kbcs ) == 2
841+
842+ def test_create_key_alterations_includes_only_pruned_kbmatches (self ):
843+ gkb_matches = create_gkb_matches (GKB_MATCHES )
844+
845+ sections1 = get_kb_matches_sections (gkb_matches , allow_partial_matches = False )
846+ key_alts1 , counts1 = create_key_alterations (
847+ gkb_matches , ALL_VARIANTS , sections1 ['kbMatches' ]
848+ )
849+
850+ sections2 = get_kb_matches_sections (gkb_matches , allow_partial_matches = True )
851+ key_alts2 , counts2 = create_key_alterations (
852+ gkb_matches , ALL_VARIANTS , sections2 ['kbMatches' ]
853+ )
854+
855+ # check partial-match-only variants are not included in key alterations when
856+ # partial matches is false
857+ assert len (key_alts1 ) == 3
858+ assert len (key_alts2 ) == 4
0 commit comments