PyMOL Schrödinger

Advanced Scripting Workshop

Part 6: Iterate and Alter

The iterate command family gives access to atom data. It executes a Python expression for every atom in a selection. It's a powerful tool for querying and modifying properties.

Example: Print b-factors, along with relevant atom identifiers:

iterate all, print(chain, resn, resi, name, b)

Example: Rename a chain:

alter chain A, chain="C"

Example: Compute molecular weight:

from pymol import stored
from chempy import atomic_mass

stored.weight = 0.0
stored.atomic_mass = atomic_mass

iterate all, stored.weight += stored.atomic_mass[elem]

print(stored.weight)

Modify chain identifiers

  1. Use PDB 2x1g which contains two biological units in the asymmetric unit: Chains A+B+F and chains C+D+G.
  2. Extract chains C+D+G to a new object (use extract command)
  3. Use alter to rename the chains so that they match in both objects

Hint: This should be a 5-line PML script

Modify residue numbers

PDB 1t46 starts the chain with residue number 565. Use alter to make it start at 1.

Notes:


© 2017 Schrödinger, Inc.