pestifer.molecule.atom module

Class for handling atoms.

class pestifer.molecule.atom.Atom(*args, serial: int, name: str, altloc: str, resname: str, chainID: str, resid: ResID, x: float, y: float, z: float, occ: float, beta: float, elem: str, charge: str, segname: str | None = None, empty: bool = False, link: str | None = 'None', recordname: str | None = 'ATOM', auth_seq_id: int | None = None, auth_comp_id: str | None = None, auth_asym_id: str | None = None, auth_atom_id: str | None = None, pdbx_pdb_ins_code: str | None = None, ORIGINAL_ATTRIBUTES: dict = <factory>)[source]

Bases: BaseObj

A class for handling atoms in molecular structures. This class represents an atom with various attributes such as serial number, name, residue name, chain ID, residue sequence number, insertion code, coordinates (x, y, z), occupancy, beta factor, element symbol, charge, and optional attributes like segment name, empty status, link status, record name, and author sequence ID, component ID, asym ID, and atom ID.

ORIGINAL_ATTRIBUTES: dict
altloc: str
auth_asym_id: str | None
auth_atom_id: str | None
auth_comp_id: str | None
auth_seq_id: int | None
beta: float
chainID: str
charge: str
elem: str
empty: bool
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': False}

Configuration for pydantic.BaseModel.

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

name: str
occ: float
overwrite_position(*args)[source]
overwrite_position(other: BaseObj)
overwrite_position(other: dict)
overwrite_position(x: float, y: float, z: float)

Overwrites the position of this atom with the position of another atom. This method is a placeholder and should be overridden in subclasses.

Parameters:

*args (Any) – The arguments to overwrite the position. Should be an Atom object.

Raises:

NotImplementedError – If this method is called without being overridden in a subclass.

pdb_line()[source]

Returns a string representation of the atom in PDB format. This method formats the atom’s attributes into a PDB line string. The line includes the record name, serial number, atom name, alternate location, residue name, chain ID, residue sequence number, insertion code, coordinates (x, y, z), occupancy, beta factor, element symbol, and charge.

Returns:

A formatted string representing the atom in PDB format.

Return type:

str

pdbx_pdb_ins_code: str | None
recordname: str | None
resid: ResID
resname: str
segname: str | None
serial: int
shortcode() str[source]

Converts the Atom.Adapter object to a string representation. This method formats the attributes of the Atom.Adapter into a string.

Returns:

A string representation of the Atom.Adapter object.

Return type:

str

x: float
y: float
z: float
class pestifer.molecule.atom.AtomList(initlist: Iterable[T] = ())[source]

Bases: BaseObjList[Atom]

A class for handling lists of Atom objects. This class inherits from BaseObjList and provides methods to manage a list of Atom objects, including serialization, reserialization, and position overwriting.

adjustSerials(Ters: TerList)[source]

Adjusts the serial numbers of atoms in the AtomList based on the provided TerList. This method reduces the serial numbers of atoms in the AtomList by the number of ignored serials in the TerList. It updates the ORIGINAL_ dictionary of each atom to store the original serial number before adjustment.

Parameters:

Ters (TerList) – A list of Ter objects containing serial numbers to be ignored (TER records in old-timey PDB files)

apply_exclusion_logics(exclusion_logics: list[str] = []) int[source]
apply_inclusion_logics(inclusion_logics: list[str] = []) int[source]
apply_psf_attributes(psfatoms: PSFAtomList)[source]

Applies attributes from a PSF atom list to the corresponding atoms in this AtomList. This method iterates through both AtomLists, ensuring they are of equal length, and updates the resname attribute of each atom in this AtomList to match the corresponding atom in the PSF atom list.

Parameters:

psfatoms (PSFAtomList) – The PSF atom list containing residue names to be applied.

describe()[source]

Abstract method to describe the contents of the BaseObjList. Subclasses should implement this method to provide a meaningful description.

classmethod from_cif(parsed: DataContainer) AtomList[source]

Create an AtomList from a DataContainer (mmCIF format).

Parameters:

parsed (DataContainer) – The parsed mmCIF data container.

Returns:

A new AtomList instance containing Atom objects created from the mmCIF data.

Return type:

AtomList

classmethod from_pdb(parsed: PDBRecordDict, model_id=None) AtomList[source]

Create an AtomList from a PDBRecordDict.

Parameters:

parsed (PDBRecordDict) – The parsed PDB data containing atom records.

Returns:

A new AtomList instance containing Atom objects created from the PDB data.

Return type:

AtomList

overwrite_positions(other: AtomList)[source]

Overwrites the positions of atoms in this AtomList with the positions of atoms in another AtomList. This method iterates through both AtomLists, ensuring they are of equal length, and updates the position (x, y, z) of each atom in this AtomList to match the corresponding atom in the other AtomList.

Parameters:

other (AtomList) – The AtomList whose atom positions will be used to overwrite the positions in this AtomList.

Raises:

AssertionError – If the lengths of the two AtomLists are not equal, an assertion error is raised.

reserialize() AtomList[source]

Reserializes the AtomList by updating the serial numbers of each atom. This method assigns a new serial number to each atom in the list, starting from 1 and incrementing for each atom. It also stores the original serial number in the ORIGINAL_ATTRIBUTES dictionary of each atom for reference.

class pestifer.molecule.atom.Hetatm(*args, serial: int, name: str, altloc: str, resname: str, chainID: str, resid: ResID, x: float, y: float, z: float, occ: float, beta: float, elem: str, charge: str, segname: str | None = None, empty: bool = False, link: str | None = 'None', recordname: str | None = 'ATOM', auth_seq_id: int | None = None, auth_comp_id: str | None = None, auth_asym_id: str | None = None, auth_atom_id: str | None = None, pdbx_pdb_ins_code: str | None = None, ORIGINAL_ATTRIBUTES: dict = <factory>)[source]

Bases: Atom

A class for handling heteroatoms in molecular structures. This class inherits from the Atom class and represents heteroatoms with additional attributes. It includes the same attributes as Atom, but is specifically used for heteroatoms in PDB files.

model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': False}

Configuration for pydantic.BaseModel.