Guest User

Tm based on Nearest Neighbor, monovalent ion, Mg2+, dNTP DNA

a guest
Feb 8th, 2013
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. #advanced Tm calculation
  6. #nearest-neighbour thermedynamics calculation of melting temperature
  7. #corrected for monovalent ion, Mg+2, dNTP and even DMSO concentrations
  8. #Credits:
  9. #Main author: Ogan ABAAN <[email protected]>
  10. #Overcount function: Greg Singer <[email protected]>
  11.  
  12. from math import log
  13.  
  14. def olcount(s, pattern):
  15. """Returns how many pattern on s, works for overlapping"""
  16. count= 0
  17. x= 0
  18. while 1:
  19. try:
  20. i= s.index(pattern,x)
  21. except ValueError:
  22. break
  23. count+= 1
  24. x= i+1
  25. return count
  26.  
  27.  
  28.  
  29. def Tm(s, dna=250, Na=50, K=0, Tris=0, Mg=1.5, dNTP=0.2, DMSO=0):
  30.  
  31. """
  32. ### THE PCR BUFFER/REACTION CONDITIONS FOR CALCULATING ION CONCETRATIONS ###
  33. # dna the oligo concentration (nM)
  34. # Na the Na+ concentration (mM)
  35. # K the K+ concetration (mM)
  36. # Tris the Tris+ concentration (mM)
  37. # Mg the Mg+2 concentration (mM)
  38. # dNTP the dNTP concentration (mM)
  39. # DMSO correction for DMSO (%)
  40. """
  41.  
  42. # NN parameters in 1M NaCl (SantaLucia J, PNAS, 1998)
  43. # deltaH (1nd column unit in kcal/mol)
  44. # deltaS (2rd column unit in cal/mol K)
  45. deltaHS= {'AA': [-7.9, -22.2],\
  46. 'TT': [-7.9, -22.2],\
  47. 'AT': [-7.2, -20.4],\
  48. 'TA': [-7.2, -21.3], \
  49. 'CA': [-8.5, -22.7], \
  50. 'TG': [-8.5, -22.7], \
  51. 'GT': [-8.4, -22.4], \
  52. 'AC': [-8.4, -22.4], \
  53. 'CT': [-7.8, -21.0], \
  54. 'AG': [-7.8, -21.0], \
  55. 'GA': [-8.2, -22.2], \
  56. 'CG': [-10.6, -27.2], \
  57. 'GC': [-9.8, -24.4], \
  58. 'GG': [-8.0, -19.9], \
  59. 'CC': [-8.0, -19.9], \
  60. 'TC': [-8.2, -22.2]}
  61.  
  62.  
  63. s= s.upper()
  64.  
  65. # Molar concentration of all monovalent ions
  66. # (Owczarzy R, Biochemistry, 2008)
  67. Mon= (Na + K + Tris / 2.0) / 1000.0
  68.  
  69. # Molar concentration for non-self complementary oligonucleotide
  70. # (SantaLucia J, PNAS, 1998)
  71. Ct= (dna / 4.0) * 1e-9
  72.  
  73. # Molar concentration of free Mg+2
  74. # (Owczarzy R, Biochemistry, 2008)
  75. fMg= (Mg - dNTP) / 1000.0
  76.  
  77. if Mon > 0:
  78. ionR= fMg ** 0.5 / Mon
  79. #print 'Ion ratio is', ionR
  80.  
  81. # calculate faction of GC
  82. fGC= float(s.count('G') + s.count('C')) / len(s)
  83.  
  84. # DMSO correction
  85. # take the average of all four coefficients previously published
  86. # (von Ahsen N, Clin Chem, 2000)
  87. DMSO_coeff= (0.75 + 0.6 + 0.675 +0.5) / 4
  88. # 1% DMSO reduces Tm by DMSO_coeff
  89. dmso= DMSO_coeff*DMSO
  90.  
  91. # double check for the 'fit-model' for criteria and range
  92. if Mon == 0 or Mg == 0:
  93. pass
  94. elif 1e-10 <= (dna*1e-9) <= 0.1 and 7 < len(s) < 61 and 0.015 <= Mon <= 1.2 and 0.01 <= Mg < 600 and dNTP <= (Mg*1.2):
  95. pass
  96. else:
  97. print 'buffer/DNA conditions out of range for calculation'
  98. return
  99.  
  100.  
  101. # collect the NN values for dh and ds
  102. dh = list()
  103. ds = list()
  104. # First, terminal base corrections
  105. if s[0]=='G' or s[0]=='C':
  106. dh.append(0.1)
  107. ds.append(-2.8)
  108. elif s[0]=='A' or s[0]=='T':
  109. dh.append(2.3)
  110. ds.append(4.1)
  111. if s[-1]=='G' or s[-1]=='C':
  112. dh.append(0.1)
  113. ds.append(-2.8)
  114. elif s[-1]=='A' or s[-1]=='T':
  115. dh.append(2.3)
  116. ds.append(4.1)
  117.  
  118. # now the rest of the sequence
  119. for keys in deltaHS:
  120. H, S = deltaHS[keys]
  121. dh.append(olcount(s, keys) * H)
  122. ds.append(olcount(s, keys) * S)
  123.  
  124. Rconst= 1.987 #gas constant in cal/mol K
  125. # this is the deltaG value calculated in Kelvin
  126. tmNN= 1000 * sum(dh) / (sum(ds) + (Rconst * log(Ct)))
  127.  
  128.  
  129. # now correct for ion composition
  130. # Decision tree based on Owczarzy R, Biochemistry, 2008
  131. if Mon == 0 or (Mon != 0 and ionR >= 6.0):
  132. # incorporate Mg correction
  133. # (Owczarzy R, Biochemistry, 2008)
  134. # various constants (1/K)
  135. Va= 3.92e-5
  136. Vb= -9.11e-6
  137. Vc= 6.26e-5
  138. Vd= 1.42e-5
  139. Ve= -4.82e-4
  140. Vf= 5.25e-4
  141. Vg= 8.31e-5
  142.  
  143. # calculate tm in K
  144. Ktm= (1 / tmNN) + Va +\
  145. (Vb * log(fMg)) +\
  146. (fGC * (Vc + Vd * log(fMg))) +\
  147. ((Ve + Vf * log(fMg) + (Vg * (log(fMg)) ** 2)) / (2 * (len(s) - 1)))
  148.  
  149. elif Mon != 0 and ionR < 0.22:
  150. # incorporate salt correction (for all monovalent ions)
  151. # (OwczarzyR, Biochemistry, 2004)
  152. # calculate tm in K
  153. Ktm= (1 / tmNN) +\
  154. (4.29 * fGC - 3.95) * 1e-5 * log(Mon) +\
  155. 9.40 * 1e-6 * log(Mon) ** 2
  156.  
  157. elif Mon != 0 and 0.22 <= ionR < 6.0:
  158. # incorporate Mg correction
  159. # (OwczarzyR, Biochemistry, 2008)
  160. # various constants (1/K) corrected for Mon+ as well
  161. Va= 3.92e-5 * (0.843 - (0.352 * Mon ** 0.5 * log(Mon)))
  162. Vb= -9.11e-6
  163. Vc= 6.26e-5
  164. Vd= 1.42e-5 * (1.279 - 4.03e-3 * log(Mon) - 8.03e-3 * log(Mon) ** 2)
  165. Ve= -4.82e-4
  166. Vf= 5.25e-4
  167. Vg= 8.31e-5 * (0.486 - 0.258 * log(Mon) + 5.25e-3 * log(Mon) ** 3)
  168.  
  169. # calculate tm in K
  170. Ktm= (1 / tmNN) + Va +\
  171. (Vb * log(fMg)) +\
  172. (fGC * (Vc + Vd * log(fMg))) +\
  173. ((Ve + Vf * log(fMg) + (Vg * (log(fMg)) ** 2)) / (2 * (len(s) - 1)))
  174.  
  175. else:
  176. print "error in Tm calculation"
  177. return
  178.  
  179. # return Tm in degrees C
  180. return 1 / Ktm - 273.15 - dmso
  181.  
  182.  
  183.  
  184.  
  185. if __name__ == '__main__':
  186. # a test case
  187. print Tm("ACGGAGAGGGATGGCATG", dna=10, Na=200, dNTP=0.1, Mg=10.0, Tris=10, K=10, DMSO=5)
Advertisement
Add Comment
Please, Sign In to add comment