pestifer.psfutil.psfatom module

Defines the PSFAtom and PSFAtomList classes for handling atoms in PSF topology files. These classes are used to represent individual atoms and collections of atoms in a PSF file. The PSFAtom class represents a single atom, while the PSFAtomList class is a collection of such atoms. These classes provide methods for parsing atom lines and managing atom properties.

class pestifer.psfutil.psfatom.PSFAtom(*args, serial: int, resid: ResID, segname: str, resname: str, atomname: str, atomtype: str, charge: float, atomicwt: float, segtype: str, ligands: list[PSFAtom] = <factory>, is_root: bool = False)[source]

Bases: BaseObj

A class representing an atom in a PSF topology file. An atom is defined by its serial number, chain ID, residue sequence number, insertion code, residue name, atom name, type, charge, atomic weight, and segment type. The class provides methods for parsing atom lines, checking if the atom is a hydrogen atom, adding ligands, and checking if the atom is part of a peptide bond.

add_ligand(other: PSFAtom)[source]

Add a ligand to the atom’s list of ligands.

Parameters:

other (PSFAtom) – The ligand atom to add.

atomicwt: float
atomname: str
atomtype: str
charge: float
isH()[source]

Check if the atom is a hydrogen atom. Returns True if the atom’s type is ‘H’, otherwise False.

is_pep(other: PSFAtom)[source]

Check if the atom is part of a peptide bond with another atom. A peptide bond is defined as a bond between a carbon atom (C) and a nitrogen atom (NH1).

Parameters:

other (PSFAtom) – The other atom to check for a peptide bond.

is_root: bool
ligands: list[PSFAtom]
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.

resid: ResID
resname: str
segname: str
segtype: str
serial: int
class pestifer.psfutil.psfatom.PSFAtomList(initlist: Iterable[T] = ())[source]

Bases: BaseObjList[PSFAtom]

A class representing a list of PSFAtom objects. This class inherits from PSFTopoElementList and provides methods for managing a collection of atoms in a PSF topology file.

apply_exclusion_logics(exclusion_logics: list[str] = []) int[source]

Apply exclusion logic expressions to filter the atom list. This method filters the atom list based on a list of exclusion logic expressions. Atoms that match any of the expressions are removed from the list.

Parameters:

exclusion_logics (list[str], optional) – A list of exclusion logic expressions to apply, by default []

Returns:

The number of atoms that were ignored (removed) from the list.

Return type:

int

apply_inclusion_logics(inclusion_logics: list[str] = []) int[source]

Apply inclusion logic expressions to filter the atom list. This method filters the atom list based on a list of inclusion logic expressions. Atoms that match any of the expressions are retained in the list.

Parameters:

inclusion_logics (list[str], optional) – A list of inclusion logic expressions to apply, by default []

Returns:

The number of atoms that were ignored (removed) from the list.

Return type:

int

describe() str[source]

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

graph()[source]

Create a networkx.Graph representation of the atom list, where atoms are nodes and bonds are edges. This method constructs a networkx graph where each atom is a node and edges are created between atoms and their ligands.

Returns:

A networkx graph representing the atom list, with atoms as nodes and bonds as edges

Return type:

networkx.Graph