Advertisement
Hugo7

mRNA -> protein translation

Feb 11th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.89 KB | None | 0 0
  1. <head>
  2. <style>
  3. body {
  4.     font-family:Monospace;
  5.     font-size:20;
  6. }
  7. </style>
  8. <script>
  9. function adn() {
  10.     location.href = "adn.php";
  11. }
  12. function arn() {
  13.     location.href = "arn.php";
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19. <?php
  20. for ($i = 1; $i <= 10; $i++) {
  21.     $str[$i] = htmlspecialchars($_POST['in'.$i]);
  22. }
  23.  
  24. if (!$str[1] == null) {
  25.     goto c;              // Si le formulaire a déjà été rempli, on n'affiche pas le formulaire
  26. }
  27. echo "
  28. <form action='prot.php' method='post'>
  29.     Collez les s&eacute;quences ARNm à traduire ici : <br/>
  30.     <input name=in1 type=textarea /><br/>
  31.     <input name=in2 type=textarea /><br/>
  32.     <input name=in3 type=textarea /><br/>
  33.     <input name=in4 type=textarea /><br/>
  34.     <input name=in5 type=textarea /><br/>
  35.     <input name=in6 type=textarea /><br/>
  36.     <input name=in7 type=textarea /><br/>
  37.     <input name=in8 type=textarea /><br/>
  38.     <input name=in9 type=textarea /><br/>
  39.     <input name=in10 type=textarea /><br/>
  40.     <br/>
  41.     <input type=submit value=Traduire! /><br/>
  42. </form>
  43. <br/><br/><br/><br/>Autres fonctions : <br/>
  44. <input type=button onClick='adn();' value='Comparer des séquences ADN' /><br/>
  45. <input type=button onClick='arn();' value='Transcrire ADN en ARN' /><br/>
  46. ";
  47.  
  48. c: //pour goto
  49.  
  50. if ($str[1] == null) {
  51.     exit();              // Si le formulaire n'a pas été rempli, exit
  52. }
  53.  
  54. //liste des codons valides, sauf les codons stop :
  55. $liste1 = array(
  56. "AAA" => "Lys",
  57. "AAC" => "Asn",
  58. "AAG" => "Lys",
  59. "AAU" => "Asn",
  60. "ACA" => "Thr",
  61. "ACC" => "Thr",
  62. "ACG" => "Thr",
  63. "ACU" => "Thr",
  64. "AGA" => "Arg",
  65. "AGC" => "Ser",
  66. "AGG" => "Arg",
  67. "AGU" => "Ser",
  68. "AUA" => "Ile",
  69. "AUC" => "Ile",
  70. "AUG" => "Met",
  71. "AUU" => "Ile",
  72. "CAA" => "Gln",
  73. "CAC" => "His",
  74. "CAG" => "Gln",
  75. "CAU" => "His",
  76. "CCA" => "Pro",
  77. "CCC" => "Pro",
  78. "CCG" => "Pro",
  79. "CCU" => "Pro",
  80. "CGA" => "Arg",
  81. "CGC" => "Arg",
  82. "CGG" => "Arg",
  83. "CGU" => "Arg",
  84. "CUA" => "Leu",
  85. "CUC" => "Leu",
  86. "CUG" => "Leu",
  87. "CUU" => "Leu",
  88. "GAA" => "Glu",
  89. "GAC" => "Asp",
  90. "GAG" => "Glu",
  91. "GAU" => "Asp",
  92. "GCA" => "Ala",
  93. "GCC" => "Ala",
  94. "GCG" => "Ala",
  95. "GCU" => "Ala",
  96. "GGA" => "Gly",
  97. "GGC" => "Gly",
  98. "GGG" => "Gly",
  99. "GGU" => "Gly",
  100. "GUA" => "Val",
  101. "GUC" => "Val",
  102. "GUG" => "Val",
  103. "GUU" => "Val",
  104.  
  105. "UAC" => "Tyr",
  106.  
  107. "UAU" => "Tyr",
  108. "UCA" => "Ser",
  109. "UCC" => "Ser",
  110. "UCG" => "Ser",
  111. "UCU" => "Ser",
  112.  
  113. "UGC" => "Cys",
  114. "UGG" => "Trp",
  115. "UGU" => "Cys",
  116. "UUA" => "Leu",
  117. "UUC" => "Phe",
  118. "UUG" => "Leu",
  119. "UUU" => "Phe"
  120. );
  121.  
  122. for ($i = 1; $i <= 10; $i++) {
  123.     // echo $i; //debug
  124.     $str_fin[$i] = null;
  125.     $str_cur[$i] = $str[$i];
  126.     while (!$str_cur[$i] == null) {
  127.         $str_tmp[$i] = substr($str_cur[$i], 0, 3); //ATGCCTGGCTA : prend ATG
  128.         $str_cur[$i] = substr($str_cur[$i], 3); //ATGCCTGGCTA : prend CCTGGCTA (le reste)
  129.         // echo "cur:".$str_cur[$i]." tmp:".$str_tmp[$i]."<br/>"; //debug
  130.         if ($str_tmp[$i] == "UGA" || $str_tmp[$i] == "UAG" || $str_tmp[$i] == "UAA") {
  131.             echo "<br/>Codon stop détecté : ".$str_tmp[$i]." dans la chaîne numéro ".$i."<br/>";
  132.             break; // Si codon stop, on arrête le while
  133.         }
  134.         foreach ($liste1 as $A => $B) {
  135.             // echo $A.$B.$str_tmp[$i].$str_fin[$i]."<br/>"; //debug
  136.             if ($str_tmp[$i] == $A) {
  137.                 $str_fin[$i] = $str_fin[$i].$B;
  138.             }
  139.             if (!strlen($str_tmp[$i]) == 3) {
  140.                 $str_fin[$i] = $str_fin[$i]."<font color='red'>ERR</font>";
  141.             }
  142.         }
  143.         //echo $str_fin[$i]; //debug
  144.     }
  145. }
  146.  
  147. // Affichage
  148. if (!$str[1] == null) {
  149.     echo "Traitement terminé <br/><br/><u>Affichage des séquences ARN et peptidiques :</u><br/>";
  150.     for ($i = 1; $i <=10; $i++) {
  151.         if (!$str[$i] == null) {
  152.             echo "<br/>".$str[$i]."<br/>".$str_fin[$i]."<br/>";
  153.         }
  154.     }
  155. }
  156.  
  157.  
  158.  
  159. ?>
  160. <br/>
  161. <small>Cr&eacute;&eacute; par Hugo en php - (c) hugoland.fr<br/>
  162. Code source (pour les curieux...) <a href="http://pastebin.com/ZdGyVb8G">ici</a></small>
  163. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement