Skip to content

Commit

Permalink
fix: ensure null calls don't hit _any_ wildcard rules
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyWesthead committed Feb 6, 2025
1 parent 697ba48 commit 0bf195f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1
15 changes: 8 additions & 7 deletions piezo/grammar_GARC1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,14 @@ def process_snp_variants(

# PRIORITY=8: any nonsynoymous mutation at this specific position in the CDS or
# PROM (e.g. rpoB@S450? or rpoB@c-15?)
row = rules.loc[
rules_mutation_type_vector
& rules_position_vector
& (rules.MUTATION.str[-1] == "?")
]
# nonsyn SNP at specified position in the CDS
row_prediction(row, predictions, 8, minor)
if mutation[-1] not in ["X", "x"]:
row = rules.loc[
rules_mutation_type_vector
& rules_position_vector
& (rules.MUTATION.str[-1] == "?")
]
# nonsyn SNP at specified position in the CDS
row_prediction(row, predictions, 8, minor)

# PRIORITY=9: an exact match
row = rules.loc[(rules_mutation_type_vector) & (rules.MUTATION == mutation)]
Expand Down
2 changes: 2 additions & 0 deletions tests/test-catalogue/NC_004148.2_TEST_v1.0_GARC1_RFUS-FRS.csv
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_A,M2@G74!&M2@G74X,U,{},"{""row"": 37}",{}
NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_A,M2@F75V:0.03,R,{},"{""row"": 38}",{}
NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_B,M2@G74!:0.04&M2@G74X:0.02,U,{},"{""row"": 39}",{}
NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_B,M3@*_ins,R,{},"{""row"": 40}",{}
NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_B,M3@S450?,R,{},"{""row"": 41}",{}
NC_004148.2,TEST,v1.0,GARC1,RFUS,DRUG_B,M3@*?,U,{},"{""row"": 42}",{}
4 changes: 4 additions & 0 deletions tests/test_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,7 @@ def test_misc():

# Double checking that a minor allele doesn't hit a general rule anymore
assert test_catalogue.predict("M2@37_del_c:0.2") == {"DRUG_A": "S", "DRUG_B": "S"}

# Checking that a null call can't hit a wildcard rule
# This catalogue has M3@S450?, this shouldn't hit that and so should get a default "S"
assert test_catalogue.predict("M3@S450X") == "S"

0 comments on commit 0bf195f

Please sign in to comment.