-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvcf_info_field.pl
44 lines (34 loc) · 1007 Bytes
/
vcf_info_field.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
sub process {
my ( $scf, $vcf_line, $samples, $data, $genetics ) = @_;
chomp $vcf_line;
my @fields = split /\t/, $vcf_line;
my @info = split /;/, $fields[7];
map { $data->{$1}{$2}++ if (/^(.+)=(.+)$/); } @info;
return;
}
sub merge {
my ( $part, $all ) = @_;
return if !defined $part;
foreach my $stat (keys %{$part}) {
foreach my $val (keys %{$part->{$stat}}) {
$all->{$stat}{$val} += $part->{$stat}{$val};
}
}
}
sub output {
my ( $data, $samples, $genome, $outfix ) = @_;
foreach my $stat ( keys %{$data} ) {
open my $stat_file, ">", "$outfix.$stat.txt"
or croak "Can't open $outfix.$stat.txt\n";
foreach my $val (
sort { $a <=> $b }
keys %{ $data->{$stat} }
)
{
print $stat_file "$val\t$data->{$stat}{$val}\n";
}
close $stat_file;
}
return;
}
1; # Needed to return a true value when imported by vcf-parallel