rdtools.torsion#
Torsion related functions.
- rdtools.torsion.determine_smallest_atom_index_in_torsion(atom1: Atom, atom2: Atom) int #
Determine the smallest atom index connected to
atom1
but notatom2
.Returns a heavy atom if available, otherwise a hydrogen atom. Useful for deterministically determining the indices of four atom in a torsion. This function assumes there ARE additional atoms connected to
atom1
, and thatatom2
is not a hydrogen atom.- Parameters:
atom1 (Chem.Atom) – The atom who’s neighbors will be searched.
atom2 (Chem.Atom) – An atom connected to
atom1
to exclude (a pivotal atom).
- Returns:
int – The smallest atom index (1-indexed) connected to
atom1
which is notatom2
.- Raises:
ValueError – If no neighbors are found or if
atom2
is a hydrogen atom.
- rdtools.torsion.find_internal_torsions(mol: Mol, exclude_methyl: bool = False) list[list[int]] #
Find the internal torsions from RDkit molecule.
- Parameters:
mol (Chem.Mol) – RDKit molecule.
exclude_methyl (bool) – Whether exclude the torsions with methyl groups.
- Returns:
list[list[int]] – A list of internal torsions.
- rdtools.torsion.find_ring_torsions(mol: Mol) list[list[int]] #
Find the ring from RDkit molecule.
- Parameters:
mol (Chem.Mol) – RDKit molecule.
- Returns:
list[list[int]] – A list of ring torsions.
- rdtools.torsion.get_torsion_tops(mol: Mol, torsion: Sequence[int], allow_non_bonding_pivots: bool = False) tuple[list[int], list[int]] #
Generate tops for the given torsion.
Top atoms are defined as atoms on one side of the torsion. The mol should be in one-piece when using this function, otherwise, the results will be misleading.
- Parameters:
mol (Chem.Mol) – The molecule to get the torsion tops from.
torsion (Sequence[int]) – The atom indices of the pivot atoms (length of 2) or a length-4 atom index sequence with the 2nd and 3rd are the pivot of the torsion.
allow_non_bonding_pivots (bool, optional) – Allow pivots. Defaults to
False
. There are cases like CC#CC or X…H…Y, where a user may want to define a torsion with a nonbonding pivots.
- Returns:
tuple[list[int], list[int]] – Two frags, one of the top of the torsion, and the other top of the torsion.
- Raises:
ValueError – If the torsion is invalid.
- rdtools.torsion.get_torsional_modes(mol: Mol, exclude_methyl: bool = False, include_ring: bool = True) list[list[int]] #
Get the torsional modes from RDkit molecule.
- Parameters:
mol (Chem.Mol) – RDKit molecule.
exclude_methyl (bool) – Whether exclude the torsions with methyl groups. defaults to
False
.include_ring (bool) – Whether include the ring torsions. Defaults to
True
.
- Returns:
list[list[int]] – A list of torsional modes.