Mercurial > repos > chawhwa > neuma
view NEUMA-1.2.1/calculate_gEUMA.2.pl @ 0:c44c43d185ef draft default tip
NEUMA-1.2.1 Uploaded
author | chawhwa |
---|---|
date | Thu, 08 Aug 2013 00:46:13 -0400 |
parents | |
children |
line wrap: on
line source
#!/usr/bin/perl # Compute gEUMA for each gene from the gUtable file and insertlendis file and print out only genes whose gEUMA is larger than 0. if(@ARGV<3) { print "usage: $0 gUtable_file insertlendis_file READLENGTH\n"; exit; } my ($gUtable_file,$insertlendis_file,$READLENGTH) = @ARGV; my $totalfreq=0; open LENDIS, $insertlendis_file or die "Can't open insertlendis file $insertlendis_file\n"; while(<LENDIS>){ chomp; my ($insert_size, $freq) = split/\t/; $insertlendis{"$insert_size"}=$freq; $totalfreq+=$freq; } close LENDIS; print "gene\tgEUMA\n"; #header open GUTABLE, $gUtable_file or die "Can't open gUtable file $gUtable_file\n"; chomp($header = <GUTABLE>); @distances = split/\t/,$header; shift @distances; #'gene' while(<GUTABLE>){ chomp; my @line = split/\t/; my $gene = shift @line; my $EUMA=0; for my $i (0..$#distances){ $d=$distances[$i]; $pUMA = $line[$i] * ($insertlendis{$d}/$totalfreq) ; $EUMA += $pUMA; } if($EUMA>=0.005) { printf "$gene\t%.2f\n",$EUMA; } # use >=0.005 instead of >0, because I'm plotting two decimals after point. (in bp) } close GUTABLE;