python_pdb.parsers module

Functions for parsing PDB files into python objects and vice versa.

python_pdb.parsers.parse_pdb(contents: str, silent: bool = False) Structure

Create structure object from PDB file.

This function is a wrapper around the Structure.from_pdb(…) classmethod that provides additional functionality of suppressing warnings.

Parameters:
  • contents – contents of a PDB file in string format.

  • silent – suppress any warnings while building the structure (Default: False)

Returns:

Structure object parsed from the PDB file.

python_pdb.parsers.parse_pdb_to_pandas(contents: str) DataFrame

Create pandas dataframe from the contents of a pdb file.

Parameters:

contents – the contents of a pdb file.

Returns:

  • record_type
    • atom_number

    • atom_name

    • alt_loc

    • residue_name

    • chain_id

    • residue_seq_id

    • residue_insert_code

    • pos_x

    • pos_y

    • pos_z

    • occupancy

    • b_factor

    • element

    • charge

and optionally model_index if there are multiple models.

Return type:

dataframe with the following columns representing a structure

python_pdb.parsers.stringify_structure(structure: Structure) str

Format structure as pdb atom records.