/* random_seq.c */
/* calls ran2 to make a random sequence */

#include "random_seq.h"
#include "nr.h"

char *random_seq (char *sequence, long length, long *seed)
{	
	long i;

	for (i=0; i<length; i++)
	{
		sequence[i] = float_to_nt(ran2(seed));
	}
	return sequence;
}

char float_to_nt (float f)
{
	if (f < 0.5)
	{
		if (f < 0.25)
			return 'U';
		else
			return 'C';
	}
	else
	{
		if (f < 0.75)
			return 'A';
		else
			return 'G';
	}
}

