You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure exactly what I expected for a maximum molecule size, but I would guess the network can handle molecules much larger than 1000 molecules.
Actual behavior
As a non-expert of this codebase, it looks like this error stems from checking a lookup table which is keyed by InChI. The toolkit cannot create InChI of molecules more than 1034 atoms long. There might be other errors later in the process, I have yet to dig into this.
openff.nagl.__version__='0.5.0'openff.nagl_models.__version__='0.3.0'Warning: OECreateInChI: InChIonlysupportsmoleculeswithbetween1and1023atoms! (note: largemoleculesupportisexperimental)
---------------------------------------------------------------------------EmptyInChiErrorTraceback (mostrecentcalllast)
CellIn[1], line1712print(f"{openff.nagl_models.__version__=}")
15molecule=Molecule.from_smiles(341*"C")
--->17molecule.assign_partial_charges(
18partial_charge_method="openff-gnn-am1bcc-0.1.0-rc.3.pt",
19toolkit_registry=NAGLToolkitWrapper(),
20 )
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py:2687, inFrozenMolecule.assign_partial_charges(self, partial_charge_method, strict_n_conformers, use_conformers, toolkit_registry, normalize_partial_charges)
2685elifisinstance(toolkit_registry, ToolkitWrapper):
2686toolkit_wrapper: ToolkitWrapper=toolkit_registry->2687toolkit_wrapper.assign_partial_charges( # type: ignore[attr-defined]2688self,
2689partial_charge_method=partial_charge_method,
2690use_conformers=use_conformers,
2691strict_n_conformers=strict_n_conformers,
2692normalize_partial_charges=normalize_partial_charges,
2693_cls=self.__class__,
2694 )
2695else:
2696raiseInvalidToolkitRegistryError(
2697f"Invalid toolkit_registry passed to assign_partial_charges."2698f"Expected ToolkitRegistry or ToolkitWrapper. Got {type(toolkit_registry)}"2699 )
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/utils/nagl_wrapper.py:142, inNAGLToolkitWrapper.assign_partial_charges(self, molecule, partial_charge_method, use_conformers, strict_n_conformers, normalize_partial_charges, _cls)
136raiseChargeMethodUnavailableError(
137f"Charge model {partial_charge_method} not supported by "138f"{self.__class__.__name__}."139 ) fromerror141model=GNNModel.load(model_path, eval_mode=True)
-->142charges=model.compute_property(
143molecule,
144as_numpy=True,
145readout_name="am1bcc_charges",
146check_domains=True,
147error_if_unsupported=True,
148 )
150molecule.partial_charges=Quantity(
151charges.astype(float),
152unit.elementary_charge,
153 )
155ifnormalize_partial_charges:
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/nn/_models.py:402, inGNNModel.compute_property(self, molecule, readout_name, as_numpy, check_domains, error_if_unsupported, check_lookup_table)
362defcompute_property(
363self,
364molecule: "Molecule",
(...)
369check_lookup_table: bool=True370 ):
371""" 372 Compute the trained property for a molecule. 373 (...) 400 result: torch.Tensor or numpy.ndarray 401 """-->402properties=self.compute_properties(
403molecule=molecule,
404as_numpy=as_numpy,
405check_domains=check_domains,
406error_if_unsupported=error_if_unsupported,
407check_lookup_table=check_lookup_table408 )
409ifreadout_nameisNone:
410iflen(properties) ==1:
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/nn/_models.py:201, inGNNModel.compute_properties(self, molecule, as_numpy, check_domains, error_if_unsupported, check_lookup_table)
197fragments, all_indices=split_up_molecule(molecule)
198# TODO: this assumes atom-wise properties199# we should add support for bond-wise/more general properties-->201results= [
202self._compute_properties(
203fragment,
204as_numpy=as_numpy,
205check_domains=check_domains,
206error_if_unsupported=error_if_unsupported,
207check_lookup_table=check_lookup_table,
208 )
209forfragmentinfragments210 ]
212# combine the results213combined_results= {}
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/nn/_models.py:202, in<listcomp>(.0)
197fragments, all_indices=split_up_molecule(molecule)
198# TODO: this assumes atom-wise properties199# we should add support for bond-wise/more general properties201results= [
-->202self._compute_properties(
203fragment,
204as_numpy=as_numpy,
205check_domains=check_domains,
206error_if_unsupported=error_if_unsupported,
207check_lookup_table=check_lookup_table,
208 )
209forfragmentinfragments210 ]
212# combine the results213combined_results= {}
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/nn/_models.py:289, inGNNModel._compute_properties(self, molecule, as_numpy, check_domains, error_if_unsupported, check_lookup_table)
287forproperty_nameinexpected_value_keys:
288try:
-->289value=self._check_property_lookup_table(
290molecule=molecule,
291readout_name=property_name,
292 )
293exceptKeyErrorase:
294logger.info(
295f"Could not find property in lookup table: {e}"296 )
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/nn/_models.py:359, inGNNModel._check_property_lookup_table(self, molecule, readout_name)
336""" 337 Check if the molecule is in the property lookup table. 338 (...) 355 if the molecule is not in the property lookup table 356 """358table=self.lookup_tables[readout_name]
-->359returntable.lookup(molecule)
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/nagl/lookups.py:141, inAtomPropertiesLookupTable.lookup(self, molecule)
121""" 122 Look up the property value for a molecule 123 (...) 137 If the property value cannot be found for this molecule 138 """139fromopenff.toolkit.topologyimportMolecule-->141inchi_key=molecule.to_inchi(fixed_hydrogens=True)
142try:
143entry=self.properties[inchi_key]
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py:1760, inFrozenMolecule.to_inchi(self, fixed_hydrogens, toolkit_registry)
1732""" 1733 Create an InChI string for the molecule using the requested toolkit backend. 1734 InChI is a standardised representation that does not capture tautomers unless specified using the fixed (...) 1756 If an invalid object is passed as the toolkit_registry parameter 1757 """1759ifisinstance(toolkit_registry, ToolkitRegistry):
->1760inchi=toolkit_registry.call(
1761"to_inchi", self, fixed_hydrogens=fixed_hydrogens1762 )
1763elifisinstance(toolkit_registry, ToolkitWrapper):
1764toolkit=toolkit_registryFile~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/utils/toolkit_registry.py:266, inToolkitRegistry.call(self, method_name, raise_exception_types, *args, **kwargs)
264forexception_typeinraise_exception_types:
265ifisinstance(e, exception_type):
-->266raisee267errors.append((toolkit, e))
269# No toolkit was found to provide the requested capability270# TODO: Can we help developers by providing a check for typos in expected method names?File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/utils/toolkit_registry.py:262, inToolkitRegistry.call(self, method_name, raise_exception_types, *args, **kwargs)
260method=getattr(toolkit, method_name)
261try:
-->262returnmethod(*args, **kwargs)
263exceptExceptionase:
264forexception_typeinraise_exception_types:
File~/micromamba/envs/openff-interchange-env/lib/python3.11/site-packages/openff/toolkit/utils/openeye_wrapper.py:1942, inOpenEyeToolkitWrapper.to_inchi(self, molecule, fixed_hydrogens)
1939inchi=oechem.OEMolToSTDInChI(oemol)
1941iflen(inchi) ==0:
->1942raiseEmptyInChiError(
1943"OEChem failed to generate an InChI for the molecule."1944 )
1946returninchiEmptyInChiError: OEChemfailedtogenerateanInChIforthemolecule.
Current environment
Which version are you using? (run python -c "import openff.nagl; print(openff.nagl.__version__)") 0.5.0
Which version of Python (python -V)? 3.11
Which operating system? macOS 15.1.1
What is the output of pip list?
If you use conda, what is the output of conda list? See linked toolkit issue
The text was updated successfully, but these errors were encountered:
mattwthompson
changed the title
InChI reliance caps the size of molecules that can be charged
Cannot assign partial charges to molecules with 1024+ atoms
Dec 9, 2024
Huh, I didn't realize this would be an issue. Thank you -- will put in a workaround for now. However InChi might have just been the wrong choice of key if this can't generalize.
Expected behavior
I'm not sure exactly what I expected for a maximum molecule size, but I would guess the network can handle molecules much larger than 1000 molecules.
Actual behavior
As a non-expert of this codebase, it looks like this error stems from checking a lookup table which is keyed by InChI. The toolkit cannot create InChI of molecules more than 1034 atoms long. There might be other errors later in the process, I have yet to dig into this.
openforcefield/openff-toolkit#1977
Code to reproduce the behavior
Holy traceback, batman!
Current environment
python -c "import openff.nagl; print(openff.nagl.__version__)"
) 0.5.0python -V
)? 3.11pip list
?conda list
? See linked toolkit issueThe text was updated successfully, but these errors were encountered: