read_depth.pl
#!/usr/bin/perl
$sum = $pos = 0;
while (<>) {
chomp;
my @data = split /\t/, $_;
if (!exists $seen{$data[0]} && $pos > 0) {
print $data[0], "\t", $sum / $pos, "\n";
$sum = $pos = 0;
} elsif (exists $seen{$data[0]}) {
$sum += $data[2];
$pos++;
} elsif (!exists $seen{$data[0]}) {
print STDERR "Processing $data[0]...\n";
$seen{$data[0]} = '';
}
}
print "\t", $sum / $pos, "\n";
read_depth.pl.txt · Last modified: by 127.0.0.1
