#!/usr/bin/perl use Data::Dumper; open $f,$ARGV[0]; while(<$f>) { chomp; $id = $_; #eat up the header line chomp($s = <$f>); if($s !~ /^>/) { push @seq,$s; } } open $fa, "top_10_hexamers.txt"; while(<$fa>) { chomp; $hx{$_}++; #hash of 10 hexamer } @words = sort keys %hx; for($i = 1;$i < 5000;$i++) { for($j = 0;$j <= $#words;$j++) { $result[$i][$j] = 0; # array of 5000 columns of position and words as columns } } foreach $x(@seq) { for($j = 0; $j < (length($x) - 6);$j++) { $wrd = substr $x,$j,6; #getting the hexamer combinations foreach $w(@words) { if($w eq $wrd) # comparing with the word { $result->{$j}->{$wrd}++; # trying to get position, word and frequency } } } $wrd = ""; } print Dumper $result;