Advertisement
BobMe

Biology calculator?

Apr 17th, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. function translate(str)
  2. r = ""
  3. if str == "UUU" then
  4. r = "Phenylalanine"
  5. elseif str == "UUC" then
  6. r = "Phenylalanine"
  7. elseif str == "UUA" then
  8. r = "Leucine"
  9. elseif str == "UUG" then
  10. r = "Leucine"
  11. elseif str == "CUU" then
  12. r = "Leucine"
  13. elseif str == "CUC" then
  14. r = "Leucine"
  15. elseif str == "CUA" then
  16. r = "Leucine"
  17. elseif str == "CUG" then
  18. r = "Leucine"
  19. elseif str == "AUU" or str == "AUC" or str == "AUA" then
  20. r = "Isoleucine"
  21. elseif str == "AUG" then
  22. r = "Start or Methionine"
  23. elseif str == "GUU" or str == "GUC" or str == "GUA" or str == "GUG" then
  24. r = "Valine"
  25. elseif str == "UCU" or str == "UCC" or str == "UCA" or str == "UCG" then
  26. r = "Serine"
  27. elseif str == "CCU" or str == "CCC" or str == "CCA" or str == "CCG" then
  28. r = "Proline"
  29. elseif str == "ACU" or str == "ACC" or str == "ACA" or str == "ACG" then
  30. r = "Threonine"
  31. elseif str == "GCU" or str == "GCC" or str == "GCA" or str == "GCG" then
  32. r = "Alanine"
  33. elseif str == "UAU" or str == "UAC" then
  34. r = "Tyrosine"
  35. elseif str == "UAA" or str == "UAG" then
  36. r = "Stop"
  37. elseif str == "CAU" or str == "CAC" then
  38. r = "Histidine"
  39. elseif str == "CAA" or str == "CAG" then
  40. r = "Glutamine"
  41. elseif str == "AAU" or str == "AAC" then
  42. r = "Asparagine"
  43. elseif str == "AAA" or str == "AAG" then
  44. r = "Lysine"
  45. elseif str == "GAU" or str == "GAC" then
  46. r = "Aspartic Acid"
  47. elseif str == "GAA" or str == "GAG" then
  48. r = "Glutamic Acid"
  49. elseif str == "UGU" or str == "UGC" then
  50. r = "Cysteine"
  51. elseif str == "UGA" then
  52. r = "Stop"
  53. elseif str == "UGG" then
  54. r = "Tryptophan"
  55. elseif str == "CGU" or str == "CGC" or str == "CGA" or str == "CGG" then
  56. r = "Arginine"
  57. elseif str == "AGU" or str == "ACC" then
  58. r = "Serine"
  59. elseif str == "AGA" or str == "AGG" then
  60. r = "Arginine"
  61. elseif str == "GGU" or str == "GGC" or str == "GGA" or str == "GGG" then
  62. r = "Glycine"
  63. end
  64. return r
  65. end
  66.  
  67. function intrans(word)
  68. if #word ~= 3 then
  69. return nil
  70. end
  71. local function trans(let)
  72. local kek = ""
  73. let = let:lower()
  74. if let == "a" then
  75. kek = "U"
  76. elseif let == "t" then
  77. kek = "A"
  78. elseif let == "c" then
  79. kek = "G"
  80. elseif let == "g" then
  81. kek = "C"
  82. end
  83. return kek
  84. end
  85. a = trans(string.sub(word,1,1))
  86. b = trans(string.sub(word,2,2))
  87. c = trans(string.sub(word,3,3))
  88. combine = a..b..c
  89. return combine
  90. end
  91.  
  92. function begin(seq)
  93. local mrna = ""
  94. local protein = ""
  95. g = string.sub(seq,#seq,#seq)
  96. if g ~= " " then
  97. seq = seq.." "
  98. end
  99. for i=1,#seq do
  100. if string.sub(seq,i,i) == " " then
  101. local a = string.sub(seq,i-3,i-3)
  102. local b = string.sub(seq,i-2,i-2)
  103. local c = string.sub(seq,i-1,i-1)
  104. local abc = a..b..c
  105. local abcc = intrans(abc)
  106. local abca = translate(abcc)
  107. if i ~= 4 then
  108. protein = protein..", "..abca
  109. mrna = mrna.." "..abcc
  110. else
  111. protein = protein..abca
  112. mrna = mrna..abcc
  113. end
  114. end
  115. end
  116. return {mrna,protein}
  117. end
  118.  
  119. function prin(tab)
  120. mrna = tab[1]
  121. protein = tab[2]
  122. print("mRNA : "..mrna.."\nProtein : "..protein)
  123. end
  124.  
  125. prin(begin("TTT TTC TTA TTG CTC CTA CTG CTT ATT ATC ATA ATG GTT GTC GTA GTG TCT TCC TCA TCG CCT CCC CCA CCG ACT ACC ACA ACG ACT GCC GCA GCG TAT TAC TAA TAG CAT CAC CAA CAG AAT AAC AAA AAG GAT GAC GAA GAG TGT TGC TGA TGG CGT CGC CGA CGGAGT ACC AGA AGG GGT GGC GGA GGG"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement