Machine Learning for Biology01 / 06

Peptides 101: The Tiny Molecular Sentences Your Body Writes

I spent two years training models on peptides before I could explain, out loud and without hedging, what a peptide actually is. This is the explanation I wish someone had handed me on day one, and the first post in a series on machine learning for biology.


#1. Twenty letters, one alphabet

Life writes with twenty letters.

Every protein in every living thing, from the enzyme digesting your lunch to the keratin in your hair to the antibodies hunting a virus, is a string built from twenty amino acids. (Two extras, selenocysteine and pyrrolysine, get spliced in by special machinery in some organisms. You can ignore them until the day you cannot.)

Each amino acid gets a one-letter code:

A  Alanine        M  Methionine
C  Cysteine       N  Asparagine
D  Aspartic acid  P  Proline
E  Glutamic acid  Q  Glutamine
F  Phenylalanine  R  Arginine
G  Glycine        S  Serine
H  Histidine      T  Threonine
I  Isoleucine     V  Valine
K  Lysine         W  Tryptophan
L  Leucine        Y  Tyrosine

So a real biological molecule can be written down like this:

GLFDIIKKIAESF

Thirteen letters. That is a peptide, and specifically it is aurein 1.2, secreted by the skin of an Australian bell frog, where it punches holes in bacteria. I will keep coming back to it because it is short enough to reason about by hand.

If you are a programmer, your instinct is already correct: this is a string, and strings are something we know how to model. Hold onto that. Also hold onto the fact that it is a physical object with a shape, because the gap between those two facts is where the whole field lives.


#2. Word, sentence, novel

Here is the distinction that confused me longest, so let us kill it immediately. One unit inside a chain is called a residue: joining it to its neighbours costs it a water molecule, so what sits in the chain is the residue of the free amino acid. Chain lengths are counted in residues.

NameLengthAnalogy
Amino acid1 residuea letter
Peptide~2 to 50 residuesa word or short sentence
Polypeptide~50+ residuesa paragraph
Proteinusually 100+, folded, functionala whole chapter, bound into a book

There is no hard border between “long peptide” and “small protein”. Biology does not care about our taxonomies. The practical rule most papers use is: under about 50 residues, call it a peptide.

That length difference is not cosmetic. It changes everything downstream:

  • A protein has enough chain to fold into a large stable three-dimensional shape, with pockets and grooves that other molecules slot into.
  • A peptide is short and floppy, and often only commits to a definite shape when it touches its target.

Which is why peptide prediction is a genuinely different problem from protein prediction. Tools tuned for 300-residue proteins fall over on 15-residue peptides, and not because of a bug. Most of them lean on evolutionary signal, and a 13-letter string has almost none to lean on. I learned this the expensive way, by trusting a confidence score that had nothing to be confident about.


#3. The chain: how letters get joined

Every amino acid has the same skeleton and one variable part:

             R                R is the side chain: the only
             │                part that differs between the
   H2N ───── C ───── COOH     twenty letters

             H

   amino     alpha    carboxyl
   end       carbon   end

Two amino acids join when the amino end of one bonds to the carboxyl end of the other, kicking out a water molecule. That link is a peptide bond, and a chain of them is a peptide:

N-terminus                                       C-terminus
    ▼                                                ▼
   H2N─[G]─C(=O)─N(H)─[L]─C(=O)─N(H)─[F]─ ··· ─[F]─COOH
           └───┬────┘
         peptide bond

Three consequences worth carrying around:

  1. Direction matters. A peptide runs from the N-terminus to the C-terminus, and that is the direction sequences are always written in. GLFDII and IIDFLG are different molecules, exactly as dog and god are different words. Order is information.
  2. The backbone is boring; the side chains are the story. The repeating N-C-C spine is identical everywhere. All the chemistry, meaning charge, greasiness, size, and the ability to form bonds, lives in the twenty R groups.
  3. The peptide bond itself is rigid and flat. It cannot rotate. So each residue contributes only two real degrees of freedom to the backbone, the angles and on either side of the alpha carbon. Protein folding is a big search, but it is a much smaller search than “any arrangement of atoms”.

So when we build features for machine learning, we are almost always summarising side-chain properties along a sequence.


#4. Five properties that explain most peptide behaviour

You do not need to memorise twenty amino acids. You need the handful of axes they vary along.

PropertyWhat it meansExamples
Chargesign of the side chain at blood pHK, R are +, D, E are −
Hydrophobicitydoes it prefer oil or water?L, I, V, F, W hate water
Sizehow much room the side chain takesG is tiny, W is huge
Polaritycan it form hydrogen bonds?S, T, N, Q are polar
Special shapesstructural oddballsP kinks the chain, C forms disulfide bridges

Now look back at aurein 1.2 with those axes in mind:

SEQ = "GLFDIIKKIAESF"  # aurein 1.2

# Every paper draws the hydrophobic line somewhere slightly different,
# which is itself a warning about how solid this feature is.
HYDROPHOBIC = set("AVLIMFWYC")
POSITIVE = set("KR")  # H is only partly protonated at pH 7.4, so leave it out
NEGATIVE = set("DE")

n = len(SEQ)
hydro = sum(c in HYDROPHOBIC for c in SEQ) / n
side_chain_charge = sum(c in POSITIVE for c in SEQ) - sum(c in NEGATIVE for c in SEQ)

print(f"length            : {n}")
print(f"hydrophobic ratio : {hydro:.2f}")
print(f"side-chain charge : {side_chain_charge:+d}")
length            : 13
hydrophobic ratio : 0.54
side-chain charge : +0

Fifty-four per cent greasy, side chains cancelling out, thirteen residues long. Short, half oily, mixed charges: that is the classic signature of a membrane-interacting peptide.

Now the correction that took me embarrassingly long to internalise. That charge number is wrong for the real molecule. Counting side chains ignores the ends of the chain: the free N-terminus carries a positive charge, and the free C-terminus a negative one. Worse, aurein 1.2 is amidated at the C-terminus in the frog, which removes that negative charge entirely. So the real net charge is +1, not 0, and the +1 is not a rounding detail. It is the thing that makes the peptide stick to a bacterial membrane, which is negatively charged, rather than to one of your own cells, which is not.

The lesson generalises: a sequence string is a lossy encoding of a molecule. Modifications, termini, disulfide bonds and D-amino acids all sit outside the twenty-letter alphabet, and if your dataset mixes modified and unmodified peptides without recording which is which, your model is learning from a corrupted label.


#5. Sequence, structure, function

The central chain of causation in this field:

The letters determine the shape, and the shape determines what the molecule does.

A peptide’s shape comes from a tug of war. Greasy side chains want to hide from water. Opposite charges want to touch. The backbone can only bend in certain ways. The molecule settles into whatever arrangement makes all those pressures least unhappy.

For aurein 1.2 the arrangement is an alpha helix, and the helix has a trick in it. An alpha helix turns about 100 degrees per residue, so if you look down the axis and mark where each residue points, you can see whether the greasy ones happen to land together:

     charged face     greasy face
             K8+  G1   S12
                   ┊      I5

       D4-         ┊

    E11-           ┊           I9

                   ┊           L2

       K7+         ┊         F13

                   ┊      I6
             F3   A10

Right of the line is S12 I5 I9 L2 F13 I6: five of those six are greasy, and S12 is a small polar residue that costs little to bury. Left of it is K8 D4 E11 K7, every charged residue in the peptide. G1 and A10 sit on the boundary, which is what tiny neutral residues tend to do. That is an amphipathic helix: a greasy face that slides into a membrane and a charged face that grips its surface. The split is not perfect, F3 lands just on the wrong side, and that is normal. Real molecules are messier than the diagram.

But the helix only exists once there is a membrane to form it against:

   free in water                    docked on a membrane
   ─────────────                    ────────────────────

    G L F D I I K K I A E S F         K   K     D   E     charged, up
      no fixed shape, an              ┌────────────────┐
      ensemble of many                │  alpha helix   │
                                      └────────────────┘
                                        L F I I  I A      greasy, down
                                      ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  membrane

#The AlphaFold objection

At which point someone always says: AlphaFold solved this years ago. For proteins, largely yes. AlphaFold2 made single-chain structure prediction routine in 2021, AlphaFold3 extended it to complexes with ligands and nucleic acids in 2024, and open models in the same family now run on one GPU, with Boltz the easiest to pick up because its weights carry a permissive licence. For a 300-residue enzyme the middle term of that chain is something you look up rather than something you fight.

For a 13-residue peptide it is not, and the reasons are structural rather than temporary:

  • No evolutionary signal. These methods lean hard on multiple sequence alignments: stacks of the same protein collected from hundreds of species, where positions that mutate in step with each other betray which residues sit close together in the fold. A designed 13-residue peptide has no family to align against, so the model is working blind.
  • There often is no single answer. Aurein 1.2 in water is an ensemble, not a structure. Asking for “the” conformation is a badly posed question, and a confidence score returned for a badly posed question is not information.
  • The useful prediction is the complex. Co-folding the peptide together with its receptor is the query that makes sense, and it requires you to already know the receptor. For an anti-inflammatory peptide screen, often you do not.

So in practice, peptide work still learns sequence → function directly, skipping the middle term. That is harder, and it is exactly why dataset honesty matters so much here. A model that never sees structure has nothing but statistical regularities in the letters to go on, and if your data contains a shortcut, the model will find the shortcut instead of the biology. I write about that failure at length in the honest negatives post, and it is the reason my own anti-inflammatory peptide results read lower than the published numbers they sit beside.


#6. What peptides actually do

Peptides are not a curiosity. They are a therapeutic class, and currently a very large one.

Signals. Insulin is a peptide hormone: 51 residues in two chains held together by disulfide bridges, telling your cells to take in glucose. Oxytocin is nine residues, closed into a ring by a single disulfide.

Weapons. Antimicrobial peptides such as aurein 1.2 disrupt bacterial membranes. Because they attack the membrane physically rather than inhibiting one enzyme, resistance is harder to evolve, though not impossible.

Brakes. Anti-inflammatory peptides, the family I work on in my own research, damp down an immune response that has overshot. Inflammation is essential right up until it is not; in rheumatoid arthritis, inflammatory bowel disease or a cytokine storm, the response itself is the disease.

Drugs. Peptide therapeutics sit in a genuinely useful middle ground. Mass below is in daltons, one dalton being roughly the mass of a hydrogen atom:

Small moleculesPeptidesAntibodies
Typical massunder ~500 Da~500 to 5,000 Da~150,000 Da
Target specificityoften loosegoodexcellent
Oral dosingusually yesrarely, and only with helpno
Blood half-lifehoursminutes unless engineereddays to weeks
Cost to manufacturelowmediumhigh
Off-target effectsmorefewerfewest

More specific than a small molecule, far cheaper and easier to make than an antibody. Two of those rows have moved since the textbook version of this table was written. Native peptides are cleared in minutes, but attaching a fatty acid so the peptide rides on serum albumin stretches that to about a week, which is how the GLP-1 receptor agonists became once-weekly injections and then the best-selling drugs in the world. And oral peptide dosing, long assumed impossible, now exists: oral semaglutide is a real approved product, though it needs an absorption enhancer and delivers on the order of one percent of the dose into the blood. Expensive, but no longer a closed door.


#7. Where machine learning comes in

Here is the problem in one sentence.

The space of possible 15-residue peptides has size

Thirty-three quintillion. Synthesising and assaying one peptide costs real money and real days. At a thousand tests a day you would not finish before the sun burns out.

So the question is never “can we test them all”. It is:

Given a sequence, can we predict whether it is worth testing?

That is a classifier. Input: a string over a 20-letter alphabet. Output: a probability. And a classifier that is only moderately good still reshapes the economics, because it moves the expensive step later in the funnel:

   every 15-letter string over the alphabet          3.3 x 10^19

              │  restrict to a library you can enumerate

   candidate set on disk                             ~10^5

              │  featurise, then score with a classifier
              │  (minutes on one GPU, no reagents)

   ranked shortlist                                  ~10^2

              │  synthesise and assay
              │  (weeks, and a real budget)

   confirmed hits                                    a handful

Every arrow in that picture is cheap except the last one. The classifier does not have to be right. It has to be right often enough that the last arrow points at better candidates than random sampling would.

The catch, and the thing that makes this interesting rather than routine, is that models eat numbers and biology hands you letters. GLFDIIKKIAESF is not a feature vector. Turning it into one without throwing away the order, the charge pattern or the local neighbourhoods that matter is the whole craft. You can hand-build those numbers, which is the next post, or you can let a protein language model build them for you, which is the post after that. Both work. Neither wins as cleanly as you would expect on sequences this short.


#8. The short version

  • Peptides are short strings over a 20-letter amino-acid alphabet, roughly 2 to 50 letters.
  • Direction matters, the backbone is uniform, and the side chains carry all the chemistry.
  • Five axes explain most behaviour: charge, hydrophobicity, size, polarity, special shapes.
  • The sequence string is lossy. Termini, amidation and disulfides change the molecule without changing a single letter, and my own charge calculation was wrong until I accounted for them.
  • sequence → structure → function. AlphaFold-class models largely solved the middle term for proteins, and did not solve it for 13-residue peptides, because there is often no single structure to predict and no evolutionary signal to predict it from.
  • So peptide work learns sequence → function directly, which is both possible and fragile.
  • The search space is astronomically large, which is precisely why an imperfect classifier in front of the wet lab is worth building.

Series: Machine Learning for Biology. Next up, turning a peptide into numbers: composition, dipeptides, CKSAAP, CTD, and the rest of the descriptor zoo.