RDKit
Open-source cheminformatics and machine learning.
UFF/Builder.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2018 Rational Discovery LLC
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_UFFBUILDER_H
12 #define RD_UFFBUILDER_H
13 
14 #include <vector>
15 #include <string>
16 #include <boost/shared_array.hpp>
17 #include <boost/scoped_ptr.hpp>
18 #ifdef RDK_THREADSAFE_SSS
19 #include <mutex>
20 #endif
21 #include <boost/noncopyable.hpp>
22 
23 namespace ForceFields {
24 class ForceField;
25 namespace UFF {
26 class AtomicParams;
27 }
28 }
29 
30 namespace RDKit {
31 class ROMol;
32 namespace UFF {
33 typedef std::vector<const ForceFields::UFF::AtomicParams *> AtomicParamVect;
34 
35 //! Builds and returns a UFF force field for a molecule
36 /*!
37 
38  \param mol the molecule to use
39  \param vdwThresh the threshold to be used in adding van der Waals terms
40  to the force field. Any non-bonded contact whose current
41  distance is greater than \c vdwThresh * the minimum value
42  for that contact will not be included.
43  \param confId the optional conformer id, if this isn't provided, the
44  molecule's
45  default confId will be used.
46  \param ignoreInterfragInteractions if true, nonbonded terms will not be added
47  between
48  fragments
49 
50  \return the new force field. The client is responsible for free'ing this.
51 */
53  ROMol &mol, double vdwThresh = 100.0, int confId = -1,
54  bool ignoreInterfragInteractions = true);
55 
56 //! Builds and returns a UFF force field for a molecule
57 /*!
58 
59  \param mol the molecule to use
60  \param params a vector with pointers to the ForceFields::UFF::AtomicParams
61  structures to be used
62  \param vdwThresh the threshold to be used in adding van der Waals terms
63  to the force field. Any non-bonded contact whose current
64  distance is greater than \c vdwThresh * the minimum value
65  for that contact will not be included.
66  \param confId the optional conformer id, if this isn't provided, the
67  molecule's
68  default confId will be used.
69  \param ignoreInterfragInteractions if true, nonbonded terms will not be added
70  between
71  fragments
72 
73  \return the new force field. The client is responsible for free'ing this.
74 */
76  ROMol &mol, const AtomicParamVect &params, double vdwThresh = 100.0,
77  int confId = -1, bool ignoreInterfragInteractions = true);
78 
79 namespace Tools {
80 class RDKIT_FORCEFIELDHELPERS_EXPORT DefaultTorsionBondSmarts : private boost::noncopyable {
81  public:
82  static const std::string &string() { return ds_string; }
83  static const ROMol *query();
84 
85  private:
87  static void create();
88  static const std::string ds_string;
89  static boost::scoped_ptr<const ROMol> ds_instance;
90 #ifdef RDK_THREADSAFE_SSS
91  static std::once_flag ds_flag;
92 #endif
93 };
94 
95 enum { RELATION_1_2 = 0, RELATION_1_3 = 1, RELATION_1_4 = 2, RELATION_1_X = 3 };
96 // these functions are primarily exposed so they can be tested.
97 RDKIT_FORCEFIELDHELPERS_EXPORT unsigned int twoBitCellPos(unsigned int nAtoms, int i, int j);
98 RDKIT_FORCEFIELDHELPERS_EXPORT void setTwoBitCell(boost::shared_array<boost::uint8_t> &res, unsigned int pos,
99  boost::uint8_t value);
100 RDKIT_FORCEFIELDHELPERS_EXPORT boost::uint8_t getTwoBitCell(boost::shared_array<boost::uint8_t> &res,
101  unsigned int pos);
102 RDKIT_FORCEFIELDHELPERS_EXPORT boost::shared_array<boost::uint8_t> buildNeighborMatrix(const ROMol &mol);
103 RDKIT_FORCEFIELDHELPERS_EXPORT void addBonds(const ROMol &mol, const AtomicParamVect &params,
104  ForceFields::ForceField *field);
105 RDKIT_FORCEFIELDHELPERS_EXPORT void addAngles(const ROMol &mol, const AtomicParamVect &params,
106  ForceFields::ForceField *field);
107 RDKIT_FORCEFIELDHELPERS_EXPORT void addNonbonded(const ROMol &mol, int confId, const AtomicParamVect &params,
109  boost::shared_array<boost::uint8_t> neighborMatrix,
110  double vdwThresh = 100.0,
111  bool ignoreInterfragInteractions = true);
113  const ROMol &mol, const AtomicParamVect &params,
115  const std::string &torsionBondSmarts = DefaultTorsionBondSmarts::string());
116 RDKIT_FORCEFIELDHELPERS_EXPORT void addInversions(const ROMol &mol, const AtomicParamVect &params,
117  ForceFields::ForceField *field);
118 }
119 }
120 }
121 
122 #endif
RDKIT_FORCEFIELDHELPERS_EXPORT void addAngles(const ROMol &mol, const AtomicParamVect &params, ForceFields::ForceField *field)
RDKIT_FORCEFIELDHELPERS_EXPORT void addInversions(const ROMol &mol, const AtomicParamVect &params, ForceFields::ForceField *field)
RDKIT_FORCEFIELDHELPERS_EXPORT unsigned int twoBitCellPos(unsigned int nAtoms, int i, int j)
RDKIT_FORCEFIELDHELPERS_EXPORT void addNonbonded(const ROMol &mol, int confId, const AtomicParamVect &params, ForceFields::ForceField *field, boost::shared_array< boost::uint8_t > neighborMatrix, double vdwThresh=100.0, bool ignoreInterfragInteractions=true)
RDKIT_FORCEFIELDHELPERS_EXPORT boost::uint8_t getTwoBitCell(boost::shared_array< boost::uint8_t > &res, unsigned int pos)
RDKIT_FORCEFIELDHELPERS_EXPORT void setTwoBitCell(boost::shared_array< boost::uint8_t > &res, unsigned int pos, boost::uint8_t value)
RDKIT_FORCEFIELDHELPERS_EXPORT ForceFields::ForceField * constructForceField(ROMol &mol, const AtomicParamVect &params, double vdwThresh=100.0, int confId=-1, bool ignoreInterfragInteractions=true)
Builds and returns a UFF force field for a molecule.
RDKIT_FORCEFIELDHELPERS_EXPORT void addBonds(const ROMol &mol, const AtomicParamVect &params, ForceFields::ForceField *field)
RDKIT_FORCEFIELDHELPERS_EXPORT void addTorsions(const ROMol &mol, const AtomicParamVect &params, ForceFields::ForceField *field, const std::string &torsionBondSmarts=DefaultTorsionBondSmarts::string())
Std stuff.
Definition: Atom.h:30
static const std::string & string()
Definition: UFF/Builder.h:82
std::vector< const ForceFields::UFF::AtomicParams * > AtomicParamVect
Definition: UFF/AtomTyper.h:28
#define RDKIT_FORCEFIELDHELPERS_EXPORT
Definition: export.h:255
A class to store forcefields and handle minimization.
Definition: ForceField.h:58
RDKIT_FORCEFIELDHELPERS_EXPORT boost::shared_array< boost::uint8_t > buildNeighborMatrix(const ROMol &mol)