-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjoinEff.pl
More file actions
34 lines (29 loc) · 755 Bytes
/
joinEff.pl
File metadata and controls
34 lines (29 loc) · 755 Bytes
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
#!/usr/bin/env perl
# join EFF lines
use strict;
use List::MoreUtils qw(first_index indexes);
my $line = <>;
print $line;
chomp $line;
my @header = split /\t/, $line;
my @effIndexes = indexes { /^EFF\[/ } @header;
my %lines;
while (<>) {
chomp;
my @F = split /\t/, $_, -1;
for my $i (0..$#F) {
$F[$i] = "." unless $F[$i] =~ /\S/;
}
push @{$lines{$F[0]}{$F[1]}}, \@F;
}
foreach my $chrom (sort keys %lines) {
foreach my $posn (sort keys %{$lines{$chrom}}) {
my $F = pop @{$lines{$chrom}{$posn}};
while (my $Fn = pop @{$lines{$chrom}{$posn}}) {
for my $i (@effIndexes) {
$F->[$i] .= "|" . $Fn->[$i];
}
}
print join("\t", @{$F}) . "\n";
}
}