# Randseq - generate a random sequence of nucleotides
# M. Raymer, 5/27/03

# The first argument is the length of the sequence to generate
$len = shift();

# Linemax controls the number of characters per line
$linemax = 75;

# Print the random nucleotides:
foreach $i (1..$len) {

	# $rn is a random number between zero and four
	$rn = rand() * 4.0;

	# print a random nucleotide
	if ($rn < 1) {
		print("A");
	} elsif ($rn < 2) {
		print("C");
	} elsif ($rn < 3) {
		print("G");
	} else {
		print("T");
	}

	# print a newline every $linemax characters
	if (($i % $linemax == 0) || ($i == $len)){
		print("\n");
	}
}


