Learning LibraryBiotech LibraryTeens

Proteins and amino acids: building the chain

A protein is a chain of amino acids, folded into a machine that does a job in your body. Building that chain from codons is just appending to a list until you hit a stop.

The big idea

A protein is a sequence of amino acids linked in order; translation builds it by appending each amino acid until a stop codon.

See it in code

1The basics

A protein is a chain of amino acids in a set order, and in Python that's a list. Once you have one, indexing reaches any link and len counts them:

python
chain = ["Met", "Ala", "Gly"]
print("Protein:", chain)
print("First amino acid:", chain[0])
print("Length:", len(chain), "amino acids")
Run it — a three-link protein you can index and measure:
Protein: ['Met', 'Ala', 'Gly']
First amino acid: Met
Length: 3 amino acids

chain[0] is the first amino acid and len(chain) is the protein's length. The order the list keeps is the order the amino acids sit in — that matters.

2A step further

Real proteins aren't handed to you as amino acids — they're built from codons. Look up each codon in the table and append the result to a growing chain:

python
codons = ["AUG", "GCU", "GGC"]
table = {"AUG": "Met", "GCU": "Ala", "GGC": "Gly"}

chain = []
for c in codons:
    chain.append(table[c])
print("Chain:", chain)
Run it — three codons translated and linked in order:
Chain: ['Met', 'Ala', 'Gly']

Look up, append, repeat — the chain grows one amino acid at a time. All that's missing is knowing when to stop.

3In our world

Add the stop codon, and the same build becomes real translation: look up each amino acid, add it to the chain, and let UAA end it — everything before the stop is the protein:

python
codons = ["AUG", "GCU", "GGC", "UAA"]
table = {"AUG": "Met", "GCU": "Ala", "GGC": "Gly", "UAA": "Stop"}

chain = []
for c in codons:
    amino = table[c]
    if amino == "Stop":
        break
    chain.append(amino)

print("Amino acid chain:", chain)
print("Protein length:", len(chain), "amino acids")
Run it — three amino acids linked into a short protein:
Amino acid chain: ['Met', 'Ala', 'Gly']
Protein length: 3 amino acids

The order matters enormously: Met-Ala-Gly folds differently from Gly-Ala-Met, and shape determines function. The list preserves order exactly, which is why a list — not a set — is the right structure for a protein.

The same idea, everywhere

Building an ordered result by appending in a loop is one of the most common patterns in all of programming: assembling a report line by line, collecting search hits, constructing a path. The 'accumulate into a list' shape shows up far beyond biology.

Try it yourself

Add codons before the stop and watch the protein lengthen. Then count how many times a specific amino acid appears with chain.count("Ala") — a first step toward analyzing what a protein is made of.

The common mistake

Treating a protein as an unordered bag of amino acids. Sequence is everything — the same amino acids in a different order fold into a different (or broken) protein. Never sort or shuffle the chain; its order is the information.

What it unlocks

Proteins are the output of translation and the genetic code, assembled with lists and list methods.