python_pdb.entities module
Classes for representing objects contained within PDB files.
- class python_pdb.entities.Atom(name: str, number: int, alt_loc: str | None, pos_x: float, pos_y: float, pos_z: float, occupancy: float, b_factor: float, element: str, charge: str | None, is_het_atom: bool = False)
Bases:
Entity
Atom representation.
- name
atom name
- Type:
str
- number
atom number in PDB file
- Type:
int
- alt_loc
alternate location of the atom
- Type:
str | None
- pos_x
atom’s x-coordinate
- Type:
float
- pos_y
atom’s y-coordinate
- Type:
float
- pos_z
atom’s z-coordinate
- Type:
float
- occupancy
atom’s occupancy
- Type:
float
- b_factor
b_factor from experimentally derived data
- Type:
float
- element
str corresponding to the element id of this atom (periodic table style)
- Type:
str
- charge
+/- charge on the atom
- Type:
str | None
- het_atom
True if the atom comes from a hetero atom record
- Type:
bool
- add_child()
Add child to entitity.
- children_equal(other)
- copy() Atom
Create a copy of the atom with the same propeties. Note the parent will be reset of the copy.
- get_children()
Get children of this entity.
- property position: tuple[float, float, float]
the x,y,z coordinates of the atom
- remove_child()
Remove child from entity.
- class python_pdb.entities.Chain(name: str)
Bases:
Entity
Chain representation.
- name
name of the chain
- Type:
str
- class python_pdb.entities.Entity
Bases:
object
Base class that Atom, Residue, Chain, Model, and Structure inherit from.
- get_coordinates() ndarray
Get n x 3 matrix of atomic coordinates based on all the atoms in the Entitity. Ordering is preserved.
- class python_pdb.entities.Model(serial_number: int | None = None)
Bases:
Entity
Representation of a PDB model.
- serial_number
optional serial number to identify the model.
- Type:
int | None
- class python_pdb.entities.Residue(name: str, seq_id: int, insert_code: str | None)
Bases:
Entity
Residue representation.
- name
Name of the residue (three letter code)
- Type:
str
- seq_id
Sequence number of the residue.
- Type:
int
- insert_code
Insert code of the residue if available.
- Type:
str | None
- get_atoms() list[Atom]
Return a list of all atoms in the residue, including atoms with alternate locations.
- property olc: str
One letter code of residue.
- property tlc: str
Three letter code of the residue.
- class python_pdb.entities.Structure
Bases:
Entity
PDB Structure representation.
- dehydrate()
Remove all water molecules from the Structure.
- classmethod from_pandas(df: DataFrame) Structure
Create Structure object from a pandas dataframe.
- Parameters:
df –
pandas dataframe that has the following columns representing a PDB structure:
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 optionaly model_index if there are multiple models
- Returns:
Structure with chains, residues, and atoms from the input dataset.
- remove_non_amino_acids()
Remove all non amino acids from the Structure.
- split_states(all_combinations=False)
Split multiple alternate locations into separate models.
If there are multiple locations for an atom (as designated by alt_loc’s) split the view of the protein into multiple models.
Warning
This method modifies the structure object by overriding the existing models property.
- Parameters:
all_combinations – states will be grouped by alt code if False (ie all ‘A’s are together) or else every different combination of alt codes will be used (Default: False).
- to_pandas() DataFrame
Convert Structure into pandas dataframe.
- 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
- exception python_pdb.entities.StructureConstructionWarning
Bases:
Warning
Raised if something is flagged for attention while building a structure.