202

Does DNA have anything like IF-statements, GOTO-jumps, or WHILE loops?

In software development, these constructs have the following functions:

  • IF-statements: An IF statement executes the code in a subsequent code block if some specific condition is met.
  • WHILE-loops: The code in a subsequent code block is executes as many times as specified, or as long as a specific condition is met.
  • Function calls: The code temporarily bypasses the subsequent code block, executing instead some other code block. After execution of the other code block the code returns (sometimes with some value) and continues the execution of the subsequent block.
  • GOTO-statements: The code bypasses the subsequent code block, jumping instead directly to some other block.

Are constructs similar to these present in DNA? If yes, how are they implemented and what are they called?

WYSIWYG
  • 35,564
  • 9
  • 67
  • 154
  • 48
    while(telomeres>0){DNA.replicate;cell.divide;telomeres-=1;sleep(x);} – aaaaa says reinstate Monica Mar 04 '15 at 04:56
  • 18
    A function call is just a fancy GOTO statement. – user Mar 04 '15 at 09:08
  • 4
    To me, GOTO only makes sense for sequential code execution, and this is not the case for DNA (lots of transcription is happening all the time in parallel). – fileunderwater Mar 04 '15 at 10:26
  • 1
    @fileunderwater Serial execution happens during signalling cascades – WYSIWYG Mar 04 '15 at 11:26
  • 10
    @MichaelKjörling A fuction call necessitates that there be a separate environment for the function. It can take arguments as inputs and returns some output. GOTO on the other hand is the part of the main program and just controls the flow of instructions. While the information flow in biological system can be controlled, it is almost impossible to provide a separate environment necessary for true functions. – WYSIWYG Mar 04 '15 at 11:35
  • @WYSIWYG yes, but isn't this more a case of positive feedback (or activation/inhibition) similar to IF-statements, and not GOTO, as in executing-bypassing-executing. Just my perception, but I don't know enought about the specifics of DNA transcription to really say. Maybe shows how hard it can be to draw clear programming-DNA analogs though. – fileunderwater Mar 04 '15 at 11:35
  • @fileunderwater There are programming alternatives to GOTO. In most languages it is deprecated. So the action of GOTO can be performed by other statements. So you are right. Moreover, GOTO requires labels; even though a promoter for a certain TF can be thought of as a label, it is more of a logical condition to be fulfilled. So more important than actual statements is the underlying logic. – WYSIWYG Mar 04 '15 at 11:40
  • 3
    I think with DNA we are closer to bits and bytes themselves or maybe machine code than to a programming language. – skymningen Mar 04 '15 at 12:27
  • @WYSIWYG True, although most control flow statements translate to a machine instruction similar to GOTO, such as a jump or conditional jump. – Michael Mar 04 '15 at 16:37
  • 1
    @skymninge Even at the level of bits and bytes, the hardware itself acts as a kind of Turing machine. – Kyle Strand Mar 04 '15 at 17:07
  • 1
    It's crucial to understand that your computer does not have loops and function calls. It does have comparisons and jumps. – Lightness Races in Orbit Mar 05 '15 at 17:44
  • DNA is not a program in the sense you're thinking. I suppose it could be considered a declarative program with the proper interpreter, though? – Lightness Races in Orbit Mar 05 '15 at 17:45
  • 1
    I am pretty sure DNA is more like generic data than a fully fledged executable program. Its the datafile that the bio-program uses – Jonathon Mar 05 '15 at 18:27
  • 2
    I think DNA is more like a HTML page: it's just a declaration of what elements could be visible on a page, (although display:none is perfectly allowed in DNA); these elements can include protein Javascript. Here and there a rudimentary form of PHP is present (see @WYSIWYG's answer). – Sanchises Mar 06 '15 at 11:37
  • This is a probably relevant article that I think nobody mentioned yet. – kon psych Mar 07 '15 at 02:30
  • @WYSIWYG I would argue that nuclear receptor activation can represent a function call. They hang out in the cytosol until activated by binding of their ligand, and then trans-locate to the nucleus to perform their function. – akaDrHouse Aug 03 '16 at 14:15
  • To learn genetics and molecular-biology this-way; could anyone refer me some books, or at least which area of study I have to look for? – Always Confused Sep 07 '16 at 12:31
  • 1
  • This has aged well. There are numerous regulatory mechanisms and feedback loops of which our knowledge is still being developed. In fact we could probably learn new coding tricks by looking at how DNA can control gene expression. – haz Jan 11 '24 at 12:06

7 Answers7

144

Biological examples similar to programming statements:

  • IF : Transcriptional activator; when present a gene will be transcribed. In general there is no termination of events unless the signal is gone; the program ends only with the death of the cell. So the IF statement is always a part of a loop.
  • WHILE : Transcriptional repressor; gene will be transcribed until repressor is not present.
  • There are no equivalents of function calls. All events happen is the same space and there is always a likelihood of interference. One can argue that organelles can act as a compartment that may have a function like properties but they are highly complex and are not just some kind of input-output devices.
  • GOTO is always dependent on a condition. This can happen in case of certain network connections such as feedforward loops and branched pathways. For example if there is a signalling pathway like this:
    A → B → C and there is another connection D → C then if somehow D is activated it will directly affect C, making A and B dispensable.

Logic gates have been constructed using synthetic biological circuits. See this review for more information.


Note

Molecular biological processes cannot be directly compared to a computer code. It is the underlying logic that is important and not the statement construct itself and these examples should not be taken as absolute analogies. It is also to be noted that DNA is just a set of instructions and not really a fully functional entity (it is functional to some extent). However, even being just a code it is comparable to a HLL code that has to be compiled to execute its functions. See this post too.

It is also important to note that the cell, like many other physical systems, is analog in nature. Therefore, in most situations there is no 0/1 (binary) value of variables. Consider gene expression. If a transcriptional activator is present, the gene will be transcribed. However, if you keep increasing the concentration of the activator, the expression of that gene will increase until it reaches a saturation point. So there is no digital logic here. Having said that, I would add that switching behaviour is possible in biological systems (including gene expression) and is also used in many cases. Certain kinds of regulatory network structures can give rise to such dynamics. Co-operativity with or without positive feedback is one of the mechanisms that can implement switching behaviour. For more details read about ultrasensitivity. Also check out "Can molecular genetics make a boolean variable from a continuous variable?"

WYSIWYG
  • 35,564
  • 9
  • 67
  • 154
  • 15
    I would classify intron splicing as a kind of GOTO, since it essentially skips the ribosome "pointer" to a different value. – March Ho Mar 04 '15 at 06:01
  • 1
    Very nice! Where would alternate reading frames fit in? – One Face Mar 04 '15 at 07:36
  • @MarchHo Yes that can also be considered an example. Lots of analogies can be drawn. Spinal reflexes can be an example of BREAK – WYSIWYG Mar 04 '15 at 08:35
  • 1
    @CRags I guess alternate reading frames can be an example of SWITCH-CASE. It all depends. The logic gating is of more relevance here than program statements. After all these statements are based on logical tests. – WYSIWYG Mar 04 '15 at 08:37
  • 14
    While your examples are clever I feel the analogy used here (DNA against computer code) is so very poor as to be misleading. – Jack Aidley Mar 04 '15 at 13:03
  • 3
    @JackAidley It is true that molecular biology cannot be directly compared to a computer code. I intended this answer for someone who is curious if a cell can perform computations like a computer program. I already mentioned that it is the underlying logic that is important and not the statement construct itself and these examples should not be taken as absolute analogies. I'll add this in the answer to avoid confusion. – WYSIWYG Mar 04 '15 at 13:10
  • And @JackAidley I nowhere mentioned that DNA is performing all the functions. A TF is a protein. Complex though it may be, the property of the system may be predictable based on the DNA code. – WYSIWYG Mar 04 '15 at 13:16
  • I really think compartmentalizations as accomplished by cellular membranes could be compared to functions. This is an impressive answer @WYSIWYG – rhill45 Mar 04 '15 at 15:37
  • 2
    WYSIWYG, it's good that you did not mention that DNA is performing all the functions you describe, but you should really consider explicitly mentioning in your answer that DNA doesn't and can't perform them; the fact that computer code describes such control structures really is a pretty fundamental aspect of Turing-completeness, and it's very important in the context of this question to note that DNA does not share that feature. – Kyle Strand Mar 04 '15 at 17:09
  • 1
    @KyleStrand IMO neither DNA does the function nor does the HLL code. Both of them just provide instructions; DNA is much more cryptic. Just because a Turing Machine has not been developed using the DNA code doesn't mean that it is theoretically impossible. This is just my opinion. There are several differences between DNA and computer code. The objective of this answer was just to point out some rudimentary similarities. I have added your suggestion though. – WYSIWYG Mar 04 '15 at 20:51
  • @WYSIWYG Thank you. I guess what I meant about "performing all the functions" is more that HLLs (and LLLs) prescribe the actual process for executing them--where jumps occur, etc.--even if they do not actually perform that process themselves. DNA, as far as we know, does not (although admittedly it could do a lot more of this sort of thing than we realize). I guess by analogy, if DNA is like a blueprint, code is somewhat like a blueprint combined with work instructions for the people actually building the thing described by the blueprint. – Kyle Strand Mar 04 '15 at 23:42
  • "organelles" seems to be like interrupt handler, or maybe events.

    I think an events based language may be better comparison for logic comprehensions.

    – Lesto Mar 05 '15 at 10:47
  • To produce computation, all you need is just a conditional jump (i.e. if X goto P). All other control statements are just for convenience and can be simulated by conditional jump. A computational system that only have a conditional jump for for control is Turing Complete. – Lie Ryan Mar 05 '15 at 12:15
  • @lesto organelles are like subprograms that interact continuously with the main program. They have their own environment and some level of autonomy, but are dependent on the cell. – WYSIWYG Mar 05 '15 at 12:15
  • @LieRyan Agreed. All you basically need are logic gates. – WYSIWYG Mar 05 '15 at 12:16
  • There are some hypotheses regarding chromatin microenvironments that would be analagous to namespaces in programming. – Armatus Apr 25 '18 at 19:30
  • "Biological examples" — But the question specifies DNA, so clearly this answer is wrong. Shows you shouldn't allow some people to vote. – David Mar 13 '19 at 13:26
  • @David I agree that this question is not great (and the answer too) but unfortunately the most well-posed (and researched) questions are often not so popular. Anyway, what do you disagree about "biological examples"? I meant analogous situations in biological systems, by that term. Note that OP is comparing DNA with a computer program. Since DNA encodes all biological information, DNA is the program. Most of my examples are related to transcriptional regulation i.e. direct operations of/on DNA. So the answer, although not great, isn't wrong. – WYSIWYG Mar 13 '19 at 14:24
  • Sorry. Didn't notice it was you. Don't want to get into a flame war. Just that the question seems to me a typical computer scientist's false analogy between the explicit information in code and in that in DNA, which provoked my recent answer to an old question. The information in DNA is not explicit and I doubt whether you could ever hope to understand the effects of the expression of proteins from reading the DNA alone. – David Mar 13 '19 at 16:30
  • I would say that chromosomal regulation is a kind of function call (DNA is 3D) DNA is activated in one part of the chromosome. Then downstream at some point this effects the opening of the chromosomal region for transcription downstream the initial DNA activation (methylation of chromosomal regions). This is kind of a stupid question honestly. We are no where close to being able to model synthetically a whole system either in vitro or in silico. Way too many moving pieces that we don't yet even have interaction models with entire important fields like biophysics not even sharing in importance. – user7875084 Dec 26 '20 at 06:59
22

DNA is not analogous to computer code which renders your search for similar constructs in it meaningless. To give a couple of simple examples why this is:

  • Computer code has a sequential order of execution; DNA acts in parallel and out of sequence, it is not "executed".

  • Computer code has a strict and consistent meaning so the line if x==4 : x=7 always does the same thing; coding DNA translates to amino acids and it's the complex chemical interactions between these acids which give proteins their function thus no piece of coding DNA can be understood outside of its protein.

Biological systems do have some pathways that operate in a similar way to computers, but you should be looking for these at the protein level not the DNA level and, even then, you need to be extremely careful that your analogy does not impair your understanding of what is really happening.

Jack Aidley
  • 6,907
  • 32
  • 48
  • 4
    When you say DNA needs proteins to execute its functions then computer programs also need compilers to execute their code. It is ultimately the machine language that tells the computer what to do. – WYSIWYG Mar 04 '15 at 13:17
  • 1
    I'm not saying that DNA needs proteins to execute its functions; I'm saying DNA is fundamentally unlike computer code. – Jack Aidley Mar 04 '15 at 14:36
  • 4
    OK, but there exist massively parallel programming languages Where every line is executed at the same time and can be out of sequence.

    And just because lines are context sensitives does not make it not a programming language, it just makes it far more complex.

    That said, the way I understood DNA it was more data than program.

    – Jonathon Mar 05 '15 at 18:31
  • 3
    Even in parallel programming languages, each statement in executed sequentially. It's just that there are multiple "threads" of execution going at the same time. DNA is neither data nor program. The analogy is totally inaccurate. – Jack Aidley Mar 05 '15 at 22:33
  • 2
    I think DNA is data and program at the same time. Its regulators of expression act as logic clauses, so the analogy is at least curious. – Rodrigo Sep 27 '15 at 18:23
  • "Computer code has a sequential order of execution" - Joule would like a word. – TLW Jan 10 '24 at 16:30
  • @JackAidley - "each statement is executed sequentially.". This is untrue, both at the language level (Joule for instance) and at the processor level (the CPU of the machine I'm typing this on can have several hundred instructions in flight at the same time in varying stages of execution). – TLW Jan 10 '24 at 16:32
  • It sounds like you could probably implement the world's worst Verilog backend with DNA :-) – TLW Jan 10 '24 at 16:33
  • 1
    Computer code is essentially 1-dimensional, because it is "read in" sequentially. DNA is literally 3-dimensional and many, many non-coding constructs take advantage of that. This is a good review, for example: https://www.annualreviews.org/doi/abs/10.1146/annurev-biodatasci-122120-110102 – Marco Jan 15 '24 at 13:22
20

There are certainly some comparisons that could be made between the way genes are expressed from DNA and logic functions, but they aren't great.

But synthetic Biology is really a blossoming new field that is attempting to integrate logic functions into biology, see e.g. Siuti et al (2013).

The above paper is a brilliant example of a group using bacteria to store information and assembling into biological circuits that can then be used to process logic functions. So its being done but not exactly in the way that you propose.

The Nightman
  • 1,836
  • 1
  • 16
  • 28
15

Just to add to previous answers, but transcriptional interference (see e.g. Shearwin et al., 2005) can be seen as a form of IF-statement (or WHILE) in the sense that:

if(x transcribed){not y transcribed}

The interference does not have to be binary though, and more common are graded responses. Transcriptional interference can also take place at the RNA stage (see e.g. Xue et al, 2014), using antisense RNA and often providing a negative feedback loop, but the interference is then removed from the DNA, and does not represent a direct IF-statement analog at the DNA stage.

To me, GOTO mainly makes sense for sequential code execution, and this is not the case for DNA (lots of transcription is happening all the time in parallel). More generally, the parallel "execution" of DNA along with the continuous interactions and feedback loops between DNA, transcripts and proteins (among other things) also means that cellular processes are far less clear-cut and traceable than computer code, which means that computer code is a very poor metaphor for cellular processes and the functioning of DNA.

fileunderwater
  • 16,670
  • 3
  • 49
  • 88
  • 2
    I think the intrinsic parallelism is a key point. Biological 'processing' is really more analog than digital, as even discrete neuron firing is an encoding of analog processes in the neuron. The processes of a cell are much better approximated as a horrendously (gloriously?) complex set of overlapping, cross-wired analog feedback loops. Gene expression makes up part of this, though it is intimately tied into many other cellular processes. – Dan Bryant Mar 04 '15 at 19:57
  • @DanBryant Great description and agreed - I have tried to clarify this point further. – fileunderwater Mar 04 '15 at 22:30
12

As WYSIWYG said there is no equivalent for function calls, as there will always be some interference. However one could argue that some modular pathways (eg. apoptosis signalling) can be seen as a "code block" where a certain input will (almost) certainly lead to a certain effect. The analogy with function calls is that, in describing many different mechanisms, it makes for shorter and more efficient "code" to consider everything between eg. caspase activation and cytochrome leakage as one block. Also, marking a protein with ubiquitin can maybe be seen as a function call for degradation.

If you are interested in the building blocks for programming with biology, check out the biobricks.org program, which aims to define modular parts (bricks) which can be sensors, logic functions, effectors,...

Sleepses
  • 682
  • 4
  • 15
  • 2
    There is interference in function calls too: they're called global variables, system configuration, hardware support, etc. – Rodrigo Sep 27 '15 at 18:26
3

Regarding function calls:

There are no equivalents of function calls. All events happen is the same space and there is always a likelihood of interference. One can argue that organelles can act as a compartment that may have a function like properties but they are highly complex and are not just some kind of input-output devices.

and

As WYSIWYG said there is no equivalent for function calls, as there will always be some interference.

I think that nuclear receptors are great examples of function calls. They hang out in the cytosol allowing normal programming to function in a normative fashion. Upon activation with their ligand, they translocate to the nucleus to activate subroutines of gene repression/activation and subsequent downstream processes.

In this fashion one could even argue that most initial ligand interactions that kick off cellular signaling are function calls.

akaDrHouse
  • 1,309
  • 7
  • 13
1

In addition to the excellent WYSIWYG answer, there are some programming-like constructs at the lower level:

  • FUNCTION CALL - replacing a single sub-unit inside a complex protein, assembled from multiple sub-units, each encoded by separate genes. This can also be seen as COMPOSITION, another programming concept.
  • IF - alternative splicing, a piece of DNA (exon) may be included or not included into transcript that encodes the final protein.
De Novo
  • 8,791
  • 1
  • 24
  • 45
h22
  • 407
  • 2
  • 8
  • 1
    I rolled back the edit that put back tics around portions of this answer that are not code. Here, FUNCTION CALL, COMPOSITION, and IF are not code, they are programming concepts – De Novo Mar 13 '19 at 04:22