bool OEAssignCharges(OEChem::OEMolBase &mol, const OEChargeEngineBase &chargeEngine) bool OEAssignCharges(OEChem::OEMCMolBase &mcMol, const OEChargeEngineBase &chargeEngine)
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 (oequacpac.OEAssignCharges(mol, new OEMMFF94Charges())) //...
Listing 2: Assigning Unoptimized AM1 Partial Charges
boolean optimizationSetting = false; if (oequacpac.OEAssignCharges(mol, new OEAM1Charges(optimizationSetting))) //...
The objects used by this function, derived from the abstract base class OEChargeEngineBase, can be though 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 = new OEAM1BCCCharges(); chargeEngine.SetSymmetrize(false); if (oequacpac.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.