User Tools

Site Tools


Sidebar

This is the sidebar. Without it, the main text is too wide!

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: 2016/11/08 09:45 by hyjeong