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

Passing a Molecule without charges to from_smirnoff's charge_from_molecules fails ungracefully #1057

Open
IAlibay opened this issue Sep 20, 2024 · 1 comment · May be fixed by #1070
Open
Labels

Comments

@IAlibay
Copy link

IAlibay commented Sep 20, 2024

Definitely not a big issue, mostly opening it because @mattwthompson told me to raise these issues 😅

Description

Passing an uncharged Molecule through charge_from_molecule leads to a TypeError when trying to iterate over None.
The traceback is clear, but the error message could be better for users.

Reproduction

from openff.toolkit import Molecule, Topology, ForceField
from openff.interchange.components._packmol import solvate_topology
from openff.interchange import Interchange
from openmm import NonbondedForce

water = Molecule.from_smiles('O')

ligand = Molecule.from_smiles('CCCCC')
ligand.generate_conformers()

off_top = Topology.from_molecules(ligand)
solvated_off_top = solvate_topology(topology=off_top)

ff = ForceField('openff-2.2.0.offxml', 'opc.offxml')
inter = Interchange.from_smirnoff(topology=solvated_off_top, force_field=ff, charge_from_molecules=[water])

Output

TypeError: 'NoneType' object is not iterable

Software versions

Interchange v0.3.29

@mattwthompson
Copy link
Member

I ran into this myself at some point recently; it's be nice to just error out early if any molecules in that list don't have partial charges for all atoms. There are some esoteric cases in which extra molecules could be passed in without charges if they're not going to match molecules, but I'd rather just enforce a simpler rule.

@mattwthompson mattwthompson linked a pull request Oct 3, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants