Bioperl: making a random sequence

Dr Nicolas Le Novere nl223@cus.cam.ac.uk
Tue, 30 May 2000 16:49:09 +0100 (BST)


On Tue, 30 May 2000, Gatherer, D. (Derek) wrote:

> I'm trying to make some 'control' DNA sequences......
> 
> srand();
> for($x=1;$x<=1000000;$x++)
> {
> 	$r = rand(1);
> 	if($r <= 0.25){ print "A"; }
> 	elsif($r <= 0.5){ print "C"; }
> 	elsif($r <= 0.75){ print "G"; }
> 	elsif($r <= 1.0){ print "T"; }
> }
> 
> This spews out nonsense sequence but the proportions of bases are not equal.
> A tends to be overrepresented at around 44% or so.  The others are
> correspondingly reduced (sorry, I left the exact figures at home).  I've
> checked that rand(1) really does generate numbers between 0 and 1, so why
> the skew to larger numbers???

I did not reproduce your problem:

percent A = 0.25068%
percent T = 0.24909%
percent G = 0.24885%
percent C = 0.25138%


--
Dr Nicolas Le Novère           
Dpt of Zoology, University of Cambridge, Downing street, Cambridge CB2 3EJ, UK
http://www.pasteur.fr/recherche/unites/neubiomol/PERSOPAGES/LENOVERE/
tel: +44 1223 336623       fax: +44 1223 336676    e-mail: nl223@cus.cam.ac.uk

=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================