Skip to content

Extract

extract_atoms(path_topo, select=None, frames=None, path_output=None, path_coords=None, kwargs_universe=dict(), kwargs_writer=dict(), overwrite=False)

Extract atoms or frames from molecular structure(s) using MDAnalysis.

PARAMETER DESCRIPTION
path_topo

Path to topology file.

TYPE: str

select

TYPE: str | None DEFAULT: None

frames

Extract frames from a trajectory. If None, the whole trajectory will be included. This is only relevant when path_output is specified.

TYPE: Sequence[int] | None DEFAULT: None

path_output

Path to save new coordinate file. If None, then no file is written.

TYPE: str | None DEFAULT: None

path_coords

Paths to coordinate file(s) to load.

TYPE: str | list[str] | None DEFAULT: None

kwargs_universe

Keyword arguments for initializing the MDAnalysis Universe.

TYPE: dict[str, Any] DEFAULT: dict()

kwargs_writer

Keyword arguments for MDAnalysis writers.

TYPE: dict[str, Any] DEFAULT: dict()

overwrite

Overwrites coordinate file located at path_output. This will error out if False and the file exists.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
AtomGroup

Atomic positions after atom selection.

Example

Suppose we want to extract just protein atoms from an Amber simulation.

run_select_atoms(
    path_topo="mol.prmtop",
    select="protein",
    frames=[0, -1],
    path_output="protein.nc",
    path_coords="traj.nc",
)