Skip to content

Instantly share code, notes, and snippets.

@hipyhop
Created February 21, 2013 22:43
Show Gist options
  • Save hipyhop/5009087 to your computer and use it in GitHub Desktop.
Save hipyhop/5009087 to your computer and use it in GitHub Desktop.
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';
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