pestifer.molecule.transform module

A Transform class for handling homogeneous coordinate transformations of segments in a molecular structure. This class represents a transformation that can be applied to segments in an asymmetric unit, including rotation and translation.

class pestifer.molecule.transform.Transform(*args, index: int, tmat: ndarray, applies_chainIDs: list[str], chainIDmap: dict[str, str] | None = None, segname_by_type_map: dict[str, str] | None = None)[source]

Bases: BaseObj

A class for handling transformations of segments in a molecular structure. This class represents a transformation that can be applied to segments in an asymmetric unit, including rotation and translation.

This method used the pidibble.pdbparse.get_symm_ops() function to extract the rotation matrix and translation vector from a PDB record. It constructs a 4 x 4 transformation matrix from these components.

applies_chainIDs: list[str]
chainIDmap: dict[str, str] | None
generate_chainIDmap(auChainIDs: list[str], daughters: dict, CM: ChainIDManager, glycan_segment_parents: dict | None = None)[source]

Generates a mapping of chain IDs for the transformation. This method creates a mapping of chain IDs that this transformation applies to, based on the asymmetric unit’s chain IDs and the daughters of segments. If the transformation is an identity transformation, it applies a “thru map” to the chain IDs. Otherwise, it generates a new mapping for the chain IDs.

Parameters:
  • auChainIDs (list) – The list of chain IDs in the asymmetric unit.

  • daughters (dict) – A dictionary mapping parent segment IDs to their daughter segment IDs.

  • CM (ChainIDManager) – The ChainIDManager instance used to manage chain IDs.

  • glycan_segment_parents (dict, optional) – Maps glycan segname → parent protein chainID (e.g. ‘AG01’ → ‘A’). Used to generate structured image segnames (e.g. AG01→CG01 when A→C).

classmethod identity()[source]

Creates an identity transformation. This method returns a Transform object with an identity transformation matrix and no chain ID mappings.

index: int
is_identity()[source]

Checks if the transformation is an identity transformation. An identity transformation is one where the transformation matrix is an identity matrix and the translation vector is zero.

Returns:

True if the transformation is an identity transformation, False otherwise.

Return type:

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.

register_mapping(segtype, chainID, seglabel)[source]

Registers a mapping of segment type to chain ID and segment label. This method updates the segname_by_type_map attribute with the provided segment type, chain ID, and segment label.

Parameters:
  • segtype (str) – The type of the segment (e.g., ‘protein’, ‘nucleic’).

  • chainID (str) – The chain ID associated with the segment.

  • seglabel (str) – The label for the segment.

segname_by_type_map: dict[str, str] | None
set_chainIDmap(chainIDmap: dict[str, str])[source]

Sets the chain ID mapping for the transformation.

Parameters:

chainIDmap (dict) – A dictionary mapping original chain IDs to new chain IDs.

tmat: ndarray
write_TcL()[source]

Generates a Tcl command string that represents the transformation. This method constructs a string that can be used in a Tcl script to apply the transformation to a segment in VMD.

Returns:

A string containing the Tcl command to apply the transformation.

Return type:

str

class pestifer.molecule.transform.TransformList(initlist: list[Transform] | PDBRecordList = [], *args, **kwargs)[source]

Bases: BaseObjList[Transform]

A class for handling lists of Transform objects. This class inherits from AncestorAwareObjList and provides methods to manage collections of Transform instances.

describe()[source]

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

classmethod identity(length: int = 1)[source]

Creates a TransformList containing a length identity transformations.