host restriction-modification system
If you owned a powerful pair of scissors that cuts any DNA bearing a certain word, you would face a problem: your own DNA contains that word too. How do you avoid cutting yourself? Bacteria solved this with a two-part system — an enzyme that cuts foreign DNA, paired with a marker that labels the cell's own DNA as 'do not cut'. This is the restriction-modification system, and it is why restriction enzymes exist at all.
The system has two enzymes that read the same recognition site. The restriction endonuclease cuts DNA at that site. The modification enzyme — a methyltransferase — adds a small methyl group (CH3) to a specific base within that same site. A methylated site is invisible to the restriction enzyme: it cannot cut there. The bacterium methylates every copy of the site in its own genome, so its DNA is protected. Invading DNA, such as a virus (bacteriophage) injecting its genome, arrives unmethylated; the restriction enzyme finds the bare sites and chops the invader to pieces. The name reflects the bacterium's-eye view: foreign DNA is 'restricted' (its ability to take over is cut short), while self DNA is 'modified' (tagged safe).
This is a primitive bacterial immune system — a defense against phage that predates the more famous CRISPR by billions of years. For biologists it has two practical consequences. First, it is why restriction enzymes exist for us to harvest. Second, it explains a real lab headache: many strains of E. coli carry their own R-M systems, so DNA you introduce can get chewed up unless you use special host strains with those systems deleted. It also means DNA methylation status can block or permit a cut, which matters when a recognition site overlaps a methylated base.
An E. coli cell carrying the EcoRI system methylates the A in every GAATTC site of its own chromosome, so its own EcoRI enzyme leaves it alone. When a phage injects unmethylated DNA, that DNA's bare GAATTC sites are cut, and the infection is aborted — unless the rare phage happens to have its sites already methylated.
Methylation tags 'self' DNA so the cell's own restriction enzyme spares it.
This bacterial methylation is a defense tag, distinct from the gene-regulating CpG methylation of eukaryotes (epigenetics) — same chemical mark, completely different job.