Skip to content

Prepare trypsin and select a local region

Trypsin and benzamidinium form the starting complex from PDB 3PTB. The example assigns BEN+, removes crystallographic waters, completes supported residues, and retains the crystal heavy-atom coordinates. It then extracts a receptor pocket for local analysis.

Prepared trypsin and benzamidinium

The displayed coordinates are a prepared starting structure. They contain 3239 atoms, including 18 ligand atoms. The receptor pocket contains 431 atoms and 14 peptide caps. The figure includes separate Protein, Benzamidinium, and Ions layers. The figures below follow the same complex through relaxation, MD, and local electronic analysis. Nequix MP-1 supplies the demonstration trajectory. The model’s protein accuracy has not been validated.

Read the crystal structure and assign the ligand’s charge state explicitly. In this 3PTB file, A:1:1 identifies the BEN residue. BEN+ selects benzamidinium with formal charge +1. Preparation repairs supported residues and adds hydrogens without moving existing atoms.

from atomli.biomol import prepare, select, within, extract_cluster
from atomli.io import read, write
source = read("3PTB.pdb")
result = prepare(source, ph=7.4, variants={"A:1:1": "BEN+"}, remove_waters=True)
atoms = result.atoms
write("prepared.h5", atoms)

The pH policy selects intrinsic residue defaults. Use explicit variants when the local chemical environment requires another state. The biomolecular guide explains residue keys, templates, and preparation reports.

Keep the protein and small molecule in separate Tako layers. The calcium ion receives its own layer.

from atomli.visualize import Viewer
protein = select(atoms, hetero=False)
ligand = select(atoms, resname="BEN")
layers = {
"Protein": protein,
"Benzamidinium": ligand,
"Ions": select(atoms, element="Ca"),
}
Viewer([atoms], look={
"proteinRepresentation": "cartoon",
"layers": layers,
"labels": False,
"cell": False,
}).write_html("prepared.html")
FIRE steps
533
Final maximum force
0.0445eV/Å
Energy change
-102.71eV

Click a measured point to select its geometry.

Click a measured point to select its geometry.

Cα trace, complete ligand, and calcium. All atoms enter the calculation.

Cα trace, complete ligand, and calcium. All atoms enter the calculation. Step 0 · Fmax 5.6002 eV/Å

Coordinates and traces: nequix-mp-1 on gpu; recorded native Atomli drivers.Model scope: Workflow demonstration; protein accuracy is unvalidated.

The maximum force falls from 5.60 to 0.0445 eV/Å in 533 FIRE steps. The dotted line marks the 0.05 eV/Å stopping criterion. Click a measured point to inspect its geometry. The viewer shows the Cα trace, complete ligand, and calcium. The calculation includes all 3239 atoms.

Attach the MLIP and record frames during relaxation. Stop if the force criterion is not met.

from atomli.calculators import MLIP
from atomli.optimize import FIRE
atoms.calc = MLIP("nequix-mp-1", device="gpu")
relax_frames = [atoms.copy()]
optimizer = FIRE(atoms, logfile="relaxation.log")
optimizer.attach(lambda: relax_frames.append(atoms.copy()), interval=20)
if not optimizer.run(fmax=0.05, steps=3000):
raise RuntimeError("MLIP relaxation did not converge")
relax_frames.append(atoms.copy())
Viewer(relax_frames, look={"layers": layers, "proteinRepresentation": "cartoon",
"labels": False, "cell": False}).write_html("relaxation.html")
Trajectory duration
500fs
Thermostat target
300K
Final temperature
306.2K

Click a measured point to select its geometry.

Click a measured point to select its geometry.

Cα trace, complete ligand, and calcium. All atoms enter the calculation.

Cα trace, complete ligand, and calcium. All atoms enter the calculation. 0 fs · 304.8 K

Coordinates and traces: nequix-mp-1 on gpu; recorded native Atomli drivers.Model scope: Workflow demonstration; protein accuracy is unvalidated.

Use the playback controls to inspect motion. Click a potential energy or temperature point to select its saved frame. The temperature trace records the initial energy exchange and thermostat response. This short trajectory does not establish protein equilibration.

Initialize velocities and use the same calculator for Langevin dynamics. These settings describe 0.5 ps of NVT dynamics at 300 K. The prepared model is nonperiodic and contains no solvent.

from atomli import units
from atomli.md.langevin import Langevin
from atomli.md.velocitydistribution import MaxwellBoltzmannDistribution
MaxwellBoltzmannDistribution(atoms, temperature_K=300)
frames = [atoms.copy()]
md = Langevin(
atoms, timestep=0.5 * units.fs, temperature_K=300,
friction=0.01 / units.fs, seed=20261111,
)
md.attach(lambda: frames.append(atoms.copy()), interval=20)
md.run(1000)
write("trajectory.h5", frames)
Viewer(frames, look={"layers": layers, "proteinRepresentation": "cartoon",
"labels": False, "cell": False}).write_html("dynamics.html")

The saved frames retain molecular topology. The same layers selection applies to every frame because MD preserves atom order.

Cluster atoms
446
Formal charge
0e
Peptide caps
14

Select a bar to locate its atom.

Select a bar to locate its atom.

Benzamidinium and the receptor pocket. ACE/NME caps are amber.

Benzamidinium and the receptor pocket. ACE/NME caps are amber. GLN221:C · |F| = 3.405 eV/Å

Forces: gxtb analytical forces on the isolated post-MD capped cluster.Geometry: nequix-mp-1 trajectory; caps added after region extraction.

The extracted post-MD complex contains 446 atoms. Its formal charge is 0. Amber atoms mark the ACE/NME caps. Select a force bar to locate its atom in the cluster. The g-xTB forces are evaluated at the extracted MD geometry, before any local g-xTB minimization.

Select the ligand and whole residues within 6 Å of its final MD coordinates. Extraction retains required disulfide partners and adds ACE/NME caps at peptide cuts. Use the resulting formal charge for the electronic calculation. unpaired=0 requests a closed shell and checks the electron-count parity.

from atomli.calculators import XTB
region = within(atoms, ligand, 6.0, residues=True)
cluster = extract_cluster(atoms, region, reference_atom=ligand[0], unpaired=0)
local = cluster.atoms
local.calc = XTB(
method="gxtb", charge=cluster.report["formal_charge"],
unpaired=0, device="cpu",
)
energy = local.get_potential_energy()
forces = local.get_forces()

The saved local force figure uses g-xTB. To evaluate the same region with DFT, replace its calculator. This example uses PBE/def2-SVP. Energies use eV and forces use eV/Å.

from atomli.calculators import QC
local.calc = QC(
xc="PBE", basis="def2-SVP", charge=cluster.report["formal_charge"],
unpaired=0, device="cpu",
)
energy = local.get_potential_energy()
forces = local.get_forces()

Both electronic calculations use isolated cluster boundaries. The cluster report records caps, boundary expansions, charge, and the mapping to the complete complex.

Complete scripts and saved data

The complete scripts retain full structures, scalar traces, and calculation records. The figure script uses these saved results to build the linked views.

Preparation script · Simulation script · Figure script · Input PDB · Prepared mmCIF · Relaxed complex · Final MD complex · Simulation record · Preparation report · Cluster report