Skip to content

bulk_assign_partial_charges error when one of many molecules fail charge assignment #2021

Description

@jaclark5

Is your feature request related to a problem? Please describe.
bulk_assign_partial_charges errors and stops progress if one molecule fails partial charge assignment. Considering that difference partial charge types may or may not handled different chemistries, this makes using this function like a a game of "wack a mole".

Describe the solution you'd like
It would be great if the function skipped the molecules it can't handle, and given that you've also discussed wanting molecules returned in the same order (#1412) maybe skipped molecules will be "None" in the output?

Describe alternatives you've considered
I just don't use bulk_assign_partial_charges and run serially with:

    charged_ligands = []
    failed_molecules = []
    for mol in tqdm.tqdm(mols, desc="Generating charges", ncols=80):
        # water partial charges should come from a specific water model
        if mol.to_openff().to_inchikey(fixed_hydrogens=True) == "XLYOFNOQVPJJNP-UHFFFAOYNA-N": # water
            continue

        try:
            charged_molecule = assign_offmol_partial_charges(
                offmol=mol.to_openff(),
                overwrite=True,
                method=openff_charge_method,
                toolkit_backend=backend,
                generate_n_conformers=generate_n_conformers,
                nagl_model=nagl_model,
            )
        except Exception as e:
            print(f"Failed to generate charges for molecule {mol.name} with error: {e}")
            failed_molecules.append(mol)
            continue

I have considered parallelizing this but it seems like bulk_assign_partial_charges could handle this.

Additional context
This became in issue in handling the MNSol dataset in the openfe-benchmarks repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions