plinder.core.structure.structure#

class plinder.core.structure.structure.Structure(*, id: str, protein_path: Path, protein_sequence: dict[str, str] | None = None, ligand_sdfs: dict[str, str] | None = None, ligand_smiles: dict[str, str] | None = None, protein_atom_array: AtomArray | None = None, ligand_mols: dict[str, tuple[Mol, Mol, Mol, tuple[NDArray[int64], NDArray[int64]]]] | None = None, add_ligand_hydrogens: bool = False, skip_3d_confgen: bool = False, structure_type: str = 'holo', complete_missing_atoms: bool = False)[source]#

Bases: BaseModel

id: str#
protein_path: Path#
protein_sequence: dict[str, str] | None#
ligand_sdfs: dict[str, str] | None#
ligand_smiles: dict[str, str] | None#
protein_atom_array: AtomArray | None#
ligand_mols: dict[str, tuple[Chem.Mol, Chem.Mol, Chem.Mol, tuple[NDArray[np.int_], NDArray[np.int_]]]] | None#
add_ligand_hydrogens: bool#
skip_3d_confgen: bool#
structure_type: str#
complete_missing_atoms: bool#

Initialize structure. This dataclass provides abstraction over plinder systems holo, apo and predicted structures. It loads and processes receptor proteins and ligands in a way that allows us to capture the pecularitties of these molecule types. It’s also intentionally design to be robust to capture structures, with or without ligand

Parameters:
idstr

PLINDER system or apo/pred id. If the structure is holo, this is used to load the holo structure

protein_pathPath

Protein structure cif path, could be holo, apo or pred path

protein_sequencedict[str, str] | None = None

Protein sequence dictionary with chain id as key and sequence as value Set from protein_path if not provided

ligand_sdfsdict[str, str] | None = None

Dictionary of ligand sdf file paths with chain id as key and sdf file path as value

ligand_smilesdict[str, str] | None = None

Dictionary of ligand smiles with chain id as key and smiles as value

protein_atom_arrayAtomArray | None = None

Protein Biotite atom array

ligand_molsdict, optional

Ligand molecules keyed by ligand ID. Each value contains the molecule loaded from SMILES, a generated template conformer, the resolved conformer, and paired atom-index arrays for the template and resolved structures.

add_ligand_hydrogensbool = False

Whether to add hydrogen to ligand or not

skip_3d_confgenbool = False

Use 2D coords instead of (default) 3D conformer generation

structure_typestr = “holo”

Structure type, “holo”, “apo” or “pred”

complete_missing_atomsbool = False

Append CCD-template heavy atoms missing from receptor residues with NaN coordinates and an is_unresolved annotation (see plinder.core.structure.ccd_template.add_missing_atoms())

class Config#

Bases: object

arbitrary_types_allowed = True#
initialize() → Structure#
load_protein() → None#
load_sequence() → None#
load_ligands() → None#
save_to_disk(filepath: Path | None = None) → None#

Write the structure AtomArray to an mmCIF file.

Parameters:
filepathPath | None

Filepath to output mmCIF. If not provided, will write to self.protein_path, potentially overwriting if the file already exists!

Returns:
None
filter(property: str, mask: Iterable[bool | int | str], copy: bool = True, negate: bool = False) → Structure | None#
set_chain(chain_id: str) → None#
superimpose(other: Structure, strip_ligands: bool = True) → tuple[Structure, float, float]#

transforms self to superimpose on other

property input_sequence_residue_mask_stacked: list[NDArray[float64]]#

Input sequence stacked by chain

property input_sequence_list_ordered_by_chain: list[str] | None#

List of protein chains ordered the way it is in structure.

property protein_chain_ordered: list[str]#

List of protein chains ordered the way it is in structure

property input_sequence_full_atom_feat: dict[str, list[str]]#

Resolved sequence full atom features.

property sequence_atom_mask: list[list[int]]#

Sequence mask indicating which residues are resolved

property ligand_chain_ordered: list[str]#

List of Ligand chains sorted in order.

property protein_coords: list[NDArray[float32]]#

list[NDArray]: The coordinates of the protein atoms in the structure.

property input_ligand_conformer_atom_array: dict[str, AtomArray]#

dict[str, AtomArray]: The coordinates of the input 3D conformer generated from input SMILES

property ligand_atom_array: dict[str, AtomArray]#

dict[str, AtomArray]: The coordinates of the input 3D conformer generated from input SMILES

property input_ligand_templates: dict[str, Mol]#

Ligand 2D mol objects from input SMILES

property protein_unresolved_atom_mask: list[NDArray[int64]]#

Per chain, 1 for CCD-template atoms with NaN coordinates, 0 for deposited atoms.

property protein_calpha_coords: list[NDArray[float32]]#

list[NDArray]: Per-chain coordinates of the protein C-alpha atoms.

property input_ligand_conformers: dict[str, Mol]#

Ligand 3D mol conformer objects from input SMILES

property input_ligand_conformers_coords: dict[str, NDArray[float64]]#

dict[NDArray]: The coordinates of the input 3D conformer generated from input SMILES

property resolved_ligand_mols: dict[str, Mol]#

Resolved holo ligand mol objects

property ligand_template2resolved_atom_order_stacks: dict[str, tuple[NDArray[int64], NDArray[int64]]]#

for every ligand this gets a pair of atom order array stacks providing index sort to match template atoms to holo conformer atoms

property resolved_ligand_mols_coords: dict[str, NDArray[float64]]#

Dictionary of ligands and their resolved atom coordinates in the holo structure.

property protein_backbone_mask: NDArray[bool]#

ndarray[np.bool_]: a logical mask for backbone atoms.

property protein_calpha_mask: NDArray[bool]#

ndarray[np.bool_]: a logical mask for alpha carbon atoms.

property protein_n_atoms: int#

int: The number of atoms in the structure.

property protein_chains: list[str]#

list[str]: The list of chain IDs in the structure.

property protein_sequence_from_structure: str#

str: The amino acid sequence of the structure.

property protein_structure_tokenized_sequence: torch.Tensor#

torch.Tensor: The tokenized sequence representation of the structure sequence.

property protein_unique_residue_names: list[str]#

list[str]: The list of distinct residue names in the structure.

property protein_unique_residue_ids: list[int]#

list[int]: The list of distinct residue IDs in the structure.

property protein_unique_atom_names: list[str]#

list[str]: The list of distinct atom names in the structure.

property protein_structure_b_factor: list[float]#

list[float]: A list of B-factor values for each atom in the structure.

classmethod get_properties() → list[str]#
model_config = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].