Codon

From Esolang
Jump to navigation Jump to search

Codon is an esolang created by User:Dtp09. It has about the same concept as RNA with a different syntax. Codon uses mRNA as programs that are read as codons and amino acids which function as opcodes.

Protein Synthesis and RNA

Protein synthesis is a biological process within cells that takes genes from DNA and synthesizes proteins with said genes. Proteins are comprised of many amino acids bound together via peptide bonds. DNA within the nucleus gets copied into single-stranded RNA that carries the information for which amino acids belong in the protein and in what order.

The basic process looks like this:

  1. RNA Polymerase transcribes a group of DNA into mRNA.
  2. mRNA exits the nucleus and enters into a ribosome.
  3. tRNA translates groups of three nucleotides in the mRNA (known as codons) into amino acids.
  4. The amino acids bind to each other as translation happens.
  5. Once there is a "Stop" codon, the protein stops being synthesized.

This idea of certain combinations of codons referring to certain amino acids is what the language is about. The genetic info you type in is read as codons, and the amino acids corresponding are treated as opcodes and operands in a program.

Codon Chart

You can also search one up if you don't like this one.

First Base Second Base Third Base
U C A G
U Phenylalanine Serine Tyrosine Cysteine U
C
Leucine Stop Stop A
Tryptophan G
C Leucine Proline Histidine Arginine U
C
Glutamine A
G
A Isoleucine Threonine Asparagine Serine U
C
Lysine Arginine A
Methionine G
G Valine Alanine Aspartic Acid Glycine U
C
Glutamic Acid A
G

Language

Syntax

  • Whitespaces are ignored
  • Line comments can be declared with #
  • Base letters are case insensitive
  • The only characters allowed outside of a comment are U, C, A, G and whitespaces.
  • Anything not between the first Methionine codon and the first Stop codon will be ignored.

Structure

Codon is a cell-based language. The cells can hold any decimal number. Codon also has two special registers, A and B, and a comparison flag.

Opcodes

# Amino Acid Description
0 Alanine Swap A and B
1 Arginine Clone A to B
2 Asparagine Clone cell pointed by A to A
3 Aspartic Acid Clone A to cell pointed by B
4 Cysteine Flip comparison flag
5 Glutamine Load immediate value to A (2 codons, max value 399)
6 Glutamic Acid Load immediate value to A (4 codons, max value 159999)
7 Glycine Jump to relative codon indicated by A if the comparison flag is set
8 Histidine Clone a value from user input to A
9 Isoleucine Clone the value in register A to output as a Unicode character
A Leucine Store A + B to A
B Lysine Store A - B to A
C Methionine Terminate Program
D Phenylalanine Store A * B to A
E Proline Store A / B to A
F Serine Round A to the nearest integer
G Threonine Negate the value in A
H Tryptophan Set comparison flag if A > B
I Tyrosine Set comparison flag if A < B
J Valine Set comparison flag if A == B

Immediate Values

Glutamine and Glutamic Acid load values from the program directly into register A. Glutamine reads the following 2 codons, and Glutamic Acid reads 4. Immediate values are represented in base20, with the order of digits being the amino acids' names in alphabetical order. This means Alanine would be 0, and Valine would be 19. The Opcode chart also shows these numbers.

Interpreter

Interpreter written in JavaScript by User:Dtp09 here.

Examples

Hello, World!

AUG
CAA GAU AUG
AUU        #H
CAA CAA CGU
AUU        #He
CAA CAA CAU
AUU AUU    #Hell
CAA CAA AAA
AUU        #Hello
CAA AAU UGU
AUU        #Hello,
CAA CGU AUG
AUU        #Hello,(0x20)
CAA UGU GGU
AUU        #Hello, W
CAA CAA AAA
AUU        #Hello, Wo
CAA CAA CCU
AUU        #Hello, Wor
CAA CAA CAU
AUU        #Hello, Worl
CAA CAA GCU
AUU        #Hello, World
CAA CGU UUU
AUU        #Hello, World!
UAA

Cat program

AUG
CAU            #input
GCU            #swap input to b
CAA GCU GCU    #0 to a
GUU            #input == 0
UGU            #input != 0
CAA GCU AAU    #load 2
GGU            #if input != 0 then skip
AUG            #exit if input is 0
GCU            #swap input to A
AUU            #output the input
CAA GCU UAU    #18
ACU            #-18
GGU            #loop back to start
UAA