From 02c329a876fdfec61cd65f8f67fd0e7c9252787d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 18 Nov 2012 17:59:11 -0600 Subject: another solution --- KMER.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 KMER.pl diff --git a/KMER.pl b/KMER.pl new file mode 100644 index 0000000..93f423b --- /dev/null +++ b/KMER.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.016; + +my @bases = qw(A C G T); +my @tetranucleotides = ( + map { s/(..)/$bases[oct("0b$1")]/egr } map { sprintf("%08b", $_) } 0..255 +); +my %tetranucleotide_map = ( + map { $tetranucleotides[$_] => $_ } 0..255 +); + +<>; +chomp(my @dna = <>); +my $dna = join('', @dna); + +my @found = (0) x 256; +for my $i (0..(length($dna) - 4)) { + $found[$tetranucleotide_map{substr($dna, $i, 4)}]++; +} + +say join(' ', @found); -- cgit v1.2.3