openforcefield / openff-interchange

A project (and object) for storing, manipulating, and converting molecular mechanics data.
https://docs.openforcefield.org/projects/interchange
MIT License
71 stars 22 forks source link

Log charge assignment #1053

Open mattwthompson opened 1 week ago

mattwthompson commented 1 week ago

Description

Resolves #1048

Checklist

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.51%. Comparing base (292faec) to head (a3679db).

Additional details and impacted files
mattwthompson commented 1 week ago

Here's what this looks like for a set of fairly simple cases:

import logging

from openff.toolkit import ForceField, Molecule, Topology

logging.basicConfig(level=logging.INFO)

ff = ForceField("openff-2.0.0.offxml")

water = Molecule.from_smiles("O")
ligand = Molecule.from_smiles("CC")
ligand.assign_partial_charges("am1bcc")

ff.create_interchange(Topology.from_molecules([water, water]))
ff.create_interchange(ligand.to_topology())
ff.create_interchange(ligand.to_topology(), charge_from_molecules=[ligand])

ForceField("opc.offxml").create_openmm_system(Molecule.from_smiles("O").to_topology())

$ python run.py
INFO:openff.toolkit.typing.engines.smirnoff.parameters:Attempting to up-convert vdW section from 0.3 to 0.4
INFO:openff.toolkit.typing.engines.smirnoff.parameters:Successfully up-converted vdW section from 0.3 to 0.4. `method="cutoff"` is now split into `periodic_method="cutoff"` and `nonperiodic_method="no-cutoff"`.
INFO:openff.toolkit.typing.engines.smirnoff.parameters:Attempting to up-convert Electrostatics section from 0.3 to 0.4
INFO:openff.toolkit.typing.engines.smirnoff.parameters:Successfully up-converted Electrostatics section from 0.3 to 0.4. `method="PME"` is now split into `periodic_potential="Ewald3D-ConductingBoundary"`, `nonperiodic_potential="Coulomb"`, and `exception_potential="Coulomb"`.
/Users/mattthompson/micromamba/envs/new-models/lib/python3.11/site-packages/mdtraj/formats/__init__.py:13: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13
  from mdtraj.formats.trr import TRRTrajectoryFile
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 0
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 3
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 1
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 4
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 2
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 5
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 0
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 1
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 2
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 3
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 4
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 5
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 6
INFO:openff.interchange.smirnoff._nonbonded:Charge section ToolkitAM1BCC, using charge method am1bccelf10, applied to (topology) atom index 7
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 0
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 1
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 2
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 3
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 4
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 5
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 6
INFO:openff.interchange.smirnoff._nonbonded:Preset charges applied to atom index 7
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 0
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 1
INFO:openff.interchange.smirnoff._nonbonded:Charge section LibraryCharges applied to (topology) atom index 2
INFO:openff.interchange.smirnoff._virtual_sites:Charge section VirtualSites applied to virtual site with orientation atoms (0, 1, 2)
IAlibay commented 1 week ago

Sorry only very briefly looking at this, so please ignore me if I'm missing something important.

Report all atom indices, not just unique molecules

This seems like it would be incredibly overwhelming to users, indeed a solvated protein-ligand complex could easily be incomprehensible.

Is there no way to:

  1. Condense this to each unique molecule
  2. Condense the per atom report of each molecule to just a summary (N atoms got this, N atoms got this, etc...)
  3. If necessary, offer a flag for folks to turn on to get a per-atom breakdown?