[Bioperl-l] Bioperl Module for Computing Background Distributions

Sean Davis sdavis2 at mail.nih.gov
Thu Sep 7 06:44:43 EDT 2006


On Thursday 07 September 2006 02:33, Wijaya Edward wrote:
> Dear Expert,
>
> Is there any existing Bioperl module that
> computes background distributions of nucleotides
> given a set of DNA sequences?
>
> Basically it computes:
>
>     frequency of nucleotide A(denin)  / Total number of bases
>
> and so forth for T or C or G.

This is pretty simple to do with straight perl.  

Sean


#!/usr/bin/perl
use strict;

my $DNA = "ACCTGGATCCCGCTTTGACA";

my %base_hash;

map {$base_hash{$_}++} split("",$DNA);

print "Length of DNA: ",length($DNA),"\n";
foreach my $base (keys %base_hash) {
    print join("\t",$base,$base_hash{$base},
$base_hash{$base}/length($DNA))."\n";
}


More information about the Bioperl-l mailing list