# CS 423 lab 5 starter code for experiment
# This code should generate two randomly composed DNA sequences of various
# lengths and run the globalAlignment and localAlignment algorithms
# Authors:
####################################################################

import globalAlignment
#import localAlignment   ## comment out once you have this module working

# this is how you call code defined in other files: modulename.functionname
# note that importing globalAlignment above will run the script in its
# entirety, so you may want to comment out any testing code at the bottom
# of that script, so it is not executed prior to the code below
s = "AGAAAAAAAACTA"
t = "TGCATCAAAG"
optimalScore = globalAlignment.globalAlignmentScore(s, t)
print ("Global alignment score: " + str(optimalScore))

# update this code so that it does the following:

# generates randomly composed DNA sequences (25%A, 25%C, 25%T, 25%G)
# of length N and returns it as a string
def randomSeq(N):
    return ""

# runs the following experiment:
# From size Start to Stop going by Step:
#     Generate 2 random DNA strings of length size
#     Calculate the global alignment score between the two strings
#     Calculate the local alignment score between the two strings
#     Write results to file per line
        elif ran < 0.50:
            seq += "T"
        elif ran < 0.75:
            seq += "C"
        else:
            seq += "G"
    return seq

########
# Timing experiment
# creates two random sequences of same length
# calculates time to find the optimal score
# writes the results to a file
# repeats for sequences of length 50 to 5000 stepping by 50
########
with open("longTimingExperiment.txt", 'w') as out:
    for N in range(50, 5001, 50):
        # generate two random sequences
        ranSeq1 = randomSeq(N)
        ranSeq2 = randomSeq(N)

        # start clock and find global score
        t0 = time.clock()
        optimalScore = globalAlignment.globalAlignmentScore(ranSeq1, ranSeq2)
        t1 = time.clock()
        
        # print the time results to the file
        totalTime = str(t1-t0)
        print("Seq Len: %d\tTotal time: %s" % (N, totalTime))
        out.write("%d\t%s\n" % (N, totalTime))