ArticleslgStudy

computer science

Smith–Waterman algorithm

Smith–Waterman algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Smith–Waterman algorithm rather than just read about it. In short: The Smith–Waterman algorithm performs local sequence alignment; that is, for determining similar regions between two strings of nucleic acid sequences or protein sequences. Instead of looking at the entire sequence, the Smith–Waterman algorithm compares segments of all possible lengths and optimizes the similarity measure.

Smith–Waterman algorithm — main illustration
Smith–Waterman algorithm — illustration

Key takeaways

  • Smith–Waterman algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Smith–Waterman algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Smith–Waterman algorithm from memory before moving on to harder problems.

Reference excerpt

The Smith–Waterman algorithm performs local sequence alignment; that is, for determining similar regions between two strings of nucleic acid sequences or protein sequences. Instead of looking at the entire sequence, the Smith–Waterman algorithm compares segments of all possible lengths and optimizes the similarity measure. The algorithm was first proposed by Temple F. Smith and Michael S. Waterman in 1981. Like the Needleman–Wunsch algorithm, of which it is a variation, Smith–Waterman is a dynamic programming algorithm. As such, it has the desirable property that it is guaranteed to find the optimal local alignment with respect to the scoring system being used (which includes the substitution matrix and the gap-scoring scheme). The main difference to the Needleman–Wunsch algorithm is that negative scoring matrix cells are set to zero. Traceback procedure starts at the highest scoring matrix cell and proceeds until a cell with score zero is encountered, yielding the highest scoring local alignment. Because of its quadratic time complexity, it often cannot be practically applied to large-scale problems and is replaced in favor of computationally more efficient alternatives such as (Gotoh, 1982), (Altschul and Erickson, 1986), and (Myers and Miller, 1988).

History In 1970, Saul B. Needleman and Christian D. Wunsch proposed a heuristic homology algorithm for sequence alignment, also referred to as the Needleman–Wunsch algorithm. It is a global alignment algorithm that requires O ( m n ) {\displaystyle O(mn)} calculation steps ( m {\displaystyle m} and n {\displaystyle n} are the lengths of the two sequences being aligned). It uses the iterative calculation of a matrix for the purpose of showing global alignment. In the following decade, Sankoff, Reichert, Beyer and others formulated alternative heuristic algorithms for analyzing gene sequences. Sellers introduced a system for measuring sequence distances. In 1976, Waterman et al. added the concept of gaps into the original measurement system. In 1981, Smith and Waterman published their Smith–Waterman algorithm for calculating local alignment. The Smith–Waterman algorithm is fairly demanding of time: To align two sequences of lengths m {\displaystyle m} and n {\displaystyle n} , O ( m 2 n + n 2 m ) {\displaystyle O(m^{2}n+n^{2}m)} time is required. Gotoh and Altschul optimized the algorithm to O ( m n ) {\displaystyle O(mn)} steps. The space complexity was optimized by Myers and Miller from O ( m n ) {\displaystyle O(mn)} to O ( n ) {\displaystyle O(n)} (linear), where n {\displaystyle n} is the length of the shorter sequence, for the case where only one of the many possible optimal alignments is desired. Chowdhury, Le, and Ramachandran later optimized the cache performance of the algorithm while keeping the space usage linear in the total length of the input sequences.

Motivation In recent years, genome projects conducted on a variety of organisms generated massive amounts of sequence data for genes and proteins, which requires computational analysis. Sequence alignment shows the relations between genes or between proteins, leading to a better understanding of their homology and functionality. Sequence alignment can also reveal conserved domains and motifs. One motivation for local alignment is the difficulty of obtaining correct alignments in regions of low similarity between distantly related biological sequences, because mutations have added too much 'noise' over evolutionary time to allow for a meaningful comparison of those regions. Local alignment avoids such regions altogether and focuses on those with a positive score, i.e. those with an evolutionarily conserved signal of similarity. A prerequisite for local alignment is a negative expectation score. The expectation score is defined as the average score that the scoring system (substitution matrix and gap penalties) would yield for a random sequence. Another motivation for using local alignments is that there is a reliable statistical model (developed by Karlin and Altschul) for optimal local alignments. The alignment of unrelated sequences tends to produce optimal local alignment scores which follow an extreme value distribution. This property allows programs to produce an expectation value for the optimal local alignment of two sequences, which is a measure of how often two unrelated sequences would produce an optimal local alignment whose score is greater than or equal to the observed score. Very low expectation values indicate that the two sequences in question might be homologous, meaning they might share a common ancestor.

Algorithm

Let A = a 1 a 2 . . . a n {\displaystyle A=a_{1}a_{2}...a_{n}} and B = b 1 b 2 . . . b m {\displaystyle B=b_{1}b_{2}...b_{m}} be the sequences to be aligned, where n {\displaystyle n} and m {\displaystyle m} are the lengths of A {\displaystyle A} and B {\displaystyle B} respectively.

Determine the substitution matrix and the gap penalty scheme.

… excerpt ends here. Continue reading the full article.

Illustrations

Smith–Waterman algorithm illustration
Smith–Waterman algorithm: Scoring method of the Smith–Waterman algorithm
Scoring method of the Smith–Waterman algorithm
Smith–Waterman algorithm: Global and local sequence alignment
Global and local sequence alignment
Smith–Waterman algorithm: Simplified Smith–Waterman algorithm when linear gap penalty function is used
Simplified Smith–Waterman algorithm when linear gap penalty function is used
Smith–Waterman algorithm: Initialization of the scoring matrix (left 1) and the scoring process of the first three elements (left 2–4)
Initialization of the scoring matrix (left 1) and the scoring process of the first three elements (left 2–4)

Worked examples

Example 1 — a first encounter with Smith–Waterman algorithm

Start with the simplest possible case. Write down what Smith–Waterman algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Smith–Waterman algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Smith–Waterman algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Smith–Waterman algorithm

In research
Smith–Waterman algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Smith–Waterman algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Smith–Waterman algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Bioinformatics algorithms, Computational phylogenetics, Dynamic programming, so understanding it makes those chapters shorter.
In everyday life
Look for Smith–Waterman algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Smith–Waterman algorithm” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Smith–Waterman algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Smith–Waterman algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Smith–Waterman algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Smith–Waterman algorithm in simple terms?

The Smith–Waterman algorithm performs local sequence alignment; that is, for determining similar regions between two strings of nucleic acid sequences or protein sequences. Instead of looking at the entire sequence, the Smith–Waterman algorithm compares segments of all possible lengths and optimize…

Why does Smith–Waterman algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Smith–Waterman algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Smith–Waterman algorithm.

Tags

  • Bioinformatics algorithms
  • Computational phylogenetics
  • Dynamic programming
  • Sequence alignment algorithms

Keep exploring