@@ -31,7 +31,12 @@ def test_invalid_expressions(self, parser, expression):
31
31
@pytest .mark .parametrize (
32
32
("expression" , "exception_class" ),
33
33
[
34
- ('INFO/HAYSTACK ~ "needle"' , filter_mod .UnsupportedRegexError ),
34
+ # NOTE: using an integer here so that we don't trigger the
35
+ # generic string issue. Can fix this later when we've gotten
36
+ # some partial string handling implemented
37
+ ("INFO/HAYSTACK ~ 0" , filter_mod .UnsupportedRegexError ),
38
+ ('CHROM="1"' , filter_mod .UnsupportedStringsError ),
39
+ ('FILTER="PASS"' , filter_mod .UnsupportedStringsError ),
35
40
("INFO/X[0] == 1" , filter_mod .UnsupportedArraySubscriptError ),
36
41
("INFO/AF[0] > 0.3" , filter_mod .UnsupportedArraySubscriptError ),
37
42
("FORMAT/AD[0:0] > 30" , filter_mod .UnsupportedArraySubscriptError ),
@@ -135,7 +140,9 @@ def test_referenced_fields(self, expr, expected):
135
140
("a + 1 + 2" , "(variant_a)+(1)+(2)" ),
136
141
("a + (1 + 2)" , "(variant_a)+((1)+(2))" ),
137
142
("POS<10" , "(variant_position)<(10)" ),
138
- ('CHROM=="chr1"' , "(variant_contig)==('chr1')" ),
143
+ # Filters based on strings disabled:
144
+ # https://github.com/sgkit-dev/vcztools/issues/189
145
+ # ('CHROM=="chr1"', "(variant_contig)==('chr1')"),
139
146
],
140
147
)
141
148
def test_repr (self , expr , expected ):
@@ -148,8 +155,6 @@ class TestBcftoolsParser:
148
155
"expr" ,
149
156
[
150
157
"2" ,
151
- '"x"' ,
152
- '"INFO/STRING"' ,
153
158
"2 + 2" ,
154
159
"(2 + 3) / 2" ,
155
160
"2 / (2 + 3)" ,
@@ -167,8 +172,12 @@ class TestBcftoolsParser:
167
172
"1 + 2 == 1 + 2 + 3" ,
168
173
"(1 + 2) == (1 + 2 + 3)" ,
169
174
"(1 == 1) != (2 == 2)" ,
170
- '("x" == "x")' ,
171
175
"-1 == 1 + 2 - 4" ,
176
+ # Filters based on strings disabled:
177
+ # https://github.com/sgkit-dev/vcztools/issues/189
178
+ # '("x" == "x")',
179
+ # '"x"',
180
+ # '"INFO/STRING"',
172
181
],
173
182
)
174
183
def test_python_arithmetic_expressions (self , expr ):
@@ -177,6 +186,24 @@ def test_python_arithmetic_expressions(self, expr):
177
186
result = parsed [0 ].eval ({})
178
187
assert result == eval (expr )
179
188
189
+ @pytest .mark .parametrize (
190
+ ("expr" , "data" ),
191
+ [
192
+ ('("x" == "x")' , {}),
193
+ ('"x"' , {}),
194
+ ('"INFO/STRING"' , {}),
195
+ ('a == "string"' , {"a" : "string" }),
196
+ ],
197
+ )
198
+ def test_python_string_expressions_data (self , expr , data ):
199
+ # Filters based on strings disabled:
200
+ # https://github.com/sgkit-dev/vcztools/issues/189
201
+ parser = filter_mod .make_bcftools_filter_parser ()
202
+ with pytest .raises (filter_mod .UnsupportedStringsError ):
203
+ parser .parse_string (expr , parse_all = True )
204
+ # result = parsed[0].eval({})
205
+ # assert result == eval(expr)
206
+
180
207
@pytest .mark .parametrize (
181
208
("expr" , "data" ),
182
209
[
@@ -189,7 +216,6 @@ def test_python_arithmetic_expressions(self, expr):
189
216
("a == a" , {"a" : 1 }),
190
217
("-a == -a" , {"a" : 1 }),
191
218
("-a == b" , {"a" : 1 , "b" : - 1 }),
192
- ('a == "string"' , {"a" : "string" }),
193
219
],
194
220
)
195
221
def test_python_arithmetic_expressions_data (self , expr , data ):
0 commit comments