rdmc.conformer_generation.sampler#

Modules for torsional sampling

class rdmc.conformer_generation.sampler.TorsionalSampler(method: str = 'GFN2-xTB', nprocs: int = 1, memory: int = 1, n_point_each_torsion: int = 45, n_dimension: int = 2, optimizer: ConfGenOptimizer | TSOptimizer | None = None, pruner: ConfGenPruner | None = None, verifiers: TSVerifier | Verifier | List[TSVerifier] | List[Verifier] | None = None)#

Bases: object

A class to find possible conformers by sampling the PES for each torsional pair. You have to have the Sparrow and xtb-python packages installed to run this workflow.

Parameters:
  • method (str, optional) – The method to be used for automated conformer search. Only the methods available in Spharrow and xtb-python can be used. Defaults to "GFN2-xTB".

  • nprocs (int, optional) – The number of processors to use. Defaults to 1.

  • memory (int, optional) – Memory in GB used by Gaussian. Defaults to 1.

  • n_point_each_torsion (float, optional) – Number of points to be sampled along each rotational mode. Defaults to 45..

  • n_dimension (int, optional) – Number of dimensions. Defaults to 2. If -1 is assigned, the number of dimension would be the number of rotatable bonds.

  • optimizer (ConfGenOptimizer or TSOptimizer, optional) – The optimizer used to optimize TS or stable specials geometries. Available options for TSOptimizer <rdmc.conformer_generation.ts_optimizers.TSOptimizer> are SellaOptimizer, OrcaOptimizer, and GaussianOptimizer.

  • pruner (ConfGenPruner, optional) – The pruner used to prune conformers based on geometric similarity after optimization. Available options are CRESTPruner and TorsionPruner.

  • verifiers (TSVerifier, Verifier, list of TSVerifiers or list of Verifiers, optional) – The verifier or a list of verifiers used to verify the obtained conformer. Available options are GaussianIRCVerifier, OrcaIRCVerifier, and XTBFrequencyVerifier.

get_conformers_by_change_torsions(mol: RDKitMol, id: int = 0, torsions: list | None = None, exclude_methyl: bool = True, on_the_fly_check: bool = True) List[RDKitMol]#

Generate conformers by rotating the angles of the torsions. A on-the-fly check can be applied, which identifies the conformers with colliding atoms.

Parameters:
  • mol (RDKitMol) – A RDKitMol molecule object.

  • id (int) – The ID of the conformer to be obtained. Defaults to 0.

  • torsions (list) – A list of four-atom-index lists indicating the torsional modes. Defaults to None, which means all the rotatable bonds will be used.

  • exclude_methyl (bool) – Whether exclude the torsions with methyl groups. Defaults to False. Only valid if torsions is not provided.

  • on_the_fly_filter (bool) – Whether to check colliding atoms on the fly. Defaults to True.

Returns:

lis – A list of RDKitMol of sampled 3D geometries for each torsional mode.

rdmc.conformer_generation.sampler.get_energy(mol: RDKitMol, confId: int = 0, method: str = 'GFN2-xTB') float#

Calculate the energy of the RDKitMol with given confId. The unit is in kcal/mol. Only support methods already supported either in sparrow or xtb-python.

Parameters:
  • mol (RDKitMol) – A RDKitMol molecule object.

  • confId (int) – The ID of the conformer for calculating energy. Defaults to 0.

  • method (str) – Which semi-empirical method to be used in running energy calculation. Defaults to "GFN2-xTB".

Returns:

The energy of the conformer.

rdmc.conformer_generation.sampler.get_separable_angle_list(samplings: List | Tuple, from_angles: List | Tuple | None = None) List[List]#

Get a angle list for each input dimension. For each dimension The input can be a int indicating the angles will be evenly sampled; or a list indicating the angles to be sampled;

Parameters:
  • samplings (Union[List, Tuple]) – An array of sampling information. For each element, it can be either list or int.

  • from_angles (Union[List, Tuple]) – An array of initial angles. If not set, all angles will begin at zeros.

Returns:

list – A list of sampled angles sets.

Examples

get_separable_angle_list([[120, 240,], 4, 0])
>>> [[120, 240], [0, 90, 180, 270], [0]]
rdmc.conformer_generation.sampler.plot_heat_map(energies: ndarray, minimum_points: List[Tuple], save_path: str, mask: ndarray | None = None, detailed_view: bool = False, title: str | None = None)#

Plot and save the heat map of a given PES.

Parameters:
  • energies (np.ndarray) – A np.ndarray containing the energies for each sampled point.

  • minimum_points (List[Tuple]) – A list of tuples containing the indices of the minimum points.

  • save_path (str) – The path to save the plot.

  • mask (np.ndarray, optional) – A np.ndarray containing the mask for the energies.

  • detailed_view (bool) – Whether to plot the detailed view of the PES. Defaults to False.

  • title (str, optional) – The title of the plot.

rdmc.conformer_generation.sampler.preprocess_energies(energies: ndarray) Tuple[ndarray, ndarray]#

Rescale the energy based on the lowest energy.

Parameters:

energies (np.ndarray) – A np.ndarray containing the energies for each sampled point.

Returns:

tuple – The rescaled energies and the mask pointing out positions having values