Created
February 21, 2013 22:43
-
-
Save hipyhop/5009087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use strict; | |
use Storable; | |
sub random_sequence { | |
my @nuc = ( 'A' , 'T' , 'C' , 'G' ); | |
my $DNA; | |
$DNA .= $nuc[rand @nuc] for 1..50; | |
return $DNA; | |
} | |
my %DNAsequences; | |
for my $i (1..10){ | |
$DNAsequences{'DNA'.$i} = random_sequence(); | |
} | |
store \%DNAsequences, 'file'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Storable; | |
my $dataref = retrieve( 'file' ); | |
while( my ($key, $value) = each %{$dataref}){ | |
foreach my $base (qw/A C G T/){ | |
my @count = ($value =~ /$base{4}/); | |
if(@count){ | |
print "Run (", $base x 4, ") found ", scalar @count, " times in $key\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment