[Bioperl-l] Bioperl Module for Computing Background Distributions

Chris Fields cjfields at uiuc.edu
Thu Sep 7 13:07:45 UTC 2006


Sean et al,

Using t/// is also a very fast way to count bases.  This is used in  
various SeqIO modules for speeding things up.

TMTOWTDI!

my $a = $dna =~ tr/a/a/;
my $c = $dna =~ tr/c/c/;
my $g = $dna =~ tr/g/g/;
my $t = $dna =~ tr/t/t/;

my $len = length($dna)

....blah blah blah


Chris

On Sep 7, 2006, at 5:44 AM, Sean Davis wrote:

> 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";
> }
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign






More information about the Bioperl-l mailing list