Skip to content

Utils

cli_align_pdb()

Command-line interface for aligning PDB file.

cli_filter_pdb()

Command-line interface for filtering PDB file lines

cli_merge_pdbs()

Command-line interface for merging PDB files

cli_write_pdb()

Command-line interface for writing PDB from topology and coordinate files.

keep_lines(lines, record_types=('ATOM', 'HETATM', 'TER', 'END'))

Filter PDB lines to keep in file.

PARAMETER DESCRIPTION
lines

List of lines in the PDB file.

TYPE: Iterable[str]

record_types

Records to keep in the PDB file.

TYPE: tuple[str, ...] DEFAULT: ('ATOM', 'HETATM', 'TER', 'END')

RETURNS DESCRIPTION
list[str]

Filtered lines.

parse_atomname(line)

Gets the atom name from a line.

PARAMETER DESCRIPTION
line

Line of a PDB file that starts with ATOM or HETATM.

TYPE: str

RETURNS DESCRIPTION
str

Atom name.

parse_resid(line)

Gets the residue ID from a line.

PARAMETER DESCRIPTION
line

Line of a PDB file that starts with ATOM or HETATM.

TYPE: str

RETURNS DESCRIPTION
str

Residue ID.

parse_resname(line)

Gets the residue name from a line.

PARAMETER DESCRIPTION
line

Line of a PDB file that starts with ATOM or HETATM.

TYPE: str

RETURNS DESCRIPTION
str

Residue ID.

replace_in_pdb_line(line, orig, new, start, stop)

General function to replace parts of a PDB line.

PARAMETER DESCRIPTION
line

PDB line.

TYPE: str

orig

Original value to check if it exists.

TYPE: str

new

If orig is in line, replace it with this value. This must be formatted for all columns, not just the value with no spaces. For example, " 42" not "42".

TYPE: str

start

Slice the line starting here to replace.

TYPE: int | None

stop

Slice the line stopping here to replace.

TYPE: int | None

run_align_pdb(pdb_path, out_path, selection_str=None)

Align structure in PDB file.

PARAMETER DESCRIPTION
pdb_path

Path to PDB file.

TYPE: str

out_path

Path to write aligned PDB file.

TYPE: str

selection_str

Selection string for MDAnalysis universe.

TYPE: str | None DEFAULT: None

run_filter_pdb(pdb_path, output_path=None, record_types=None)

Only keep PDB lines that contain specified record types.

PARAMETER DESCRIPTION
pdb_path

Path to PDB file.

TYPE: str

output_path

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

TYPE: str | None DEFAULT: None

record_types

Records to keep in the PDB file. Defaults to ("ATOM", "HETATM", "TER", "END").

TYPE: tuple[str, ...] | None DEFAULT: None

RETURNS DESCRIPTION
list[str]

PDB file lines.

run_merge_pdbs(*pdb_paths, output_path=None)

Merge PDB files. No atoms are removed, only added.

PARAMETER DESCRIPTION
*pdb_paths

Paths to PDB files in order of decreasing precedence. We assume the residue indices are consistent across PDB files.

TYPE: str DEFAULT: ()

run_write_pdb(file_paths, output_path, selection_str=None, stride=1)

Write PDB file from file paths.

PARAMETER DESCRIPTION
file_paths

Paths of files to load into MDAnalysis.

TYPE: Iterable[str]

output_path

Path to save PDB file.

TYPE: str

selection_str

Selection string for MDAnalysis universe.

TYPE: str | None DEFAULT: None