Skip to content

Commit fe1721d

Browse files
daviesrobjkbonfield
authored andcommitted
Add CRAM container skipping test
The test creates a CRAM file with records in lots of containers, many of which should be skipped when making a region query that expects to return the first and last two records in the file.
1 parent 28bde92 commit fe1721d

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

test/index3.sam

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@HD VN:1.6 SO:coordinate
2+
@SQ SN:CHROMOSOME_I LN:1009800 M5:8ede36131e0dbf3417807e48f77f3ebd
3+
@CO CRAM container skipping test - very long reads followed by short ones.
4+
@CO Use option seqs_per_slice=2 when writing CRAM so that records are
5+
@CO stored in multiple containers.
6+
r0-1 0 CHROMOSOME_I 1 50 10000M * 0 0 * *
7+
r0-2 0 CHROMOSOME_I 1 50 10000M * 0 0 * *
8+
r1-1 0 CHROMOSOME_I 1000 50 100M * 0 0 * *
9+
r1-2 0 CHROMOSOME_I 1000 50 100M * 0 0 * *
10+
r2-1 0 CHROMOSOME_I 2000 50 100M * 0 0 * *
11+
r2-2 0 CHROMOSOME_I 2000 50 100M * 0 0 * *
12+
r3-1 0 CHROMOSOME_I 3000 50 100M * 0 0 * *
13+
r3-2 0 CHROMOSOME_I 3000 50 100M * 0 0 * *
14+
r4-1 0 CHROMOSOME_I 4000 50 100M * 0 0 * *
15+
r4-2 0 CHROMOSOME_I 4000 50 100M * 0 0 * *
16+
r5-1 0 CHROMOSOME_I 5000 50 100M * 0 0 * *
17+
r5-2 0 CHROMOSOME_I 5000 50 100M * 0 0 * *

test/index3_exp.sam

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@HD VN:1.6 SO:coordinate
2+
@SQ SN:CHROMOSOME_I LN:1009800 M5:8ede36131e0dbf3417807e48f77f3ebd
3+
@CO CRAM container skipping test - very long reads followed by short ones.
4+
@CO Use option seqs_per_slice=2 when writing CRAM so that records are
5+
@CO stored in multiple containers.
6+
r0-1 0 CHROMOSOME_I 1 50 10000M * 0 0 * *
7+
r0-2 0 CHROMOSOME_I 1 50 10000M * 0 0 * *
8+
r5-1 0 CHROMOSOME_I 5000 50 100M * 0 0 * *
9+
r5-2 0 CHROMOSOME_I 5000 50 100M * 0 0 * *

test/test.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,18 @@ sub test_index
10891089
unlink("$$opts{tmp}/index.cram.crai");
10901090
test_compare($opts,"$$opts{path}/test_index $$opts{tmp}/index.cram", "$$opts{tmp}/index.cram.crai", "$$opts{path}/index.cram.crai", gz=>1);
10911091

1092+
# CRAM container skipping test
1093+
# Prepare a file with records split into multiple containers, the first two
1094+
# records spanning far enough to overlap the last two.
1095+
cmd("$$opts{path}/test_view $nthreads -C -p $$opts{tmp}/index3.cram -x $$opts{tmp}/index3.cram.crai -o seqs_per_slice=2 $$opts{path}/index3.sam");
1096+
# An index lookup for the last two records should return the first two
1097+
# as well.
1098+
test_compare($opts, "$$opts{path}/test_view $nthreads -p $$opts{tmp}/index3_rgn.sam $$opts{tmp}/index3.cram CHROMOSOME_I:5000-5100",
1099+
"$$opts{path}/index3_exp.sam", "$$opts{tmp}/index3_rgn.sam");
1100+
# Also check the multi-region iterator
1101+
test_compare($opts, "$$opts{path}/test_view $nthreads -M -p $$opts{tmp}/index3_rgnm.sam $$opts{tmp}/index3.cram CHROMOSOME_I:5000-5100",
1102+
"$$opts{path}/index3_exp.sam", "$$opts{tmp}/index3_rgnm.sam");
1103+
10921104
# BCF
10931105
test_compare($opts,"$$opts{path}/test_view $nthreads -l 0 -b -m 14 -x $$opts{tmp}/index.bcf.csi $$opts{path}/index.vcf > $$opts{tmp}/index.bcf", "$$opts{tmp}/index.bcf.csi", "$$opts{path}/index.bcf.csi", gz=>1);
10941106
unlink("$$opts{tmp}/index.bcf.csi");

0 commit comments

Comments
 (0)