5 die "Usage: $0 <input_bcf> <scaffold> <output_svg>\n" if @ARGV<3;
7 my @samples = qw
/ JHH001 GZXJ03 GZXJ05 GZXJ26 GZXJ27 GZXJ28 GZXJ29 GZXJ30 GZXJ33 BHX011 BHX019 GZXJ04 GZXJ06 GZXJ31 GZXJ32 GZXJ36 GZXJ37 GZXJ38 /;
13 open I
, "-|", "bcftools view -I $in";
16 # Read genotype from bcf file, and push into @gt;
21 my @line = split /\t/;
22 next if $line[5] < 20;
23 $line[7] =~ /;FQ=([0-9\-.]+)/;
27 foreach (9 .. ($ns+8)) {
28 my @sample = split /:/, $line[$_];
29 if ($sample[4] >= 20 and $sample[2] >= 1) {
35 next if (!grep {$_ ne $a[0]} @a);
41 foreach (0 .. ($ns-1)) {
42 my ($a1, $a2) = split /\//, $a[$_];
43 if (($a1 eq "0") and ($a2 eq "0")) {
46 } elsif (($a1 eq "1") and ($a2 eq "1")) {
50 push @b, "$line[3]$line[4]";
64 # SVG attribute definitions;
67 print O
"<?xml version=\"1.0\"?>\n";
68 print O
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"$w\" height=\"$h\">\n";
69 print O
"<g transform=\"translate(10,10)\">\n\n";
74 print O
"<text x=\"$x0\" y=\"0\" font-family=\"Courier\" font-size=\"7\" fill=\"black\">$_</text>\n";
83 print O
"<text x=\"0\" y=\"$y\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[0]</text>\n";
84 print O
"<text x=\"70\" y=\"$y\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[1]</text>\n";
85 foreach (2 .. ($ns+1)) {
90 my $h = length ${$a}[$_];
95 if (${$a}[$ns+2] eq "equal") {
97 } elsif (${$a}[$ns+2] eq ${$a}[$_]) {
105 print O
"<rect x=\"$xr\" y=\"$yr\" width=\"30\" height=\"10\" fill=\"$color\" stroke-width=\"0.5\" stroke=\"black\"/>\n";
106 print O
"<text x=\"$xt\" y=\"$yt\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[$_]</text>\n";
109 print O
"\n</g>\n</svg>\n";