Skip to content

Instantly share code, notes, and snippets.

@coela
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save coela/0d5f619608a0d6c4fbdf to your computer and use it in GitHub Desktop.

Select an option

Save coela/0d5f619608a0d6c4fbdf to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use List::Util qw(sum);
my @data = ();
my @all = ();
my $keisu = 3;
my $cutoff = 0;
my $linenum = 0;
while(<>){
$linenum++;
next if $linenum == 1;
chomp;
my @line = split /\t/;
if (/^\:/ || eof()){
print $_ . "\n";
@data = sort {$a <=> $b} @data;
my $num = scalar @data;
my @half = @data[0..int($num/2 -1)];
my $half_num = scalar @half;
$cutoff = sum(@half)/$half_num * $keisu;
my @up = grep {$_->[1] >= $cutoff} @all;
for (@up){
print join " " , @$_;
print "\n";
}
@data = ();
@all = ();
}
else{
push @all, \@line;
if ($line[0] >=1200 && $line[0] <=1500){
push @data, $line[1];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment