OETorLib
class OETorLib
Stores and manages torsion libraries used during conformer generation. Torsion rules can be loaded from files or added as SMARTS-based rule strings, and are consulted by OETorDriver when sampling rotatable-bond dihedral angles.
See also
OETorDriveOptions class
Constructors
OETorLib(const unsigned type = OETorLibType::Default)
Default and copy constructors. The constructor with the type
parameter allows the user to set the torsion library type from values
in the OETorLibType namespace.
operator=
OETorLib & operator=(const OETorLib &)
Assignment operator.
operator bool
operator bool() const
Returns false if the OETorLib object is empty, otherwise returns true.
AddTorsionLibrary
bool AddTorsionLibrary(const std::string &)
bool AddTorsionLibrary(OEPlatform::oeistream &)
Takes a string or an oeistream object to add a torsion
library. This will put the new torsion library above the
current torsion library, which means that they will be checked
first for a match. To replace the torsion library, call
OETorLib::SetTorsionLibrary. The method returns
true if the library is added successfully.
AddTorsionRule
bool AddTorsionRule(const std::string &)
Adds a single torsion rule as a string. The format for rules is a SMARTS pattern followed by the torsion angles. The method returns true if the rule is added successfully. The following is an example of a general rule:
[*:1][CH2:2][a:3][a:4] 0 180 90 -90 45 -45 135 -135
The following code demonstrates how to add a new torsion
rule to an existing OEOmega object named omega.
Example of adding a new torsion rule
// Adding the torsion rule "[O:1]=[C:2]-[O:3][CH3:4] 90" as a string
// This takes precedent over previous rule
OETorLib torLib;
const char *rule = "[O:1]=[C:2]-[O:3][CH3:4] 90";
if (!torLib.AddTorsionRule(rule))
OEThrow.Fatal("Failed to add torsion rule: %s", rule);
omegaOpts.SetTorLib(torLib);
omega.SetOptions(omegaOpts);
if(omega(mol))
OEWriteMolecule(ofs, mol);
See the appendix for a full listing.
The new rule will take precedence over all rules previously added to this object either from a file or from calling this method.
bool AddTorsionRule(OEChem::OEQMolBase &qmol, std::vector<int> °rees)
The next signature of AddTorsionRule takes a generic
OEQMolBase with a corresponding
std::vector<int> containing the angles. The pattern
represented by OEQMolBase should have map
indices set on the atoms considered in the torsion. In
SMARTS, this means the atoms should have map indices
numbered from 1 to 4. This can theoretically allow torsion rules to
be written in other query file formats provided there is a
method for setting the appropriate map indices. The following
code demonstrates how to initialize an
OEQMolBase and use it to define a new torsion rule.
Example of adding a new torsion rule from a query molecule
// Adding torsion rule "[O:1]=[C:2]-[O:3][CH3:4] 45" as a query
// molecule. This takes precedent over default rule
OEQMol qmol;
OEParseSmarts(qmol,"[O:1]=[C:2]-[O:3][CH3:4]");
std::vector<int> degrees;
degrees.push_back(45);
OETorLib torLib;
if (!torLib.AddTorsionRule(qmol, degrees))
OEThrow.Fatal("Failed to add torsion rule");
omegaOpts.SetTorLib(torLib);
omega.SetOptions(omegaOpts);
if (omega(mol))
OEWriteMolecule(ofs, mol);
ClearTorsionLibrary
void ClearTorsionLibrary()
Clears the current torsion library. Omega cannot operate with an empty torsion library, so a new torsion library must be set before running Omega.
GetTorRule
const OEChem::OESubSearch* GetTorRule(const OEChem::OEMolBase&,
const OEChem::OEBondBase&) const
Returns the torsion rule associated with the specified bond of the specified molecule. The method returns a null pointer if a torsion rule is not found. The rules are stored as OESubSearch objects.
See also
OEGetTorValuesfunction.
GetTorRules
OESystem::OEIterBase<OEChem::OESubSearch>* GetTorRules()
Returns an iterator over the torsion rules. The rules are stored as OESubSearch objects.
HasTorRule
bool HasTorRule(const OEChem::OEMolBase&, const OEChem::OEBondBase&) const
Checks if a torsion rule exists with the specified bond of the specified molecule. Returns true if a rule exists.
ResetTorsionLibrary
bool ResetTorsionLibrary()
Resets the torsion library stored internally by Omega. The method returns true if the library is reset successfully.
SetTorsionLibrary
bool SetTorsionLibrary(const std::string &)
bool SetTorsionLibrary(OEPlatform::oeistream &)
bool SetTorsionLibrary(unsigned int type)
Replaces the current torsion library with the one passed in as an
argument. If the argument is a type, it is expected to be a value
in the OETorLibType namespace. The method returns
true if the library is set successfully.