openforcefield/openff-toolkit

Add an API point to get a list of available charge methods

Yoshanuikabundi opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

Investigating the available charge methods often requires knowledge of how each toolkit wrapper is implemented, or inspecting the documentation.

Describe the solution you'd like

It would be neat to have an API point like Molecule.get_available_charge_methods(toolkit_registry=GLOBAL_TOOLKIT_REGISTRY) -> list[str] to get a list of possible values of the Molecule.assign_partial_charges(partial_charge_method) argument. This could return a list of all the charges that can be provided by the given toolkit registry, with toolkits that take higher precedence having their charge methods returned first.

(Good cop hat): Seems like a great feature, and provides an opportunity to slightly restructure how each wrapper keeps track of what charge method it supports. I'm sure I ran into it before, but I can't find record of myself asking for it

(Bad cop hat): It'd be great if the Molecule API just re-routed to each wrapper which itself reported what charge methods it knows about. Currently this is defined, but not AFAICT in a way that's cleanly accessible externally nor quite uniform. If these lists are duplicated or hard-coded in some way, they're guaranteed to go out of date if people like me are ever responsible for keeping them in sync.

0.16.0+

In [1]: from openff.toolkit import GLOBAL_TOOLKIT_REGISTRY, Molecule

In [2]: Molecule.from_smiles("O").get_available_charge_methods()
Out[2]:
['gasteiger',
 'formal_charge',
 'mmff94',
 'am1-mulliken',
 'am1bccnosymspt',
 'am1bccelf10',
 'zeros',
 'am1bcc',
 'am1elf10']

In [3]: [
   ...:     (wrapper, wrapper.supported_charge_methods)
   ...:     for wrapper in GLOBAL_TOOLKIT_REGISTRY.registered_toolkits
   ...: ]
Out[3]:
[(ToolkitWrapper around OpenEye Toolkit version 2023.2.3,
  ['am1bcc',
   'am1-mulliken',
   'gasteiger',
   'mmff94',
   'am1bccnosymspt',
   'am1elf10',
   'am1bccelf10']),
 (ToolkitWrapper around The RDKit version 2023.09.5, ['mmff94', 'gasteiger']),
 (ToolkitWrapper around AmberTools version 22.0,
  ['am1bcc', 'am1-mulliken', 'gasteiger']),
 (ToolkitWrapper around Built-in Toolkit version None,
  ['zeros', 'formal_charge'])]