OBChargeModel Class Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
OBChargeModel Class Reference

`#include <openbabel/chargemodel.h>`

Inheritance diagram for OBChargeModel:
[legend]

List of all members.

## Public Types
typedef std::map< const char *, OBPlugin *, CharPtrLess > | PluginMapType
typedef PluginMapType::const_iterator | PluginIterator
## Public Member Functions
const char * | TypeID ()
virtual bool | ComputeCharges (OBMol &)
const std::vector< double > & | GetFormalCharges () const
const std::vector< double > & | GetPartialCharges () const
vector3 | GetDipoleMoment (OBMol &)
virtual const char * | Description ()
virtual bool | Display (std::string &txt, const char *param, const char *ID=NULL)
virtual OBPlugin * | MakeInstance (const std::vector< std::string > &)
virtual void | Init ()
const char * | GetID () const
virtual PluginMapType & | GetMap () const =0
## Static Public Member Functions
static OBPlugin * | GetPlugin (const char *Type, const char *ID)
static bool | ListAsVector (const char *PluginID, const char *param, std::vector< std::string > &vlist)
static void | List (const char *PluginID, const char *param=NULL, std::ostream *os=&std::cout)
static std::string | ListAsString (const char *PluginID, const char *param=NULL)
static std::string | FirstLine (const char *txt)
static PluginIterator | Begin (const char *PluginID)
static PluginIterator | End (const char *PluginID)
## Protected Member Functions
void | FillChargeVectors (OBMol &mol)
virtual double | DipoleScalingFactor ()
## Static Protected Member Functions
static PluginMapType & | PluginMap ()
static PluginMapType & | GetTypeMap (const char *PluginID)
static OBPlugin * | BaseFindType (PluginMapType &Map, const char *ID)
## Protected Attributes
std::vector< double > | m_partialCharges
std::vector< double > | m_formalCharges
const char * | _id

## Detailed Description

Atomic partial charge models.

Since:
  version 2.3

Classes derived from OBChargeModel implement different atomic partial charge models. It is intended to allow assinging partial charges beyond the traditional Gasteiger-Marsili sigma charges previously used in Open Babel. A --partialcharge method is provided for the babel command-line, allowing you to override the Gasteiger charge assignment and use other charge models.

The advantage of plugin classes is that no existing code has to be modified when a new class is added. You can list those that are present by babel -L charges or from a menu item in the GUI.

Any OBChargeModel derived class works like other plugins and needs to to have a constructor, a function returning a short description, and a ComputeCharges() function which does the work. A single global instance of the class needs to be instantiated to define the ID, by which the class is subsequently accessed.

Once ComputeCharges() has been called, the atoms of the molecule can be queried for partial or formal charges using OBAtom::GetPartialCharge() or in vector form from the model itself:

      OBMol inputMolecule;
      OBChargeModel *mmffCharges = OBChargeModel::FindType("mmff94");
      const std::vector<double> partialCharges;
      if (mmffCharges && mmffCharges->ComputeCharges(inputMolecule)) {
        partialCharges = mmffCharges->GetPartialCharges();
      }

Note: Formal charges are also returned as floating point values, since some charge models consider delocalized charges (e.g., 0.5 for an O in a carboxylate CO2- group).

      OBChargeModel *gasteiger = OBChargeModel::FindType("gasteiger");
      if (gasteiger) {
        cout << " gasteiger: " << dipoleMagnitude(gasteiger->GetDipoleMoment(mol));
      }

By default, Open Babel 2.3 includes Gasteiger and MMFF94 partial charges. If the Eigen matrix library is found when compiling, the QEq and QTPIE methods will be added. Future releases will likely add additional charge models, including the EEM method.

## Member Function Documentation

const char* TypeID | ( |  | ) | `[inline, virtual]`

Redefined by each plugin type: "formats", "fingerprints", etc.

Reimplemented from OBPlugin.

virtual bool ComputeCharges | ( | OBMol & |  | ) | `[inline, virtual]`

Returns:
  whether partial charges were successfully assigned to this molecule

Note:
  The method should fill m_partialCharges and m_formalCharges as well

const std::vector<double>& GetFormalCharges | ( |  | ) | const`[inline]`

Returns:
  a vector of the formal charges on each atom, indexed from 0 This method returns floating point formal charges since some charge models consider fractional charges (e.g., 0.5 for an oxygen in a carboxylate CO2- group).

Note:
  If ComputeCharges() has not been called, this will return an empty vector

const std::vector<double>& GetPartialCharges | ( |  | ) | const`[inline]`

Returns:
  a vector of the partial charges on each atom, indexed from 0

Note:
  If ComputeCharges() has not been called, this will return an empty vector

vector3 GetDipoleMoment | ( | OBMol & | mol | ) |

Returns:
  a vector of the dipole moment from this molecule

void FillChargeVectors | ( | OBMol & | mol | ) | `[protected]`

Fill the internal partial and formal charge vectors (convenience function)

virtual double DipoleScalingFactor | ( |  | ) | `[inline, protected, virtual]`

Provide a scaling factor for the dipole moment -- ideally calibrated from many molecules.

## Member Data Documentation

std::vector<double> m_partialCharges`[protected]`

std::vector<double> m_formalCharges`[protected]`

The documentation for this class was generated from the following files:

- chargemodel.h
- chargemodel.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines