IUBio

Permutations of A,G,C,T.

Don & bashford at toad.scripps.edu
Tue May 30 17:56:08 EST 1995


>>>>> "Robert" == Robert D Darby <darby at halcyon.com> writes:
In article <Pine.ULT.3.91.950529010952.29923A-100000 at coho.halcyon.com> "Robert D. Darby" <darby at halcyon.com> writes:


    Robert> Does anyone have a simple program, Basic, Assembler, C,
    Robert> whatever to create the permutations of A,G,C,T for a
    Robert> specified output length.  Or, can you point me to an FTP
    Robert> location.  Yes, yes, I know this is not terribly complex,
    Robert> but I am in a rush and don't have time to code and debug.

It is very easy to do this in perl.  Here is a script that I
just wrote for you.  If your system has perl installed (many Unix
systems do) just put the following program in a file called
"random-dna" or something and make it executable.

Don Bashford
The Scripps Research Institute
bashford at scripps.edu
----------------------------------------------------------------------
#!/usr/bin/perl
$usage = "\
This program writes a random DNA sequence to standard output.  Usage:
   $0 len [seed]
where len is an integer specifying the length of the sequence desired,
and seed sets the seed for the random number generator.
";

@bases = ("A", "G", "C", "T");

(@ARGV == 1 || @ARGV == 2) && int ($ARGV[0]) || die $usage;

# If you don't like setting the seed from the command line,
# change this to just "srand;" and it will set the seed from
# the time.
srand ($ARGV[1]) if @ARGV == 2;

for ($i=1; $i<=$ARGV[0]; ++$i) {
    $n = int (rand(4));
    print $bases[$n];
}
print "\n";




More information about the Bio-soft mailing list

Send comments to us at biosci-help [At] net.bio.net