PDB File Parser#

PDB file parser for molecular structure analysis using pdbreader.

This module provides functionality to parse PDB (Protein Data Bank) files and extract atomic coordinates and molecular information using the pdbreader library.

class hbat.core.pdb_parser.PDBParser[source]#

Bases: object

Parser for PDB format files using pdbreader.

This class handles parsing of PDB (Protein Data Bank) format files and converts them into HBAT’s internal atom and residue representations. Uses the pdbreader library for robust PDB format handling.

__init__() None[source]#

Initialize PDB parser.

Creates a new parser instance with empty atom and residue lists.

parse_file(filename: str) bool[source]#

Parse a PDB file.

Reads and parses a PDB format file, extracting all ATOM and HETATM records and converting them to HBAT’s internal representation.

Parameters:

filename (str) – Path to the PDB file to parse

Returns:

True if parsing completed successfully, False otherwise

Return type:

bool

Raises:

IOError if file cannot be read

parse_lines(lines: List[str]) bool[source]#

Parse PDB format lines.

Parses PDB format content provided as a list of strings, useful for processing in-memory PDB data.

Parameters:

lines (List[str]) – List of PDB format lines

Returns:

True if parsing completed successfully, False otherwise

Return type:

bool

get_atoms_by_element(element: str) List[Atom][source]#

Get all atoms of specific element.

Parameters:

element (str) – Element symbol (e.g., ‘C’, ‘N’, ‘O’)

Returns:

List of atoms matching the element

Return type:

List[Atom]

get_atoms_by_residue(res_name: str) List[Atom][source]#

Get all atoms from residues with specific name.

Parameters:

res_name (str) – Residue name (e.g., ‘ALA’, ‘GLY’)

Returns:

List of atoms from matching residues

Return type:

List[Atom]

get_hydrogen_atoms() List[Atom][source]#

Get all hydrogen atoms.

Returns:

List of all hydrogen and deuterium atoms

Return type:

List[Atom]

has_hydrogens() bool[source]#

Check if structure contains hydrogen atoms.

Determines if the structure has a reasonable number of hydrogen atoms compared to heavy atoms, indicating explicit hydrogen modeling.

Returns:

True if structure appears to contain explicit hydrogens

Return type:

bool

get_residue_list() List[Residue][source]#

Get list of all residues.

Returns:

List of all residues in the structure

Return type:

List[Residue]

get_chain_ids() List[str][source]#

Get list of unique chain IDs.

Returns:

List of unique chain identifiers in the structure

Return type:

List[str]

get_statistics() Dict[str, Any][source]#

Get basic statistics about the structure.

Provides counts of atoms, residues, chains, and element composition.

Returns:

Dictionary containing structure statistics

Return type:

Dict[str, Any]

get_bonds() List[Bond][source]#

Get list of all bonds.

Returns:

List of all bonds in the structure

Return type:

List[Bond]

get_bonds_for_atom(serial: int) List[Bond][source]#

Get all bonds involving a specific atom.

Parameters:

serial (int) – Atom serial number

Returns:

List of bonds involving this atom

Return type:

List[Bond]

get_bonded_atoms(serial: int) List[int][source]#

Get serial numbers of atoms bonded to the specified atom.

Parameters:

serial (int) – Atom serial number

Returns:

List of bonded atom serial numbers

Return type:

List[int]

get_bond_detection_statistics() Dict[str, int][source]#

Get statistics about bond detection methods used.

Returns a dictionary with counts of bonds detected by each method.