polymerist.rdutils.selection ============================ .. py:module:: polymerist.rdutils.selection .. autoapi-nested-parse:: Utilities for conditional selection of chemical objects, such as atoms and bonds, from RDKit molecules Attributes ---------- .. autoapisummary:: polymerist.rdutils.selection.AtomCondition polymerist.rdutils.selection.BondCondition polymerist.rdutils.selection.AtomLike polymerist.rdutils.selection.BondLike polymerist.rdutils.selection.atom_is_mapped polymerist.rdutils.selection.atom_adjoins_linker polymerist.rdutils.selection.atoms polymerist.rdutils.selection.bonds polymerist.rdutils.selection.atom_neighbors polymerist.rdutils.selection.has_atom_neighbors Functions --------- .. autoapisummary:: polymerist.rdutils.selection.atom_neighbors_by_condition polymerist.rdutils.selection.has_atom_neighbors_by_condition polymerist.rdutils.selection.atoms_by_condition polymerist.rdutils.selection.bonds_by_condition polymerist.rdutils.selection.bond_condition_by_atom_condition_factory polymerist.rdutils.selection.mapped_atoms polymerist.rdutils.selection.mapped_neighbors polymerist.rdutils.selection.bonded_pairs polymerist.rdutils.selection.bonds_between_mapped_atoms Module Contents --------------- .. py:data:: AtomCondition .. py:data:: BondCondition .. py:data:: AtomLike .. py:data:: BondLike .. py:function:: atom_neighbors_by_condition(atom: rdkit.Chem.rdchem.Atom, condition: AtomCondition = lambda atom: True, as_indices: bool = False, negate: bool = False) -> Generator[AtomLike, None, None] Generate all neighboring atoms (i.e. atoms bonded to the passed atom) satisfying a condition :Parameters: * **atom** (*Chem.Atom*) -- An atom object whose neighbors are to be inspected * **condition** (*Callable[[Chem.Atom], bool], default lambda atom : True*) -- Condition on atoms which returns bool; Always returns True if unset * **as_indices** (*bool, default False*) -- Whether to return results as their indices (default) or as Atom objects * **negate** (*bool, default False*) -- Whether to invert the condition provided (by default False) :returns: **selected_atoms** -- An iterable Generator of the atoms meeting the chosen condition :rtype: Generator[Union[int, Chem.Atom]] .. py:function:: has_atom_neighbors_by_condition(atom: rdkit.Chem.rdchem.Atom, condition: AtomCondition = lambda atom: True, negate: bool = False) -> bool Identify if any neighbors of an atom satisfy some condition .. py:function:: atoms_by_condition(mol: rdkit.Chem.rdchem.Mol, condition: AtomCondition = lambda atom: True, as_indices: bool = False, negate: bool = False) -> Generator[AtomLike, None, None] Generate a subset of atoms in a Mol based on a condition :Parameters: * **mol** (*Chem.Mol*) -- An RDKit molecule object * **condition** (*Callable[[Chem.Atom], bool], default lambda atom : True*) -- Condition on atoms which returns bool; Always returns True if unset * **as_indices** (*bool, default False*) -- Whether to return results as their indices (default) or as Atom objects * **negate** (*bool, default False*) -- Whether to invert the condition provided (by default False) :returns: **selected_atoms** -- An iterable Generator of the atoms meeting the chosen condition :rtype: Generator[Union[int, Chem.Atom]] .. py:function:: bonds_by_condition(mol: rdkit.Chem.rdchem.Mol, condition: BondCondition = lambda bond: True, as_indices: bool = True, as_pairs: bool = True, negate: bool = False) -> Generator[BondLike, None, None] Select a subset of bonds in a Mol based on a condition :Parameters: * **mol** (*Chem.Mol*) -- An RDKit molecule object * **condition** (*Callable[[Chem.Bond], bool], default lambda bond : True*) -- Condition on bonds which returns bool; Always returns True if unset * **as_indices** (*bool, default True*) -- Whether to return results as Bond objects or their indices (default) * **as_pairs** (*bool, default True*) -- Whether to return bonds as the pair of bondss they connect (default) or the bond itself Note that if as_pairs=True and as_indices=False, will return as pairs of Bonds objects * **negate** (*bool, default False*) -- Whether to invert the condition provided (by default False) :returns: **selected_bonds** -- A set of the bonds meeting the chosen condition Depending on flags set, bond will be represented as: * Bond indices * Bond objects * 2-tuples of Atom objects * 2-tuples of atom indices :rtype: Generator[Union[int, Bond, tuple[int, int], tuple[Atom, Atom]]] .. py:function:: bond_condition_by_atom_condition_factory(atom_condition: AtomCondition, binary_operator: Callable[[bool, bool], bool] = logical_or) -> BondCondition Dynamically define a bond condition based on an atom condition applied to the pair of atom a bond connects Evaluation over bond determined by a specified atom condition and a binary logical comparison made between the pair of atom condition evaluations By default, this binary condition is OR (i.e. the bond will evaluate True if either of its atoms meets the atom condition) .. py:data:: atom_is_mapped :type: AtomCondition .. py:data:: atom_adjoins_linker :type: AtomCondition .. py:function:: mapped_atoms(mol: rdkit.Chem.rdchem.Mol, as_indices: bool = False) -> Generator[AtomLike, None, None] Return all atoms (either as Atom objects or as indices) which have been assigned a nonzero atom map number .. py:function:: mapped_neighbors(atom: rdkit.Chem.rdchem.Atom, as_indices: bool = False) -> Generator[AtomLike, None, None] Return all mapped atoms that an atom is bonded to .. py:function:: bonded_pairs(mol: rdkit.Chem.rdchem.Mol, *atom_idxs: Container[int], as_indices: bool = True, as_pairs: bool = True) -> Generator[BondLike, None, None] Returns all bonds in a Mol which connect a pair of atoms whose indices both lie within the given atom indices .. py:function:: bonds_between_mapped_atoms(mol: rdkit.Chem.rdchem.Mol, as_indices: bool = True, as_pairs: bool = True) -> Generator[BondLike, None, None] Returns all bonds spanning between two mapped (i.e. nonzero atom map number) atoms .. py:data:: atoms .. py:data:: bonds .. py:data:: atom_neighbors .. py:data:: has_atom_neighbors