3 Author: Hu Xuesong @ BIOPIC <galaxy001@gmail.com>
4 Version: 1.0.0 @ 20120720
10 use Data
::Dump
qw(ddx);
11 use Galaxy
::IO
::FASTAQ
;
12 use Galaxy
::SeqTools
qw(translate revcom);
15 die "Usage: $0 <vcf.gz> <minGQ> <out>\n" if @ARGV<3;
20 warn "From [$vcfs] with [minGQ=$qual] to [$outfs]\n";
22 open O
,'>',$outfs."q$qual.snp.lst" or die;
23 open OI
,'>',$outfs."q$qual.indel.lst" or die;
25 my $vcf = Vcf
->new(file
=>$vcfs);
27 my (@samples) = $vcf->get_samples();
32 my $t = 'Samples:'.join(',',@samples);
33 print O
join("\t",'#CHROM','POS','GT','QUAL',$t),"\n";
34 print OI
join("\t",'#CHROM','POS','GT','QUAL',$t),"\n";
36 while (my $x=$vcf->next_data_hash()) {
37 next if $$x{QUAL
} < 20;
38 my ($Dindel,@GTs)=(0);
39 my %GTs = %{$$x{gtypes
}};
40 my @Bases = ($$x{REF
},@
{$$x{ALT
}});
41 $Dindel = length($Bases[1]) - length($Bases[0]);
42 for my $sample (keys %GTs) {
43 my $sampleID = $sample;
44 $sampleID =~ s/\.bam$//i;
45 next if $GTs{$sample}{DP
}<=0;
46 next if $GTs{$sample}{GQ
}<$qual; # 10:219090, 20:88956, 15:150149.
47 my ($a1,$a2,$a3) = $vcf->split_gt($GTs{$sample}{GT
});
50 for (($Bases[$a1],$Bases[$a2])) {
52 $t = length $_ if $t < length $_;
55 $t = join('',sort keys %t);
60 push @GTs, join('|',"$a1/$a2","$Bases[$a1]/$Bases[$a2]",$GTs{$sample}{DP
},$GTs{$sample}{GQ
},$t);
63 #if (length($Bases[0]) == 1) {
64 my @t = map { length($_) } @Bases;
68 @t = sort { $b <=> $a } keys %t;
71 print O
join("\t",$$x{CHROM
},$$x{POS
},join('/',@Bases,$Dindel),$$x{QUAL
}, join(", ",@GTs) ),"\n";
73 print OI
join("\t",$$x{CHROM
},$$x{POS
},join('/',@Bases,$Dindel),$$x{QUAL
}, join(", ",@GTs), $t[-1] ),"\n";
76 # for my $gt (keys %GTs) {
77 # my ($a1,$a2,$a3) = $vcf->split_gt($gt);
78 # if ($a3 or ($a1 != $a2)) {
86 # CHROM => "scaffold75",
88 # FORMAT => ["GT", "PL", "DP", "SP", "GQ"],
90 # "BHX011.bam" => { DP => 19, GQ => 61, GT => "0/0", PL => "0,57,255", SP => 0 },
91 # "BHX019.bam" => { DP => 26, GQ => 82, GT => "0/0", PL => "0,78,255", SP => 0 },
92 # "JHH001.bam" => { DP => 28, GQ => 99, GT => "0/1", PL => "244,0,255", SP => 9 },
102 # PV4 => "0.13,1,0.12,1",
109 #print $vcf->format_line($x);
121 while ($c =~ /[^\0]/g) {
123 push @ret,[$p,substr($a,$p-1,1),substr($b,$p-1,1)];
130 bcftools view
/bak/archive
/projects/Tiger
/BCF/WGS
/parents
.bcgv
.bcf
|bgzip
-c
> parents
.bcgv
.vcf
.gz
&
131 #tabix -p vcf parents.bcgv.vcf.gz
133 perl filtervcf
.pl bam2
.bcgv
.vcf
.gz
20 bam2
&