python 3 cleaner code, calculating values from dictionary
Question: Currently my code is working and usable but I think there are a few lines of
code that I do not need. I am inputting a sequence (of DNA) and having the
code calculate some values and returning the values to me. I input the
sequence, and then a concentration, and the melting temperature, dH, dS, and
dG returned to me. Just posting to see if there is any way I could have the
code cleaned up or if you guys think it is good as is. This is for python3 as
well. Thanks for the help!

    
    
    import math
    sequence1 = input("Enter DNA Sequence: ")
    sequence2 = [i for i in sequence1[0::1]]
    sequenceR = [i for i in sequence2[::-1]]
    dnac = input("Enter DNA Concentration (M): ") #Effectively Ct
    dnac = float(dnac)
    #assume 1M NaOH, though this adjustment is easy to establish if necessary.
    first = sequence1[0]
    last = sequence1[-1]
    sequence = [i+j for i,j in zip(sequence1[0::1], sequence1[1::1])]
    
    navbles={       "AA": (-7.9     ,-22.2  ,-1.0),
                            "TT": (-7.9     ,-22.2  ,-1.0),
                            "AT": (-7.2     ,-20.4  ,-0.88),
                            "TA": (-7.2     ,-21.3  ,-0.58),
                            "CA": (-8.5     ,-22.7  ,-1.45),
                            "TG": (-8.5     ,-22.7  ,-1.45),
                            "GT": (-8.4     ,-22.4  ,-1.44),
                            "AC": (-8.4     ,-22.4  ,-1.44),
                            "CT": (-7.8     ,-21.0  ,-1.28),
                            "AG": (-7.8     ,-21.0  ,-1.28),
                            "GA": (-8.2     ,-22.2  ,-1.30),
                            "TC": (-8.2     ,-22.2 ,-1.30),
                            "CG": (-10.6 ,-27.2     ,-2.17),
                            "GC": (-9.8     ,-24.4  ,-2.24),
                            "GG": (-8.0     ,-19.9  ,-1.84),
                            "CC": (-8.0     ,-19.9  ,-1.84),
                            "A" : (0        , 0     ,               0),
                            "C" : (0        , 0     ,               0),
                            "G" : (0        , 0     ,               0),
                            "T" : (0        , 0 ,           0),     }
    initiator={     "G": (0.1 ,-2.8,        0.98),
                            "C": (0.1 ,-2.8,        0.98),
                            "A": (2.3, 4.1, 1.03),
                            "T": (2.3, 4.1, 1.03) }
    
    complement = {'A' : 'T', 'T' : 'A', 'G' : 'C', 'C' : 'G'}
    
    #First and last terms, to start off
    F1 = initiator[first]
    L1 = initiator[last]
    dH1 = F1[0]
    dH2 = L1[0]
    dS1 = F1[1]
    dS2 = L1[1]
    dG1 = F1[2]
    dG2 = L1[2]
    
    R = 1.987 #cal mol K
    #answer = (dH1/(dS1 + R*C))+(dH2/(dS2 + R*C))
    answerH = dH1 + dH2
    answerS = dS1 + dS2
    answerG = dG1 + dG2
    #the iterative meat
    for na in range(len(sequence)):
            n = navbles[sequence[na]]
            H = n[0]
            S = n[1]
            G = n[2]
            #answer = answer + (H/(S + R*C))
            answerG = answerG + G
            answerH = answerH + H
            answerS = answerS + S
    
    #symmetry check
    if sequenceR == sequence2:
            symm = "y"
    else:
            symm = "n"
    if symm == "y":
            answerS = answerS + -1.4
    else:
            pass
    #complementary check
    sequenceC = []
    for i in range(len(sequenceR)):
            sequenceC.append(complement[sequenceR[i]])
    
    if sequenceC == sequence2:
            comp = "y"
    else:
            comp = "n"
    
    if comp == "n":
            C = math.log(dnac / 4)
    else:
            C = math.log(dnac)
    #print(C)
    answerT = (1000*answerH)/(answerS + R*C)
    print('Tm =', answerT)
    print('dH(kcal) = ', answerH)
    print('dS(cal) = ', answerS)
    print('dG(kcal) = ', answerG)
    
    #print(sequence1)
    


Answer: I think this looks fine. You could always refactor for performance if you plan
on applying it to really large databases in the future, but sometimes a
straight forward approach is all it takes to get the job done.

