Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametrization error #581

Closed
matteo-ambrosetti opened this issue Apr 16, 2020 · 6 comments
Closed

Parametrization error #581

matteo-ambrosetti opened this issue Apr 16, 2020 · 6 comments

Comments

@matteo-ambrosetti
Copy link

Hello everyone,
I am trying to perform an MD of betaine in water but seems that it is not possible for openforcefield to get the parameters of the solute.

I get the following warning:
Warning: In AmberToolsToolkitwrapper.compute_partial_charges_am1bcc: Molecule '' has more than one conformer, but this function will only generate charges for the first one.

But the problem is the following error:

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-5-5939983b4e9d> in <module>
    44 
    45 # Parametrize the topology and create an OpenMM System.
---> 46 system = forcefield.create_openmm_system(off_topology)
    47 
    48 # Create the integrator to do Langevin dynamics

~/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/typing/engines/smirnoff/forcefield.py in create_openmm_system(self, topology, **kwargs)
  1136         # Add forces and parameters to the System
  1137         for parameter_handler in parameter_handlers:
-> 1138             parameter_handler.create_force(system, topology, **kwargs)
  1139 
  1140         # Let force Handlers do postprocessing

~/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/typing/engines/smirnoff/parameters.py in create_force(self, system, topology, **kwargs)
  2925             toolkit_registry = kwargs.get('toolkit_registry', GLOBAL_TOOLKIT_REGISTRY)
  2926             temp_mol.generate_conformers(n_conformers=10, toolkit_registry=toolkit_registry)
-> 2927             temp_mol.compute_partial_charges_am1bcc(toolkit_registry=toolkit_registry)
  2928 
  2929             # Assign charges to relevant atoms

~/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/topology/molecule.py in compute_partial_charges_am1bcc(self, toolkit_registry)
  2301             charges = toolkit_registry.call(
  2302                       'compute_partial_charges_am1bcc',
-> 2303                       self
  2304             )
  2305         elif isinstance(toolkit_registry, ToolkitWrapper):

~/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/utils/toolkits.py in call(self, method_name, *args, **kwargs)
  3660                 method = getattr(toolkit, method_name)
  3661                 try:
-> 3662                     return method(*args, **kwargs)
  3663                 except NotImplementedError:
  3664                     pass

~/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/utils/toolkits.py in compute_partial_charges_am1bcc(self, molecule)
  3189                 subprocess.check_output([
  3190                     "antechamber", "-i", "charged.mol2", "-fi", "mol2", "-o", "charges2.mol2", "-fo", "mol2", "-c", "wc", "-cf",
-> 3191                     "charges.txt", "-pf", "yes"
  3192                 ])
  3193                 #os.system('cat charges.txt')

~/anaconda3/envs/openmm/lib/python3.7/subprocess.py in check_output(timeout, *popenargs, **kwargs)
   409 
   410     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 411                **kwargs).stdout
   412 
   413 

~/anaconda3/envs/openmm/lib/python3.7/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)
   510         if check and retcode:
   511             raise CalledProcessError(retcode, process.args,
--> 512                                      output=stdout, stderr=stderr)
   513     return CompletedProcess(process.args, retcode, stdout, stderr)
   514 

CalledProcessError: Command '['antechamber', '-i', 'charged.mol2', '-fi', 'mol2', '-o', 'charges2.mol2', '-fo', 'mol2', '-c', 'wc', '-cf', 'charges.txt', '-pf', 'yes']' returned non-zero exit status 1.

Could it be caused by the dimension of the molecule?

To reproduce the error:

import simtk.openmm as omm
import simtk.openmm.app as app
import simtk.unit as unit
import openforcefield.topology as off_top
from openforcefield.typing.engines.smirnoff import ForceField
import numpy as np

# Read input geometry
pdbfile = app.PDBFile("betaine.pdb")
omm_topology = pdbfile.topology

# Betaine 30
solute = off_top.Molecule.from_smiles('C1=CC=C(C=C1)C2=CC(=[N+](C(=C2)C3=CC=CC=C3)C4=CC(=C(C(=C4)C5=CC=CC=C5)[O-])C6=CC=CC=C6)C7=CC=CC=C7')

# System
all_system = [solute]

# Create the Open Force Field Topology from an OpenMM Topology object.
off_topology = off_top.Topology.from_openmm(openmm_topology=omm_topology, unique_molecules=all_system)

# Load the OpenFF "Parsley" force field.
forcefield = ForceField('openff-1.1.0.offxml')

# Parametrize the topology and create an OpenMM System.
system = forcefield.create_openmm_system(off_topology)

betaine.zip

@mattwthompson
Copy link
Member

Hi, thanks for the bug report. There are a few things that could be the cause of this

  • Molecule may be too big for antechamber - unlikely; 43 heavy atoms shouldn't be too much
  • Molecule may have too many rings - also unlikely, although I don't have much intuition here
  • Something may quirky with a different version of AmberTools

I'm unable to reproduce this on my machine using your snippet, although I may not be using the most up-to-date dependencies or the same ones as you are. Could you show the output of conda list?

@matteo-ambrosetti
Copy link
Author

Thanks @mattwthompson,
here is the output of conda list


# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
acpype                    20200315132700           pypi_0    pypi
ambertools                18.0                          0    omnia
ase                       3.19.1                     py_0    conda-forge
attrs                     19.3.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
biopython                 1.76             py37h516909a_0    conda-forge
blas                      1.0                         mkl
bleach                    3.1.4              pyh9f0ad1d_0    conda-forge
bzip2                     1.0.8                h7b6447c_0
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
cairo                     1.14.12              h8948797_3
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
cftime                    1.1.1.2          py37h03ebfcd_0    conda-forge
chemper                   1.0.0+1.g3e54eb4          pypi_0    pypi
click                     7.1.1              pyh8c360ce_0    conda-forge
curl                      7.68.0               hf8cf82a_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
cython                    0.29.15          py37he6710b0_0
dbus                      1.13.6               he372182_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             py37hc8dfbb8_1001    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
fftw3f                    3.3.4                         2    omnia
flask                     1.1.2              pyh9f0ad1d_0    conda-forge
fontconfig                2.13.0               h9420a91_0
freetype                  2.9.1                h8a8886c_1
glib                      2.63.1               h5a9c865_0
griddataformats           0.5.0                      py_0    conda-forge
gsd                       2.1.0            py37hc1659b7_0    conda-forge
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
hdf4                      4.2.13                        0    conda-forge
hdf5                      1.10.4          nompi_h3c11f04_1106    conda-forge
icu                       58.2                 h9c2bf20_1
importlib-metadata        1.5.2            py37hc8dfbb8_0    conda-forge
importlib_metadata        1.5.2                         0    conda-forge
intel-openmp              2020.0                      166
iodata                    0.1.7            py37h035aef0_0    theochem
ipykernel                 5.2.0            py37h43977f1_1    conda-forge
ipython                   7.13.0           py37hc8dfbb8_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.5.1                      py_0    conda-forge
itsdangerous              1.1.0                      py_0    conda-forge
jedi                      0.16.0           py37hc8dfbb8_1    conda-forge
jinja2                    2.11.1                     py_0    conda-forge
joblib                    0.14.1                     py_0    conda-forge
jpeg                      9b                   h024ee3a_2
json5                     0.9.0                      py_0    conda-forge
jsonschema                3.2.0            py37hc8dfbb8_1    conda-forge
jupyter                   1.0.0                      py_2    conda-forge
jupyter_client            6.1.2                      py_0    conda-forge
jupyter_console           6.1.0                      py_1    conda-forge
jupyter_core              4.6.3            py37hc8dfbb8_1    conda-forge
jupyterlab                2.0.1                      py_0    conda-forge
jupyterlab_server         1.0.7                      py_0    conda-forge
kiwisolver                1.1.0            py37h99015e2_1    conda-forge
krb5                      1.16.4               h173b8e3_0
ld_impl_linux-64          2.33.1               h53a641e_7
libboost                  1.67.0               h46d08c1_4
libcurl                   7.68.0               hda55be3_0    conda-forge
libedit                   3.1.20181209         hc058e9b_0
libffi                    3.2.1                hd88cf55_4
libgcc                    7.2.0                h69d50b8_2
libgcc-ng                 9.1.0                hdf63c60_0
libgfortran-ng            7.3.0                hdf63c60_0
libnetcdf                 4.7.3                hb80b6cc_0
libpng                    1.6.37               hbc83047_0
libsodium                 1.0.17               h516909a_0    conda-forge
libssh2                   1.8.2                h22169c7_2    conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0
libtiff                   4.1.0                h2733197_0
libuuid                   1.0.3                h1bed415_2
libxcb                    1.13                 h1bed415_1
libxml2                   2.9.9                hea5a465_1
markupsafe                1.1.1            py37h8f50634_1    conda-forge
matplotlib                3.1.3                    py37_0
matplotlib-base           3.1.3            py37hef1b27d_0
mdanalysis                0.20.1           py37he1b5a44_0    conda-forge
mistune                   0.8.4           py37h516909a_1000    conda-forge
mkl                       2020.0                      166
mkl-service               2.3.0            py37he904b0f_0
mkl_fft                   1.0.15           py37ha843d7b_0
mkl_random                1.1.0            py37hd6b4f25_0
mmtf-python               1.1.2                      py_0    conda-forge
msgpack-python            1.0.0            py37h99015e2_1    conda-forge
nbconvert                 5.6.1                    py37_0    conda-forge
nbformat                  5.0.4                      py_0    conda-forge
ncurses                   6.2                  he6710b0_0
netcdf4                   1.5.3            py37hbf33ddf_0
networkx                  2.4                        py_0
nglview                   2.7.5              pyh5ca1d4c_0    conda-forge
notebook                  6.0.3                    py37_0    conda-forge
numpy                     1.18.1           py37h4f9e942_0
numpy-base                1.18.1           py37hde5b4d6_1
olefile                   0.46                     py37_0
openforcefield            0.6.0+163.g20712c1          pypi_0    pypi
openmm                    7.4.1           py37_cuda101_rc_1    omnia
openssl                   1.1.1f               h516909a_0    conda-forge
packaging                 20.3                       py_0
pandas                    1.0.3            py37h0573a6f_0
pandoc                    2.9.2                         0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parmed                    3.2.0+27.gaa15556a          pypi_0    pypi
parso                     0.6.2                      py_0    conda-forge
patsy                     0.5.1                      py_0    conda-forge
pcre                      8.43                 he6710b0_0
pexpect                   4.8.0            py37hc8dfbb8_1    conda-forge
pickleshare               0.7.5           py37hc8dfbb8_1001    conda-forge
pillow                    7.0.0            py37hb39fc2d_0
pip                       20.0.2                   py37_1
pixman                    0.38.0               h7b6447c_0
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.5                      py_0    conda-forge
prompt_toolkit            3.0.5                         0    conda-forge
ptyprocess                0.6.0                   py_1001    conda-forge
py-boost                  1.67.0           py37h04863e7_4
py3dmol                   0.8.0                      py_0    conda-forge
pygments                  2.6.1                      py_0    conda-forge
pyparsing                 2.4.6                      py_0
pyqt                      5.9.2            py37hcca6a23_4    conda-forge
pyrsistent                0.16.0           py37h8f50634_0    conda-forge
python                    3.7.7           hcf32534_0_cpython
python-dateutil           2.8.1                      py_0
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2019.3                     py_0
pyzmq                     19.0.0           py37hac76be4_1    conda-forge
qt                        5.9.7                h5867ecd_1
qtconsole                 4.7.2              pyh9f0ad1d_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
rdkit                     2019.09.3.0      py37hc20afe1_1    rdkit
readline                  8.0                  h7b6447c_0
scikit-learn              0.22.1           py37hd81dba3_0
scipy                     1.4.1            py37h0b6359f_0
seaborn                   0.10.0                     py_1    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                46.1.1                   py37_0
sip                       4.19.8           py37hf484d3e_0
six                       1.14.0                   py37_0
sqlite                    3.31.1               h7b6447c_0
statsmodels               0.11.1           py37h8f50634_1    conda-forge
terminado                 0.8.3            py37hc8dfbb8_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.8                hbc83047_0
tornado                   6.0.4            py37h8f50634_1    conda-forge
traitlets                 4.3.3            py37hc8dfbb8_1    conda-forge
wcwidth                   0.1.9              pyh9f0ad1d_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
werkzeug                  1.0.1              pyh9f0ad1d_0    conda-forge
wheel                     0.34.2                   py37_0
widgetsnbextension        3.5.1                    py37_0    conda-forge
xmltodict                 0.12.0                     py_0
xz                        5.2.4                h14c3975_4
zeromq                    4.3.2                he1b5a44_2    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11               h7b6447c_3
zstd                      1.3.7                h0b5b093_0
                                                                                                                                             
                                                                                                      

@mattwthompson
Copy link
Member

Hmm, you're using a different version of AmberTools but I switched to the one you installed and still can't trigger this error. Nothing in your environment looks horribly out of date. If you update with conda install -c conda-forge ambertools does the issue persist? A conda update --all may also be helpful

@matteo-ambrosetti
Copy link
Author

Ok, now I get a different error 👍 , this is in some way positive!

/home/matteo/anaconda3/envs/openmm/bin/to_be_dispatched/antechamber: Fatal Error!
Weird atomic valence (3) for atom (ID: 9, Name: C9).
       Possible open valence.
Traceback (most recent call last):
  File "error.py", line 25, in <module>
    system = forcefield.create_openmm_system(off_topology)
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/typing/engines/smirnoff/forcefield.py", line 1138, in create_openmm_system
    parameter_handler.create_force(system, topology, **kwargs)
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/typing/engines/smirnoff/parameters.py", line 2927, in create_force
    temp_mol.compute_partial_charges_am1bcc(toolkit_registry=toolkit_registry)
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/topology/molecule.py", line 2303, in compute_partial_charges_am1bcc
    self
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/utils/toolkits.py", line 3662, in call
    return method(*args, **kwargs)
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/site-packages/openforcefield-0.6.0+163.g20712c1-py3.7.egg/openforcefield/utils/toolkits.py", line 3191, in compute_partial_charges_am1bcc
    "charges.txt", "-pf", "yes"
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/home/matteo/anaconda3/envs/openmm/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['antechamber', '-i', 'charged.mol2', '-fi', 'mol2', '-o', 'charges2.mol2', '-fo', 'mol2', '-c', 'wc', '-cf', 'charges.txt', '-pf', 'yes']' returned non-zero exit status 1.

@j-wags
Copy link
Member

j-wags commented Apr 21, 2020

Hi @matteo-ambrosetti,

The new error looks like the same issue as #532, which is caused by the new version of AmberTools adding a more strict input checker that doesn't like oxygen anions.

This will be fixed in our 0.7.0 release in a few weeks. Until then, you can apply an ugly patch to fix this:

  • Get the location of toolkits.py:
python -c "from openforcefield.utils import toolkits; print(toolkits.__file__)"
  • On line 2747, change
                    "yes -c bcc -nc {}".format(net_charge))

to

                    "yes -dr n -c bcc -nc {}".format(net_charge))
  • On line 2754, change:
                    "-cf charges.txt -pf yes")

to

                    "-dr n -cf charges.txt -pf yes")

Apologies again for the ugly patch. We're going to get better about bugfix releases, we've just got a ton going on right now!

@matteo-ambrosetti
Copy link
Author

Ok, now everything works perfectly.
Thanks again @j-wags!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants