RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
TorsionPreferences.h
Go to the documentation of this file.
1//
2// Copyright (C) 2017-2026 Sereina Riniker and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef _RD_TORSIONPREFERENCES_H_
12#define _RD_TORSIONPREFERENCES_H_
13#include <vector>
14#include <string>
15#include <utility>
16#include <memory>
17#include <tuple>
18#include <variant>
19#include <boost/dynamic_bitset.hpp>
22
23namespace RDKit {
24class ROMol;
25} // namespace RDKit
26
27namespace ForceFields {
28namespace CrystalFF {
29
30//! A structure used to the experimental torsion patterns
32 unsigned int torsionIdx;
33 std::string smarts;
34 std::vector<double> V;
35 std::vector<int> signs;
36 std::unique_ptr<const RDKit::ROMol> dp_pattern;
37 unsigned int idx[4];
38};
39
41 std::size_t torsionIdx;
42 std::string smarts;
43 std::vector<double> heights;
44 std::vector<double> positions;
45 std::vector<double> widths;
46 std::unique_ptr<const RDKit::ROMol> dp_pattern;
47 unsigned int idx[4];
48};
49
51struct Params {
52 double distance{1.0};
53 double fourthDim{1.0};
54 double chiral{1.0};
55 double kTermAngle{1.0};
56 double kTermImproper{10.0};
57 double kTermTorsion{100.0};
58 double etTermScaling{1.0};
59};
60
61namespace SEQ {
62constexpr Params Cosine;
63constexpr Params Gaussian;
64} // namespace SEQ
65namespace AIO {
66constexpr Params Cosine = {.distance = 2.15,
67 .fourthDim = 2.15,
68 .kTermAngle = 0.1,
69 .kTermImproper = .001,
70 .kTermTorsion = 2.15,
71 .etTermScaling = 0.05};
72
73constexpr Params Gaussian = {.distance = 2.15,
74 .fourthDim = 2.15,
75 .kTermAngle = 0.1,
76 .kTermImproper = .001,
77 .kTermTorsion = .75,
78 .etTermScaling = 0.05};
79
80} // namespace AIO
81} // namespace ETKDGForceConsts
82
83using CosineExp_T = std::pair<std::vector<int>, std::vector<double>>;
84using GaussianExp_T = std::tuple<std::vector<double>, std::vector<double>,
85 std::vector<double>, double>;
86
87using TorsionLookup = std::vector<std::vector<double>>;
88template <typename T>
89concept TorsionAngleType = std::is_same_v<T, ExpTorsionAngle> ||
90 std::is_same_v<T, GaussianExpTorsionAngle>;
91
92//! Which functional form the parameters stored in a CrystalFFDetails
93//! instance use
98
99//! Holds either the cosine-series (ETKDGv1/v2) or the Gaussian-fit
100//! (ETKDGv4) parameters for a single torsion term
101using TorsionParamVariant = std::variant<CosineExp_T, GaussianExp_T>;
102
103//! Points at the SMARTS-pattern entry (of whichever functional form was
104//! used) that produced a torsion match
106 std::variant<const ExpTorsionAngle *, const GaussianExpTorsionAngle *>;
107
110 std::vector<std::vector<int>> expTorsionAtoms;
111 std::vector<TorsionParamVariant> expTorsionAngles;
112 std::vector<std::size_t> torsionIdx;
113 std::vector<std::vector<int>> improperAtoms;
114 std::vector<std::pair<int, int>> bonds;
115 std::vector<std::vector<int>> angles;
116 std::vector<int> atomNums;
118 boost::dynamic_bitset<> constrainedAtoms;
119 double *distMat;
121 std::vector<RDKit::DGeomHelpers::Path14Configuration> path14Configs;
124 std::unique_ptr<RDKit::DGeomHelpers::InternalCoordinates> internalCoords;
125};
126
127//! Get the experimental torsional angles in a molecule
129 const RDKit::ROMol &mol, CrystalFFDetails &details,
130 bool useExpTorsions = false, bool useSmallRingTorsions = false,
131 bool useMacrocycleTorsions = false, bool useBasicKnowledge = false,
132 unsigned int version = 2, bool verbose = false);
133
134//! \overload
136 const RDKit::ROMol &mol, CrystalFFDetails &details,
137 std::vector<std::tuple<unsigned int, std::vector<unsigned int>,
138 TorsionAnglePtrVariant>> &torsionBonds,
139 bool useExpTorsions = false, bool useSmallRingTorsions = false,
140 bool useMacrocycleTorsions = false, bool useBasicKnowledge = false,
141 unsigned int version = 2, bool verbose = false);
142
143//! Populate the lookuptable for the minimizations
144//! The size of the lookup table is defined in `GaussianTorsionAngleContribs.h`!
146
147} // namespace CrystalFF
148} // namespace ForceFields
149
150#endif
#define RDKIT_FORCEFIELDHELPERS_EXPORT
Definition export.h:261
std::variant< const ExpTorsionAngle *, const GaussianExpTorsionAngle * > TorsionAnglePtrVariant
RDKIT_FORCEFIELDHELPERS_EXPORT void populateRefTable(CrystalFFDetails &details)
RDKIT_FORCEFIELDHELPERS_EXPORT void getExperimentalTorsions(const RDKit::ROMol &mol, CrystalFFDetails &details, bool useExpTorsions=false, bool useSmallRingTorsions=false, bool useMacrocycleTorsions=false, bool useBasicKnowledge=false, unsigned int version=2, bool verbose=false)
Get the experimental torsional angles in a molecule.
std::pair< std::vector< int >, std::vector< double > > CosineExp_T
std::tuple< std::vector< double >, std::vector< double >, std::vector< double >, double > GaussianExp_T
std::variant< CosineExp_T, GaussianExp_T > TorsionParamVariant
std::vector< std::vector< double > > TorsionLookup
Std stuff.
std::vector< RDKit::DGeomHelpers::Path14Configuration > path14Configs
std::vector< TorsionParamVariant > expTorsionAngles
std::vector< std::vector< int > > improperAtoms
std::vector< std::pair< int, int > > bonds
std::unique_ptr< RDKit::DGeomHelpers::InternalCoordinates > internalCoords
std::vector< std::vector< int > > expTorsionAtoms
std::vector< std::vector< int > > angles
A structure used to the experimental torsion patterns.
std::unique_ptr< const RDKit::ROMol > dp_pattern
std::unique_ptr< const RDKit::ROMol > dp_pattern