Skip to content

Commit b55f827

Browse files
Add some examples of query from docs
1 parent 2d58178 commit b55f827

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/test_bcftools_validation.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def test_vcf_output_with_output_option(tmp_path, args, vcf_file):
140140
("query --list-samples", "1kg_2020_chrM.vcf.gz"),
141141
(r"query -f 'A\n'", "sample.vcf.gz"),
142142
(r"query -f '%CHROM:%POS\n'", "sample.vcf.gz"),
143+
(r"query -f '[%CHROM %POS %GT\n]'", "sample.vcf.gz"),
143144
(r"query -f '%INFO/DP\n'", "sample.vcf.gz"),
144145
(r"query -f '%AC{0}\n'", "sample.vcf.gz"),
145146
(r"query -f '%REF\t%ALT\n'", "sample.vcf.gz"),
@@ -152,8 +153,6 @@ def test_vcf_output_with_output_option(tmp_path, args, vcf_file):
152153
(r"query -f '%POS\n' -e 'POS=112'", "sample.vcf.gz"),
153154
(r"query -f '[%CHROM\t]\n'", "sample.vcf.gz"),
154155
(r"query -f '[%CHROM\t]\n' -i 'POS=112'", "sample.vcf.gz"),
155-
(r"query -f '%CHROM\t%POS\t%REF\t%ALT[\t%SAMPLE=%GT]\n'", "sample.vcf.gz"),
156-
(r"query -f 'GQ:[ %GQ] \t GT:[ %GT]\n'", "sample.vcf.gz"),
157156
(r"query -f '[%CHROM:%POS %SAMPLE %GT\n]'", "sample.vcf.gz"),
158157
(r"query -f '[%SAMPLE %GT %DP\n]'", "sample.vcf.gz"),
159158
(
@@ -164,6 +163,18 @@ def test_vcf_output_with_output_option(tmp_path, args, vcf_file):
164163
r"query -f '[%POS %QUAL\n]' -i'(QUAL > 10 && POS > 100000)'",
165164
"sample.vcf.gz",
166165
),
166+
# Examples from bcftools query documentation
167+
(r"query -f '%CHROM %POS %REF %ALT{0}\n'", "sample.vcf.gz"),
168+
(r"query -f '%CHROM\t%POS\t%REF\t%ALT[\t%SAMPLE=%GT]\n'", "sample.vcf.gz"),
169+
(r"query -f 'GQ:[ %GQ] \t GT:[ %GT]\n'", "sample.vcf.gz"),
170+
# POS0 not supported
171+
# (r"query -f '%CHROM\t%POS0\t%END\t%ID\n'", "sample.vcf.gz"),
172+
# Filtering on GT not supported
173+
# (r"query -f [%CHROM:%POS %SAMPLE %GT\n]' -i'GT=\"alt\"'", "sample.vcf.gz"),
174+
# Indexing not supported in filtering
175+
# (r"query -f '%AC{1}\n' -i 'AC[1]>10' ", "sample.vcf.gz"),
176+
# TODO fill-out more of these when supported for more stuff is available
177+
# in filtering
167178
],
168179
)
169180
def test_output(tmp_path, args, vcf_name):
@@ -211,10 +222,10 @@ def test_query_arithmethic(tmp_path, expr):
211222
[
212223
# Check boolean logic evaluation. Will evaluate this with
213224
# POS=112, so POS=112 is True and POS!=112 is False
214-
("POS==112 || POS!=112", True),
215-
("POS==112 && POS!=112", False),
225+
("POS==112 || POS!=112", True),
226+
("POS==112 && POS!=112", False),
216227
("POS==112 || POS!=112 && POS!= 112", True),
217-
("(POS==112 || POS!=112) && POS!= 112", False),
228+
("(POS==112 || POS!=112) && POS!= 112", False),
218229
],
219230
)
220231
def test_query_logic_precendence(tmp_path, expr, expected):

0 commit comments

Comments
 (0)