Skip to content

Commit 05a52fd

Browse files
committed
fix implementation of Negate.__call__ in scoreconditions
1 parent 46fffc9 commit 05a52fd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pyvdrm/asi2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ def __bool__(self):
7474
return self.score
7575

7676

77-
class Negate(AsiUnaryExpr):
77+
class Negate(AsiExpr):
7878
"""Unary negation of boolean child"""
7979
def __call__(self, mutations):
80-
arg = self.children(mutations)
81-
return Score(not arg.score, arg.residues)
80+
child = self.children[0](mutations)
81+
if child is None:
82+
return Score(True, []) # TODO: propagate negative residues
83+
return Score(not child.score, child.residues)
8284

8385

8486
class AndExpr(AsiExpr):

pyvdrm/tests/test_asi2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def test_score_from(self):
5151
rule = ASI2("SCORE FROM ( 100G => 10, 101D => 20 )")
5252
self.assertEqual(rule(VariantCalls("100G 102G")), 10)
5353

54+
def test_score_from(self):
55+
rule = ASI2("SCORE FROM ( NOT 100G => 10, NOT 101SD => 20 )")
56+
self.assertEqual(rule(VariantCalls("100G 102G")), 20)
57+
self.assertEqual(rule(VariantCalls("100S 101S")), 10)
58+
5459
def test_score_residues(self):
5560
rule = ASI2("SCORE FROM ( 100G => 10, 101D => 20 )")
5661
expected_residue = repr({Mutation('S100G')})

0 commit comments

Comments
 (0)