Skip to main content

Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

  • Primer
  • Published:

What is dynamic programming?

Sequence alignment methods often use something called a 'dynamic programming' algorithm. What is dynamic programming and how does it work?

This is a preview of subscription content, access via your institution

Access options

Rent or buy this article

Prices vary by article type

from$1.95

to$39.95

Prices may be subject to local taxes which are calculated during checkout

Figure 1: The filled dynamic programming matrix for two DNA sequences, x = TTCATA and y = TGCTCGTA, for a scoring system of +5 for a match, −2 for a mismatch and −6 for each insertion or deletion.

References

  1. Bellman, R.E. Eye of the Hurricane: An Autobiography (World Scientific, Singapore, 1984).

    Book  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Supplementary information

Supplementary Note

An example of global sequence alignment by dynamic programming. (C 7 kb)

The program is ANSI C and should compile on any machine that has a C compiler, with a command line like: gcc -o global global.c

To run the program: ./global

To change the sequences or the scoring system, you have to edit the appropriate #define's at the top of the program, and recompile. This is meant to be a simple working example of the mechanics of dynamic programming sequence alignment. The details of reading FASTA files and such are left as an exercise to the reader. Any questions about this program should be addressed directly to the author.

Further study

Further study

To study a working example, you can download a small, bare-bones C implementation of this algorithm (see Supplementary Note). I used this C program to generate Figure 1.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Eddy, S. What is dynamic programming?. Nat Biotechnol 22, 909–910 (2004). https://doi.org/10.1038/nbt0704-909

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1038/nbt0704-909

This article is cited by

Search

Quick links

Nature Briefing

Sign up for the Nature Briefing newsletter — what matters in science, free to your inbox daily.

Get the most important science stories of the day, free in your inbox. Sign up for Nature Briefing