Loading...
Searching...
No Matches
OBChargeModel Class Referenceabstract

`#include <openbabel/chargemodel.h>`

Inheritance diagram for OBChargeModel:
[legend]

## 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 &m)
virtual bool | ComputeCharges (OBMol &m, const char *args)
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=nullptr)
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=nullptr, std::ostream *os=&std::cout)
static std::string | ListAsString (const char *PluginID, const char *param=nullptr)
static std::string | FirstLine (const char *txt)
static PluginIterator | Begin (const char *PluginID)
static PluginIterator | End (const char *PluginID)
static void | LoadAllPlugins ()

## 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

## Static Protected Attributes

static int | AllPluginsLoaded = 0

## 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 obabel 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 obabel -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();
}
OpenBabel::OBChargeModel
Atomic partial charge models.
Definition chargemodel.h:33
OpenBabel::OBChargeModel::ComputeCharges
virtual bool ComputeCharges(OBMol &m)
Definition chargemodel.h:41
OpenBabel::OBChargeModel::GetPartialCharges
const std::vector< double > & GetPartialCharges() const
Definition chargemodel.h:54
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121

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));
}
OpenBabel::OBChargeModel::GetDipoleMoment
vector3 GetDipoleMoment(OBMol &)
Definition chargemodel.cpp:50

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

## TypeID()

const char * TypeID | ( |  | ) |

inline virtual

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

Reimplemented from OBPlugin.

## ComputeCharges() [1/2]

virtual bool ComputeCharges | ( | OBMol & | m | ) |

inline virtual

Returns
  whether partial charges were successfully assigned to this molecule

Note
  The method should fill m_partialCharges and m_formalCharges as well

Referenced by GetDipoleMoment().

## ComputeCharges() [2/2]

virtual bool ComputeCharges | ( | OBMol & | m,
|  | const char * | args )

inline virtual

Referenced by ComputeCharges().

## GetFormalCharges()

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

## GetPartialCharges()

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

## GetDipoleMoment()

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

Returns
  a vector of the dipole moment from this molecule

## FillChargeVectors()

void FillChargeVectors | ( | OBMol & | mol | ) |

protected

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

## DipoleScalingFactor()

virtual double DipoleScalingFactor | ( |  | ) |

inline protected virtual

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

Referenced by GetDipoleMoment().

## Member Data Documentation

## m_partialCharges

std::vector<double> m_partialCharges

protected

Referenced by FillChargeVectors(), and GetPartialCharges().

## m_formalCharges

std::vector<double> m_formalCharges

protected

Referenced by FillChargeVectors(), and GetFormalCharges().

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

- chargemodel.h
- chargemodel.cpp