~ubuntu-branches/debian/sid/libvcflib/sid

« back to all changes in this revision

Viewing changes to tests/vcfdistance.t

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2016-09-16 15:52:29 UTC
  • Revision ID: package-import@ubuntu.com-20160916155229-24mxrntfylvsshsg
Tags: upstream-1.0.0~rc1+dfsg
ImportĀ upstreamĀ versionĀ 1.0.0~rc1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
use Test::More;
 
4
use Local::vcflib::Test;
 
5
 
 
6
my @vcf = split /\n/, <<'';
 
7
##fileformat=VCFv4.0
 
8
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO
 
9
refseq  502     .       G       A       38553   PASS    
 
10
refseq  552     .       G       A       24044   PASS    
 
11
refseq  660     .       G       A       38553   PASS    
 
12
refseq  678     .       G       A       24044   PASS    
 
13
refseq  684     .       G       A       24044   PASS    
 
14
 
 
15
sub variants {
 
16
    join "\n", @vcf[0 .. $_[0] + 1]
 
17
}
 
18
 
 
19
my ($output, $header) = ('', <<'');
 
20
##fileformat=VCFv4.0
 
21
##INFO=<ID=BasesToClosestVariant,Number=1,Type=Integer,Description="Number of bases to the closest variant in the file.">
 
22
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO
 
23
 
 
24
#
 
25
# Various numbers of variant lines
 
26
#
 
27
($output) = run_ok(["vcfdistance"], variants(5));
 
28
is $output, $header . <<'', "distances for 5 variant lines";
 
29
refseq  502     .       G       A       38553   PASS    BasesToClosestVariant=50;
 
30
refseq  552     .       G       A       24044   PASS    BasesToClosestVariant=50;
 
31
refseq  660     .       G       A       38553   PASS    BasesToClosestVariant=18;
 
32
refseq  678     .       G       A       24044   PASS    BasesToClosestVariant=6;
 
33
refseq  684     .       G       A       24044   PASS    BasesToClosestVariant=6;
 
34
 
 
35
($output) = run_ok(["vcfdistance"], variants(4));
 
36
is $output, $header . <<'', "distances for 4 variant lines";
 
37
refseq  502     .       G       A       38553   PASS    BasesToClosestVariant=50;
 
38
refseq  552     .       G       A       24044   PASS    BasesToClosestVariant=50;
 
39
refseq  660     .       G       A       38553   PASS    BasesToClosestVariant=18;
 
40
refseq  678     .       G       A       24044   PASS    BasesToClosestVariant=18;
 
41
 
 
42
($output) = run_ok(["vcfdistance"], variants(3));
 
43
is $output, $header . <<'', "distances for 3 variant lines";
 
44
refseq  502     .       G       A       38553   PASS    BasesToClosestVariant=50;
 
45
refseq  552     .       G       A       24044   PASS    BasesToClosestVariant=50;
 
46
refseq  660     .       G       A       38553   PASS    BasesToClosestVariant=108;
 
47
 
 
48
($output) = run_ok(["vcfdistance"], variants(2));
 
49
is $output, $header . <<'', "distances for 2 variant lines";
 
50
refseq  502     .       G       A       38553   PASS    BasesToClosestVariant=50;
 
51
refseq  552     .       G       A       24044   PASS    BasesToClosestVariant=50;
 
52
 
 
53
($output) = run_ok(["vcfdistance"], variants(1));
 
54
is $output, $header . <<'', "distances for 1 variant line";
 
55
refseq  502     .       G       A       38553   PASS    
 
56
 
 
57
($output) = run_ok(["vcfdistance"], variants(0));
 
58
is $output, $header, "distances for 0 variant lines";
 
59
 
 
60
#
 
61
# Various combinations of reference sequences (obviously non-comparable)
 
62
#
 
63
@vcf = split /\n/, <<'';
 
64
##fileformat=VCFv4.0
 
65
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO
 
66
ref1    502     .       G       A       38553   PASS    
 
67
ref2    552     .       G       A       24044   PASS    
 
68
ref2    660     .       G       A       38553   PASS    
 
69
ref2    678     .       G       A       24044   PASS    
 
70
ref3    684     .       G       A       24044   PASS    
 
71
 
 
72
($output) = run_ok(["vcfdistance"], variants(5));
 
73
is $output, $header . <<'', "distances for 5 variant lines; three references";
 
74
ref1    502     .       G       A       38553   PASS    
 
75
ref2    552     .       G       A       24044   PASS    BasesToClosestVariant=108;
 
76
ref2    660     .       G       A       38553   PASS    BasesToClosestVariant=18;
 
77
ref2    678     .       G       A       24044   PASS    BasesToClosestVariant=18;
 
78
ref3    684     .       G       A       24044   PASS    
 
79
 
 
80
($output) = run_ok(["vcfdistance"], variants(4));
 
81
is $output, $header . <<'', "distances for 4 variant lines, two references";
 
82
ref1    502     .       G       A       38553   PASS    
 
83
ref2    552     .       G       A       24044   PASS    BasesToClosestVariant=108;
 
84
ref2    660     .       G       A       38553   PASS    BasesToClosestVariant=18;
 
85
ref2    678     .       G       A       24044   PASS    BasesToClosestVariant=18;
 
86
 
 
87
($output) = run_ok(["vcfdistance"], variants(3));
 
88
is $output, $header . <<'', "distances for 3 variant lines, two references";
 
89
ref1    502     .       G       A       38553   PASS    
 
90
ref2    552     .       G       A       24044   PASS    BasesToClosestVariant=108;
 
91
ref2    660     .       G       A       38553   PASS    BasesToClosestVariant=108;
 
92
 
 
93
($output) = run_ok(["vcfdistance"], variants(2));
 
94
is $output, $header . <<'', "distances for 2 variant lines, two references";
 
95
ref1    502     .       G       A       38553   PASS    
 
96
ref2    552     .       G       A       24044   PASS    
 
97
 
 
98
done_testing;