Bioperl: making a random sequence

Osborne, Brian Brian.Osborne@osip.com
Tue, 30 May 2000 09:37:24 -0400


Derek,

Your code looked right to me so I checked it on perl 5.005_03, Linux,
2.2.13. It appears to be doing the anticipated thing : %25.00004 A once,
%24.9959 A the next time, then %24.9514, etc. My only guess is that perl's
rand and srand borrow from the system's libraries somehow, and you're on a
different OS. But "Programming Perl" doesn't hint at such a relationship
between perl and the system.

Brian Osborne
OSI Pharmaceuticals
http://www.osip.com
777 Old Saw Mill River Rd.
Tarrytown NY USA
10591-6705
brian.osborne@osip.com
TEL 914 467 6291
FAX 914 345 3565


-----Original Message-----
From: Gatherer, D. (Derek) [mailto:D.Gatherer@organon.nhe.akzonobel.nl]
Sent: Tuesday, May 30, 2000 4:12 AM
To: BioPerl
Subject: Bioperl: making a random sequence


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