Skip to main content
The System class represents the topology of a molecular system, containing atom-level information such as names, residue names, masses, and coordinates.

Loading Systems

from_pdb

System.from_pdb(path: str) -> System
Load a molecular system from a PDB file.
path
str
required
Path to the PDB file
system
System
A System object containing the topology and initial coordinates
from warp_md import System

# Load protein structure
system = System.from_pdb("protein.pdb")
print(f"Loaded {system.n_atoms()} atoms")
PDB files use Angstrom units. Coordinates are automatically stored in the appropriate format.

from_gro

System.from_gro(path: str) -> System
Load a molecular system from a GROMACS GRO file.
path
str
required
Path to the GRO file
system
System
A System object containing the topology and initial coordinates
from warp_md import System

# Load GROMACS structure
system = System.from_gro("conf.gro")
GRO files use nanometers. Coordinates are automatically converted to Angstroms internally.

from_pdbqt

System.from_pdbqt(path: str) -> System
Load a molecular system from a PDBQT file (AutoDock format).
path
str
required
Path to the PDBQT file
system
System
A System object containing the topology
from warp_md import System

# Load docking structure
system = System.from_pdbqt("ligand.pdbqt")

Selection Methods

select

system.select(expr: str) -> Selection
Create a selection of atoms using a selection expression.
expr
str
required
Selection expression using the warp-md selection language
selection
Selection
A Selection object containing the matched atom indices
# Select backbone atoms
backbone = system.select("backbone")

# Select by residue name
water = system.select("resname SOL")

# Select by atom name
ca_atoms = system.select("name CA")
Selections are cached internally for performance. Repeated calls with the same expression return instantly.
Supported Keywords:
  • name - Atom name (e.g., “CA”, “N”, “O”)
  • resname - Residue name (e.g., “ALA”, “SOL”)
  • resid - Residue ID or range (e.g., “1”, “10:20”)
  • chain - Chain identifier (e.g., “A”, “B”)
  • protein - All protein residues
  • backbone - Protein backbone atoms (N, CA, C, O, OXT)
Operators:
  • and - Logical AND
  • or - Logical OR
  • not - Logical NOT
  • () - Grouping

select_indices

system.select_indices(indices: list[int]) -> Selection
Create a selection from an explicit list of atom indices.
indices
list[int]
required
List of zero-based atom indices
selection
Selection
A Selection object containing the specified indices
# Select specific atoms by index
indices = [0, 5, 10, 15]
custom_sel = system.select_indices(indices)

System Information

n_atoms

system.n_atoms() -> int
Get the total number of atoms in the system.
count
int
Number of atoms
count = system.n_atoms()
print(f"System contains {count} atoms")

atom_table

system.atom_table() -> dict
Get detailed information about all atoms as a dictionary.
table
dict
Dictionary containing atom properties:
  • name: List of atom names (str)
  • resname: List of residue names (str)
  • resid: List of residue IDs (int)
  • chain_id: List of chain IDs (int)
  • mass: List of atomic masses (float)
atoms = system.atom_table()

# Access atom properties
for i in range(10):
    print(f"Atom {i}: {atoms['name'][i]} {atoms['resname'][i]} {atoms['resid'][i]}")

# Get all CA atom indices
ca_indices = [i for i, name in enumerate(atoms['name']) if name == 'CA']

positions0

system.positions0() -> np.ndarray | None
Get the initial/reference coordinates from the topology file.
coords
np.ndarray | None
Array of shape (n_atoms, 3) containing xyz coordinates in Angstroms, or None if not available
coords = system.positions0()
if coords is not None:
    print(f"Initial coords shape: {coords.shape}")
    print(f"First atom position: {coords[0]}")
Not all file formats include coordinates. PDBQT files may return None.

Usage Example

from warp_md import System, Trajectory, RgPlan

# Load system
system = System.from_pdb("protein.pdb")
print(f"Loaded {system.n_atoms()} atoms")

# Inspect atom information
atoms = system.atom_table()
print(f"First residue: {atoms['resname'][0]} {atoms['resid'][0]}")

# Create selections
backbone = system.select("backbone")
ca_atoms = system.select("name CA")
chain_a = system.select("chain A")

# Use selections in analysis
traj = Trajectory.open_xtc("trajectory.xtc", system)
plan = RgPlan(ca_atoms, mass_weighted=True)
rg = plan.run(traj, system, device="auto")

print(f"Computed Rg for {len(rg)} frames")

Build docs developers (and LLMs) love