Overlay
overlay.py is a PyMOL Python script for least-squares superposition of molecular structures.
The script determines corresponding atoms, calculates the optimal rigid-body transformation, and applies the transformation to the mobile PyMOL object.
Installation
Download overlay.py from the project's GitHub repository: https://github.com/JezTame/pymol-overlay
Load the script in PyMOL:
run overlay.py
Usage
Superimpose one object onto another:
overlay mobile, target
The mobile object is transformed; the target remains fixed.
For proteins, the fit uses corresponding C-alpha atoms. For ligands, heavy atoms are matched by atom name.
The RMSD is reported in the PyMOL terminal.
Options
Protein residue correspondence can be specified using strict residue-number matching or ordered matching.
overlay mobile, target, mode=ordered
A text report is generated by default containing the rotation matrix, translation vector and screw-axis information.
Atom selection and correspondence
`overlay.py` can superimpose not only complete molecules but also selected portions of molecules, such as the adenosine or phosphate groups of ADP, ATP or NAD. For non-protein structures, the least-squares fit uses all selected non-hydrogen atoms.
- The order of atom picking in the two selections is immaterial.** Corresponding atoms are identified by their atom names, not by their order in the PDB file or in the PyMOL selection. The two selections being compared may contain atoms in completely different order, provided that every selected atom has a uniquely named counterpart in the other selection.
The script checks that atom names and element types agree before calculating the transformation. If the selections contain unmatched or duplicate atom names, an error is reported, and no fitting is performed.
The resulting rotation and translation are applied to the **entire parent object** of the moving selection, not just to the atoms used to calculate the fit. This allows, for example, the adenosine portions of ADP and NAD to be superimposed while retaining and transforming the complete molecules.
Notes
The script performs least-squares superposition without iterative rejection of outliers.
Atom correspondence is validated before applying the fit.