Bioperl: making a random sequence

Gatherer, D. (Derek) D.Gatherer@organon.nhe.akzonobel.nl
Tue, 30 May 2000 10:12:12 +0200


Morning all

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???

Do I need to tweak srand() somehow?

All help gratefuly appreciated.

Derek
=========== 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
====================================================================