These scripts are made to encode text to mRNA codon sequences and visa-versa.  Use it here.

Encode

This script translates the single letter name of amino acids to the corresponding RNA. You can translate all letters (upper and lower), all numbers, most symbols (excluding ` and forward slash)

Decode

This script translates mRNA into the single letter name for the corresponding amino acid. It has a maximum of 100 codons per run

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>mRNA Encoder/Decoder by Michael Dombrowski | mikedombrowski.com | v1.1.0</title>
</head>

<body>
	<p>These scripts are made to encode text to mRNA codon sequences and visa-versa</p>
	<p>These scripts were completely written by
		<a href="http://mikedombrowski.com">Michael Dombrowski.</a>
	</p>
	<p>&nbsp; &nbsp; &nbsp;
		<a href="mailto:michael@mikedombrowski.com">Email Me Here</a>
	</p>
	<br/>
	<FORM NAME="myform" ACTION="" METHOD="GET">
		Enter what you want to be encoded or decoded. For decode start with the first AUG:
		<INPUT TYPE="text" NAME="inputbox" VALUE="">
		<INPUT TYPE="button" NAME="button" Value="Encode" onClick="encode(this.form)">
		<INPUT TYPE="button" NAME="button" Value="Decode" onClick="decode(this.form)">
	</FORM>
	<input type="button" onclick="toggle_visibility('1');;" value="More about encoding mRNA" />
	<input type="button" onclick="toggle_visibility('2');" value="More about decoding mRNA" />
	<div id="1" style="display:none">
		<p>This script translates the single letter name of amino acids to the corresponding RNA. You can translate all letters (upper
			and lower), all numbers, most symbols (excluding ` and forward slash)</p>
	</div>
	<div id="2" style="display:none">
		<p>This script translates mRNA into the single letter name for the corresponding amino acid. It has a maximum of 100 codons
			per run</p>
	</div>
	<div>
		<p id="description"></p>
		<p id="resultArea"></p>
		<button style="display:none" id="clearBtn">Clear</button>
	</div>
	<script type="text/javascript">
		function toggle_visibility(id) {
			var e = document.getElementById(id);
			if (e.style.display == 'none') {
				e.style.display = 'block';
			} else {
				e.style.display = 'none'
			};
		}
	</script>
	<script type="text/javascript">
		var resultArea = document.getElementById("resultArea");
		var descriptionDiv = document.getElementById("description");

		document.getElementById("clearBtn").onclick = function () {
			resultArea.innerText = "";
			descriptionDiv.innerText = "";
			document.getElementsByName("myform")[0].inputbox.value = "";
			document.getElementById("clearBtn").style.display = "none";
		};

		function decode(form) {
			let RNA1 = form.inputbox.value;
			let RNA = RNA1.toUpperCase();
			let start = 3;
			let stop = 6;
			let result = new Array();

			descriptionDiv.innerHTML =
				'This script translates mRNA into the single letter name for the corresponding amino acid. It has a maximum of 100 codons per run <br/>Your input &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' +
				RNA;
			resultArea.innerText = "Your decoded RNA --- ";

			if (RNA.substring(0, 3) !== 'AUG') {
				alert('You did not start with the first AUG codon!');
			} else {
				result.push('M/Start');
			}

			for (let i = 0; i <= 100; i++) {
				switch (RNA.substring(start, stop)) {
					case '"B"':
						result.push("B");
						break;
					case '"O"':
						result.push('O');
						break;
					case '"X"':
						result.push('X');
						break;
					case '"J"':
						result.push('J');
						break;
					case '"U"':
						result.push('U');
						break;
					case '"Z"':
						result.push('Z');
						break;
					case 'AUG':
						result.push('M');
						break;
					case 'UUU':
						result.push('F');
						break;
					case 'UUC':
						result.push('F');
						break;
					case 'UUG':
						result.push('L');
						break;
					case 'UUA':
						result.push('L');
						break;
					case 'CUU':
						result.push('L');
						break;
					case 'CUC':
						result.push('L');
						break;
					case 'CUA':
						result.push('L');
						break;
					case 'CUG':
						result.push('L');
						break;
					case 'AUU':
						result.push('I');
						break;
					case 'AUC':
						result.push('I');
						break;
					case 'AUA':
						result.push('I');
						break;
					case 'GUU':
						result.push('V');
						break;
					case 'GUC':
						result.push('V');
						break;
					case 'GUA':
						result.push('V');
						break;
					case 'GUG':
						result.push('V');
						break;
					case 'UCU':
						result.push('S');
						break;
					case 'AUA':
						result.push('I');
						break;
					case 'UCC':
						result.push('S');
						break;
					case 'UCA':
						result.push('S');
						break;
					case 'UCG':
						result.push('S');
						break;
					case 'CCU':
						result.push('P');
						break;
					case 'CCC':
						result.push('P');
						break;
					case 'CCA':
						result.push('P');
						break;
					case 'CCG':
						result.push('P');
						break;
					case 'ACU':
						result.push('T');
						break;
					case 'ACC':
						result.push('T');
						break;
					case 'ACA':
						result.push('T');
						break;
					case 'ACG':
						result.push('T');
						break;
					case 'GCU':
						result.push('A');
						break;
					case 'GCC':
						result.push('A');
						break;
					case 'GCA':
						result.push('A');
						break;
					case 'GCG':
						result.push('A');
						break;
					case 'UAU':
						result.push('Y');
						break;
					case 'UAC':
						result.push('Y');
						break;
					case 'CAU':
						result.push('H');
						break;
					case 'CAC':
						result.push('H');
						break;
					case 'CAA':
						result.push('Q');
						break;
					case 'CAG':
						result.push('Q');
						break;
					case 'AAU':
						result.push('N');
						break;
					case 'AAC':
						result.push('N');
						break;
					case 'AAA':
						result.push('K');
						break;
					case 'AAG':
						result.push('K');
						break;
					case 'GAU':
						result.push('D');
						break;
					case 'GAC':
						result.push('D');
						break;
					case 'GAA':
						result.push('E');
						break;
					case 'GAG':
						result.push('E');
						break;
					case 'UGU':
						result.push('C');
						break;
					case 'UCA':
						result.push('S');
						break;
					case 'UGC':
						result.push('C');
						break;
					case 'UGG':
						result.push('W');
						break;
					case 'CGU':
						result.push('R');
						break;
					case 'CGC':
						result.push('R');
						break;
					case 'CGA':
						result.push('R');
						break;
					case 'CGG':
						result.push('R');
						break;
					case 'AGU':
						result.push('S');
						break;
					case 'AGC':
						result.push('S');
						break;
					case 'AGA':
						result.push('R');
						break;
					case 'UCA':
						result.push('S');
						break;
					case 'AGG':
						result.push('R');
						break;
					case 'GGU':
						result.push('G');
						break;
					case 'GGC':
						result.push('G');
						break;
					case 'GGA':
						result.push('G');
						break;
					case 'GGG':
						result.push('G');
						break;
					case ' ':
						result.push(' ');
						start -= 2;
						stop -= 2;
						break;
					default:
						console.error("Uknown codon", RNA.substring(start, stop));
						break;
				}
				start += 3;
				stop += 3;
			}

			if (RNA.substring(start, stop) == 'UAA') {
				result.push('Stop. Please input starting at the next AUG and run again.');
			}
			if (RNA.substring(start, stop) == 'UAG') {
				result.push('Stop. Please input starting at the next AUG and run again.');
			}
			if (RNA.substring(start, stop) == 'UGA') {
				result.push('Stop. Please input starting at the next AUG and run again.');
			}

			resultArea.innerText += result;
			document.getElementById("clearBtn").style.display = "block";
		}
		//                   ,--.               ,----..                           
		//    ,---,.       ,--.'|  ,----..     /   /   \      ,---,        ,---,. 
		//  ,'  .' |   ,--,:  : | /   /   \   /   .     :   .'  .' `\    ,'  .' | 
		//,---.'   |,`--.'`|  ' :|   :     : .   /   ;.  \,---.'     \ ,---.'   | 
		//|   |   .'|   :  :  | |.   |  ;. /.   ;   /  ` ;|   |  .`\  ||   |   .' 
		//:   :  |-,:   |   \ | :.   ; /--` ;   |  ; \ ; |:   : |  '  |:   :  |-, 
		//:   |  ;/||   : '  '; |;   | ;    |   :  | ; | '|   ' '  ;  ::   |  ;/| 
		//|   :   .''   ' ;.    ;|   : |    .   |  ' ' ' :'   | ;  .  ||   :   .' 
		//|   |  |-,|   | | \   |.   | '___ '   ;  \; /  ||   | :  |  '|   |  |-, 
		//'   :  ;/|'   : |  ; .''   ; : .'| \   \  ',  / '   : | /  ; '   :  ;/| 
		//|   |    \|   | '`--'  '   | '/  :  ;   :    /  |   | '` ,/  |   |    \ 
		//|   :   .''   : |      |   :    /    \   \ .'   ;   :  .'    |   :   .' 
		//|   | ,'  ;   |.'       \   \ .'      `---`     |   ,.'      |   | ,'   
		//`----'    '---'          `---`                  '---'        `----'     

		function encode(form) {
			let arr;
			let RNA = form.inputbox.value;
			let start = 0;
			let stop = 1;

			descriptionDiv.innerHTML =
				'This script translates the single letter name of amino acids to the corresponding RNA.  You can translate all letters (upper and lower), all numbers, most symbols (excluding ` and forward slash) The many "A"s at the end is the poly-A tail and is added for accuracy<br/>Your input is --- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' +
				RNA;
			resultArea.innerText = 'Your encoded RNA --- AUG';

			const randChoice = (arr) => {
				return arr[Math.floor(Math.random() * arr.length)];
			};

			for (let i = 0; i <= 50; i++) {
				switch (RNA.toUpperCase().substring(start, stop)) {
					case ' ':
						break;
					case 'M':
						resultArea.innerText += "AUG";
						break;
					case 'F':
						arr = ['UUC', 'UUU'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'L':
						arr = ['UUG', 'UUA', 'CUU', 'CUC', 'CUA', 'CUG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'I':
						arr = ['AUU', 'AUC', 'AUA'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'V':
						arr = ['GUU', 'GUC', 'GUA', 'GUG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'P':
						arr = ['CCU', 'CCC', 'CCA', 'CCG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'T':
						arr = ['ACU', 'ACC', 'ACA', 'ACG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'A':
						arr = ['GCU', 'GCC', 'GCA', 'GCG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'Y':
						arr = ['UAU', 'UAC'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'H':
						arr = ['CAU', 'CAC'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'Q':
						arr = ['CAA', 'CAG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'N':
						resultArea.innerText += 'AAU';
						break;
					case 'K':
						resultArea.innerText += 'AAA';
						break;
					case 'D':
						arr = ['GAU', 'GAC'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'E':
						arr = ['GAA', 'GAG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'C':
						resultArea.innerText += 'UGU';
						break;
					case 'W':
						resultArea.innerText += 'UGG';
						break;
					case 'R':
						arr = ['CGU', 'CGC', 'CGA', 'CGG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'S':
						arr = ['UCU', 'UCC', 'UCA', 'UCG', 'AGU', 'AGC'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'G':
						arr = ['GGU', 'GGC', 'GGA', 'GGG'];
						resultArea.innerText += randChoice(arr);
						break;
					case 'B':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'J':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'O':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'Q':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'U':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'X':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;
					case 'Z':
						resultArea.innerText += '"' + RNA.substring(start, stop) + '"';
						break;

						//symbols
					case '`':
						resultArea.innerText += '"`"';
						break;
					case '~':
						resultArea.innerText += '"~"';
						break;

					case '<':
						resultArea.innerText += '&lt';
						break;
					case '>':
						resultArea.innerText += '&gt';
						break;

					default:
						resultArea.innerText += RNA.substring(start, stop);
						break;
				}

				start++;
				stop++;
			}
			resultArea.innerText += 'UAAAAAAAAAAAAAAAA';
			document.getElementById("clearBtn").style.display = "block";
		}
	</script>
	<center>
		<p>&copy; 2011 Michael Dombrowski, Some Rights Reserved</p>
		<p>
			<a href="http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en">Creative Commons Attribution-NonCommercial-ShareAlike</a>
		</p>
		<p>
			<a href="http://mikedombrowski.com">http://mikedombrowski.com</a> | mRNA Encoder/Decoder v1.1.0</p>
	</center>
</body>

</html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.