position value 12498248 1.033560 12512575 0.566400 12513687 0.632940 12520106 0.232530 12523984 0.247300 12525383 1.487640 #### #!usr/bin/perl use warnings; use strict; use List::Util 'sum'; print ' ############### Establish windows of 10kb and calculate the average Recomb Rate ############### '; my $recomb_all = $ARGV[0]; my @recomb_all = @{get_contents ($recomb_all)}; #Testing content print "line 1 column 2 ::: $recomb_all[0][1]\n"; my $length = (scalar @recomb_all) - 1; my @window; my $window_size = 10000; my $window_step = 10000; my @average; for (my $i = 0; ($i + $window_size - $window_step) <= $recomb_all[$length][0]; $i += $window_step) { my $e = $i + $window_size; if ($e > $recomb_all[$length][0]) { $e = $recomb_all[$length][0]; push (@window, $recomb_all[$length][1]); print "@window\n"; push (@average, $recomb_all[$length][0], my $av = average (@window)); } } #print "@window\n"; #print "@average\n"; exit; ####################### #SUBROUTINES ####################### sub get_contents { my ( $file ) = @_; my @contents; open (FH, "< $file") or die "I cannot open $file file: $!\n"; my $x = 0; while () { next unless /\S/; next if /^\s*[A-Z]+/i; @{$contents[$x]} = split /\s+/; ++$x; } return (\@contents); } # ---------- end of subroutine get_contents ---------- sub average { my @array = @_; return sum(@array) / @array; }