diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-11-18 17:59:11 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-11-18 17:59:11 -0600 |
commit | 02c329a876fdfec61cd65f8f67fd0e7c9252787d (patch) | |
tree | 5eb98d930ebfcca52ea1b1bc9ecf9c0c02ccc2cf | |
parent | e2e7f64c2647b1047669311dd509ba8c72d7bed6 (diff) | |
download | rosalind-02c329a876fdfec61cd65f8f67fd0e7c9252787d.tar.gz rosalind-02c329a876fdfec61cd65f8f67fd0e7c9252787d.zip |
another solution
-rw-r--r-- | KMER.pl | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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); |