How RNA folds
A single RNA strand folds back on itself, pairing one stretch of its sequence with another, into a shape as specific as a protein's. Unlike protein folding, the first step can be computed exactly: RNA's pairs nest like parentheses, so a dynamic program over the sequence string finds the best set of them. This lesson names the folded parts, builds that algorithm, watches it fail on tRNA, and then follows tRNA's two-dimensional cloverleaf into its three-dimensional L.
A strand that pairs with itself

(A) RNA is usually a single strand. (B) When a single-stranded RNA folds back on itself, hydrogen bonds between complementary sequences can stabilize it into a three-dimensional shape with complex surface characteristics.
Defining the sequence of the RNA as its primary structure, its secondary structure represents the pairing just described. The contiguous base pairs arrange themselves as double helices, which are locally rigid.
The secondary structure is a set of pairs between positions of the string. A run of stacked pairs is a stem, an A-form double helix (lesson 7.1). The unpaired stretches between stems are loops, named by what closes them:
| Loop | What it is |
|---|---|
| Hairpin loop | unpaired bases closed by a single pair, capping the end of a stem |
| Bulge | unpaired bases on one side only, between two stems |
| Internal loop | unpaired bases on both sides, between two stems |
| Multiloop (junction) | a loop from which three or more stems leave |
| Pseudoknot | bases in a loop pairing with bases outside it, so two stems interleave |
Write each position as . if unpaired, ( if it pairs with a later position, and ) if it pairs with an
earlier one, and you have dot-bracket notation. A structure without pseudoknots is nested: for any two
pairs and with , either (side by side) or (one inside the other).
Nested pair sets are exactly the balanced-parenthesis strings, which makes a secondary structure a tree:
each loop is a node and each stem an edge. A pseudoknot is a pair that crosses another, and it needs a second
bracket type, [ and ].
Below is yeast tRNA-Phe's secondary structure. Edit the brackets or the sequence and the drawing and loop counts follow:
The cloverleaf of yeast tRNA-Phe: four stems around a multiloop. Switch to arcs to see why nested pairs
never cross. Then change position 19 (in the D loop) to [ and position 56 (in the T loop) to ] to add
G19–C56, one of the crossing contacts the 3D fold makes.
Folding as dynamic programming
Nestedness is what makes RNA secondary structure computable. If position pairs with , nothing inside can pair with anything outside it, so the problem splits into independent subproblems on substrings. That's the setting for dynamic programming. The simplest version, Nussinov's algorithm (1978), maximizes the number of pairs. Let be the most pairs a nested structure on positions can have. Base is either unpaired, or paired with , or paired with some inside, splitting the interval:
with when : a hairpin loop needs at least three unpaired bases to turn around. Filling the table by increasing span takes time and space. A traceback from recovers the pairs, exactly as in sequence alignment (unit 5).
import numpy as np
PAIRS = {("G", "C"), ("C", "G"), ("A", "U"), ("U", "A"), ("G", "U"), ("U", "G")}
def nussinov(seq, min_loop=3):
n = len(seq)
N = np.zeros((n, n), dtype=int)
for span in range(min_loop + 1, n):
for i in range(n - span):
j = i + span
best = max(N[i + 1, j], N[i, j - 1])
if (seq[i], seq[j]) in PAIRS:
best = max(best, N[i + 1, j - 1] + 1)
for k in range(i + 1, j):
best = max(best, N[i, k] + N[k + 1, j])
N[i, j] = best
pairs, stack = [], [(0, n - 1)]
while stack: # traceback
i, j = stack.pop()
if i >= j or N[i, j] == 0:
continue
if N[i, j] == N[i + 1, j]:
stack.append((i + 1, j))
elif N[i, j] == N[i, j - 1]:
stack.append((i, j - 1))
elif (seq[i], seq[j]) in PAIRS and N[i, j] == N[i + 1, j - 1] + 1:
pairs.append((i, j))
stack.append((i + 1, j - 1))
else:
k = next(k for k in range(i + 1, j) if N[i, j] == N[i, k] + N[k + 1, j])
stack += [(i, k), (k + 1, j)]
return N, sorted(pairs)
def dot_bracket(n, pairs):
s = ["."] * n
for i, j in pairs:
s[i], s[j] = "(", ")"
return "".join(s)
def pairs_of(db):
stack, out = [], set()
for k, c in enumerate(db):
if c == "(":
stack.append(k)
elif c == ")":
out.add((stack.pop(), k))
return out
trna = "GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCACCA"
true = "(((((((..((((........)))).(((((.......))))).....(((((.......))))))))))))...."
N, predicted = nussinov(trna)
found = set(predicted) & pairs_of(true)
print(trna)
print(dot_bracket(len(trna), predicted), f" Nussinov, {len(predicted)} pairs")
print(true, f" real, {len(pairs_of(true))} pairs")
print(f"{len(found)} of the {len(pairs_of(true))} real pairs recovered")
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCACCA (((((((((((...)))(((((((((.((((.(((...))(...)))).)))))))..))).)))).))))).... Nussinov, 28 pairs (((((((..((((........)))).(((((.......))))).....(((((.......)))))))))))).... real, 21 pairs 5 of the 21 real pairs recovered
Maximizing pairs gets tRNA badly wrong. It finds 28 pairs where the real fold has 21, and only 5 of them are real. Pair counting rewards any pairing at all, including lone pairs and short runs that real RNA wouldn't form. Shuffle the sequence and it still finds nearly as many:
rng = np.random.default_rng(1)
shuffled = "".join(rng.permutation(list(trna)))
print(f"shuffled tRNA: {nussinov(shuffled)[0][0, -1]} pairs")
shuffled tRNA: 27 pairs
Real folding programs keep the same recursion but score free energy instead of pairs. What stabilizes a stem is stacking between neighboring pairs (lesson 7.1), and every loop costs entropy, so in the nearest-neighbor energy model each stacked pair of pairs contributes a measured negative (the most stable, a G–C stacked on a C–G, about −3.4 kcal/mol at 37 °C), and each hairpin, bulge, internal loop, and multiloop contributes a positive penalty that grows with its size. Zuker's algorithm minimizes that energy over nested structures in the same , and it's what Mfold, RNAfold, and their descendants run. Replace the max with a sum of Boltzmann weights (unit 4) and the same table gives McCaskill's partition function, and with it the probability of every possible pair. Allowing general pseudoknots breaks the nesting, and with it the subproblem independence. Optimal folding with arbitrary pseudoknots is NP-hard, so most programs leave them out.
The widget runs Nussinov on any sequence you type. Watch the DP matrix fill from the diagonal outward, then compare its fold with the real one above.
Nussinov folding of yeast tRNA-Phe. The matrix shows for every substring (darker is more pairs), with the traceback's cells outlined and the cells where it adds a pair in red. Hover a cell for its value. Switch the score to H-bonds (G–C 3, A–U 2, G–U 1) and see how much, or how little, the fold changes.
Beyond Watson–Crick pairs
The GU base pair is a prominent and very important element of large RNA structures since it is especially stable because of its two hydrogen bonds. It is known as the "wobble" pair, since a G in the first position of a tRNA's anticodon (the three bases that pair with a codon of the mRNA) can accept either a C or a U in the third codon (wobble) position.
Although Watson-Crick base pairs are the most prevalent type of pairs in nucleic acids, in single-stranded RNA, 40% of the base pairs form other types. A systematic classification has been adopted. In this system, base pairing is defined as hydrogen bonding between edges of the interacting bases. Each base has three edges: Watson-Crick, sugar, and Hoogsteen (in purines) or C–H (in pyrimidines). The canonical Watson-Crick pair is a CG or AT pair interacting through the Watson-Crick edges with cis mutual orientation of the glycosidic bonds and antiparallel local orientation of the opposing nucleotide strands.

Base-pairing patterns in the Leontis–Westhof nomenclature. (a) The edges that can form base pairs with another base. (b) The 12 base-pair classes. (c) A noncanonical pair between the Watson–Crick and Hoogsteen edges with trans orientation of the glycosidic bonds, a class important in RNA architecture. (d) A pair between the Hoogsteen and sugar edges, also trans.
The twelve classes come from counting: any of three edges on one base can meet any of three on the other, giving six unordered edge combinations, and each can have its two glycosidic bonds on the same side (cis) or opposite sides (trans) of the pairing axis. So the canonical pair is "cis Watson–Crick/Watson–Crick", and the reverse Hoogsteen pairs you'll find in the tRNA lab are "trans Watson–Crick/Hoogsteen". A secondary-structure algorithm that knows only A–U, G–C, and G–U can't see noncanonical pairs, yet they hold most tertiary contacts together.
From cloverleaf to L
The tRNA molecule is folded into an overall L-shape, with two arms at right angles to each other. The original cloverleaf is still apparent, but with additional interactions between distant parts of the structure. The arms consist of short A-RNA helices with extensive base-base interactions that hold the two arms together. The longer double helical anticodon arm has the short helix of the D stem stacked upon it. The other arm is formed by the helix of the acceptor stem, on which is stacked the four base-pair T arm helix. This feature of helix-helix stacking has turned out to be of central importance for other complex RNAs. The nine additional base-base interactions that maintain the structural fold all tend to be in the elbow region, where the two arms are joined together. Almost all of these are of non-Watson-Crick type, and several are triplet interactions. Other crystal structures of tRNAs have shown that the overall L shape is invariant, as are many of the tertiary interactions.
Yeast tRNA-Phe at 1.93 Å (1EHZ). In the first view the acceptor stem is blue, the D arm orange, the anticodon arm aqua, and the T arm violet. The acceptor stacks on the T arm and the D arm on the anticodon arm, making the two limbs of the L. The second view marks the tertiary pairs in red; all of them sit at the elbow where the D and T loops meet. The third measures the molecule's span: the anticodon, which reads the mRNA, is about 73 Å from the 3′ end that carries the amino acid.
Open 1EHZ in Mol*Each stem in the cloverleaf widget above is one of these A-form helices, and each crossing pair you add there is one of the tertiary contacts at the elbow, which a nested-structure algorithm can't represent.
RNA that does chemistry
The three-dimensional shapes and other chemical properties of certain RNA molecules allow them to function as catalysts. Catalytic RNAs, called ribozymes, can speed up reactions involving their own nucleotides as well as other cellular substances. In living organisms today, the formation of peptide bonds between amino acids is catalyzed by ribozymes.
Several distinct categories of RNA enzymes are known. The first ribozyme to be discovered was an intron that cuts itself out of the RNA it sits in (a self-splicing intron); these ribozymes form a characteristic secondary structure. Smaller self-cleaving RNAs include the hammerhead ribozyme, whose structure shows three A-RNA stems connected to a central two-domain region encompassing the catalytic core.
Riboswitches are noncoding mRNA sequences, found at the 5′ untranslated end (the stretch before the protein-coding part), that interact with small-molecule ligands and interfere with expression of the genes involved in metabolism of these ligands. When the ligand binds, the RNA changes shape, and the new shape turns production of the gene's protein up or down. These single-stranded RNA molecules act without protein assistance. The crystal structure of the adenine-binding riboswitch, which distinguishes bound adenine from guanine with high specificity, has two parallel double helices wrapped around each other and connected by three hairpin loops; the 5′- and 3′-end sequences form the third double helix. The internal bulges zipper up to form the purine binding pocket. The guanine riboswitch from a different organism shows very similar architecture.

(a) An A-RNA dodecamer with non-Watson–Crick pairs in its helix. (b) Phenylalanine tRNA. (c) A group I intron ribozyme. (d) A hammerhead ribozyme; the shorter strand is a DNA that inhibits the reaction. (e) A guanine riboswitch with hypoxanthine (yellow) bound in its pocket.
The ribosome consists of two subunits, each a complex of proteins and ribosomal RNA. In bacteria the 30SThe S (svedberg) numbers measure how fast a particle sinks in a centrifuge, a rough proxy for size. They don't add up: the 30S and 50S subunits make a 70S ribosome. subunit contains about 20 proteins and a single RNA of around 1500 nucleotides; the 50S subunit contains about 30 proteins, an RNA of about 3000 nucleotides, and the small (120 nucleotide) 5S RNA. The large subunit carries out the catalytic step of peptide bond formation, and the sites where it happens are made of RNA, not protein. Bacterial ribosomes are targeted by many clinically important antibiotics, which bind its RNA.
The guanine riboswitch bound to hypoxanthine (orange), 1.95 Å (1U8D). The ligand sits in a pocket at the three-way junction, surrounded entirely by RNA bases. A drug designed against a riboswitch or the ribosome is docked into a pocket like this one, lined with nucleotides instead of side chains.
Open 1U8D in Mol*Check yourself
A 40-nucleotide RNA has the structure ((((((....))))))....((((((....)))))).... and a mutation changes one base
in the first stem. Predict whether the second hairpin's structure changes, and explain using the recursion.
Reasoning
Usually not. The two hairpins are side by side, so the optimal structure for the whole string is the best split at a point between them, and the second hairpin's subproblem doesn't depend on anything in the first. A mutation that weakens the first stem changes its own subproblem's best answer. The exception is when the mutation creates a new pairing partner for bases in the second region, making a structure that spans the split point score better than the two hairpins do.
Two RNAs have the same secondary structure, one stem of eight pairs. In RNA 1 the stem is all G–C pairs; in RNA 2 it alternates A–U and G–U. Which is more likely to keep that structure at 37 °C, and which part of the energy model decides it?
Reasoning
RNA 1. The stability of a stem is a sum over stacked pairs of pairs, and stacks of G–C pairs are the most favorable steps (around −3 kcal/mol each), while steps involving A–U, and especially G–U wobble pairs, are much weaker. The hairpin loop penalty is the same for both, so the stems decide it. RNA 2's stem may be only marginally more stable than the unfolded strand, or less.
In tRNA, G19 pairs with C56 by Watson–Crick hydrogen bonds. Why doesn't it appear in the cloverleaf, and what would happen to the dot-bracket string if you added it?
Reasoning
G19 sits in the D loop and C56 in the T loop. The pair (19, 56) crosses the pairs of the D stem (10–25) and the
T stem (49–65): it has one end inside each of two hairpins that are side by side. A crossing pair can't be
written with one bracket type, so it needs [ and ], which makes it a pseudoknot-like tertiary contact. The
nested secondary structure stays the cloverleaf, and the crossing pairs are what fold it into the L.