# Permutations of A,G,C,T.

Doug Eernisse DEernisse at fullerton.edu
Tue May 30 15:54:32 EST 1995

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

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

You can use the commercial program MacClade to do this, or you
can paste the following script into a HyperCard button if you
have a Mac with any version of HyperCard (not HyperCard Player).

I will send you the stack I just created for this script in email,
but I have taken the liberty of including the script here in case
it is of use to others as well, plus it DID take me 15 minutes to
program! It is not terribly fast, but probably much faster than
whatever you plan to do with the random sequences.

(Convert "-->>" to the character you get when you type "L" with
the option key depressed.)

on mouseUp
ask "Generate how many random DNA sequences?" with "100"
if it is empty then exit mouseUp
else put it into numSeqs
ask "How many base pairs should each be?" with "100"
if it is empty then exit mouseUp
else put it into SeqLength

answer "Would you like the base pair frequencies to be equal?" -->>
with "Cancel" or "Custom" or "Equal"
if it is cancel then exit mouseup
else if it is equal then
put "0.25" into Afreq
put "0.25" into Cfreq
put "0.25" into Gfreq
put "0.25" into Tfreq
else
if (it is empty) or (it < 0) or (it > 1) then
else
put it into Afreq
end if
ask "Enter the average probability of a Thymine:" with Afreq
if (it is empty) or (it < 0) or (it > 1) or (it > (1 - Afreq)) then
else
put it into Tfreq
end if
ask "Enter the average probability of a Cytosine:" with  -->>
((1 - (Afreq + Tfreq))/2)
if (it is empty) or (it < 0) or (it > 1) or  -->>
(it > (1 - (Afreq + Tfreq))) then
else
put it into Cfreq
end if
put (1 - (Afreq + Cfreq + Tfreq)) into Gfreq
answer "The average probability of a Guanine is " & Gfreq  -->>
with "Abort" or "OK"
if it is "Abort" then exit mouseUp
end if

ask file "Save output to..." with "RSeqs " & the short date
if it is empty then exit mouseup
else put it into fname

set cursor to busy
put trunc(Afreq * 1000) into aVal
put trunc(Cfreq * 1000) + aVal into cVal
put trunc(Gfreq * 1000) + cVal into gVal
put length(SeqLength) into maxL

repeat with x = 1 to numSeqs
put empty into newSeq
repeat SeqLength
put random(1000) into whichNuc
if (whichNuc > gVal) then
put "T" after newSeq
else if (whichNuc > cVal) then
put "G" after newSeq
else if (whichNuc > aVal) then
put "C" after newSeq
else
put "A" after newSeq
end if
end repeat
put (MaxL - length(x) + 1) into pad
end repeat
put "Seq" & x & padding & newSeq & return after output
end repeat
open file fname
write output to file fname
close file fname
play "boing"
end mouseUp

--
Doug Eernisse <DEernisse at fullerton.edu>
Dept. Biological Science MH282
California State University
Fullerton, CA 92634

```