Skip to content

Commit 3d994d3

Browse files
committed
Add support for matching VCF lines by ID
See #1739
1 parent a79ca97 commit 3d994d3

12 files changed

+105
-8
lines changed

test/annotate35.1.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
##fileformat=VCFv4.2
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##INFO=<ID=src,Number=1,Type=String,Description="">
4+
##INFO=<ID=dst,Number=1,Type=String,Description="">
5+
##contig=<ID=chr1,length=248956422>
6+
#CHROM POS ID REF ALT QUAL FILTER INFO
7+
chr1 902 ID6 N <INS> . PASS src=ID6
8+
chr1 902 ID5 N <INS> . PASS src=ID5
9+
chr1 902 ID4 N <INS> . PASS src=ID4
10+
chr1 902 ID3 N <INS> . PASS src=ID3
11+
chr1 902 ID2 N <INS> . PASS src=ID2
12+
chr1 902 ID1 N <INS> . PASS src=ID1

test/annotate35.2.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
##fileformat=VCFv4.2
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##INFO=<ID=src,Number=1,Type=String,Description="">
4+
##INFO=<ID=dst,Number=1,Type=String,Description="">
5+
##contig=<ID=chr1,length=248956422>
6+
#CHROM POS ID REF ALT QUAL FILTER INFO
7+
chr1 902 ID6 N <INS> . PASS src=ID6;dst=ID6
8+
chr1 902 ID5 N <INS> . PASS src=ID5;dst=ID5
9+
chr1 902 ID4 N <INS> . PASS src=ID4;dst=ID4
10+
chr1 902 ID3 N <INS> . PASS src=ID3;dst=ID3
11+
chr1 902 ID2 N <INS> . PASS src=ID2;dst=ID2
12+
chr1 902 ID1 N <INS> . PASS src=ID1;dst=ID1

test/annotate35.vcf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##fileformat=VCFv4.2
2+
##INFO=<ID=src,Number=1,Type=String,Description="">
3+
##INFO=<ID=dst,Number=1,Type=String,Description="">
4+
##contig=<ID=chr1,length=248956422>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO
6+
chr1 902 ID6 N <INS> . PASS src=ID6
7+
chr1 902 ID5 N <INS> . PASS src=ID5
8+
chr1 902 ID4 N <INS> . PASS src=ID4
9+
chr1 902 ID3 N <INS> . PASS src=ID3
10+
chr1 902 ID2 N <INS> . PASS src=ID2
11+
chr1 902 ID1 N <INS> . PASS src=ID1

test/annots35.tab

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
chr1 902 ID4 N <INS> ID4
2+
chr1 902 ID2 N <INS> ID2
3+
chr1 902 ID6 N <INS> ID6
4+
chr1 902 ID1 N <INS> ID1
5+
chr1 902 ID3 N <INS> ID3
6+
chr1 902 ID5 N <INS> ID5

test/annots35.vcf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##fileformat=VCFv4.2
2+
##INFO=<ID=src,Number=1,Type=String,Description="">
3+
##INFO=<ID=dst,Number=1,Type=String,Description="">
4+
##contig=<ID=chr1,length=248956422>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO
6+
chr1 902 ID4 N <INS> . PASS src=ID4
7+
chr1 902 ID2 N <INS> . PASS src=ID2
8+
chr1 902 ID6 N <INS> . PASS src=ID6
9+
chr1 902 ID3 N <INS> . PASS src=ID3
10+
chr1 902 ID1 N <INS> . PASS src=ID1
11+
chr1 902 ID5 N <INS> . PASS src=ID5

test/isec.match-id.1.1.vcf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
##fileformat=VCFv4.2
2+
##INFO=<ID=src,Number=1,Type=String,Description="">
3+
##contig=<ID=chr1,length=248956422>
4+
#CHROM POS ID REF ALT QUAL FILTER INFO
5+
chr1 902 ID1 A C . . .
6+
chr1 902 ID2 A C . . .
7+
chr1 902 ID3 A C . . .

test/isec.match-id.1.2.vcf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
##fileformat=VCFv4.2
2+
##INFO=<ID=src,Number=1,Type=String,Description="">
3+
##contig=<ID=chr1,length=248956422>
4+
#CHROM POS ID REF ALT QUAL FILTER INFO
5+
chr1 902 ID3 A C . . .
6+
chr1 902 ID2 A C . . .
7+
chr1 902 ID1 A C . . .

test/isec.match-id.1.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##fileformat=VCFv4.2
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##INFO=<ID=src,Number=1,Type=String,Description="">
4+
##contig=<ID=chr1,length=248956422>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO
6+
chr1 902 ID3 A C . . .
7+
chr1 902 ID2 A C . . .
8+
chr1 902 ID1 A C . . .

test/isec.match-id.2.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##fileformat=VCFv4.2
2+
##FILTER=<ID=PASS,Description="All filters passed">
3+
##INFO=<ID=src,Number=1,Type=String,Description="">
4+
##contig=<ID=chr1,length=248956422>
5+
#CHROM POS ID REF ALT QUAL FILTER INFO
6+
chr1 902 ID1 A C . . .
7+
chr1 902 ID2 A C . . .
8+
chr1 902 ID3 A C . . .

test/test.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
run_test(\&test_vcf_stats,$opts,in=>['stats.counts'],out=>'stats.counts.chk',args=>'-s -');
5050
run_test(\&test_vcf_stats,$opts,in=>['stats.counts'],out=>'stats.counts.2.chk',args=>q[-s - -i 'type="snp"']);
5151
run_test(\&test_vcf_stats,$opts,in=>['stats.vaf'],out=>'stats.vaf.1.chk',args=>q[-s -]);
52+
run_test(\&test_vcf_isec,$opts,in=>['isec.match-id.1.1','isec.match-id.1.2'],out=>'isec.match-id.1.out',args=>'-n =2 -w 2 --no-version');
53+
run_test(\&test_vcf_isec,$opts,in=>['isec.match-id.1.1','isec.match-id.1.2'],out=>'isec.match-id.2.out',args=>'-n =2 -w 2 -c id --no-version');
5254
run_test(\&test_vcf_isec,$opts,in=>['isec.a','isec.b'],out=>'isec.ab.out',args=>'-n =2');
5355
run_test(\&test_vcf_isec,$opts,in=>['isec.a','isec.b'],out=>'isec.ab.flt.out',args=>'-n =2 -i"STRLEN(REF)==2"');
5456
run_test(\&test_vcf_isec,$opts,in=>['isec.a','isec.b'],out=>'isec.ab.both.out',args=>'-n =2 -c both');
@@ -524,6 +526,8 @@
524526
run_test(\&test_vcf_sort,$opts,in=>'sort',out=>'sort.out',args=>q[-m 0],fmt=>'%CHROM\\t%POS\\t%REF,%ALT\\n');
525527
run_test(\&test_vcf_sort,$opts,in=>'sort',out=>'sort.out',args=>q[-m 1000],fmt=>'%CHROM\\t%POS\\t%REF,%ALT\\n');
526528
run_test(\&test_vcf_regions,$opts,in=>'regions');
529+
run_test(\&test_vcf_annotate,$opts,in=>'annotate35',vcf=>'annots35',out=>'annotate35.1.out',args=>q[-c CHROM,POS,~ID,REF,ALT,INFO/src]);
530+
run_test(\&test_vcf_annotate,$opts,in=>'annotate35',tab=>'annots35',out=>'annotate35.2.out',args=>q[-c CHROM,POS,~ID,REF,ALT,dst:=src]);
527531
run_test(\&test_vcf_annotate,$opts,in=>'annotate.escape.1',tab=>'annotate.escape.1',out=>'annotate.escape.1.1.out',args=>q[-c CHROM,POS,ISTR,FMT/FSTR]);
528532
run_test(\&test_vcf_annotate,$opts,in=>'annotate.match.1',tab=>'annotate.match.1',out=>'annotate.match.1.1.out',args=>q[-c CHROM,POS,-,-,SCORE,~X,-,- -i'STR={X}']);
529533
run_test(\&test_vcf_annotate,$opts,in=>'annotate.match.1',tab=>'annotate.match.1',out=>'annotate.match.1.2.out',args=>q[-c CHROM,POS,REF,ALT,SCORE,-,~X,- -i'INT={X}']);
@@ -1477,7 +1481,9 @@ sub test_vcf_isec
14771481
my $files = join(' ',@files);
14781482
$args{args} =~ s/{PATH}/$$opts{path}/g;
14791483
test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools isec $args{args} $files");
1480-
test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools isec -Ob $args{args} $files");
1484+
1485+
# Either improve or disable completely: the output type does not make sense in all modes
1486+
# test_cmd($opts,%args,cmd=>"$$opts{bin}/bcftools isec -Ob $args{args} $files");
14811487
}
14821488
sub test_vcf_isec2
14831489
{

0 commit comments

Comments
 (0)