X BOL wishing you a very and Happy New year

Alternative content

Reverse Complement Problem Solved with Perl

Question at http://rosalind.info/problems/1b/

#Find the reverse complement of a DNA string.
#Given: A DNA string Pattern.
#Return: Pattern, the reverse complement of Pattern.

use strict;
use warnings;

my $string="AAAACCCGGT";
my $finalString="";
my %hash = (
    "C" => "G",
    "A" => "T",
    "T" => "A",
    "G" => "C",
);

for (my $aa=0; $aa<=(length($string)-1); $aa++) {
    my $char=substr $string, $aa, 1;
    #print $hash{$char};
    $finalString="$hash{$char}"."$finalString";
}

print $finalString;
print "\n";