Skip to content

Commit

Permalink
permit alphanumerics, spaces, and underscores in flag strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-k committed Jan 9, 2018
1 parent d2ce277 commit eda0fab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyvdrm/hcvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def parser(self, rule):
[(and_, 2, opAssoc.LEFT, AndExpr),
(or_, 2, opAssoc.LEFT, OrExpr)]) | condition

score = Optional(Literal('-')) + integer | quote + Word(alphas) + quote
score = Optional(Literal('-')) + integer | quote + Regex(r'[a-zA-Z0-9 _]+') + quote
scoreitem = booleancondition + mapper + score
scoreitem.setParseAction(ScoreExpr)
scorelist = max_ + l_par + delimitedList(scoreitem) + r_par |\
Expand Down
4 changes: 2 additions & 2 deletions pyvdrm/tests/test_hcvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def test_score_from_exactly(self):
self.assertEqual(0, score)

def test_score_comment(self):
rule = HCVR("SCORE FROM (100G => 10, 200T => 3, 100S => \"comment\")")
rule = HCVR("SCORE FROM (100G => 10, 200T => 3, 100S => \"flag1 with_space\")")
self.assertEqual(rule(VariantCalls("100G")), 10)
result = rule.dtree(VariantCalls("100S 200T"))
self.assertEqual(result.score, 3)
self.assertTrue("comment" in result.flags)
self.assertTrue("flag1 with_space" in result.flags)

class TestActualRules(unittest.TestCase):
def test_hivdb_rules_parse(self):
Expand Down

0 comments on commit eda0fab

Please sign in to comment.