OEAssignCharges

bool OEAssignCharges(OEChem::OEMolBase &mol,
                     const OEChargeEngineBase &chargeEngine)
bool OEAssignCharges(OEChem::OEMCMolBase &mcMol,
                     const OEChargeEngineBase &chargeEngine)

Note

This function is designed to replace the legacy function OEAssignPartialCharges.

This function sets the charge of each atom in the molecule mol based on the specific nature of the chargeEngine object passed as the second argument. In general, charge engine implementations place scalar partial charges on atoms, but could be implemented to perform other roles such as assign multi-pole charges.

Listing 1: Assigning MMFF Partial Charges to a Molecule

if (OEAssignCharges(mol, OEMMFF94Charges()))
    //...

Another example:

Listing 2: Assigning Unoptimized AM1 Partial Charges

const bool optimizationSetting = false;
if (OEAssignCharges(mol, OEAM1Charges(optimizationSetting)))
    //...

The objects used by this function, derived from the abstract base class OEChargeEngineBase, can be thought of as “options objects” which describe the details of a specific charge model. OEAssignCharges analyzes these options and may need to add explicit hydrogens or perceive residues before assigning charges.

Listing 3: Assigning Non-symmetrized AM1BCC Partial Charges

OEAM1BCCCharges chargeEngine;
chargeEngine.SetSymmetrize(false);
if (OEAssignCharges(mol, chargeEngine))
    //...

Some prerequisites, such as setting the aromaticity model, would alter the input molecule in ways that are incidental to the calculation. In this case, a copy of the input molecule is made before the alterations are made and the charges are transferred back to the input molecule after the calculation. This ensures that only charges, explicit hydrogens, residue perception, residue names, and the number of conformations returned can change on the input molecule.

This function returns false if does not succeed.

See also