FB
Deep Learning Neural Networks Bioinformatics Python

RNA Secondary Structure Prediction with Deep Learning

A Bachelor's thesis in Computer Engineering (University of Pisa) exploring deep-learning approaches that improve existing solutions for predicting how RNA molecules fold — a foundational problem for medicine, drug development and bioinformatics.

RNA secondary structure prediction with deep learning

Why RNA structure matters

RNA is far more than a passive messenger between DNA and protein. Non-coding RNAs regulate gene expression, catalyse reactions and form the working machinery of the cell, and their function is determined by how the single strand folds back on itself. That folding — the pattern of base pairs that gives RNA its secondary structure — governs whether a molecule is stable, what it interacts with, and how it behaves as a drug target or a therapeutic in its own right. Understanding structure is therefore a prerequisite for RNA-based medicine, from mRNA vaccines to antisense and small-molecule approaches.

Determining structure experimentally, through crystallography or chemical probing, is accurate but slow and expensive. Computational prediction fills the gap by inferring the most likely base-pairing pattern directly from sequence, at a fraction of the cost — provided the predictions are reliable enough to trust.

The limits of classical prediction

The established computational approach minimises a thermodynamic free-energy model using dynamic programming. These methods are principled and fast, but they rest on approximate energy parameters and, in their classical form, cannot represent important real structures such as pseudoknots — the crossed base pairs that appear in many functional RNAs. Their accuracy also degrades as sequences grow longer. The result is a well-understood but imperfect baseline that leaves room for data-driven methods to help.

A deep-learning approach

This thesis investigates how deep learning can improve on those existing solutions by learning the mapping from sequence to structure directly from data rather than from a fixed energy model. Framed this way, secondary-structure prediction becomes a task neural networks are well suited to: capture the long-range dependencies between distant bases that pair up, generalise across families of RNA, and represent patterns that hand-crafted thermodynamic rules struggle to encode.

The work examines how neural architectures can be trained on curated RNA datasets, how predicted base-pairing can be evaluated against known structures, and where learned models complement — rather than simply replace — the strengths of the classical thermodynamic methods. The emphasis throughout is on improving existing pipelines pragmatically, combining the reliability of established tools with the flexibility of representation learning.

A concrete example: reading a stem-loop

To make the task tangible, consider the most common RNA motif, the stem-loop (or hairpin). A stretch of the strand pairs with a complementary stretch further along — A with U, G with C — forming a double-helical "stem," while the unpaired bases in between bulge out as a "loop." Predicting this correctly means recognising that two regions which are far apart when you read the sequence left-to-right actually belong together in space. Multiply that across dozens of interacting stems, loops, bulges and junctions, and the combinatorics explain why the problem is hard. A good model has to reason about the whole sequence at once, weighing every candidate pairing against all the others, because closing one stem changes which other pairings are still possible. This is precisely the kind of global, long-range reasoning that modern neural architectures are built for, and why framing the output as a full base-pairing matrix — rather than a left-to-right label sequence — matches the structure of the biology.

Data, training and evaluation

Any learned predictor is only as good as the data and the yardstick used to judge it. RNA structure prediction is evaluated by comparing the predicted set of base pairs against experimentally determined reference structures, typically using precision, recall and F1 over the predicted pairs — a natural fit because the task reduces to deciding, for every possible pair of positions, whether the two bases bond. Careful dataset curation matters just as much: models must be tested on RNA families they were not trained on, otherwise apparent accuracy simply reflects memorised homologues rather than a genuinely learned folding prior. This thesis treats that train/test discipline as central, so that reported improvements over the classical baseline are meaningful rather than an artefact of data leakage.

The technical stack

The experiments are implemented in Python using standard deep-learning and scientific-computing tooling — neural-network frameworks for model definition and training, alongside NumPy and pandas for handling sequence datasets and structural annotations, and established RNA benchmarks for evaluation. The project is structured as a reproducible experimental pipeline covering data preparation, model training and quantitative comparison against classical predictors.

From prediction to therapeutics

Better structure prediction is not an academic nicety — it feeds directly into RNA-based medicine. The design of mRNA vaccines depends on choosing sequences that fold into stable, well-translated structures; small interfering RNAs and antisense oligonucleotides must reach their targets without being trapped in unintended folds; and riboswitches and other structured RNAs are increasingly viewed as druggable targets for small molecules. In each case, a fast and reliable computational estimate of how a candidate sequence will fold lets researchers screen and refine designs in silico long before committing to synthesis and assays, shortening iteration cycles across the life sciences.

Connection to my later research

RNA secondary structure prediction was the entry point into a longer line of work on structure-aware machine learning for the life sciences. The same core intuition — that biological molecules are governed by their shape, and that models should learn from structure rather than raw sequence — carries directly into my later Master's research on Aptamer Predictive Triage, where geometric and generative deep learning are applied to designing molecular binders. Both sit within a broader focus on applied AI for healthcare and medicine.

Architectures that fit the problem

Secondary-structure prediction is, at heart, a decision about every possible pair of positions in a sequence: do these two bases bond or not? That framing points naturally toward neural architectures that can model relationships between distant tokens. Recurrent and convolutional networks capture local context and medium-range motifs; attention-based models and pairwise representations are well suited to the long-range dependencies that define stems and loops, where bases far apart in sequence sit adjacent in structure. Casting the output as a base-pairing probability matrix lets the model reason about the whole structure at once and makes it straightforward to compare against a known contact map during training.

The pragmatic contribution of this thesis is not to crown a single architecture but to show where learned models add value on top of the classical thermodynamic pipeline — for instance on sequences and motifs the energy model handles poorly — while being honest about where the established tools remain strong. Treating the two families as complementary, rather than as rivals, is what makes the result useful to a working bioinformatician.

Limitations and future directions

Deep learning is not a free win for RNA structure. Learned models can inherit the biases of the databases they are trained on, and because well-characterised structures cluster into a limited set of RNA families, a model can look excellent on paper while quietly overfitting to homologues it has effectively already seen. That is why held-out, cross-family evaluation is non-negotiable and why the classical thermodynamic methods remain a valuable, bias-free baseline to measure against. Pseudoknots, long non-coding RNAs and tertiary interactions push every current method to its limits. The natural next steps follow directly from these gaps: richer structural supervision, architectures that model pairwise interactions explicitly, and hybrid systems that let a neural model refine a thermodynamic prediction rather than start from scratch. Framing the work this way — as steady, measurable improvement on a hard, well-defined problem — is what makes it credible rather than hype.

Frequently asked questions

What is RNA secondary structure prediction?

It is the computational task of inferring, from an RNA sequence, the pattern of base pairs the molecule forms when it folds — the secondary structure that largely governs its stability, interactions and function.

Why use deep learning instead of thermodynamic methods?

Classical methods rely on approximate energy parameters, cannot represent pseudoknots in their standard form, and degrade on longer sequences. Deep learning can learn the sequence-to-structure mapping from data, capturing patterns fixed rules miss — ideally complementing, not replacing, the classical approach.

How is it evaluated?

By comparing predicted base pairs to experimentally determined structures with precision, recall and F1 — and, crucially, by testing on RNA families not seen in training so the score reflects real generalisation.

Why does this matter for medicine?

RNA folding underpins mRNA vaccines, siRNA and antisense therapeutics, and structured RNA drug targets. Reliable prediction enables in-silico screening and refinement before expensive synthesis and assays.

Building AI for computational biology?

I design machine-learning and deep-learning systems for healthcare, medicine and the life sciences.

Get in touch