211 Commits

Author SHA1 Message Date
Greg Landrum
1acae67cba Merge branch 'master' into PDB_29September2013 2013-10-08 05:51:57 +02:00
ptosco
d402867610 - fixed a bug in the MMFF stretch-bend gradient calculation
- put in better evidence the extents of the UFF hack so that it can be
  easily commented out if required
2013-10-07 17:53:20 +02:00
Greg Landrum
c95d57aa54 add in-place form of addHs() 2013-10-04 07:58:53 +02:00
ptosco
1957baadb0 - replaced the call to sanitizeMMFFMol() in the MMFFMolProperties
constructor (which is overkill, if the molecule had already been
  sanitized) with a call to MolOps::Kekulize(). Thus it is not
  necessary to call Kekulize() either from Python or from C++,
  and no changes are required to the scripts/source codes
  previously used for UFF
- removed the code which throws an exception asking to reload the
  molecule with sanitize=false since it is not necessary:
  only one test in the MMFF validation suite fails if the
  molecule is aromatized and then re-kekulized (CIKSEU10), and
  it represents a case where the position of double bonds in
  a conjugated, non-aromatic system makes a difference for atom
  type assignments, which in general is a nonsense. This is not
  due to a bug in the code, but rather depends on MMFF atom
  typing rules. Hence, I kept the sanitize=false and the call to
  sanitizeMMFFMol() in testMMFFForceField.cpp, but I would not
  generalize this requirement to "normal" molecules, because it
  is really not necessary, since you do not have a reference
  kekulization to refer to in the real world.
- updated Docs/Book/GettingStartedInPython.rst accordingly
- updated tests accordingly
2013-10-01 23:16:15 +02:00
Greg Landrum
d6faad6e40 more mmff api consistency 2013-09-29 07:58:34 +02:00
ptosco
57147304bb - Replaced the setupMMFFForceField() function (which returned a pointer
to a newly allocated MMFFMolProperties object) with a simple
  constructor of the MMFFMolProperties object
- Replaced in a few MMFF-related functions the "ROMol *" argument
  with a "ROMol &" argument for consistency with similar RDKit
  functions
- Renamed the SetupMMFFForceField() function in Python into
  GetMMFFMolProperties() for consistency
- Updated the MMFF tests according to the aforementioned changes
  in the API
2013-09-28 18:45:51 +02:00
ptosco
3646270a49 - Implemented a hack to improve the UFF-generated geometries of 3- and
4-membered rings containing sp2 atoms. The hack consists in
  altering on-the-fly the theta0 equilibrium angle, depending on
  ring size and collocation of the two edges of the angle (i.e.,
  both edges inside the ring or one inside and one outside)
- Added a relevant test in
  Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp
2013-09-24 14:45:08 +02:00
Greg Landrum
2efd05a7e3 Fixes #105 2013-09-23 01:38:14 -04:00
ptosco
ec8eb5a1bf - Changed all occurrences of RDKit::PI into M_PI
- added #ifdef M_PI (...) #endif in all relevant places
- made length() and sqLength() method consistent
  with respect to usage of pow(x, 2) vs x*x in
  Code/Geometry/point.h
- removed gzip-related boost.iostreams dependency and
  replaced with portable "cmake -E tar xzf" command
  in Code/ForceField/MMFF/CMakeLists.txt
2013-09-20 17:45:41 +02:00
Greg Landrum
3a59557c91 fix a typo introduced in this morning's refactoring 2013-09-20 14:54:29 +02:00
Greg Landrum
f4efe253cb get windows builds working 2013-09-20 04:46:49 +01:00
Greg Landrum
219d6ea690 allow the MMFF optimization code to be called a second time on a molecule 2013-09-18 05:01:38 +02:00
Greg Landrum
8924ffd1ef modify sanitizeMMFFMol() so that it no longer throws when sanitization fails;
remove precondition test for sanitizeMMFFMol() failure from setupMMFFForceField() in favor of throwing the appropriate exception
2013-09-18 04:51:49 +02:00
ptosco
b1acab59b0 - I have made MMFF atom typing more robust since I realized that
incorrect typing might arise when hydrogens were not added after
  generating 3D coordinates from SMILES strings; now all 761 test molecules
  are correctly typed no matter whether hydrogens are explicit or implicit

- MMFF test suite: I have cut down to the bare essential the
  MMFF94/MMFF94s reference log files, but their size could be reduced only
  by about 30%. It could have been reduced more converting multiple spaces
  into a tab, but the MMFF94 file (the larger one) would still be around
  11 MB, and human readability would be greatly impaired. Hence I decided
  to keep the spaces and gzip the reference logs, which reduces their
  combined size to ~ 3.5 MB, which I think is fine; the test program checks
  if the gunzipped files already exist, otherwise it gunzips them upfront.
  While cutting, I also sorted the molecules in the same order as in the
  SDF/SMILES files, so that it runs about 10 times faster than before.
  Now the test runs on MMFF94 only (MMFF94s only concerns different OOP
  parameters, there are no algorithmic differences, so as long as one does
  not alter the original parameters it can be safely skipped), computing
  every 4th molecule, and it runs in 12 seconds on my laptop. Running
  all molecules takes ~ 50 seconds, but I think it is rather overkill,
  and I would keep it as it is.

- I have added a test suite for MMFF ForceFieldHelpers (like the one
  already existing for UFF); I have also complemented the Python wrapper
  test suite for ForceFieldHelpers with a few tests for MMFF.

- I have written Python wrappers for the MMFF-related functionality;
  while doing that I realized that many of the wrapper code relocations
  that I made in my previous pull request were not necessary/appropriate,
  so I reverted them. The only difference from the UFF Python API is that,
  just like for the C++ API, in addition to the PyForceField object there
  is a PyMMFFMolProperties object which is created before constructing the
  force field itself; the PyMMFFMolProperties is necessary to set (e.g.,
  dielectric constant, dielectric model) or get (e.g., atom type, formal
  and partial charge) some MMFF properties which are not present in UFF,
  while preserving binary compatibility of the libraries. Probably you
  remember that we discussed about setting atom type and charge properties
  with SetProp besides populating the MMFFMolProperties object, in order
  to allow easy access to Python users. However, I think that the solution
  I adopted is preferrable since it is more consistent with the C++ API,
  it enables faster access to properties and it allows tailoring the MMFF
  environment (i.e., choosing MMFF94/MMFF94s, setting the verbosity level,
  including/excluding terms from the MMFF equation, setting dielectric
  constant/model) just as from C++.

  The MMFF-related Python functions I implemented are:

  * MMFFOptimizeMolecule(mol, mmffVariant = "MMFF94", maxIters = 200,
      nonBondedThresh = 100.0, confId = -1, ignoreInterfragInteractions
      = true)

    uses MMFF to optimize a molecule's structure (just like
    UFFOptimizeMolecule)

  * SanitizeMMFFMol(mol)

    sanitizes a molecule according to MMFF requirements

  * SetupMMFFForceField(mol, mmffVariant = "MMFF94", mmffVerbosity = 0)

    returns a PyMMFFMolProperties object for a molecule; the
    PyMMFFMolProperties object is required by MMFFGetMoleculeForceField()
    and can be used to get/set MMFF properties

  * MMFFGetMoleculeForceField(mol, pyMMFFMolProperties,
      nonBondedThresh = 100.0, confId = -1, ignoreInterfragInteractions
      = true)

    returns a MMFF force field for a molecule (just like
    UFFGetMoleculeForceField)

  * MMFFHasAllMoleculeParams(mol)

    checks if MMFF parameters are available for all of a molecule's atoms
    (just like UFFHasAllMoleculeParams)

  There are also a few methods connected to the PyMMFFMolProperties class
  which mirror those available from C++ for the MMFFMolProperties class:

  * GetMMFFAtomType(idx)

    Retrieves MMFF atom type for atom with index idx

  * GetMMFFFormalCharge(idx)

    Retrieves MMFF formal charge for atom with index idx

  * GetMMFFPartialCharge(idx)

    Retrieves MMFF partial charge for atom with index idx

  * SetMMFFDielectricModel(dielModel = 1)

    sets the DielModel MMFF property (1: constant; 2: distance-dependent;
    defaults to constant)

  * SetMMFFDielectricConstant(dielConst = 1.0)

    Sets the DielConst MMFF property (defaults to 1.0)

  * SetMMFFBondTerm(state = True)

    Sets the bond term to be included in the MMFF equation (defaults
    to True)

  * SetMMFFAngleTerm(state = True)

    Sets the angle term to be included in the MMFF equation (defaults
    to True)

  * SetMMFFStretchBendTerm(state = True)

    Sets the stretch-bend term to be included in the MMFF equation (defaults
    to True)

  * SetMMFFOopTerm(state = True)

    Sets the out-of-plane bend term to be included in the MMFF equation
    (defaults to True)

  * SetMMFFTorsionTerm(state = True)

    Sets the torsional term to be included in the MMFF equation (defaults
    to True)

  * SetMMFFVdWTerm(state = True)

    Sets the Van der Waals term to be included in the MMFF equation
    (defaults to True)

  * SetMMFFEleTerm(state = True)

    Sets the electrostatic term to be included in the MMFF equation
    (defaults to True)

  * SetMMFFVariant(mmffVariant = "MMFF94")

    Sets the MMFF variant to be used ("MMFF94" or "MMFF94s"; defaults to
    "MMFF94")

  * SetMMFFVerbosity(verbosity = 0)

    Sets the MMFF verbosity (0: none; 1: low; 2: high; defaults to 0)

  Hence, most users will do something like this to optimize a molecule
  structure obtained from a SMILES string:

  from rdkit import Chem
  from rdkit.Chem import AllChem

  m = Chem.MolFromSmiles("O=C(C)c1cccnc1", False)
  AllChem.SanitizeMMFFMol(m)
  m2 = Chem.AddHs(m)
  AllChem.EmbedMolecule(m2)
  # Opt
  AllChem.MMFFOptimizeMolecule(m2)
  print >>file('structure_min.sdf','w'), Chem.MolToMolBlock(m2)

  Those willing to play a bit more with MMFF properties may do the
  following:

  from rdkit import Chem
  from rdkit.Chem import AllChem

  m = Chem.MolFromSmiles("O=C(C)c1cccnc1", False)
  AllChem.SanitizeMMFFMol(m)
  m2 = Chem.AddHs(m)
  AllChem.EmbedMolecule(m2)
  pyMP = AllChem.SetupMMFFForceField(m2)
  pyMP.SetMMFFVariant("MMFF94s")
  pyMP.SetMMFFDielectricModel(2)
  pyFF = AllChem.MMFFGetMoleculeForceField(m2, pyMP)
  pyFF.Minimize()
  print >>file('structure_min.sdf','w'), Chem.MolToMolBlock(m2)
  print 'Energy = {0:12.4f}'.format(pyFF.CalcEnergy())
  i = 0
  for i in range(0, m2.GetNumAtoms()):
    print '{0:4d} {1:4d} {2:8.4f} {3:8.4f}'.format(i + 1,
      int(pyMP.GetMMFFAtomType(i)),
      float(pyMP.GetMMFFFormalCharge(i)),
      float(pyMP.GetMMFFPartialCharge(i)))

- OOP backport to UFF. I added the inversion term to the UFF
  implementation following the original UFF paper by Rappe'. I have already
  modified the figures in a couple of test files to reflect the new energy
  values.

- 2-bit neighbor matrix and graph-based angle enumeration now reflect
  the MMFF implementation.
2013-09-16 12:08:02 +02:00
Greg Landrum
0212d82468 compiles and passes all tests 2013-08-19 05:53:49 +02:00
ptosco
3f4297fa44 Created a new MMFF branch. I moved some files/folders from
Code/ForceField and Code/GraphMol/ForceFieldHelpers to the
respective UFF subfolders since from now on UFF will not be
the only available force field anymore. I updated the
relevant CMakeLists.txt files accordingly.

Paolo
2013-08-18 09:11:29 +02:00
Greg Landrum
b4f2ec374e Fixes: #61 2013-07-04 18:00:09 +02:00
Greg Landrum
e29aa466db github-28: fix a doc wart 2013-05-09 14:45:12 +00:00
Greg Landrum
b96cff10e8 fix and test sf.net issue 254 2012-09-23 10:13:46 +00:00
Greg Landrum
a99ad44859 clean up some compiler warnings 2011-12-31 15:58:57 +00:00
Greg Landrum
b993f89afe remove the bjam-based build system 2010-09-27 03:54:07 +00:00
Greg Landrum
f3fbef45c5 update copyright statements 2010-09-26 17:04:37 +00:00
Greg Landrum
cb6cdb99b3 merge in a set of changes from Riccardo V. to install .h files as well;
this needs more testing.
2010-09-04 14:07:22 +00:00
Greg Landrum
ada36a2799 fix and test issue 3009337 2010-06-02 04:57:53 +00:00
Greg Landrum
f14fbecf6a change the default tolerance for dgeom embedding to be a bit more conservative 2010-04-18 06:17:23 +00:00
Greg Landrum
ec192d981e changes to robustify (and somewhat speed up) the optimizer. These will change results 2010-02-28 13:11:34 +00:00
Greg Landrum
9727cffa61 make python wrappers and tests optional 2010-01-22 11:22:58 +00:00
Greg Landrum
c346a41951 get the tests working on windows. 2010-01-19 06:34:58 +00:00
Greg Landrum
53485592ca builds on windows with visual studio; need to pass back to linux now 2009-10-01 13:35:48 +00:00
Greg Landrum
76297b0fff builds and passes tests on linux 2009-09-28 11:02:18 +00:00
Greg Landrum
9cabf87374 remove vflib from Jamfiles
remove const specifiers from return values in DataStructs
add initial pass at query-query matching for Atoms and Bonds
fix and test for sf.net issu 2738320
add Mol.AddRecursiveQuery() method to Mol
2009-06-29 11:47:38 +00:00
Greg Landrum
02bcdcaaa3 further robustification in the face of bad parameters 2009-04-13 15:10:47 +00:00
Greg Landrum
ac6fc48f37 partial fix for issue 2757824; more testing required 2009-04-13 11:53:51 +00:00
Greg Landrum
8e731f9e70 move the MolDiscriminators calculations into Subgraphs in order to remove the lapack dependency from the core molecule code;
At some point the BalabanJ calculation, still in MolDiscriminators.cpp, should be 
moved to MolDescriptors.
2009-04-10 04:09:49 +00:00
Greg Landrum
d2616120e6 docs update 2009-03-04 12:23:11 +00:00
Greg Landrum
f3dc387bc4 merge changes from revs991:996 on Ullmann_9Feb2009 branch;
get USE_VFLIB fulling working and make it the default
2009-02-28 16:52:06 +00:00
Greg Landrum
e05580e495 This is a sizeable one: change the way BGL is used so that atoms and bonds are stored as bundled properties
instead of using the property map interface.
A nice side-effect is that the wart of having to use property maps to loop over bonds or atom neighbors
is now gone.
This potentially breaks lots of client C++ code.
2009-02-11 20:19:25 +00:00
Greg Landrum
0abf10a8d9 revs979 and 980 should not have been on the trunk. They belong on the easy_install branch.
I must now wear the ribbons of shame.
2009-02-04 20:39:35 +00:00
Greg Landrum
f0b288cfed big changes again (repeat the 979, 980 disaster on the correct branch) 2009-02-04 20:13:44 +00:00
Greg Landrum
34027acd93 update where libraries get installed on build 2009-02-04 18:40:28 +00:00
Greg Landrum
8bf7a4c187 now all tests pass here as well 2009-02-03 05:26:10 +00:00
Greg Landrum
55010e7213 fix a warning and a round-off problem 2008-12-04 07:20:55 +00:00
Greg Landrum
507d7e84e7 fix and test sf.net issue2378119 2008-12-03 19:34:55 +00:00
Greg Landrum
2580fbaaa2 this is probably a ways from done, but now at least we can run bjam under mingw without it immediately erroring out 2008-11-15 17:14:13 +00:00
Greg Landrum
2dafc16f29 fix and test sf.net issue 2094445 2008-09-05 05:43:53 +00:00
Greg Landrum
89a34d1a39 get this building on Darwin; NOTE: this may not work on win or linux yet 2008-09-03 19:24:35 +00:00
Greg Landrum
a3e6cb057e this is a mass of cleanup stuff; mostly line endings 2008-07-07 13:21:24 +00:00
Greg Landrum
ac5a7d72c7 these are no longer needed 2008-07-07 06:36:34 +00:00
Greg Landrum
e8f3536845 remove a bunch of compiler warnings 2008-05-26 20:05:57 +00:00
Greg Landrum
8424d36830 get things building on windows. 2008-04-08 18:24:56 +00:00