openff-interchange icon indicating copy to clipboard operation
openff-interchange copied to clipboard

JSON roundtrip doesn't work with `from_openmm` generated system

Open IAlibay opened this issue 1 year ago • 3 comments

Description

Interchange.parse_raw() yields a KeyError: 'name' when passing a JSON generated from an Interchange object that was created from an OpenMM System & Topology (via Interchange.from_openmm).

Note: the openmm System & Topology were created using SystemGenerator.

Reproduction

from openmm import app, MonteCarloBarostat
from openmm import unit as omm_unit
from openmmforcefields.generators.system_generators import SystemGenerator
from openff.toolkit import Molecule
from openff.units import unit
from openff.units.openmm import to_openmm, from_openmm
from openff.interchange import Interchange
import os

os.environ['INTERCHANGE_EXPERIMENTAL'] = "1"

forcefield_kwargs = {
    'constraints': app.HBonds,
    'rigidWater': True,
    'removeCMMotion': True,
    'hydrogenMass': 4.0 * omm_unit.amu
}

periodic_kwargs = {
    'nonbondedMethod': app.PME,
    'nonbondedCutoff': to_openmm(9 * unit.angstrom)
}

non_periodic_kwargs = {
    'nonbondedMethod': app.NoCutoff,
}

system_generator = SystemGenerator(
    forcefields=['amber/ff14SB.xml', 'amber/tip3p_standard.xml'],
    small_molecule_forcefield='openff-2.1.0',
    forcefield_kwargs=forcefield_kwargs,
    nonperiodic_forcefield_kwargs=non_periodic_kwargs,
    periodic_forcefield_kwargs=periodic_kwargs,
    cache=None,
    barostat=None,
)

off = Molecule.from_smiles('C')
off.generate_conformers()
off.assign_partial_charges(partial_charge_method='am1bcc')

system_generator.create_system(off.to_topology().to_openmm(), molecules=[off])

model = app.Modeller(app.Topology(), [])
model.add(
    off.to_topology().to_openmm(), to_openmm(off.conformers[0])
)

model.addSolvent(
    system_generator.forcefield,
    model='tip3p',
    padding=to_openmm(12 * unit.angstrom),
    positiveIon='Na+', negativeIon='Cl-',
    ionicStrength=to_openmm(0.15 * unit.molar),
    neutralize=True,
)

system = system_generator.create_system(
    model.topology, molecules=[off],
)

inter = Interchange.from_openmm(system, model.topology, model.positions)

inter2 = Interchange.parse_raw(inter.json())

Output

Click me
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[1], line 65
     59 system = system_generator.create_system(
     60     model.topology, molecules=[off],
     61 )
     63 inter = Interchange.from_openmm(system, model.topology, model.positions)
---> 65 inter2 = Interchange.parse_raw(inter.json())

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/pydantic/v1/main.py:539, in BaseModel.parse_raw(cls, b, content_type, encoding, proto, allow_pickle)
    528 @classmethod
    529 def parse_raw(
    530     cls: Type['Model'],
   (...)
    536     allow_pickle: bool = False,
    537 ) -> 'Model':
    538     try:
--> 539         obj = load_str_bytes(
    540             b,
    541             proto=proto,
    542             content_type=content_type,
    543             encoding=encoding,
    544             allow_pickle=allow_pickle,
    545             json_loads=cls.__config__.json_loads,
    546         )
    547     except (ValueError, TypeError, UnicodeDecodeError) as e:
    548         raise ValidationError([ErrorWrapper(e, loc=ROOT_KEY)], cls)

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/pydantic/v1/parse.py:37, in load_str_bytes(b, content_type, encoding, proto, allow_pickle, json_loads)
     35     if isinstance(b, bytes):
     36         b = b.decode(encoding)
---> 37     return json_loads(b)
     38 elif proto == Protocol.pickle:
     39     if not allow_pickle:

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/interchange/components/interchange.py:97, in interchange_loader(data)
     95     tmp["box"] = Quantity(val["val"], unit.Unit(val["unit"]))
     96 elif key == "topology":
---> 97     tmp["topology"] = Topology.from_json(val)
     98 elif key == "collections":
     99     from openff.interchange.smirnoff import (
    100         SMIRNOFFAngleCollection,
    101         SMIRNOFFBondCollection,
   (...)
    107         SMIRNOFFVirtualSiteCollection,
    108     )

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/toolkit/utils/serialization.py:153, in Serializable.from_json(cls, serialized)
    150 import json
    152 d = json.loads(serialized)
--> 153 return cls.from_dict(d)

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/toolkit/topology/topology.py:1261, in Topology.from_dict(cls, topology_dict)
   1246 """
   1247 Create a new Topology from a dictionary representation
   1248
   (...)
   1258
   1259 """
   1260 topology = cls()
-> 1261 topology._initialize_from_dict(topology_dict)
   1262 return topology

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/toolkit/topology/topology.py:1285, in Topology._initialize_from_dict(self, topology_dict)
   1282     self.box_vectors = Quantity(box_vectors_unitless, box_vectors_unit)
   1284 for molecule_dict in topology_dict["molecules"]:
-> 1285     new_mol = Molecule.from_dict(molecule_dict)
   1286     self._add_molecule_keep_cache(new_mol)
   1287 self._invalidate_cached_properties()

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py:1234, in FrozenMolecule.from_dict(cls, molecule_dict)
   1232 # This implementation is a compromise to let this remain as a classmethod
   1233 mol = cls()
-> 1234 mol._initialize_from_dict(molecule_dict)
   1235 return mol

File ~/software/mambaforge/install/envs/ofe_demo/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py:1249, in FrozenMolecule._initialize_from_dict(self, molecule_dict)
   1246 # TODO: Provide useful exception messages if there are any failures
   1248 self._initialize()
-> 1249 self.name = molecule_dict["name"]
   1250 for atom_dict in molecule_dict["atoms"]:
   1251     self._add_atom(**atom_dict, invalidate_cache=False)

KeyError: 'name'

Software versions

  • Which operating system and version are you using? Ubuntu 20.04 LTS
  • How did you install Interchange? conda-forge
  • What is the output of running conda list?
Click me
```
# packages in environment at /home/bioc1523/software/mambaforge/install/envs/ofe_demo:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
adjusttext                1.1.1              pyhd8ed1ab_0    conda-forge
alsa-lib                  1.2.12               h4ab18f5_0    conda-forge
ambertools                23.6            nompi_py311he003265_102    conda-forge
amberutils                21.0                     pypi_0    pypi
annotated-types           0.6.0              pyhd8ed1ab_0    conda-forge
anyio                     4.3.0              pyhd8ed1ab_0    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
argon2-cffi               23.1.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py311h459d7ec_4    conda-forge
arpack                    3.8.0           nompi_h0baa96a_101    conda-forge
arrow                     1.3.0              pyhd8ed1ab_0    conda-forge
asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
astunparse                1.6.3              pyhd8ed1ab_0    conda-forge
atk-1.0                   2.38.0               h04ea711_2    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
attrs                     23.2.0             pyh71513ae_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.tarfile         1.0.0              pyhd8ed1ab_1    conda-forge
beautifulsoup4            4.12.3             pyha770c72_0    conda-forge
biopython                 1.83            py311h459d7ec_0    conda-forge
bleach                    6.1.0              pyhd8ed1ab_0    conda-forge
blosc                     1.21.5               hc2324a3_1    conda-forge
brotli                    1.1.0                hd590300_1    conda-forge
brotli-bin                1.1.0                hd590300_1    conda-forge
brotli-python             1.1.0           py311hb755f60_1    conda-forge
bson                      0.5.9                      py_0    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
c-ares                    1.28.1               hd590300_0    conda-forge
c-blosc2                  2.14.4               hb4ffafa_1    conda-forge
ca-certificates           2024.7.4             hbcca054_0    conda-forge
cachecontrol              0.14.0             pyhd8ed1ab_0    conda-forge
cachecontrol-with-filecache 0.14.0             pyhd8ed1ab_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cachetools                5.3.3              pyhd8ed1ab_0    conda-forge
cachy                     0.3.0              pyhd8ed1ab_1    conda-forge
cairo                     1.18.0               h3faef2a_0    conda-forge
certifi                   2024.7.4           pyhd8ed1ab_0    conda-forge
cffi                      1.16.0          py311hb3a22ac_0    conda-forge
cftime                    1.6.3           py311h1f0f07a_0    conda-forge
chardet                   5.2.0           py311h38be061_1    conda-forge
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
cinnabar                  0.4.1              pyhd8ed1ab_0    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
click-default-group       1.2.4              pyhd8ed1ab_0    conda-forge
clikit                    0.6.2              pyhd8ed1ab_2    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_0    conda-forge
conda-lock                2.5.7              pyhd8ed1ab_0    conda-forge
contourpy                 1.2.1           py311h9547e67_0    conda-forge
coverage                  7.5.1           py311h331c9d8_0    conda-forge
crashtest                 0.4.1              pyhd8ed1ab_0    conda-forge
cryptography              42.0.8          py311h4a61cc7_0    conda-forge
cudatoolkit               11.8.0              h4ba93d1_13    conda-forge
cycler                    0.12.1             pyhd8ed1ab_0    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
debugpy                   1.8.1           py311hb755f60_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dill                      0.3.8              pyhd8ed1ab_0    conda-forge
distlib                   0.3.8              pyhd8ed1ab_0    conda-forge
edgembar                  0.2                      pypi_0    pypi
ensureconda               1.4.4              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
exceptiongroup            1.2.0              pyhd8ed1ab_2    conda-forge
executing                 2.0.1              pyhd8ed1ab_0    conda-forge
expat                     2.6.2                h59595ed_0    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
fftw                      3.3.10          nompi_hc118613_108    conda-forge
filelock                  3.14.0             pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_2    conda-forge
fontconfig                2.14.2               h14ed4e7_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.51.0          py311h459d7ec_0    conda-forge
fqdn                      1.5.1              pyhd8ed1ab_0    conda-forge
freetype                  2.12.1               h267a509_2    conda-forge
freetype-py               2.3.0              pyhd8ed1ab_0    conda-forge
fribidi                   1.0.10               h36c2ea0_0    conda-forge
gdk-pixbuf                2.42.11              hb9ae30d_0    conda-forge
gettext                   0.22.5               h59595ed_2    conda-forge
gettext-tools             0.22.5               h59595ed_2    conda-forge
giflib                    5.2.2                hd590300_0    conda-forge
gitdb                     4.0.11             pyhd8ed1ab_0    conda-forge
gitpython                 3.1.43             pyhd8ed1ab_0    conda-forge
glew                      2.1.0                h9c3ff4c_2    conda-forge
glib                      2.80.2               hf974151_0    conda-forge
glib-tools                2.80.2               hb6ce0ca_0    conda-forge
glm                       0.9.9.8              h00ab1b0_0    conda-forge
graphite2                 1.3.13            h59595ed_1003    conda-forge
graphviz                  9.0.0                h78e8752_1    conda-forge
greenlet                  3.0.3           py311hb755f60_0    conda-forge
griddataformats           1.0.2              pyhd8ed1ab_0    conda-forge
gsd                       3.2.1           py311h1f0f07a_0    conda-forge
gst-plugins-base          1.24.4               h9ad1361_0    conda-forge
gstreamer                 1.24.4               haf2f30d_0    conda-forge
gtk2                      2.24.33              h280cfa0_4    conda-forge
gts                       0.7.6                h977cf35_4    conda-forge
gufe                      1.0.0              pyhd8ed1ab_0    conda-forge
h5py                      3.11.0          nompi_py311hebc2b07_100    conda-forge
harfbuzz                  8.4.0                h3d44ed6_0    conda-forge
hdf4                      4.2.15               h2a13503_7    conda-forge
hdf5                      1.14.3          nompi_h4f84152_101    conda-forge
html5lib                  1.1                pyh9f0ad1d_0    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
idna                      3.7                pyhd8ed1ab_0    conda-forge
importlib-metadata        7.1.0              pyha770c72_0    conda-forge
importlib_metadata        7.1.0                hd8ed1ab_0    conda-forge
importlib_resources       6.4.0              pyhd8ed1ab_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
ipykernel                 6.29.3             pyhd33586a_0    conda-forge
ipython                   8.24.0             pyh707e725_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.0              pyhd3deb0d_0    conda-forge
isoduration               20.11.0            pyhd8ed1ab_0    conda-forge
jaraco.classes            3.4.0              pyhd8ed1ab_1    conda-forge
jaraco.context            5.3.0              pyhd8ed1ab_1    conda-forge
jaraco.functools          4.0.0              pyhd8ed1ab_0    conda-forge
jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
jeepney                   0.8.0              pyhd8ed1ab_0    conda-forge
jinja2                    3.1.4              pyhd8ed1ab_0    conda-forge
joblib                    1.4.2              pyhd8ed1ab_0    conda-forge
jsonpointer               2.4             py311h38be061_3    conda-forge
jsonschema                4.22.0             pyhd8ed1ab_0    conda-forge
jsonschema-specifications 2023.12.1          pyhd8ed1ab_0    conda-forge
jsonschema-with-format-nongpl 4.22.0             pyhd8ed1ab_0    conda-forge
jupyter_client            7.4.9              pyhd8ed1ab_0    conda-forge
jupyter_contrib_core      0.4.0              pyhd8ed1ab_0    conda-forge
jupyter_contrib_nbextensions 0.7.0              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2           py311h38be061_0    conda-forge
jupyter_events            0.10.0             pyhd8ed1ab_0    conda-forge
jupyter_highlight_selected_word 0.2.0           pyhd8ed1ab_1006    conda-forge
jupyter_latex_envs        1.4.6           pyhd8ed1ab_1002    conda-forge
jupyter_nbextensions_configurator 0.6.1              pyhd8ed1ab_0    conda-forge
jupyter_server            2.14.0             pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.5.3              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.3.0              pyhd8ed1ab_1    conda-forge
jupyterlab_widgets        3.0.10             pyhd8ed1ab_0    conda-forge
kartograf                 1.0.1              pyhd8ed1ab_0    conda-forge
keyring                   25.2.1             pyha804496_0    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.4.5           py311h9547e67_1    conda-forge
krb5                      1.21.2               h659d440_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
lcms2                     2.16                 hb7c19ff_0    conda-forge
ld_impl_linux-64          2.40                 h55db66e_0    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libaec                    1.1.3                h59595ed_0    conda-forge
libasprintf               0.22.5               h661eb56_2    conda-forge
libasprintf-devel         0.22.5               h661eb56_2    conda-forge
libblas                   3.9.0           22_linux64_openblas    conda-forge
libboost                  1.84.0               h8013b2b_2    conda-forge
libboost-python           1.84.0          py311h92ebd52_2    conda-forge
libbrotlicommon           1.1.0                hd590300_1    conda-forge
libbrotlidec              1.1.0                hd590300_1    conda-forge
libbrotlienc              1.1.0                hd590300_1    conda-forge
libcap                    2.69                 h0f662aa_0    conda-forge
libcblas                  3.9.0           22_linux64_openblas    conda-forge
libclang-cpp15            15.0.7          default_h127d8a8_5    conda-forge
libclang13                18.1.7          default_h087397f_0    conda-forge
libcups                   2.3.3                h4637d8d_4    conda-forge
libcurl                   8.7.1                hca28451_0    conda-forge
libdeflate                1.20                 hd590300_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 hd590300_2    conda-forge
libevent                  2.1.12               hf998b51_1    conda-forge
libexpat                  2.6.2                h59595ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.3                h59595ed_0    conda-forge
libgcc-ng                 13.2.0               h77fa898_7    conda-forge
libgcrypt                 1.10.3               hd590300_0    conda-forge
libgd                     2.3.3                h119a65a_9    conda-forge
libgettextpo              0.22.5               h59595ed_2    conda-forge
libgettextpo-devel        0.22.5               h59595ed_2    conda-forge
libgfortran-ng            13.2.0               h69a702a_7    conda-forge
libgfortran5              13.2.0               hca663fb_7    conda-forge
libglib                   2.80.2               hf974151_0    conda-forge
libglu                    9.0.0             hac7e632_1003    conda-forge
libgomp                   13.2.0               h77fa898_7    conda-forge
libgpg-error              1.49                 h4f305b6_0    conda-forge
libiconv                  1.17                 hd590300_2    conda-forge
libjpeg-turbo             3.0.0                hd590300_1    conda-forge
liblapack                 3.9.0           22_linux64_openblas    conda-forge
libllvm14                 14.0.6               hcd5def8_4    conda-forge
libllvm15                 15.0.7               hb3ce162_4    conda-forge
libllvm18                 18.1.7               hb77312f_0    conda-forge
libnetcdf                 4.9.2           nompi_h9612171_113    conda-forge
libnghttp2                1.58.0               h47da74e_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.27          pthreads_h413a1c8_0    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.43               h2797004_0    conda-forge
libpq                     16.3                 ha72fbe1_0    conda-forge
librsvg                   2.58.0               hadf69e7_1    conda-forge
libsndfile                1.2.2                hc60ed4a_1    conda-forge
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libsqlite                 3.45.3               h2797004_0    conda-forge
libssh2                   1.11.0               h0841786_0    conda-forge
libstdcxx-ng              13.2.0               hc0a3c3a_7    conda-forge
libsystemd0               255                  h3516f8a_1    conda-forge
libtiff                   4.6.0                h1dd3fc0_3    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp                   1.4.0                h2c329e2_0    conda-forge
libwebp-base              1.4.0                hd590300_0    conda-forge
libxcb                    1.15                 h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxkbcommon              1.7.0                h662e7e4_0    conda-forge
libxml2                   2.12.7               hc051c1a_0    conda-forge
libxslt                   1.1.39               h76b75d6_0    conda-forge
libzip                    1.10.1               h2629f0a_3    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
llvmlite                  0.42.0          py311ha6695c7_1    conda-forge
lomap2                    3.0.3              pyhd8ed1ab_0    conda-forge
lxml                      5.2.2           py311hc0a218f_0    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
lzo                       2.10              hd590300_1001    conda-forge
markupsafe                2.1.5           py311h459d7ec_0    conda-forge
matplotlib-base           3.8.4           py311h54ef318_0    conda-forge
matplotlib-inline         0.1.7              pyhd8ed1ab_0    conda-forge
mda-xdrlib                0.2.0              pyhd8ed1ab_0    conda-forge
mdanalysis                2.7.0           py311h320fe9a_1    conda-forge
mdtraj                    1.9.9           py311h90fe790_1    conda-forge
mistune                   3.0.2              pyhd8ed1ab_0    conda-forge
mmpbsa-py                 16.0                     pypi_0    pypi
mmtf-python               1.1.3              pyhd8ed1ab_0    conda-forge
more-itertools            10.3.0             pyhd8ed1ab_0    conda-forge
mpg123                    1.32.6               h59595ed_0    conda-forge
mpiplus                   v0.0.2             pyhd8ed1ab_0    conda-forge
mrcfile                   1.5.0              pyhd8ed1ab_0    conda-forge
msgpack-python            1.0.7           py311h9547e67_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mysql-common              8.3.0                hf1915f5_4    conda-forge
mysql-libs                8.3.0                hca2cd23_4    conda-forge
nbclassic                 1.0.0              pyhb4ecaf3_1    conda-forge
nbclient                  0.10.0             pyhd8ed1ab_0    conda-forge
nbconvert                 7.16.4               hd8ed1ab_0    conda-forge
nbconvert-core            7.16.4             pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          7.16.4               hd8ed1ab_0    conda-forge
nbformat                  5.10.4             pyhd8ed1ab_0    conda-forge
ncurses                   6.5                  h59595ed_0    conda-forge
nest-asyncio              1.6.0              pyhd8ed1ab_0    conda-forge
netcdf-fortran            4.6.1           nompi_hacb5139_103    conda-forge
netcdf4                   1.6.5           nompi_py311he8ad708_100    conda-forge
networkx                  3.3                pyhd8ed1ab_1    conda-forge
nglview                   3.0.3              pyh8a188c0_0    conda-forge
nomkl                     1.0                  h5ca1d4c_0    conda-forge
nose                      1.3.7                   py_1006    conda-forge
notebook                  6.5.6              pyha770c72_0    conda-forge
notebook-shim             0.2.4              pyhd8ed1ab_0    conda-forge
nspr                      4.35                 h27087fc_0    conda-forge
nss                       3.100                hca3bf56_0    conda-forge
numba                     0.59.1          py311h96b013e_0    conda-forge
numexpr                   2.9.0           py311h039bad6_100    conda-forge
numpy                     1.26.4          py311h64a7726_0    conda-forge
ocl-icd                   2.3.2                hd590300_1    conda-forge
ocl-icd-system            1.0.0                         1    conda-forge
openfe                    1.0.0              pyhd8ed1ab_1    conda-forge
openfe-analysis           0.2.0              pyhd8ed1ab_0    conda-forge
openff-amber-ff-ports     0.0.4              pyhca7485f_0    conda-forge
openff-forcefields        2024.04.0          pyhca7485f_0    conda-forge
openff-interchange        0.3.27             pyhd8ed1ab_0    conda-forge
openff-interchange-base   0.3.27             pyhd8ed1ab_0    conda-forge
openff-models             0.1.2              pyhca7485f_0    conda-forge
openff-toolkit            0.15.2             pyhd8ed1ab_0    conda-forge
openff-toolkit-base       0.15.2             pyhd8ed1ab_0    conda-forge
openff-units              0.2.2              pyhca7485f_0    conda-forge
openff-utilities          0.1.12             pyhd8ed1ab_0    conda-forge
openjpeg                  2.5.2                h488ebb8_0    conda-forge
openmm                    8.1.1           py311h6d2dbb8_1    conda-forge
openmmforcefields         0.13.0             pyhd8ed1ab_0    conda-forge
openmmtools               0.23.1             pyhd8ed1ab_0    conda-forge
openssl                   3.3.1                h4ab18f5_1    conda-forge
overrides                 7.7.0              pyhd8ed1ab_0    conda-forge
packaging                 24.0               pyhd8ed1ab_0    conda-forge
packmol-memgen            2024.2.9                 pypi_0    pypi
pandas                    2.2.2           py311h320fe9a_0    conda-forge
pandoc                    3.2                  ha770c72_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
panedr                    0.8.0              pyhd8ed1ab_0    conda-forge
pango                     1.52.2               ha41ecd1_0    conda-forge
parmed                    4.2.2           py311hb755f60_1    conda-forge
parso                     0.8.4              pyhd8ed1ab_0    conda-forge
pastel                    0.2.1              pyhd8ed1ab_0    conda-forge
patsy                     0.5.6              pyhd8ed1ab_0    conda-forge
pcre2                     10.43                hcad00b1_0    conda-forge
pdb4amber                 22.0                     pypi_0    pypi
pdbfixer                  1.9                pyh1a96a4e_0    conda-forge
perl                      5.32.1          7_hd590300_perl5    conda-forge
pexpect                   4.9.0              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    10.3.0          py311h18e6fac_0    conda-forge
pint                      0.23               pyhd8ed1ab_0    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pixman                    0.43.2               h59595ed_0    conda-forge
pkginfo                   1.11.1             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_1    conda-forge
platformdirs              4.2.1              pyhd8ed1ab_0    conda-forge
plotly                    5.22.0             pyhd8ed1ab_0    conda-forge
plugcli                   0.2.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.5.0              pyhd8ed1ab_0    conda-forge
ply                       3.11               pyhd8ed1ab_2    conda-forge
pmw                       2.0.1           py311h38be061_1008    conda-forge
pooch                     1.8.1              pyhd8ed1ab_0    conda-forge
prometheus_client         0.20.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.42             pyha770c72_0    conda-forge
psutil                    5.9.8           py311h459d7ec_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pulseaudio-client         17.0                 hb77b528_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
py-cpuinfo                9.0.0              pyhd8ed1ab_0    conda-forge
py3dmol                   2.1.0              pyhd8ed1ab_0    conda-forge
pycairo                   1.26.0          py311h8feb60e_0    conda-forge
pycparser                 2.22               pyhd8ed1ab_0    conda-forge
pydantic                  2.7.1              pyhd8ed1ab_0    conda-forge
pydantic-core             2.18.2          py311h5ecf98a_0    conda-forge
pyedr                     0.8.0              pyhd8ed1ab_0    conda-forge
pygments                  2.18.0             pyhd8ed1ab_0    conda-forge
pygraphviz                1.12            py311hbf5cbc9_0    conda-forge
pylev                     1.4.0              pyhd8ed1ab_0    conda-forge
pymbar                    3.1.1           py311h7c22f60_3    conda-forge
pymol-open-source         3.0.0           py311hbd307dc_8    conda-forge
pymsmt                    22.0                     pypi_0    pypi
pyparsing                 3.1.2              pyhd8ed1ab_0    conda-forge
pyqt                      5.15.9          py311hf0fb5b6_5    conda-forge
pyqt5-sip                 12.12.2         py311hb755f60_5    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
pytables                  3.9.2           py311h3e8b7c9_2    conda-forge
pytest                    8.2.0              pyhd8ed1ab_0    conda-forge
python                    3.11.9          hb806964_0_cpython    conda-forge
python-constraint         1.4.0                      py_0    conda-forge
python-dateutil           2.9.0              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.19.1             pyhd8ed1ab_0    conda-forge
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python-tzdata             2024.1             pyhd8ed1ab_0    conda-forge
python_abi                3.11                    4_cp311    conda-forge
pytng                     0.3.1           py311hb2be122_1    conda-forge
pytraj                    2.0.6                    pypi_0    pypi
pytz                      2024.1             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0.1           py311h459d7ec_1    conda-forge
pyzmq                     24.0.1          py311ha4b6469_1    conda-forge
qt-main                   5.15.8              hc9dc06e_21    conda-forge
rdkit                     2024.03.2       py311h1d78c4b_0    conda-forge
readline                  8.2                  h8228510_1    conda-forge
referencing               0.35.1             pyhd8ed1ab_0    conda-forge
reportlab                 4.1.0           py311h459d7ec_0    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
rfc3339-validator         0.1.4              pyhd8ed1ab_0    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
rise                      5.7.1           py311h38be061_2    conda-forge
rlpycairo                 0.2.0              pyhd8ed1ab_0    conda-forge
rpds-py                   0.18.1          py311h5ecf98a_0    conda-forge
ruamel.yaml               0.18.6          py311h459d7ec_0    conda-forge
ruamel.yaml.clib          0.2.8           py311h459d7ec_0    conda-forge
sander                    22.0                     pypi_0    pypi
scikit-learn              1.4.2           py311hc009520_0    conda-forge
scipy                     1.13.0          py311h517d4fd_1    conda-forge
seaborn                   0.13.2               hd8ed1ab_2    conda-forge
seaborn-base              0.13.2             pyhd8ed1ab_2    conda-forge
secretstorage             3.3.3           py311h38be061_2    conda-forge
send2trash                1.8.3              pyh0d859eb_0    conda-forge
setuptools                69.5.1             pyhd8ed1ab_0    conda-forge
sip                       6.7.12          py311hb755f60_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
smirnoff99frosst          1.1.0              pyh44b312d_0    conda-forge
smmap                     5.0.0              pyhd8ed1ab_0    conda-forge
snappy                    1.2.0                hdb0a2a9_1    conda-forge
sniffio                   1.3.1              pyhd8ed1ab_0    conda-forge
soupsieve                 2.5                pyhd8ed1ab_1    conda-forge
sqlalchemy                2.0.30          py311h331c9d8_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
statsmodels               0.14.1          py311h1f0f07a_0    conda-forge
tenacity                  8.3.0              pyhd8ed1ab_0    conda-forge
terminado                 0.18.1             pyh0d859eb_0    conda-forge
threadpoolctl             3.5.0              pyhc1e730c_0    conda-forge
tidynamics                1.1.2              pyhd8ed1ab_0    conda-forge
tinycss2                  1.3.0              pyhd8ed1ab_0    conda-forge
tinydb                    4.8.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tomlkit                   0.12.5             pyha770c72_0    conda-forge
toolz                     0.12.1             pyhd8ed1ab_0    conda-forge
tornado                   6.4             py311h459d7ec_0    conda-forge
tqdm                      4.66.4             pyhd8ed1ab_0    conda-forge
traitlets                 5.14.3             pyhd8ed1ab_0    conda-forge
types-python-dateutil     2.9.0.20240316     pyhd8ed1ab_0    conda-forge
typing-extensions         4.11.0               hd8ed1ab_0    conda-forge
typing_extensions         4.11.0             pyha770c72_0    conda-forge
typing_utils              0.1.0              pyhd8ed1ab_0    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
uri-template              1.3.0              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.18            pyhd8ed1ab_0    conda-forge
validators                0.28.1             pyhd8ed1ab_0    conda-forge
virtualenv                20.26.2            pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
webcolors                 1.13               pyhd8ed1ab_0    conda-forge
webencodings              0.5.1              pyhd8ed1ab_2    conda-forge
websocket-client          1.8.0              pyhd8ed1ab_0    conda-forge
wheel                     0.43.0             pyhd8ed1ab_1    conda-forge
widgetsnbextension        3.5.1              pyh9f0ad1d_3    conda-forge
xcb-util                  0.4.0                hd590300_1    conda-forge
xcb-util-image            0.4.0                h8ee46fc_1    conda-forge
xcb-util-keysyms          0.4.0                h8ee46fc_1    conda-forge
xcb-util-renderutil       0.3.9                hd590300_1    conda-forge
xcb-util-wm               0.4.1                h8ee46fc_1    conda-forge
xkeyboard-config          2.42                 h4ab18f5_0    conda-forge
xmltodict                 0.13.0             pyhd8ed1ab_0    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.1.1                hd590300_0    conda-forge
xorg-libsm                1.2.4                h7391055_0    conda-forge
xorg-libx11               1.8.9                h8ee46fc_0    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxrender           0.9.11               hd590300_0    conda-forge
xorg-libxt                1.3.0                hd590300_1    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xf86vidmodeproto     2.3.1             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
zeromq                    4.3.5                h75354e8_4    conda-forge
zipp                      3.17.0             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               hd590300_5    conda-forge
zlib-ng                   2.0.7                h0b41bf4_0    conda-forge
zstd                      1.5.6                ha6fb4c9_0    conda-forge
```

IAlibay avatar Jul 12 '24 00:07 IAlibay

Note: it's not isolated to SystemGenerator

from openff.interchange import Interchange
from openff.toolkit import Molecule, ForceField
from openff.units import unit
import numpy as np
import os
os.environ['INTERCHANGE_EXPERIMENTAL'] = "1"

mol = Molecule.from_smiles("CC")
mol.generate_conformers()
sage = ForceField("openff-2.0.0.offxml")
cubic_box = unit.Quantity(30 * np.eye(3), unit.angstrom)

interchange = Interchange.from_smirnoff(topology=[mol], force_field=sage, box=cubic_box)
interchange.positions = mol.conformers[0]

interchange2 = Interchange.from_openmm(interchange.to_openmm(), interchange.to_openmm_topology())
Interchange.parse_raw(interchange2.json())

IAlibay avatar Jul 12 '24 14:07 IAlibay

This looks similar to https://github.com/openforcefield/openff-toolkit/issues/1783 ... which in that thread I insist was fixed in the version you're using ... hmm

The issue here is with the toolkit / how information is passed between Interchange and the toolkit since Topology didn't always play nicely with _SimpleMolecules that are necessary to use when importing from OpenMM

mattwthompson avatar Jul 12 '24 15:07 mattwthompson

This is unlikely to land before 0.4.0 but I hope to take a closer look at this soon.

I assume the use case is simple on the surface (save state out to JSON, trust that it'll be loaded back and represent the same state) but I anticipate the work will mostly be in gathering up and testing various corner cases.

mattwthompson avatar Aug 27 '24 16:08 mattwthompson

Probably won't make it in 0.4.1 but hoping to take a stab at this before the timeframe of a 0.4.2 release

mattwthompson avatar Oct 29 '24 20:10 mattwthompson

This is due to a bug in the toolkit

mattwthompson avatar Nov 01 '24 14:11 mattwthompson

With toolkit 0.16.6, I can get this snippet running locally without error: https://github.com/openforcefield/openff-interchange/issues/1003#issuecomment-2225655695

The linked PR includes a minimal test, even though the fix is ultimately upstream

mattwthompson avatar Nov 12 '24 22:11 mattwthompson

This is done; the linked PR adds tests but the desired functionality is in place.

After running the original snippet:

In [2]: from openff.interchange.drivers.all import get_openmm_energies

In [3]: get_openmm_energies(inter), get_openmm_energies(inter2)
Out[3]:
(EnergyReport(energies={'Bond': <Quantity(0.0, 'kilojoule / mole')>, 'Angle': <Quantity(0.226034896, 'kilojoule / mole')>, 'Torsion': <Quantity(0.0, 'kilojoule / mole')>, 'Nonbonded': <Quantity(3125.7172, 'kilojoule / mole')>}),
 EnergyReport(energies={'Bond': <Quantity(0.0, 'kilojoule / mole')>, 'Angle': <Quantity(0.226034896, 'kilojoule / mole')>, 'Torsion': <Quantity(0.0, 'kilojoule / mole')>, 'Nonbonded': <Quantity(3125.7172, 'kilojoule / mole')>}))

This is with the following versions installed, relevant ones being the toolkit and Interchange:

$ micromamba list openff                                 9:55:27  ☁  fcf43997 ☂
List of packages in environment: "/Users/mattthompson/micromamba/envs/openff-interchange-env"

  Name                     Version    Build         Channel
─────────────────────────────────────────────────────────────────
  openff-amber-ff-ports    0.0.4      pyhca7485f_0  conda-forge
  openff-forcefields       2024.09.0  pyhff2d567_0  conda-forge
  openff-interchange       0.4.0      pyhd8ed1ab_0  conda-forge
  openff-interchange-base  0.4.0      pyhd8ed1ab_0  conda-forge
  openff-nagl              0.5.0      pyhd8ed1ab_0  conda-forge
  openff-nagl-base         0.5.0      pyhd8ed1ab_0  conda-forge
  openff-nagl-models       0.3.0      pyhd8ed1ab_1  conda-forge
  openff-recharge          0.5.2      pyhd8ed1ab_0  conda-forge
  openff-toolkit           0.16.6     pyhd8ed1ab_0  conda-forge
  openff-toolkit-base      0.16.6     pyhd8ed1ab_0  conda-forge
  openff-units             0.2.2      pyhca7485f_0  conda-forge
  openff-utilities         0.1.13     pyhd8ed1ab_0  conda-forge

mattwthompson avatar Dec 10 '24 15:12 mattwthompson