Clustal to Blast script

Hey guys.
I’m rather new to scripting but as I’ve been learning for my hobby project I figured I’d make something useful for work too.
I thought I’d share in case any of you are in medicine.

This is my way of merging DNA alignments from Clustal Omega to get conserved regions where they exist and choose random bases where they do not. This enables me to take the output and feed into a BLAST. This was made to use in non coding regions (enhancer, promoter and other peptide binding sites).

For those that aren’t in medicine/biosciences: Clustal aligns sections of DNA. BLAST searches trough databases for sections resembling the input sequence. These methods can be combined in several ways.

I tried it out and it works rather well, however it is slow and I’m sure it could be optimized a lot.

I do realize I could just as well have made this in javascript instead of unityscript, but after some banging my head against a wall I realized it would be much easier in unityscript as I know that better.

I post this both to share and for criticism. If anyone wants to come with improvements (in particular increasing speed) I’d be very happy.

The finished project is pretty much only this script but I figured I’d save some space trough only posting the script instead of a build.

edit: I forgot to mention, DNA is 4 bases, a, c, t ang g, so I ignore any other letter or symbol in the input strings (spaces or - tend to signify no match in that area on that specific sequence).

Here comes wall of code:

var btnTexture : Texture;

var str1a : String = "";
var str2a : String = "";
var str3a : String = "";
var str4a : String = "";
var str5a : String = "";
var str6a : String = "";
var str7a : String = "";
var str8a : String = "";
var str9a : String = "";
var str10a : String = "";
var str11a : String = "";
var str12a : String = "";
var str13a : String = "";
var str14a : String = "";
var str15a : String = "";
var str16a : String = "";
var str17a : String = "";
var str18a : String = "";
var str19a : String = "";
var str20a : String = "";


var strFinalA  = new Array();
var strFinalB  = new Array();
var strFinalC  = new Array();

var n = 10000;
var randomnumber : float;

var strG : String = "g";
var gC : int = strG[0];
var strA : String = "a";
var aC : int = strA[0];
var strT : String = "t";
var tC : int = strT[0];
var strC : String = "c";
var cC : int = strC[0];

var g : int;
var a : int;
var t : int;
var c : int;

var finalString : String;
var stringLength : int = 60;
var stringStr : String = "60";
var numbOfStr : int = 3;
var numbStr : String = "3";

function OnGUI () {
    // Make a text field that modifies stringToEdit.


    GUI.Label (Rect (500, 10, 300, 300), "In the first row type the number of bases in your input sequences (how many in each of them). \n It is very important that you do not insert the wrong number in the first row. \n Then press the first checkbox. \n In the second row type the number of sequences you are comparing.  \n Press the second Checkbox. \n Input your sequences, one for each line. \n The last line is the merged output, leave that empty. \n When you have input your sequences press the last Checkbox. \n The run will take a few seconds (longer sequences take more time, there is no upper limit to length). \n If you need to start over by any reason, make sure to clear the last line before running again.");

	stringStr = GUI.TextField (Rect (10, 10, 200, 20), stringStr, 5);
	
	// here is the length of strings to input:
		if (GUI.Button(Rect(300,10,50,50),btnTexture)){
    		 stringLength = parseInt (stringStr);
     		strFinalA.Clear();
        }
	// here is the number of strings to input:
	numbStr = GUI.TextField (Rect (10, 30, 200, 20), numbStr, 5);
		
		if (GUI.Button(Rect(300,60,50,50),btnTexture)){
    		 numbOfStr = parseInt (numbStr);
     		strFinalA.Clear();
        }
        
    str1a = GUI.TextField (Rect (10, 50, 200, 20), str1a);
    str2a = GUI.TextField (Rect (10, 70, 200, 20), str2a);
    str3a = GUI.TextField (Rect (10, 90, 200, 20), str3a);
    str4a = GUI.TextField (Rect (10, 110, 200, 20), str4a);
    str5a = GUI.TextField (Rect (10, 130, 200, 20), str5a);
    str6a = GUI.TextField (Rect (10, 150, 200, 20), str6a);
    str7a = GUI.TextField (Rect (10, 170, 200, 20), str7a);
    str8a = GUI.TextField (Rect (10, 190, 200, 20), str8a);
    str9a = GUI.TextField (Rect (10, 210, 200, 20), str9a);
    str10a = GUI.TextField (Rect (10, 230, 200, 20), str10a);
    str11a = GUI.TextField (Rect (10, 250, 200, 20), str11a);
    str12a = GUI.TextField (Rect (10, 270, 200, 20), str12a);
    str13a = GUI.TextField (Rect (10, 290, 200, 20), str13a);
    str14a = GUI.TextField (Rect (10, 310, 200, 20), str14a);
    str15a = GUI.TextField (Rect (10, 330, 200, 20), str15a);
    str16a = GUI.TextField (Rect (10, 350, 200, 20), str16a);
    str17a = GUI.TextField (Rect (10, 370, 200, 20), str17a);
    str18a = GUI.TextField (Rect (10, 390, 200, 20), str18a);
    str19a = GUI.TextField (Rect (10, 410, 200, 20), str19a);
    str20a = GUI.TextField (Rect (10, 430, 200, 20), str20a);
    

    if (!btnTexture) {
        Debug.LogError("Please assign a texture on the inspector");
        return;
    }
    if (GUI.Button(Rect(300,470,50,50),btnTexture)){
        Debug.Log("Clicked the button with an image");
        n=0;
        }


    finalString = GUI.TextField (Rect (10, 470, 200, 20), finalString);

}

function Update () {
if (n < stringLength){
    

if (str1a[n] == "g"){
g += 1;
}
if (str2a[n] == "g"){
g += 1;
}
if (str3a[n] == "g"){
g += 1;
}

if (str1a[n] == "a"){
a += 1;
}
if (str2a[n] == "a"){
a += 1;
}
if (str3a[n] == "a"){
a += 1;
}

if (str1a[n] == "t"){
t += 1;
}
if (str2a[n] == "t"){
t += 1;
}
if (str3a[n] == "t"){
t += 1;
}

if (str1a[n] == "c"){
c += 1;
}
if (str2a[n] == "c"){
c += 1;
}
if (str3a[n] == "c"){
c += 1;
}


if (numbOfStr >= 4){
if (str4a[n] == "g"){
g += 1;
}
if (str4a[n] == "a"){
a += 1;
}
if (str4a[n] == "t"){
t += 1;
}
if (str4a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 5){
if (str5a[n] == "g"){
g += 1;
}
if (str5a[n] == "a"){
a += 1;
}
if (str5a[n] == "t"){
t += 1;
}
if (str5a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 6){
if (str6a[n] == "g"){
g += 1;
}
if (str6a[n] == "a"){
a += 1;
}
if (str6a[n] == "t"){
t += 1;
}
if (str6a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 7){
if (str7a[n] == "g"){
g += 1;
}
if (str7a[n] == "a"){
a += 1;
}
if (str7a[n] == "t"){
t += 1;
}
if (str7a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 8){
if (str8a[n] == "g"){
g += 1;
}
if (str8a[n] == "a"){
a += 1;
}
if (str8a[n] == "t"){
t += 1;
}
if (str8a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 9){
if (str8a[n] == "g"){
g += 1;
}
if (str9a[n] == "a"){
a += 1;
}
if (str9a[n] == "t"){
t += 1;
}
if (str9a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 10){
if (str10a[n] == "g"){
g += 1;
}
if (str10a[n] == "a"){
a += 1;
}
if (str10a[n] == "t"){
t += 1;
}
if (str10a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 11){
if (str11a[n] == "g"){
g += 1;
}
if (str11a[n] == "a"){
a += 1;
}
if (str11a[n] == "t"){
t += 1;
}
if (str11a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 12){
if (str12a[n] == "g"){
g += 1;
}
if (str12a[n] == "a"){
a += 1;
}
if (str12a[n] == "t"){
t += 1;
}
if (str12a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 13){
if (str13a[n] == "g"){
g += 1;
}
if (str13a[n] == "a"){
a += 1;
}
if (str13a[n] == "t"){
t += 1;
}
if (str13a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 14){
if (str14a[n] == "g"){
g += 1;
}
if (str14a[n] == "a"){
a += 1;
}
if (str14a[n] == "t"){
t += 1;
}
if (str14a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 15){
if (str15a[n] == "g"){
g += 1;
}
if (str15a[n] == "a"){
a += 1;
}
if (str15a[n] == "t"){
t += 1;
}
if (str15a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 16){
if (str16a[n] == "g"){
g += 1;
}
if (str16a[n] == "a"){
a += 1;
}
if (str16a[n] == "t"){
t += 1;
}
if (str16a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 17){
if (str17a[n] == "g"){
g += 1;
}
if (str17a[n] == "a"){
a += 1;
}
if (str17a[n] == "t"){
t += 1;
}
if (str17a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 18){
if (str18a[n] == "g"){
g += 1;
}
if (str18a[n] == "a"){
a += 1;
}
if (str18a[n] == "t"){
t += 1;
}
if (str18a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 19){
if (str19a[n] == "g"){
g += 1;
}
if (str19a[n] == "a"){
a += 1;
}
if (str19a[n] == "t"){
t += 1;
}
if (str19a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 20){
if (str20a[n] == "g"){
g += 1;
}
if (str20a[n] == "a"){
a += 1;
}
if (str20a[n] == "t"){
t += 1;
}
if (str20a[n] == "c"){
c += 1;
}
}


print("The cycle is"+ n);
print("g is"+ g);
print("a is"+ a);
print("t is"+ t);
print("c is"+ c);




if ((g>a)  (g>t)  (g>c)){
	strFinalA.push("g");
}
if ((a>g)  (a>t)  (a>c)){
	strFinalA.push("a");
}
if ((t>a)  (t>g)  (t>c)){
	strFinalA.push("t");
}
if ((c>a)  (c>t)  (c>g)){
	strFinalA.push("c");
}

if ((g==a)  (g>t)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("g");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("a");
}
}
if ((g==t)  (g>a)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("g");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}
if ((g==c)  (g>a)  (g>t)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("g");
}
}


if ((a==t)  (a>g)  (a>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("a");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}
if ((a==c)  (c>g)  (c>t)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("a");
}
}


if ((t==c)  (c>a)  (c>g)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}

if ((g==a)  (g==t)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("g");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("a");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((c==t)  (c==a)  (c>g)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("a");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("c");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((t==c)  (t==g)  (t>a)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("g");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("c");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((a==c)  (a==g)  (a>t)){
	randomnumber = Random.value;
	if (randomnumber <= 0.33){
		strFinalA.push("g");
}
	if ((randomnumber > 0.33)  (randomnumber <= 0.66)){
		strFinalA.push("c");
}
	if (randomnumber > 0.66) {
		strFinalA.push("a");
}
}
if ((a==c)  (a==g)  (a==t)){
	randomnumber= Random.value;
	if (randomnumber <= 0.25){
		strFinalA.push("g");
}
	if ((randomnumber > 0.25)  (randomnumber <= 0.5)){
		strFinalA.push("c");
}
	if ((randomnumber > 0.5)  (randomnumber <= 0.75)) {
		strFinalA.push("a");
}
	if (randomnumber > 0.75){
		strFinalA.push("t");
}
}
n += 1;

g = 0;
a = 0;
t = 0;
c = 0;
}
if (n==stringLength){
finalString = Array(strFinalA).Join("");

print(finalString);
n++;
}
}

Array’s anyone?

Sure but where?
You mean transform the input strings to arrays and do the computations on them?
I don’t really see how that saves me space. Will it make it run faster?

I am using an array to save the most common base for each position. Could this be done better if I do the computations on arrays instead of strings?

He means for the strings. So you don’t have the same code 20 times.

I’m very new to using arrays. How would they save me space?
I mean if I transform my strings to arrays how would the calculation differ? Don’t I still need one check for each of the four characters on each position?

The part of the code that repeats is this:

if (numbOfStr >= 4){

if (str4a[n] == "g"){

g += 1;

}

if (str4a[n] == "a"){

a += 1;

}

if (str4a[n] == "t"){

t += 1;

}

could I (if using arrays) make it go over all 20 arrays and check for each character on a specific position instead?
I guess I’d need an array of arrays for that.

First, you’re falsely limiting your speed by increasing N only as fast as Update runs.
Using for loop will stop your program until it finishes, but you’ll get done much faster.
If you want to update visuals as the program runs, you can use yield statements to make, say, ten calculations per frame instead of just one.

Print statements are “the slowest thing you can do”. Drop them, or make them conditional so they only trigger once in a while instead of every loop.

Try string += “x” instead of string.push(x)? Not sure if either of those has a performance boost.

Using arrays will consolidate your code, not necessarily increase speed (but so much easier to make changes, it doesn’t matter if you lose speed):

var strings : String[20];
var count : int[ parseInt("t"[0]) ]; // count gtac - might not work, just trying to cheat some more efficiency in :)
// or -
var count : int[ 4 ];

...

for ( var n : int = 0; n < strings.length; n++ ) {
  for ( var ix : int = 0; ix < strings[n].Length; ix++ ) { // I forget the 'length' member of strings, but it's something
    count[ parseInt( strings[n][ix] ) ]++; // "increase the count of the character at position ix in string n"
    // or -
    switch ( strings[n][ix] ) {
      case "g"[0]: count[0]++; break;
      /* etc */
    }
  }
}

...

function OnGUI() {
  for ( ix = 0; ix < strings.length; ix++ ) {
    strings[ix] = GUILayout.TextField( strings[ix] );
  }
}

Thanks. Looks like that’d be a much better way of doing it.
I did figure I could do it faster than on update but I messed up my first try with loops so I put in that update just because I knew it’d work.

I did follow some of the advice here. It’s now in a loop and the GUI looks a bit better. I haven’t moved my strings to an array as it is now fast enough for increases in speed to be redundant and it is doing what I want it to. I do agree on this being a lot bulkier than necessary, but it does what it’s supposed to and it does it instantly.

Here is the new script for anyone that might want it:

var str1a : String = "";
var str2a : String = "";
var str3a : String = "";
var str4a : String = "";
var str5a : String = "";
var str6a : String = "";
var str7a : String = "";
var str8a : String = "";
var str9a : String = "";
var str10a : String = "";
var str11a : String = "";
var str12a : String = "";
var str13a : String = "";
var str14a : String = "";
var str15a : String = "";
var str16a : String = "";
var str17a : String = "";
var str18a : String = "";
var str19a : String = "";
var str20a : String = "";


var strFinalA  = new Array();
var strFinalB  = new Array();
var strFinalC  = new Array();

var randomnumber : float;

var strG : String = "g";
var gC : int = strG[0];
var strA : String = "a";
var aC : int = strA[0];
var strT : String = "t";
var tC : int = strT[0];
var strC : String = "c";
var cC : int = strC[0];

var g : int;
var a : int;
var t : int;
var c : int;

var finalString : String;
var stringLength : int = 60;
var stringStr : String = "60";
var numbOfStr : int = 3;
var numbStr : String = "3";

function OnGUI () {
    // Make a text field that modifies stringToEdit.


    GUI.Label (Rect (500, 10, 300, 300), "In the first row type the number of bases in your input sequences (how many in each of them). \n It is very important that you do not insert the wrong number in the first row. \n Then press the first checkbox. \n In the second row type the number of sequences you are comparing.  \n Press the second Checkbox. \n Input your sequences, one for each line. \n The last line is the merged output, leave that empty. \n When you have input your sequences press the last Checkbox. \n The run will take a few seconds (longer sequences take more time, there is no upper limit to length). \n If you need to start over by any reason, make sure to clear the last line before running again.");

	stringStr = GUI.TextField (Rect (10, 10, 200, 20), stringStr, 5);
	
	// here is the length of strings to input:
		if (GUI.Button(Rect(220,10,200,20),"Length of Sequence")){
    		 stringLength = parseInt (stringStr);
     		strFinalA.Clear();
        }
	// here is the number of strings to input:
	numbStr = GUI.TextField (Rect (10, 30, 200, 20), numbStr, 5);
		
		if (GUI.Button(Rect(220,30,200,20),"Number of Sequences")){
    		 numbOfStr = parseInt (numbStr);
     		strFinalA.Clear();
        }
        
    str1a = GUI.TextField (Rect (10, 50, 200, 20), str1a);
    str2a = GUI.TextField (Rect (10, 70, 200, 20), str2a);
    str3a = GUI.TextField (Rect (10, 90, 200, 20), str3a);
    str4a = GUI.TextField (Rect (10, 110, 200, 20), str4a);
    str5a = GUI.TextField (Rect (10, 130, 200, 20), str5a);
    str6a = GUI.TextField (Rect (10, 150, 200, 20), str6a);
    str7a = GUI.TextField (Rect (10, 170, 200, 20), str7a);
    str8a = GUI.TextField (Rect (10, 190, 200, 20), str8a);
    str9a = GUI.TextField (Rect (10, 210, 200, 20), str9a);
    str10a = GUI.TextField (Rect (10, 230, 200, 20), str10a);
    str11a = GUI.TextField (Rect (10, 250, 200, 20), str11a);
    str12a = GUI.TextField (Rect (10, 270, 200, 20), str12a);
    str13a = GUI.TextField (Rect (10, 290, 200, 20), str13a);
    str14a = GUI.TextField (Rect (10, 310, 200, 20), str14a);
    str15a = GUI.TextField (Rect (10, 330, 200, 20), str15a);
    str16a = GUI.TextField (Rect (10, 350, 200, 20), str16a);
    str17a = GUI.TextField (Rect (10, 370, 200, 20), str17a);
    str18a = GUI.TextField (Rect (10, 390, 200, 20), str18a);
    str19a = GUI.TextField (Rect (10, 410, 200, 20), str19a);
    str20a = GUI.TextField (Rect (10, 430, 200, 20), str20a);
    


    if (GUI.Button(Rect(220,470,200,20),"Merge Sequences")){
        RunIt ();
        }


    finalString = GUI.TextField (Rect (10, 470, 200, 20), finalString);

}

function RunIt () {
    
for (var n = 0; n < stringLength; n++){
if (str1a[n] == "g"){
g += 1;
}
if (str2a[n] == "g"){
g += 1;
}
if (str3a[n] == "g"){
g += 1;
}

if (str1a[n] == "a"){
a += 1;
}
if (str2a[n] == "a"){
a += 1;
}
if (str3a[n] == "a"){
a += 1;
}

if (str1a[n] == "t"){
t += 1;
}
if (str2a[n] == "t"){
t += 1;
}
if (str3a[n] == "t"){
t += 1;
}

if (str1a[n] == "c"){
c += 1;
}
if (str2a[n] == "c"){
c += 1;
}
if (str3a[n] == "c"){
c += 1;
}


if (numbOfStr >= 4){
if (str4a[n] == "g"){
g += 1;
}
if (str4a[n] == "a"){
a += 1;
}
if (str4a[n] == "t"){
t += 1;
}
if (str4a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 5){
if (str5a[n] == "g"){
g += 1;
}
if (str5a[n] == "a"){
a += 1;
}
if (str5a[n] == "t"){
t += 1;
}
if (str5a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 6){
if (str6a[n] == "g"){
g += 1;
}
if (str6a[n] == "a"){
a += 1;
}
if (str6a[n] == "t"){
t += 1;
}
if (str6a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 7){
if (str7a[n] == "g"){
g += 1;
}
if (str7a[n] == "a"){
a += 1;
}
if (str7a[n] == "t"){
t += 1;
}
if (str7a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 8){
if (str8a[n] == "g"){
g += 1;
}
if (str8a[n] == "a"){
a += 1;
}
if (str8a[n] == "t"){
t += 1;
}
if (str8a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 9){
if (str8a[n] == "g"){
g += 1;
}
if (str9a[n] == "a"){
a += 1;
}
if (str9a[n] == "t"){
t += 1;
}
if (str9a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 10){
if (str10a[n] == "g"){
g += 1;
}
if (str10a[n] == "a"){
a += 1;
}
if (str10a[n] == "t"){
t += 1;
}
if (str10a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 11){
if (str11a[n] == "g"){
g += 1;
}
if (str11a[n] == "a"){
a += 1;
}
if (str11a[n] == "t"){
t += 1;
}
if (str11a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 12){
if (str12a[n] == "g"){
g += 1;
}
if (str12a[n] == "a"){
a += 1;
}
if (str12a[n] == "t"){
t += 1;
}
if (str12a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 13){
if (str13a[n] == "g"){
g += 1;
}
if (str13a[n] == "a"){
a += 1;
}
if (str13a[n] == "t"){
t += 1;
}
if (str13a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 14){
if (str14a[n] == "g"){
g += 1;
}
if (str14a[n] == "a"){
a += 1;
}
if (str14a[n] == "t"){
t += 1;
}
if (str14a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 15){
if (str15a[n] == "g"){
g += 1;
}
if (str15a[n] == "a"){
a += 1;
}
if (str15a[n] == "t"){
t += 1;
}
if (str15a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 16){
if (str16a[n] == "g"){
g += 1;
}
if (str16a[n] == "a"){
a += 1;
}
if (str16a[n] == "t"){
t += 1;
}
if (str16a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 17){
if (str17a[n] == "g"){
g += 1;
}
if (str17a[n] == "a"){
a += 1;
}
if (str17a[n] == "t"){
t += 1;
}
if (str17a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 18){
if (str18a[n] == "g"){
g += 1;
}
if (str18a[n] == "a"){
a += 1;
}
if (str18a[n] == "t"){
t += 1;
}
if (str18a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 19){
if (str19a[n] == "g"){
g += 1;
}
if (str19a[n] == "a"){
a += 1;
}
if (str19a[n] == "t"){
t += 1;
}
if (str19a[n] == "c"){
c += 1;
}
}
if (numbOfStr >= 20){
if (str20a[n] == "g"){
g += 1;
}
if (str20a[n] == "a"){
a += 1;
}
if (str20a[n] == "t"){
t += 1;
}
if (str20a[n] == "c"){
c += 1;
}
}


// print("The cycle is"+ n);
// print("g is"+ g);
// print("a is"+ a);
// print("t is"+ t);
// print("c is"+ c);




if ((g>a)  (g>t)  (g>c)){
	strFinalA.push("g");
}
if ((a>g)  (a>t)  (a>c)){
	strFinalA.push("a");
}
if ((t>a)  (t>g)  (t>c)){
	strFinalA.push("t");
}
if ((c>a)  (c>t)  (c>g)){
	strFinalA.push("c");
}

if ((g==a)  (g>t)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("g");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("a");
}
}
if ((g==t)  (g>a)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("g");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}
if ((g==c)  (g>a)  (g>t)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("g");
}
}


if ((a==t)  (a>g)  (a>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("a");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}
if ((a==c)  (c>g)  (c>t)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("a");
}
}


if ((t==c)  (c>a)  (c>g)){
	randomnumber= Random.value;
	if (randomnumber <= (0.5)){
		strFinalA.push("c");
}
	if (randomnumber > (0.5)) {
		strFinalA.push("t");
}
}

if ((g==a)  (g==t)  (g>c)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("g");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("a");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((c==t)  (c==a)  (c>g)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("a");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("c");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((t==c)  (t==g)  (t>a)){
	randomnumber= Random.value;
	if (randomnumber <= (0.33)){
		strFinalA.push("g");
}
	if ((randomnumber > (0.33))  (randomnumber <= (0.66))){
		strFinalA.push("c");
}
	if (randomnumber > (0.66)) {
		strFinalA.push("t");
}
}
if ((a==c)  (a==g)  (a>t)){
	randomnumber = Random.value;
	if (randomnumber <= 0.33){
		strFinalA.push("g");
}
	if ((randomnumber > 0.33)  (randomnumber <= 0.66)){
		strFinalA.push("c");
}
	if (randomnumber > 0.66) {
		strFinalA.push("a");
}
}
if ((a==c)  (a==g)  (a==t)){
	randomnumber= Random.value;
	if (randomnumber <= 0.25){
		strFinalA.push("g");
}
	if ((randomnumber > 0.25)  (randomnumber <= 0.5)){
		strFinalA.push("c");
}
	if ((randomnumber > 0.5)  (randomnumber <= 0.75)) {
		strFinalA.push("a");
}
	if (randomnumber > 0.75){
		strFinalA.push("t");
}
}

g = 0;
a = 0;
t = 0;
c = 0;
}
if (n==stringLength){
finalString = Array(strFinalA).Join("");

print(n);

}
}