Package org.openmolecules.chem.conf.gen
Class ConformerGenerator
- java.lang.Object
-
- org.openmolecules.chem.conf.gen.ConformerGenerator
-
public class ConformerGenerator extends java.lang.Object
This class generates 3D-conformers of a given molecule using the following strategy:- All rotatable, non-ring bonds are determined.
- Fragments separated by rotatable bonds are considered rigid, but there may be more than one possible fragment conformer, e.g. chair- and boat conformers of a saturated 6-membered ring.
- These atom coordinate sets of rigid fragments are handed out by a dedicated RigidFragmentProvider instance, which either generates them using a self organization algorithm, or which takes it from a cache.
- For every rotatable bond a list of preferred torsion angles is determined based on from a COD statistics of similar bond environments.
- For individual torsion values likelihoods are estimated based on frequency and atom collisions of vicinal fragments.
- A dedicated (systematic, biased or random) torsion set strategy delivers collision-free torsion sets, i.e. conformers.
For generating conformers in multiple threads, every thread needs its own ConformerGenerator instance. If they use a RigidFragmentCache, then the cache is shared among all ConformerGenerators.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DW_FRAGMENTS_FILE
int[]
mDiagnosticCollisionAtoms
java.lang.String
mDiagnosticCollisionString
java.lang.String
mDiagnosticTorsionString
static boolean
PRINT_DEBUG_INDEXES
static boolean
PRINT_ELIMINATION_RULES_WITH_STRUCTURES
static boolean
PRINT_EXIT_REASON
static boolean
PRINT_TORSION_AND_FRAGMENT_LIKELYHOODS
static int
STRATEGY_ADAPTIVE_RANDOM
static int
STRATEGY_LIKELY_RANDOM
static int
STRATEGY_LIKELY_SYSTEMATIC
static int
STRATEGY_PURE_RANDOM
protected static double
VDW_TOLERANCE_HYDROGEN
protected static double
VDW_TOLERANCE_OTHER
static boolean
WRITE_DW_FRAGMENT_FILE
-
Constructor Summary
Constructors Constructor Description ConformerGenerator()
Instantiates a ConformerGenerator for creating non-reproducible conformers.ConformerGenerator(boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating non-reproducible conformers.ConformerGenerator(long seed, boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L.ConformerGenerator(long seed, RigidFragmentCache cache, boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L.ConformerGenerator(long seed, RigidFragmentProvider rfp)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addHydrogenAtoms(StereoMolecule mol)
Adds explicit hydrogen atoms where they are implicit by filling valences and adapting for atom charges.Conformer
generateConformerFromTorsionSet(TorsionSet torsionset)
Computes a conformer from a TorsionSet object.int
getConformerCount()
Conformer
getNextConformer()
Conformer
getNextConformer(TorsionSet[] torsion_set_out)
Creates the next random, likely or systematic new(!) conformer of the molecule that was passed when calling initializeConformers().StereoMolecule
getNextConformerAsMolecule(StereoMolecule mol)
Creates the next random, likely or systematic new(!) conformer of the molecule that was passed when calling initializeConformers().Conformer
getOneConformer(StereoMolecule mol)
Fills all free valences of mol with explicit hydrogens and tries to create a reasonable conformer by starting with the most likely torsion set.StereoMolecule
getOneConformerAsMolecule(StereoMolecule mol)
Fills all free valences of mol with explicit hydrogens and tries to create a reasonable conformer by starting with the most likely torsion set.int
getPotentialConformerCount()
Calculates the potential count of conformers by multiplying degrees of freedom (torsions per rotatable bond & rigid fragment multiplicities).double
getPreviousConformerContribution()
With best current knowledge about colliding torsion combinations and based on the individual frequencies of currently active torsions this method returns the conformers's overall contribution to the total set of non colliding conformers.int
getRotatableBondCount()
After calling initializeConformers() this method returns the number of rotatable bonds, which are used to separate the molecule into rigid fragments.static double
getToleratedVDWRadius(int atomicNo)
protected boolean
initialize(StereoMolecule mol, boolean use60degreeSteps)
Don't call this method directly.boolean
initializeConformers(StereoMolecule mol)
One of the initializeConformers() methods needs to be called, before getting individual conformers of the same molecule by getNextConformer().boolean
initializeConformers(StereoMolecule mol, int strategy, int maxTorsionSets, boolean use60degreeSteps)
One of the initializeConformers() methods needs to be called, before getting individual conformers of the same molecule by getNextConformer().void
setThreadMaster(ThreadMaster tm)
If the conformer generation must be stopped from outside, for instance because of user intervention or because of a defined timeout, the provide a ThreadMaster with this method.void
setUseSelfOrganizerIfAllFails(boolean b)
If a molecule has at least one rotatable bond if all permutations of torsions collide beyond a tolerated strain, then the standard behaviour of this class is to return that clashing conformer with the lowest strain.
If passing true to this method, the ConformerGenerator will use the ConformerSelfOrganizer in these cases to generate conformers.
-
-
-
Field Detail
-
STRATEGY_LIKELY_SYSTEMATIC
public static final int STRATEGY_LIKELY_SYSTEMATIC
- See Also:
- Constant Field Values
-
STRATEGY_PURE_RANDOM
public static final int STRATEGY_PURE_RANDOM
- See Also:
- Constant Field Values
-
STRATEGY_LIKELY_RANDOM
public static final int STRATEGY_LIKELY_RANDOM
- See Also:
- Constant Field Values
-
STRATEGY_ADAPTIVE_RANDOM
public static final int STRATEGY_ADAPTIVE_RANDOM
- See Also:
- Constant Field Values
-
VDW_TOLERANCE_HYDROGEN
protected static final double VDW_TOLERANCE_HYDROGEN
- See Also:
- Constant Field Values
-
VDW_TOLERANCE_OTHER
protected static final double VDW_TOLERANCE_OTHER
- See Also:
- Constant Field Values
-
PRINT_TORSION_AND_FRAGMENT_LIKELYHOODS
public static final boolean PRINT_TORSION_AND_FRAGMENT_LIKELYHOODS
- See Also:
- Constant Field Values
-
PRINT_DEBUG_INDEXES
public static final boolean PRINT_DEBUG_INDEXES
- See Also:
- Constant Field Values
-
PRINT_EXIT_REASON
public static final boolean PRINT_EXIT_REASON
- See Also:
- Constant Field Values
-
PRINT_ELIMINATION_RULES_WITH_STRUCTURES
public static final boolean PRINT_ELIMINATION_RULES_WITH_STRUCTURES
- See Also:
- Constant Field Values
-
DW_FRAGMENTS_FILE
public static final java.lang.String DW_FRAGMENTS_FILE
- See Also:
- Constant Field Values
-
mDiagnosticCollisionString
public java.lang.String mDiagnosticCollisionString
-
mDiagnosticTorsionString
public java.lang.String mDiagnosticTorsionString
-
mDiagnosticCollisionAtoms
public int[] mDiagnosticCollisionAtoms
-
WRITE_DW_FRAGMENT_FILE
public static boolean WRITE_DW_FRAGMENT_FILE
-
-
Constructor Detail
-
ConformerGenerator
public ConformerGenerator()
Instantiates a ConformerGenerator for creating non-reproducible conformers. Uses the default rigid fragment cache, which is initially empty unless RigidFragmentCache.getDefaultInstance().loadDefaultCache() was called before. While rigid fragments, when found in the cache are always energy minimized, the ones not found in the cache are generated by self organization and not minimized afterawrds.
-
ConformerGenerator
public ConformerGenerator(long seed, boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L. Uses the default rigid fragment cache, which is initially empty unless RigidFragmentCache.getDefaultInstance().loadDefaultCache() was called before. While rigid fragments, when found in the cache, are always energy minimized, the ones not found in the cache are generated by self organization and energy minimized before cached and being used, if optimizeRigidFragments is true.- Parameters:
seed
- != 0L if conformers shall be created in a reproducible wayoptimizeRigidFragments
- if true, then all rigid fragments will be energy minimized by the MMFF94s+ forcefield
-
ConformerGenerator
public ConformerGenerator(boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating non-reproducible conformers. Uses the default rigid fragment cache, which is initially empty unless RigidFragmentCache.getDefaultInstance().loadDefaultCache() was called before. While rigid fragments, when found in the cache, are always energy minimized, the ones not found in the cache are generated by self organization and energy minimized before cached and being used, if optimizeRigidFragments is true.- Parameters:
optimizeRigidFragments
- if true, then all rigid fragments will be energy minimized by the MMFF94s+ forcefield
-
ConformerGenerator
public ConformerGenerator(long seed, RigidFragmentCache cache, boolean optimizeRigidFragments)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L. Uses a custom rigid fragment cache or no cache at all. Rigid fragments, when found in the cache, are always energy minimized. The ones not found in the cache are generated by self organization. They are energy minimized before being cached and being used, if optimizeRigidFragments is true.- Parameters:
seed
- != 0L if conformers shall be created in a reproducible waycache
- may be null for generating all rigid fragment conformers on the flyoptimizeRigidFragments
- if true, then all rigid fragments will be energy minimized by the MMFF94s+ forcefield
-
ConformerGenerator
public ConformerGenerator(long seed, RigidFragmentProvider rfp)
Instantiates a ConformerGenerator for creating reproducible conformers unless seed is 0L. Uses a custom RigidFragmentProvider, which typically should be done if your fragments shall be energy minimized with something else than the MMFF94s+ forcefield, e.g. a QM method.- Parameters:
seed
- != 0L if conformers shall be created in a reproducible wayrfp
-
-
-
Method Detail
-
addHydrogenAtoms
public static void addHydrogenAtoms(StereoMolecule mol)
Adds explicit hydrogen atoms where they are implicit by filling valences and adapting for atom charges. New hydrogen atoms receive new 2D-coordinates by equally locating them between those two neighbors with the widest angle between their bonds. Any stereo configurations deducible from 2D-coordinates are retained.- Parameters:
mol
-
-
getToleratedVDWRadius
public static double getToleratedVDWRadius(int atomicNo)
-
setThreadMaster
public void setThreadMaster(ThreadMaster tm)
If the conformer generation must be stopped from outside, for instance because of user intervention or because of a defined timeout, the provide a ThreadMaster with this method.- Parameters:
tm
-
-
getOneConformerAsMolecule
public StereoMolecule getOneConformerAsMolecule(StereoMolecule mol)
Fills all free valences of mol with explicit hydrogens and tries to create a reasonable conformer by starting with the most likely torsion set. If there are collisions, then less likely torsions are tried to find a collision free conformer. If it succeeds, mol receives the modified atom coordinates and mol is returned. If the conformer generation fails, then null is returned. The torsion strategy used is STRATEGY_ADAPTIVE_RANDOM. New 3D-coordinates correctly reflect E/Z and R/S bond/atom parities. This is a convenience method that does not require any initialization.- Parameters:
mol
- the molecule that receive new 3D coordinates in place- Returns:
- original molecule with new 3D-coordinates or null
-
getOneConformer
public Conformer getOneConformer(StereoMolecule mol)
Fills all free valences of mol with explicit hydrogens and tries to create a reasonable conformer by starting with the most likely torsion set. If there are collisions, then less likely torsions are tried to find a collision free conformer. If this fails, then null is returned. The torsion strategy used is STRATEGY_ADAPTIVE_RANDOM. New 3D-coordinates correctly reflect E/Z and R/S bond/atom parities. This is a convenience method that does not require any initialization.- Parameters:
mol
- the molecule from which to create the conformer
-
initialize
protected boolean initialize(StereoMolecule mol, boolean use60degreeSteps)
Don't call this method directly. Rather call initializeConformers() !!! Adds implicit hydrogens to the molecule and determines all rotatable bonds, which are not part of a ring. Generates rigid fragments between rotatable bonds. The base conformer is constructed by connecting all rigid fragments using the most frequent torsions. Atoms of different fragments in the base conformer may collide. In order to obtain collision free conformers choose a TorsionStrategy and call getNextConformer() at least once.- Parameters:
mol
-use60degreeSteps
- use 60 degree steps for every rotatable bond instead of torsion DB
-
getRotatableBondCount
public int getRotatableBondCount()
After calling initializeConformers() this method returns the number of rotatable bonds, which are used to separate the molecule into rigid fragments.- Returns:
-
getNextConformerAsMolecule
public StereoMolecule getNextConformerAsMolecule(StereoMolecule mol)
Creates the next random, likely or systematic new(!) conformer of the molecule that was passed when calling initializeConformers(). A new conformer is one, whose combination of torsion angles was not used in a previous conformer created by this function since the last call of initializeConformers(). Parameter mol may be null or recycle the original molecule to receive new 3D coordinates. If it is null, then a fresh copy of the original molecule with new atom coordinates is returned. Every call of this method creates a new collision-free conformer until the employed torsion set strategy decides that it cannot generate any more suitable torsion sets.- Parameters:
mol
- null or molecule used during initialization or a copy of it- Returns:
- conformer or null, if all/maximum torsion permutations have been tried
-
getNextConformer
public Conformer getNextConformer()
-
getNextConformer
public Conformer getNextConformer(TorsionSet[] torsion_set_out)
Creates the next random, likely or systematic new(!) conformer of the molecule that was passed when calling initializeConformers(). A new conformer is one, whose combination of torsion angles was not used in a previous conformer created by this function since the last call of initializeConformers(). Every call of this method creates a new collision-free conformer until the employed torsion set strategy decides that it cannot generate any more suitable torsion sets.- Parameters:
torsion_set_out
- : will contain the TorsionSet that gave rise to the conformer.- Returns:
- conformer or null, if all/maximum torsion permutations have been tried
-
getConformerCount
public int getConformerCount()
- Returns:
- count of valid delivered conformers
-
getPotentialConformerCount
public int getPotentialConformerCount()
Calculates the potential count of conformers by multiplying degrees of freedom (torsions per rotatable bond & rigid fragment multiplicities). Cannot be called before calling initializeConformers().- Returns:
-
getPreviousConformerContribution
public double getPreviousConformerContribution()
With best current knowledge about colliding torsion combinations and based on the individual frequencies of currently active torsions this method returns the conformers's overall contribution to the total set of non colliding conformers.- Returns:
- this conformer's contribution to all conformers
-
setUseSelfOrganizerIfAllFails
public void setUseSelfOrganizerIfAllFails(boolean b)
If a molecule has at least one rotatable bond if all permutations of torsions collide beyond a tolerated strain, then the standard behaviour of this class is to return that clashing conformer with the lowest strain.
If passing true to this method, the ConformerGenerator will use the ConformerSelfOrganizer in these cases to generate conformers. getNextConformer will then deliver conformers until the self organization fails to create new conformers.- Parameters:
b
-
-
initializeConformers
public boolean initializeConformers(StereoMolecule mol)
One of the initializeConformers() methods needs to be called, before getting individual conformers of the same molecule by getNextConformer(). Open valences of the passed molecule are filled with hydrogen atoms. The passed molecule may repeatedly be used as container for a new conformer's atom coordinates, if it is passed as parameter to getNextConformer(). This method uses the STRATEGY_LIKELY_RANDOM strategy with a maximum of 100.000 distinct torsion sets and uses torsions from crystallographic data.- Parameters:
mol
- will be saturated with hydrogen atoms- Returns:
- false if there is a structure problem
-
initializeConformers
public boolean initializeConformers(StereoMolecule mol, int strategy, int maxTorsionSets, boolean use60degreeSteps)
One of the initializeConformers() methods needs to be called, before getting individual conformers of the same molecule by getNextConformer(). Open valences of the passed molecule are filled with hydrogen atoms. The passed molecule may repeatedly be used as container for a new conformer's atom coordinates, if it is passed as parameter to getNextConformer().- Parameters:
mol
- will be saturated with hydrogen atomsstrategy
- one of the STRATEGY_ constantsmaxTorsionSets
- maximum number of distinct torsion sets the strategy will try (default 100000)use60degreeSteps
- use 60 degree steps for every rotatable bond instead of torsion DB- Returns:
- false if there is a structure problem
-
generateConformerFromTorsionSet
public Conformer generateConformerFromTorsionSet(TorsionSet torsionset)
Computes a conformer from a TorsionSet object.- Parameters:
torsionset
-- Returns:
- the generated conformer.
-
-