Skip to content

Commit eda0fab

Browse files
committed
permit alphanumerics, spaces, and underscores in flag strings
1 parent d2ce277 commit eda0fab

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pyvdrm/hcvr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def parser(self, rule):
328328
[(and_, 2, opAssoc.LEFT, AndExpr),
329329
(or_, 2, opAssoc.LEFT, OrExpr)]) | condition
330330

331-
score = Optional(Literal('-')) + integer | quote + Word(alphas) + quote
331+
score = Optional(Literal('-')) + integer | quote + Regex(r'[a-zA-Z0-9 _]+') + quote
332332
scoreitem = booleancondition + mapper + score
333333
scoreitem.setParseAction(ScoreExpr)
334334
scorelist = max_ + l_par + delimitedList(scoreitem) + r_par |\

pyvdrm/tests/test_hcvr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ def test_score_from_exactly(self):
108108
self.assertEqual(0, score)
109109

110110
def test_score_comment(self):
111-
rule = HCVR("SCORE FROM (100G => 10, 200T => 3, 100S => \"comment\")")
111+
rule = HCVR("SCORE FROM (100G => 10, 200T => 3, 100S => \"flag1 with_space\")")
112112
self.assertEqual(rule(VariantCalls("100G")), 10)
113113
result = rule.dtree(VariantCalls("100S 200T"))
114114
self.assertEqual(result.score, 3)
115-
self.assertTrue("comment" in result.flags)
115+
self.assertTrue("flag1 with_space" in result.flags)
116116

117117
class TestActualRules(unittest.TestCase):
118118
def test_hivdb_rules_parse(self):

0 commit comments

Comments
 (0)