polymerist.rdutils.selection
Utilities for conditional selection of chemical objects, such as atoms and bonds, from RDKit molecules
Attributes
Functions
|
Generate all neighboring atoms (i.e. atoms bonded to the passed atom) satisfying a condition |
|
Identify if any neighbors of an atom satisfy some condition |
|
Generate a subset of atoms in a Mol based on a condition |
|
Select a subset of bonds in a Mol based on a condition |
|
Dynamically define a bond condition based on an atom condition applied to the pair of atom a bond connects |
|
Return all atoms (either as Atom objects or as indices) which have been assigned a nonzero atom map number |
|
Return all mapped atoms that an atom is bonded to |
|
Returns all bonds in a Mol which connect a pair of atoms whose indices both lie within the given atom indices |
|
Returns all bonds spanning between two mapped (i.e. nonzero atom map number) atoms |
Module Contents
- polymerist.rdutils.selection.AtomCondition
- polymerist.rdutils.selection.BondCondition
- polymerist.rdutils.selection.AtomLike
- polymerist.rdutils.selection.BondLike
- polymerist.rdutils.selection.atom_neighbors_by_condition(atom: rdkit.Chem.rdchem.Atom, condition: AtomCondition = lambda atom: ..., as_indices: bool = False, negate: bool = False) Generator[AtomLike, None, None][source]
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
- Return type:
Generator[Union[int, Chem.Atom]]
- polymerist.rdutils.selection.has_atom_neighbors_by_condition(atom: rdkit.Chem.rdchem.Atom, condition: AtomCondition = lambda atom: ..., negate: bool = False) bool[source]
Identify if any neighbors of an atom satisfy some condition
- polymerist.rdutils.selection.atoms_by_condition(mol: rdkit.Chem.rdchem.Mol, condition: AtomCondition = lambda atom: ..., as_indices: bool = False, negate: bool = False) Generator[AtomLike, None, None][source]
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
- Return type:
Generator[Union[int, Chem.Atom]]
- polymerist.rdutils.selection.bonds_by_condition(mol: rdkit.Chem.rdchem.Mol, condition: BondCondition = lambda bond: ..., as_indices: bool = True, as_pairs: bool = True, negate: bool = False) Generator[BondLike, None, None][source]
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
- Return type:
Generator[Union[int, Bond, tuple[int, int], tuple[Atom, Atom]]]
- polymerist.rdutils.selection.bond_condition_by_atom_condition_factory(atom_condition: AtomCondition, binary_operator: Callable[[bool, bool], bool] = logical_or) BondCondition[source]
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)
- polymerist.rdutils.selection.atom_is_mapped: AtomCondition
- polymerist.rdutils.selection.atom_adjoins_linker: AtomCondition
- polymerist.rdutils.selection.mapped_atoms(mol: rdkit.Chem.rdchem.Mol, as_indices: bool = False) Generator[AtomLike, None, None][source]
Return all atoms (either as Atom objects or as indices) which have been assigned a nonzero atom map number
- polymerist.rdutils.selection.mapped_neighbors(atom: rdkit.Chem.rdchem.Atom, as_indices: bool = False) Generator[AtomLike, None, None][source]
Return all mapped atoms that an atom is bonded to
- polymerist.rdutils.selection.bonded_pairs(mol: rdkit.Chem.rdchem.Mol, *atom_idxs: Container[int], as_indices: bool = True, as_pairs: bool = True) Generator[BondLike, None, None][source]
Returns all bonds in a Mol which connect a pair of atoms whose indices both lie within the given atom indices
- polymerist.rdutils.selection.bonds_between_mapped_atoms(mol: rdkit.Chem.rdchem.Mol, as_indices: bool = True, as_pairs: bool = True) Generator[BondLike, None, None][source]
Returns all bonds spanning between two mapped (i.e. nonzero atom map number) atoms
- polymerist.rdutils.selection.atoms
- polymerist.rdutils.selection.bonds
- polymerist.rdutils.selection.atom_neighbors
- polymerist.rdutils.selection.has_atom_neighbors