endoh2 is an ASCII to DNA transcoder, quick example with text “YJL”:


% echo YJL | ./prog > YJL.c
This chromosome program synthesizes a double helix. The helix can also be compiled as a C program.

% cat YJL.c
#include "prog.c"

AT
C~~G
C~~~G
G~~~~C
C~~~~G
C~~~G
A~~T
CG
TA
G~~C
G~~~C
C~~~~G
A~~~~T
T~~~A
A~~T
CG
TA
A~~T
A~~~T
G~~~~C
G~~~~C
A~~~T
A~~T
GC

You don’t need to compile yourself, the Makefile can do that for you:


% make YJL
cc -Wall -std=c11 -O2 YJL.c -o YJL

If you run the synthesized DNA program, you get the input ASCII text, is this a form of hiding information in DNA?


% ./YJL
YJL

If you ask how the source code, prog.c, looks like, well, you don’t need to have smart gene to guess, it’s all in the gene — no pun intended:


#include <stdio.h>
#define TA q=
/*XYXY*/
#define
/*X YXY*/CG r=
void p(int n,int c){;
for(;n--;) putchar(c)
#define Y( z)d;d=c++\
%2<1?x=x*4 +z,c%8>5?\
x=x?p(1,x), 0:x:0:0;d=
#define
/*X YX*/C Y(1)
#define
/*X YX*/G Y(2)
;}int(*f)( void),d,c,
#define/*X YX*/A Y(0)
#define/*XY*/AT int\
m(void
/**/){d=
#define/*XYX*/T Y(3)
#define GC d; return\
0;}int(*f) (void )=m;
x,q,r; int main(){if(
f)f();else {for(puts(
"#include" "\40\"pro\
g.c
\"\n\n \101T"+0);
d=!d?x=(x= getchar())
<0?0:x,8*8 :d,TA++c%8
,TA(1+7*q- q*q)/3,r=c
*15-c*c-36 ,p(r<0?!q+
4:r/6+!q+4 ,32),q||x;
c%=16)q?p( 1,"ACGT"[x
/d&3]),p(q ,126),p(1,
"TGCA"[x/d &3]),d/=4,
p(001,10): puts(c%8?\
"CG":"TA") ;puts("GC"
);}return 0;}/**/

The author said: “Enjoy DNA programming!” and “The synthesized helix of course follows the base-pairing rules for DNA: A is bonding only to T, and C is bonding only to G.”

I wonder if a DNA programming language can be done — or is there already one? Not for actual DNA, of course. If you know of Brainfuck, coding in only those brainfucking symbols, which I have done once five years ago, why not CGAT?

endoh2 is written in C11 by Yusuke Endoh, 2014-10-29, inspired by Perl’s Acme::DoubleHelix, it has 32 LOC or 785 bytes.