6 #die "Usage: $0 <blood vcf.gz> <sperm vcf.gz>\n" if @ARGV < 2;
7 die "Usage: $0 <blood vcf> <sperm vcf>\n" if @ARGV < 2;
8 my ($inbd,$insp)=@ARGV;
10 #open IBD, "-|", "zcat $inbd" or die "$!";
11 #open ISP, "-|", "zcat $insp" or die "$!";
12 open IBD
,'<',$inbd or die "$!";
13 open ISP
,'<',$insp or die "$!";
14 open O
,'>',"$insp.stat";
20 my ($chr,$pos,undef,$ref,$alt,undef,undef,$INFO,undef,$data) = split /\t/,$str;
21 my @GeneTypes=split /,/,$alt;
22 unshift @GeneTypes,$ref;
23 my $GT = (split /:/,$data)[0];
24 my @GTs=split /[\/|]/,$GT;
25 my @ret = ( $chr, $pos, $GeneTypes[$GTs[0]] . $GeneTypes[$GTs[1]] );
31 my ($chr,$pos,undef,$ref,$alt,$QUAL,undef,$INFO,undef,$data) = split /\t/;
32 next if $INFO =~ /INDEL;/;
34 my $GQ = (split /:/,$data)[-1];
36 next unless $chr =~ /^chr\d+/;
38 ($chr,$pos,$GT) = @
{getGT
($_)};
39 $SNP{$chr}{$pos}{'SP'} = $GT;
43 my ($chr,$pos,undef,$ref,$alt,$QUAL,undef,$INFO,undef,$data) = split /\t/;
44 next if $INFO =~ /INDEL;/;
46 my $GQ = (split /:/,$data)[-1];
48 next unless $chr =~ /^chr\d+/;
50 ($chr,$pos,$GT) = @
{getGT
($_)};
51 $SNP{$chr}{$pos}{'BD'} = $GT;
54 my (%Results,%subResults);
55 for my $chr (keys %SNP) {
56 for my $pos (keys %{$SNP{$chr}}) {
57 my ($GT1,$GT2) = ( $SNP{$chr}{$pos}{'BD'}, $SNP{$chr}{$pos}{'SP'} );
58 unless ( defined $GT1 ) {
59 ++$Results{$chr}{'SpermOnly'};
60 ++$Results{'_All_'}{'SpermOnly'};
63 unless ( defined $GT2 ) {
64 ++$Results{$chr}{'BloodOnly'};
65 ++$Results{'_All_'}{'BloodOnly'};
68 my @gt1 = split //,$GT1;
69 my @gt2 = split //,$GT2;
71 if ($gt1[0] eq $gt1[1]) { $flag1='Hom'; } else { $flag1='Het'; }
72 if ($gt2[0] eq $gt2[1]) { $flag2='Hom'; } else { $flag2='Het'; }
73 #print "$gt1[0] $gt1[1] $gt2[0] $gt2[1] $flag1,$flag2\n";
78 $str = $flag1 . '-' . $flag2;
79 if ( $flag1 eq $flag2 ) {
80 if ($flag1 eq 'Hom') {
81 $subtype = 'Hom' . $gt1[1] . $gt2[1];
83 $subtype = 'Het' . $GT1 . $GT2;
87 ++$Results{$chr}{$str};
88 ++$Results{'_All_'}{$str};
89 if ( defined $subtype ) {
90 ++$subResults{$chr}{$subtype};
91 ++$subResults{'_All_'}{$subtype};
98 for my $chr (sort keys %Results) {
100 for my $type (sort keys %{$Results{$chr}}) {
101 print O
"$type: $Results{$chr}{$type}\t";
103 if (exists $subResults{$chr}) {
105 for my $type (sort keys %{$subResults{$chr}}) {
106 print O
"$type: $subResults{$chr}{$type}\t";
117 perl cntsnp
.pl blood
.gz sperm23
.gz
119 perl cntsnp
.pl blood
.mda
.filter
.gz sperm23
.vcf
.filter
.gz