esolang

Typogenetics

A toy molecular biology from Gödel, Escher, Bach: strings of four letters code for the enzymes that cut, copy and rewrite those same strings.

Douglas Hofstadter, 1979 · Turing complete: unknown · ●●○ moderate

Tested with 1 known program · Test method

Run it

The idea

In Gödel, Escher, Bach (1979), Douglas Hofstadter wanted to show how DNA can be both a message and the reader of that message. So he invented a game with the shape of molecular biology and none of the chemistry.

Read the story

A strand is a string of the letters A, C, G and T. Read two letters at a time, a strand translates into enzymes: little programs of operations like "cut", "move right", "insert a C", "start copying". Enzymes then act on strands, including the ones that coded for them. The question Hofstadter asks: is there a strand that makes enzymes that make copies of that strand?

The program is the strand. It is code (through translation) and data (as the thing enzymes act on) at the same time.

The machine

Purines are A and G; pyrimidines are C and T. Complements pair A with T and C with G.

Each pair of letters, a duet, is one amino acid. AA is punctuation: it ends one enzyme and starts the next. Each amino acid also has a kink: straight (s), left (l) or right (r).

DuetOpKinkDoes
ACcutsCut the strand(s) after this unit
AGdelsDelete this unit
ATswirSwitch to the other strand
CA / CCmvr / mvls / sMove one unit right / left
CG / CTcop / offr / lTurn copy mode on / off
GA GC GG GTina inc ing ints r r lInsert A / C / G / T to the right
TA / TCrpy / rpur / lSearch right for a pyrimidine / purine
TG / TTlpy / lpul / lSearch left for a pyrimidine / purine
  • Binding. An enzyme folds according to its kinks. The angle between its first and last segment picks its favourite letter: straight on A, a left turn C, a right turn G, back the way it came T. It binds to one of those letters on the strand.
  • Copy mode. While on, every unit the enzyme passes is matched by its complement on the other strand, laid down upside down.
  • Falling off. If the enzyme moves past the end or into a gap, it lets go. At the end, the double strand comes apart, and every piece is a new strand.

GEB's two worked examples do not agree on exactly which kinks count in the fold. This implementation follows Dan Kortschak's Go implementation, which counts them so that the book's main example comes out as printed.

Example

The book's example: the enzyme rpu-inc-cop-mvr-mvl-swi-lpu-int acting on TAGATCCAGTCCATCGA.

The book's example: the enzyme rpu-inc-cop-mvr-mvl-swi-lpu-int acting on TAGATCCAGTCCATCGA. Its fold makes it prefer G, and the strand has three Gs:

enzyme rpu-inc-cop-mvr-mvl-swi-lpu-int binds G
  at 2: ATG + TAGACATCCAGTCCATCGA
  at 8: ATG + TAGATCCAGTCCACATCGA
  at 15: TAGATCCAGTCCATCGAC + G

Binding at the second G gives GEB's answer. Walk it. Search right for a purine, insert C, start copying, step right and back, switch strands (now going the other way), search for a purine on the new strand, insert T. Two strands come out.

A self-replicator (a test case in Kortschak's package): this strand translates into two enzymes, and their combined action on it leaves two copies of it.

CGTTCCTCTCTCTCTATAGAGAGAGAGGAACG codes for cop-lpu-mvl-rpu-rpu-rpu-rpu-rpy-rpy-ina-ina-ina-ina-ing (binds T), cop (binds A)
gen 1: 2 x CGTTCCTCTCTCTCTATAGAGAGAGAGGAACG
...
gen 5: 32 x CGTTCCTCTCTCTCTATAGAGAGAGAGGAACG

Look at it. It is a palindrome of complements. Copy mode writes the complement, upside down, and for this strand that is the strand itself.

Patterns it teaches

  • Self-replication: replication from a strand's own products, with no outside copier.
  • Code as data: the same letters are read as a program (translation) and written as data (by enzymes).
  • Quine: the replicating strand is a quine in a chemistry; copying gives the complement, so the trick is to be your own complement.
  • Artificial life: later researchers ran soups of random strands and searched for replicators and hypercycles.

Try this

  1. Translate CGTTCC by hand. Which enzymes, and which letter does each prefer?
  2. Run the self-replicator with one letter changed in the middle. Does it still copy? Which positions are safe to mutate?
  3. Hard: find a different self-replicating strand. Start from complement-palindromes.

Further

  • Douglas Hofstadter, Gödel, Escher, Bach (1979), chapter XVI, "Self-Ref and Self-Rep".
  • Dan Kortschak's Go implementation: github.com/kortschak/typo
  • Later papers searched Typogenetics soups for replicators and hypercycles, for example "A study of replicators and hypercycles by Hofstadter's typogenetics".

Also in Artificial life

Write your own in Run Convert a program from Typogenetics

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: typogenetics.

Command line

shib run typogenetics -e 'CGTTCCTCTCTCTCTATAGAGAGAGAGGAACG' --input '2'
shib manual typogenetics

Source

Module
langs/museum/ports.js
Interpreter
langs/museum/typogenetics.js, langs/common.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language