Loading...
Searching...
No Matches
Molecule Class Reference

The Molecule class represents a chemical molecule.

`#include <avogadro/core/molecule.h>`

Inheritance diagram for Molecule:

## Public Types

using | AtomType = Atom
using | BondType = Bond
using | CustomElementMap = std::map<unsigned char, std::string>
using | ElementMask = std::bitset<element_count>

## Public Member Functions

| Molecule ()
| Molecule (const Molecule &other)
| Molecule (Molecule &&other) noexcept
Molecule & | operator= (const Molecule &other)
Molecule & | operator= (Molecule &&other) noexcept
virtual | ~Molecule ()
void | readProperties (const Molecule &other)
void | setData (const std::string &name, const Variant &value)
Variant | data (const std::string &name) const
bool | hasData (const std::string &name) const
void | setDataMap (const VariantMap &map)
const VariantMap & | dataMap () const
VariantMap & | dataMap ()
MatrixX | spectra (const std::string &name) const
void | setSpectra (const std::string &name, const MatrixX &value)
std::set< std::string > | spectraTypes () const
void | setPartialCharges (const std::string &type, const MatrixX &value)
MatrixX | partialCharges (const std::string &type) const
std::set< std::string > | partialChargeTypes () const
Array< AtomHybridization > & | hybridizations ()
const Array< AtomHybridization > & | hybridizations () const
AtomHybridization | hybridization (Index atomId) const
bool | setHybridizations (const Core::Array< AtomHybridization > &hybs)
bool | setHybridization (Index atomId, AtomHybridization hybridization)
Array< signed char > & | formalCharges ()
const Array< signed char > & | formalCharges () const
signed char | formalCharge (Index atomId) const
bool | setFormalCharges (const Core::Array< signed char > &charges)
bool | setFormalCharge (Index atomId, signed char charge)
signed char | totalCharge () const
char | totalSpinMultiplicity () const
Array< unsigned short > & | isotopes ()
const Array< unsigned short > & | isotopes () const
unsigned short | isotope (Index atomId) const
bool | setIsotopes (const Core::Array< unsigned short > &isotopes)
bool | setIsotope (Index atomId, unsigned short isotope)
Array< Vector3ub > & | colors ()
const Array< Vector3ub > & | colors () const
Vector3ub | color (Index atomId) const
bool | setColors (const Core::Array< Vector3ub > &colors)
bool | setColor (Index atomId, Vector3ub color)
bool | setLayer (Index atomId, size_t layer)
size_t | layer (Index atomId) const
const Array< Vector2 > & | atomPositions2d () const
Array< Vector2 > & | atomPositions2d ()
Vector2 | atomPosition2d (Index atomId) const
bool | setAtomPositions2d (const Core::Array< Vector2 > &pos)
bool | setAtomPosition2d (Index atomId, const Vector2 &pos)
const Array< Vector3 > & | atomPositions3d () const
Array< Vector3 > & | atomPositions3d ()
Vector3 | atomPosition3d (Index atomId) const
bool | setAtomPositions3d (const Core::Array< Vector3 > &pos)
bool | setAtomPosition3d (Index atomId, const Vector3 &pos)
std::string | atomLabel (Index atomId) const
bool | setAtomLabel (Index atomId, const std::string &label)
const Core::Array< std::string > | atomLabels () const
bool | setAtomLabels (const Core::Array< std::string > &label)
void | setAtomSelected (Index atomId, bool selected)
bool | atomSelected (Index atomId) const
bool | isSelectionEmpty () const
const ElementMask | elements () const
virtual AtomType | addAtom (unsigned char atomicNumber)
AtomType | addAtom (unsigned char atomicNumber, Vector3 position3d)
virtual bool | removeAtom (Index index)
| Remove the specified atom from the molecule.
virtual bool | removeAtom (const AtomType &atom)
| Remove the specified atom from the molecule.
virtual void | clearAtoms ()
AtomType | atom (Index index) const
virtual bool | removeBond (Index index)
| Remove the specified bond.
virtual bool | removeBond (const BondType &bond)
| Remove the specified bond.
virtual void | clearBonds ()
BondType | bond (Index index) const
BondType | bond (const AtomType &a, const AtomType &b) const
BondType | bond (Index atomId1, Index atomId2) const
std::string | bondLabel (Index bondIndex) const
bool | setBondLabel (Index bondIndex, const std::string &label)
const Core::Array< std::string > | bondLabels () const
bool | setBondLabels (const Core::Array< std::string > &label)
Mesh * | addMesh ()
| Add a mesh to the molecule.
Mesh * | mesh (Index index)
const Mesh * | mesh (Index index) const
Index | meshCount () const
void | clearMeshes ()
Cube * | addCube ()
| Add a cube to the molecule.
Cube * | cube (Index index)
const Cube * | cube (Index index) const
Index | cubeCount () const
void | clearCubes ()
bool | setActiveCubeIndex (Index index)
| Set the active cube index for volume rendering.
Index | activeCubeIndex () const
| Get the index of the active cube.
Cube * | activeCube ()
| Get the active cube for volume rendering.
const Cube * | activeCube () const
std::vector< Cube * > | cubes ()
| Get the cubes vector set (if present) for the molecule.
const std::vector< Cube * > | cubes () const
std::string | formula (const std::string &delimiter="", int showCountsOver=1) const
double | mass () const
double | monoisotopicMass () const
Vector3 | centerOfGeometry () const
Vector3 | centerOfMass () const
double | radius () const
std::pair< Vector3, Vector3 > | bestFitPlane () const
void | setBasisSet (BasisSet *basis)
BasisSet * | basisSet ()
const BasisSet * | basisSet () const
Array< double > | vibrationFrequencies () const
void | setVibrationFrequencies (const Array< double > &freq)
Array< double > | vibrationIRIntensities () const
void | setVibrationIRIntensities (const Array< double > &intensities)
Array< double > | vibrationRamanIntensities () const
void | setVibrationRamanIntensities (const Array< double > &intensities)
Array< Vector3 > | vibrationLx (int mode) const
void | setVibrationLx (const Array< Array< Vector3 > > &lx)
void | perceiveBondsSimple (const double tolerance=0.45, const double minDistance=0.32)
void | perceiveBondsFromResidueData ()
void | perceiveBondOrders ()
void | perceiveSubstitutedCations ()
size_t | coordinate3dCount () const
bool | setCoordinate3d (int coord)
Array< Vector3 > | coordinate3d (size_t index) const
bool | setCoordinate3d (const Array< Vector3 > &coords, size_t index)
void | clearCoordinate3d ()
void | estimateVelocities ()
Array< Vector3 > | velocities (int index) const
bool | setVelocities (const Array< Vector3 > &velocities, int index)
void | clearVelocities ()
bool | setTimeStep (double timestep, int index)
double | timeStep (int index, bool &status)
const Array< Vector3 > & | forceVectors () const
Array< Vector3 > & | forceVectors ()
Vector3 | forceVector (Index atomId) const
bool | setForceVectors (const Core::Array< Vector3 > &forces)
bool | setForceVector (Index atomId, const Vector3 &force)
Residue & | addResidue (std::string &name, Index &number, char &id)
void | addResidue (Residue &residue)
Residue & | residue (Index index)
const Residue & | residue (Index index) const
Array< Residue > & | residues ()
const Array< Residue > & | residues () const
Index | residueCount () const
std::string | residueLabel (Index residueIndex) const
bool | setResidueLabel (Index residueIndex, const std::string &label)
const Core::Array< std::string > | residueLabels () const
bool | setResidueLabels (const Core::Array< std::string > &label)
Index | atomCount () const
Index | atomCount (unsigned char atomicNumber) const
| Get the number of atoms in the molecule that match atomicNumber.
Index | bondCount () const
std::pair< Index, Index > | bondPair (Index bondId) const
bool | setBondPairs (const Array< std::pair< Index, Index > > &pairs)
const Array< std::pair< Index, Index > > & | bondPairs () const
const Array< unsigned char > & | bondOrders () const
const Graph & | graph () const
const Array< unsigned char > & | atomicNumbers () const
unsigned char | atomicNumber (Index atomId) const
bool | setBondOrders (const Array< unsigned char > &orders)
bool | setBondOrder (Index bondId, unsigned char order)
bool | hasCustomElements () const
bool | setBondPair (Index bondId, const std::pair< Index, Index > &pair)
unsigned char | bondOrder (Index bondId) const
bool | setAtomicNumbers (const Core::Array< unsigned char > &nums)
bool | setAtomicNumber (Index atomId, unsigned char atomicNumber)
std::map< unsigned char, size_t > | composition () const
std::map< std::string, size_t > | formulaComposition () const
Array< std::pair< Index, Index > > | getAtomBonds (Index index) const
Array< unsigned char > | getAtomOrders (Index index) const
bool | removeBonds (Index atom)
void | addBonds (const Array< std::pair< Index, Index > > &bonds, const Array< unsigned char > &orders)
void | swapBond (Index a, Index b)
void | swapAtom (Index a, Index b)
std::list< Index > | getAtomsAtLayer (size_t layer)
Layer & | layer ()
const Layer & | layer () const
void | boundingBox (Vector3 &boxMin, Vector3 &boxMax, const double radius=1.0) const
const CustomElementMap & | customElementMap () const
void | setCustomElementMap (const CustomElementMap &map)
virtual BondType | addBond (Index atom1, Index atom2, unsigned char order=1)
virtual BondType | addBond (const AtomType &atom1, const AtomType &atom2, unsigned char order=1)
virtual bool | removeBond (Index atom1, Index atom2)
| Remove the specified bond.
virtual bool | removeBond (const AtomType &atom1, const AtomType &atom2)
| Remove the specified bond.
Array< BondType > | bonds (const AtomType &a)
| Get all bonds to `a`.
Array< BondType > | bonds (Index a)
| Get all bonds to `a`.
Array< const BondType * > | bonds (Index a) const
| Get all bonds to `a`.
void | setUnitCell (UnitCell *uc)
UnitCell * | unitCell ()
const UnitCell * | unitCell () const
void | setHallNumber (unsigned short hallNumber)
unsigned short | hallNumber () const
Constraints
Methods for distance, angle, torsion, etc. constraints
void | addConstraint (Real Value, Index a, Index b, Index c=MaxIndex, Index d=MaxIndex)
void | addConstraint (Constraint &c)
void | removeConstraint (Index a, Index b, Index c=MaxIndex, Index d=MaxIndex)
void | clearConstraints ()
void | setConstraints (const std::vector< Core::Constraint > &constraints)
std::vector< Core::Constraint > & | constraints ()
const std::vector< Core::Constraint > & | constraints () const
void | setFrozenAtom (Index atomId, bool frozen)
bool | frozenAtom (Index atomId) const
bool | frozenAtomAxis (Index atomId, int axis) const
void | setFrozenAtomAxis (Index atomId, int axis, bool frozen)
Eigen::VectorXd | frozenAtomMask () const

## Static Public Member Functions

static std::pair< Vector3, Vector3 > | bestFitPlane (const Array< Vector3 > &pos)
static std::pair< Index, Index > | makeBondPair (const Index &a, const Index &b)

## Protected Attributes

VariantMap | m_data
std::map< std::string, MatrixX > | m_partialCharges
| Sets of atomic partial charges.
std::map< std::string, MatrixX > | m_spectra
| Sets of spectra.
CustomElementMap | m_customElementMap
ElementMask | m_elements
Array< Vector2 > | m_positions2d
Array< Vector3 > | m_positions3d
Array< std::string > | m_atomLabels
Array< std::string > | m_bondLabels
Array< std::string > | m_residueLabels
Array< Array< Vector3 > > | m_coordinates3d
| Store conformers/trajectories.
Array< Array< Vector3 > > | m_velocities
| Store velocities.
Array< double > | m_timesteps
Array< AtomHybridization > | m_hybridizations
Array< signed char > | m_formalCharges
Array< unsigned short > | m_isotopes
| Store isotopes of the atoms.
Array< Vector3 > | m_forceVectors
Array< Vector3ub > | m_colors
Array< double > | m_vibrationFrequencies
Array< double > | m_vibrationIRIntensities
Array< double > | m_vibrationRamanIntensities
Array< Array< Vector3 > > | m_vibrationLx
std::vector< bool > | m_selectedAtoms
std::vector< Mesh * > | m_meshes
std::vector< Cube * > | m_cubes
Index | m_activeCubeIndex = 0
BasisSet * | m_basisSet
UnitCell * | m_unitCell
Array< Residue > | m_residues
unsigned short | m_hallNumber = 0
std::vector< Core::Constraint > | m_constraints
Eigen::VectorXd | m_frozenAtomMask

## Member Typedef Documentation

## AtomType

using AtomType = Atom

Typedef for Atom class.

## BondType

using BondType = Bond

Typedef for Bond class.

## CustomElementMap

using CustomElementMap = std::map<unsigned char, std::string>

Type for custom element map.

## ElementMask

using ElementMask = std::bitset<element_count>

Type for element masks (e.g., does this molecule contain certain elements)

## Constructor & Destructor Documentation

## Molecule() [1/3]

Molecule | ( |  | ) |

Creates a new, empty molecule.

## Molecule() [2/3]

Molecule | ( | const Molecule & | other | ) |

Copy constructor

## Molecule() [3/3]

Molecule | ( | Molecule && | other | ) |

noexcept

Move constructor

## ~Molecule()

virtual ~Molecule | ( |  | ) |

virtual

Destroys the molecule object.

Reimplemented in Molecule.

## Member Function Documentation

## operator=() [1/2]

Molecule & operator= | ( | const Molecule & | other | ) |

Assignment operator

## operator=() [2/2]

Molecule & operator= | ( | Molecule && | other | ) |

noexcept

Move assignment operator

## readProperties()

void readProperties | ( | const Molecule & | other | ) |

Adds the properties from the supplied molecule to this molecule. Does not otherwise modify atoms / bonds / residues, etc.

## setData()

void setData | ( | const std::string & | name,
|  | const Variant & | value )

Sets the data value with `name` to `value`.

## data()

Variant data | ( | const std::string & | name | ) | const

Returns
  the data value for `name`.

## hasData()

bool hasData | ( | const std::string & | name | ) | const

Returns
  true if the molecule has data with the given key, false otherwise.

## setDataMap()

void setDataMap | ( | const VariantMap & | map | ) |

Set the molecule's variant data to the entries in map.

## dataMap() [1/2]

const VariantMap & dataMap | ( |  | ) | const

Returns
  the molecule's variant data.

## dataMap() [2/2]

VariantMap & dataMap | ( |  | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## spectra()

MatrixX spectra | ( | const std::string & | name | ) | const

Returns
  a specific spectra entry

## setSpectra()

void setSpectra | ( | const std::string & | name,
|  | const MatrixX & | value )

Sets the spectra value with `name` to `value`.

## spectraTypes()

std::set< std::string > spectraTypes | ( |  | ) | const

Returns
  the list of available spectra

## setPartialCharges()

void setPartialCharges | ( | const std::string & | type,
|  | const MatrixX & | value )

Sets atomic partial charges with `type` to `value`.

## partialCharges()

MatrixX partialCharges | ( | const std::string & | type | ) | const

Returns
  the atomic partial charges of type `type`

## partialChargeTypes()

std::set< std::string > partialChargeTypes | ( |  | ) | const

Returns
  the types of partial charges available stored with this molecule.

## hybridizations() [1/2]

Array< AtomHybridization > & hybridizations | ( |  | ) |

Returns
  a vector of hybridizations for the atoms in the molecule.

## hybridizations() [2/2]

const Array< AtomHybridization > & hybridizations | ( |  | ) | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## hybridization()

AtomHybridization hybridization | ( | Index | atomId | ) | const

Get the hybridization for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The hybridization of the atom indexed at atomId, or 0 if atomId is invalid.

## setHybridizations()

bool setHybridizations | ( | const Core::Array< AtomHybridization > & | hybs | ) |

Replace the current array of hybridizations.

Parameters

  hybs | The new hybridization array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setHybridization()

bool setHybridization | ( | Index | atomId,
|  | AtomHybridization | hybridization )

Set the hybridization of a single atom.

Parameters

  atomId | The index of the atom to modify.
  hybridization | The new hybridization.

Returns
  True on success, false otherwise.

## formalCharges() [1/2]

Array< signed char > & formalCharges | ( |  | ) |

Returns
  a vector of formal charges for the atoms in the molecule.

## formalCharges() [2/2]

const Array< signed char > & formalCharges | ( |  | ) | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## formalCharge()

signed char formalCharge | ( | Index | atomId | ) | const

Get the formal charge for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The formal charge of the atom indexed at atomId, or 0 if atomId is invalid.

## setFormalCharges()

bool setFormalCharges | ( | const Core::Array< signed char > & | charges | ) |

Replace the current array of formal charges.

Parameters

  charges | The new formal charge array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setFormalCharge()

bool setFormalCharge | ( | Index | atomId,
|  | signed char | charge )

Set the formal charge of a single atom.

Parameters

  atomId | The index of the atom to modify.
  charge | The new formal charge.

Returns
  True on success, false otherwise.

## totalCharge()

signed char totalCharge | ( |  | ) | const

Get the total charge on the molecule. The method will first check to see if a total charge has been set. If not, it will calculate the total charge from the formal charges (if set). If neither has been set, it will assume the total charge is zero.

Returns
  The total charge of the molecule.

## totalSpinMultiplicity()

char totalSpinMultiplicity | ( |  | ) | const

Get the total spin multiplicity of the molecule. The method will first check to see if a total spin has been set. If not, it will either suggest a singlet if an even number of electrons are present, or a doublet if an odd number of electrons are present.

Returns
  The total spin multiplicity of the molecule.

## isotopes() [1/2]

Array< unsigned short > & isotopes | ( |  | ) |

Returns
  an array of the isotopes for the atoms in the molecule.

## isotopes() [2/2]

const Array< unsigned short > & isotopes | ( |  | ) | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## isotope()

unsigned short isotope | ( | Index | atomId | ) | const

Get the isotope for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The isotope of the atom indexed at atomId, or 0 if atomId is invalid.

## setIsotopes()

bool setIsotopes | ( | const Core::Array< unsigned short > & | isotopes | ) |

Replace the current array of isotopes.

Parameters

  charges | The new isotope array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setIsotope()

bool setIsotope | ( | Index | atomId,
|  | unsigned short | isotope )

Set the isotope of a single atom.

Parameters

  atomId | The index of the atom to modify.
  isotope | The new isotope (or zero for most common)

Returns
  True on success, false otherwise.

## colors() [1/2]

Array< Vector3ub > & colors | ( |  | ) |

Returns
  a vector of colors for the atoms in the moleucle.

## colors() [2/2]

const Array< Vector3ub > & colors | ( |  | ) | const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## color()

Vector3ub color | ( | Index | atomId | ) | const

Get the color for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The color of the atom indexed at atomId, or (0,0,0) if atomId is invalid. If no color is set for the given atomId, the default color for the atomic number of the atomId is returned.

## setColors()

bool setColors | ( | const Core::Array< Vector3ub > & | colors | ) |

Replace the current array of colors.

Parameters

  colors | The new color array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setColor()

bool setColor | ( | Index | atomId,
|  | Vector3ub | color )

Set the color of a single atom.

Parameters

  atomId | The index of the atom to modify.
  color | The new color.

Returns
  True on success, false otherwise.

## atomPositions2d() [1/2]

const Array< Vector2 > & atomPositions2d | ( |  | ) | const

Returns
  a vector of 2d atom positions for the atoms in the molecule.

## atomPositions2d() [2/2]

Array< Vector2 > & atomPositions2d | ( |  | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## atomPosition2d()

Vector2 atomPosition2d | ( | Index | atomId | ) | const

Get the 2D position of a single atom.

Parameters

  atomId | The index of the atom.

Returns
  The position of the atom, or Vector3::Zero() if no position information has been set.

## setAtomPositions2d()

bool setAtomPositions2d | ( | const Core::Array< Vector2 > & | pos | ) |

Replace the current array of 2D atomic coordinates.

Parameters

  pos | The new coordinate array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setAtomPosition2d()

bool setAtomPosition2d | ( | Index | atomId,
|  | const Vector2 & | pos )

Set the 2D position of a single atom.

Parameters

  atomId | The index of the atom to modify.
  pos | The new position of the atom.

Returns
  True on success, false otherwise.

## atomPositions3d() [1/2]

const Array< Vector3 > & atomPositions3d | ( |  | ) | const

Returns
  a vector of 3d atom positions for the atoms in the molecule.

## atomPositions3d() [2/2]

Array< Vector3 > & atomPositions3d | ( |  | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## atomPosition3d()

Vector3 atomPosition3d | ( | Index | atomId | ) | const

Get the 3D position of a single atom.

Parameters

  atomId | The index of the atom.

Returns
  The position of the atom, or Vector3::Zero() if no position information has been set.

## setAtomPositions3d()

bool setAtomPositions3d | ( | const Core::Array< Vector3 > & | pos | ) |

Replace the current array of 3D atomic coordinates.

Parameters

  pos | The new coordinate array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setAtomPosition3d()

bool setAtomPosition3d | ( | Index | atomId,
|  | const Vector3 & | pos )

Set the 3D position of a single atom.

Parameters

  atomId | The index of the atom to modify.
  pos | The new position of the atom.

Returns
  True on success, false otherwise.

## atomLabel()

std::string atomLabel | ( | Index | atomId | ) | const

Returns
  Any custom label for the requested atom.

Parameters

  atomId | The index of the atom.

## setAtomLabel()

bool setAtomLabel | ( | Index | atomId,
|  | const std::string & | label )

Set the custom label of a single atom.

Parameters

  atomId | The index of the atom to modify.
  label | The new label of the atom.

Returns
  True on success, false otherwise.

## setAtomLabels()

bool setAtomLabels | ( | const Core::Array< std::string > & | label | ) |

Set all the atom labels in the molecule.

Parameters

  label | The new label array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setAtomSelected()

void setAtomSelected | ( | Index | atomId,
|  | bool | selected )

Set whether the specified atom is selected or not.

## atomSelected()

bool atomSelected | ( | Index | atomId | ) | const

Query whether the supplied atom index has been selected.

## isSelectionEmpty()

bool isSelectionEmpty | ( |  | ) | const

Returns
  whether the selection is empty or not

## customElementMap()

const CustomElementMap & customElementMap | ( |  | ) | const

A map of custom element atomic numbers to string identifiers. These ids can be used to override the generic custom element names returned by the Elements class, and should be somewhat meaningful to the user.

Note
  Custom element atomic numbers lie between CustomElementMin and CustomElementMax.

See also
  Avogadro::QtGui::CustomElementDialog
  hasCustomElements

## setCustomElementMap()

void setCustomElementMap | ( | const CustomElementMap & | map | ) |

A map of custom element atomic numbers to string identifiers. These ids can be used to override the generic custom element names returned by the Elements class, and should be somewhat meaningful to the user.

Note
  Custom element atomic numbers lie between CustomElementMin and CustomElementMax.

See also
  Avogadro::QtGui::CustomElementDialog
  hasCustomElements

## elements()

const Molecule::ElementMask elements | ( |  | ) | const

Returns
  the elements currently in this molecule

## addAtom()

virtual AtomType addAtom | ( | unsigned char | atomicNumber | ) |

virtual

Adds an atom to the molecule.

Reimplemented in Molecule.

## removeAtom() [1/2]

virtual bool removeAtom | ( | Index | index | ) |

virtual

Parameters

  index | The index of the atom to be removed.

Returns
  True on success, false if the atom was not found.

Reimplemented in Molecule.

## removeAtom() [2/2]

virtual bool removeAtom | ( | const AtomType & | atom | ) |

virtual

Parameters

  atom | The atom to be removed.

Returns
  True on success, false if the atom was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Molecule.

## clearAtoms()

virtual void clearAtoms | ( |  | ) |

virtual

Remove all atoms from the molecule.

## atom()

AtomType atom | ( | Index | index | ) | const

Returns
  the atom at `index` in the molecule.

## addBond() [1/2]

virtual BondType addBond | ( | Index | atom1,
|  | Index | atom2,
|  | unsigned char | order = 1 )

virtual

Create a new bond in the molecule.

Parameters

  atom1 | The first atom in the bond.
  atom2 | The second atom in the bond.
  order | The bond order.

Returns
  The new bond object. Will be invalid if atom1 or atom2 does not exist.

Reimplemented in Molecule.

## addBond() [2/2]

virtual BondType addBond | ( | const AtomType & | atom1,
|  | const AtomType & | atom2,
|  | unsigned char | order = 1 )

virtual

Create a new bond in the molecule.

Parameters

  atom1 | The first atom in the bond.
  atom2 | The second atom in the bond.
  order | The bond order.

Returns
  The new bond object. Will be invalid if atom1 or atom2 does not exist.

Reimplemented in Molecule.

## removeBond() [1/4]

virtual bool removeBond | ( | Index | index | ) |

virtual

Parameters

  index | The index of the bond to be removed.

Returns
  True on success, false if the bond was not found.

Reimplemented in Molecule.

## removeBond() [2/4]

virtual bool removeBond | ( | const BondType & | bond | ) |

virtual

Parameters

  bond | The bond to be removed.

Returns
  True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Molecule.

## removeBond() [3/4]

virtual bool removeBond | ( | Index | atom1,
|  | Index | atom2 )

virtual

Parameters

  atom1 | One atom in the bond.
  atom2 | The other atom in the bond.

Returns
  True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Molecule.

## removeBond() [4/4]

virtual bool removeBond | ( | const AtomType & | atom1,
|  | const AtomType & | atom2 )

virtual

Parameters

  atom1 | One atom in the bond.
  atom2 | The other atom in the bond.

Returns
  True on success, false if the bond was not found. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in Molecule.

## clearBonds()

virtual void clearBonds | ( |  | ) |

virtual

Remove all bonds from the molecule.

## bond() [1/3]

BondType bond | ( | Index | index | ) | const

Returns
  the bond at `index` in the molecule.

## bond() [2/3]

BondType bond | ( | const AtomType & | a,
|  | const AtomType & | b ) const

Returns
  the bond between atoms `a` and `b`.

## bond() [3/3]

BondType bond | ( | Index | atomId1,
|  | Index | atomId2 ) const

Returns
  the bond between atomId1 and atomId2.

## bondLabel()

std::string bondLabel | ( | Index | bondIndex | ) | const

Returns
  Any custom label for the requested bond.

Parameters

  bondIndex | The index of the bond.

## setBondLabel()

bool setBondLabel | ( | Index | bondIndex,
|  | const std::string & | label )

Set the custom label of a single bond.

Parameters

  bondIndex | The index of the bond to modify.
  label | The new label of the bond.

Returns
  True on success, false otherwise.

## setBondLabels()

bool setBondLabels | ( | const Core::Array< std::string > & | label | ) |

Set all the bond labels in the molecule.

Parameters

  label | The new label array. Must be of length bondCount().

Returns
  True on success, false otherwise.

## bonds() [1/3]

Array< BondType > bonds | ( | const AtomType & | a | ) |

Returns
  A vector of bonds to the supplied atom `a`.

## bonds() [2/3]

Array< BondType > bonds | ( | Index | a | ) |

Returns
  A vector of bonds to the supplied atom `a`.

## bonds() [3/3]

Array< const BondType * > bonds | ( | Index | a | ) | const

Returns
  A vector of bonds to the supplied atom `a`.

## addMesh()

Mesh * addMesh | ( |  | ) |

Returns
  The mesh object added to the molecule.

## addCube()

Cube * addCube | ( |  | ) |

Returns
  The cube object added to the molecule.

## setActiveCubeIndex()

bool setActiveCubeIndex | ( | Index | index | ) |

Parameters

  index | The index of the cube to make active.

Returns
  True if the index is valid and was set, false otherwise.

## activeCubeIndex()

Index activeCubeIndex | ( |  | ) | const

Returns
  The active cube index, or 0 if no cubes exist.

## activeCube()

Cube * activeCube | ( |  | ) |

Returns
  A pointer to the active cube, or nullptr if no cubes exist.

## cubes()

std::vector< Cube * > cubes | ( |  | ) |

Returns
  The cube vector for the molecule

## formula()

std::string formula | ( | const std::string & | delimiter = "",
|  | int | showCountsOver = 1 ) const

Returns
  the chemical formula of the molecule.

Parameters

  delimiter | Delimiter to insert between tokens, defaults to none.
  showCountsOver | Show atom counts above this (defaults to 1).

## mass()

double mass | ( |  | ) | const

Returns
  The mass of the molecule obtained by summing constituent atomic masses.

## monoisotopicMass()

double monoisotopicMass | ( |  | ) | const

Returns
  the monoisotopic mass of the molecule obtained by summing the isotopic masses of the atoms (including the most common isotope if not specified).

## centerOfGeometry()

Vector3 centerOfGeometry | ( |  | ) | const

Returns
  The center of geometry of the molecule obtained by summing the coordinates of the atoms.

## centerOfMass()

Vector3 centerOfMass | ( |  | ) | const

Returns
  The center of mass of the molecule obtained by summing the coordinates of the atoms weighted by mass.

## radius()

double radius | ( |  | ) | const

Returns
  The minimum radius of a sphere centered on centerOfGeometry containing all the centers of the atoms.

## bestFitPlane() [1/2]

std::pair< Vector3, Vector3 > bestFitPlane | ( |  | ) | const

Returns
  The (centroid, normal vector) pair of the best-fit plane of the atoms of the molecule.

## bestFitPlane() [2/2]

std::pair< Vector3, Vector3 > bestFitPlane | ( | const Array< Vector3 > & | pos | ) |

static

Returns
  The normal vector of the best-fit plane of some specific atoms.

## setBasisSet()

void setBasisSet | ( | BasisSet * | basis | ) |

Set the basis set for the molecule, note that the molecule takes ownership of the object.

## basisSet()

BasisSet * basisSet | ( |  | ) |

Returns
  the basis set (if present) for the molecule.

## setUnitCell()

void setUnitCell | ( | UnitCell * | uc | ) |

The unit cell for this molecule. May be nullptr for non-periodic structures.

## unitCell() [1/2]

UnitCell * unitCell | ( |  | ) |

The unit cell for this molecule. May be nullptr for non-periodic structures.

## unitCell() [2/2]

const UnitCell * unitCell | ( |  | ) | const

The unit cell for this molecule. May be nullptr for non-periodic structures.

## setHallNumber()

void setHallNumber | ( | unsigned short | hallNumber | ) |

The space group for this molecule. It is updated after every space group operation.

## hallNumber()

unsigned short hallNumber | ( |  | ) | const

The space group for this molecule. It is updated after every space group operation.

## perceiveBondsSimple()

void perceiveBondsSimple | ( | const double | tolerance = 0.45,
|  | const double | minDistance = 0.32 )

Perceives bonds in the molecule based on the 3D coordinates of the atoms. atoms are considered bonded if within the sum of radii plus a small `tolerance`.

Parameters

  tolerance | The calculation tolerance.
  minDistance | = atoms closer than the square of this are ignored

## perceiveBondsFromResidueData()

void perceiveBondsFromResidueData | ( |  | ) |

Perceives bonds in the molecule based on preset residue data.

Use this if you have residue data available (e.g., reading PDB or MMTF files) Otherwise consider

See also
  perceiveBondsSimple and
  perceiveBondOrders

## perceiveSubstitutedCations()

void perceiveSubstitutedCations | ( |  | ) |

Perceives all-carbon-substituted onium ions of nitrogen, oxygen, phosphorus, sulfur, arsenic and selenium.

## clearCoordinate3d()

void clearCoordinate3d | ( |  | ) |

Clear coordinate sets (except the default set)

## estimateVelocities()

void estimateVelocities | ( |  | ) |

Estimate velocities from the coordinate sets and timesteps.

## velocities()

Array< Vector3 > velocities | ( | int | index | ) | const

Get the velocities for the specified index.

## setVelocities()

bool setVelocities | ( | const Array< Vector3 > & | velocities,
|  | int | index )

Set the velocities for the specified index.

## clearVelocities()

void clearVelocities | ( |  | ) |

Clear all velocity sets.

## setTimeStep()

bool setTimeStep | ( | double | timestep,
|  | int | index )

Timestep property is used when molecular dynamics trajectories are read

## forceVectors() [1/2]

const Array< Vector3 > & forceVectors | ( |  | ) | const

Returns
  a vector of forces for the atoms in the molecule.

## forceVectors() [2/2]

Array< Vector3 > & forceVectors | ( |  | ) |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## forceVector()

Vector3 forceVector | ( | Index | atomId | ) | const

Get the force of a single atom.

Parameters

  atomId | The index of the atom.

Returns
  The force vector of the atom, or Vector3::Zero() if no force information has been set.

## setForceVectors()

bool setForceVectors | ( | const Core::Array< Vector3 > & | forces | ) |

Replace the current array of force vectors.

Parameters

  forces | The new coordinate array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setForceVector()

bool setForceVector | ( | Index | atomId,
|  | const Vector3 & | force )

Set the 3D position of a single atom.

Parameters

  atomId | The index of the atom to modify.
  force | The new position of the atom.

Returns
  True on success, false otherwise.

## residueCount()

Index residueCount | ( |  | ) | const

Returns
  The number of residues in the molecule.

## residueLabel()

std::string residueLabel | ( | Index | residueIndex | ) | const

Returns
  Any custom label for the requested residue.

Parameters

  residueIndex | The index of the residue.

## setResidueLabel()

bool setResidueLabel | ( | Index | residueIndex,
|  | const std::string & | label )

Set the custom label of a single residue.

Parameters

  residueIndex | The index of the residue to modify.
  label | The new label of the residue.

Returns
  True on success, false otherwise.

## setResidueLabels()

bool setResidueLabels | ( | const Core::Array< std::string > & | label | ) |

Set all the residue labels in the molecule.

Parameters

  label | The new label array. Must be of length residueCount().

Returns
  True on success, false otherwise.

## atomCount() [1/2]

Index atomCount | ( |  | ) | const

Returns
  The number of atoms in the molecule.

## atomCount() [2/2]

Index atomCount | ( | unsigned char | atomicNumber | ) | const

Parameters

  atomicNumber | The atomic number to match on.

Returns
  The number of atoms with the supplied atomic number.

## bondCount()

Index bondCount | ( |  | ) | const

Returns
  the number of bonds in the molecule.

## bondPair()

std::pair< Index, Index > bondPair | ( | Index | bondId | ) | const

Get the set of bonded atoms corresponding to bondId.

Parameters

  bondId | The index of the requested bond.

Returns
  The bonded atom pair, represented as a pair of atom indices.

## setBondPairs()

bool setBondPairs | ( | const Array< std::pair< Index, Index > > & | pairs | ) |

Replace the current array of bonded atoms.

Parameters

  pairs | The array.

Returns
  True on success, false on failure.

Note
  The bonded atoms are represented as a pair of bond indices.
  If needed, the elements in pairs will be modified to ensure that the first atom index is less than the second.

## bondPairs()

const Array< std::pair< Index, Index > > & bondPairs | ( |  | ) | const

Returns
  a vector of pairs of atom indices of the bonds in the molecule.

## bondOrders()

const Array< unsigned char > & bondOrders | ( |  | ) | const

Returns
  a vector of the bond orders for the bonds in the molecule.

## graph()

const Graph & graph | ( |  | ) | const

Returns
  the graph for the molecule.

## atomicNumbers()

const Array< unsigned char > & atomicNumbers | ( |  | ) | const

Returns
  a vector of atomic numbers for the atoms in the molecule.

## atomicNumber()

unsigned char atomicNumber | ( | Index | atomId | ) | const

Get the atomic number for the requested atom.

Parameters

  atomId | The index of the atom.

Returns
  The atomic number of the atom indexed at atomId, or Avogadro::InvalidElement if atomId is invalid.

## setBondOrders()

bool setBondOrders | ( | const Array< unsigned char > & | orders | ) |

Replace the current array of bond orders.

Parameters

  orders | The new array.

Returns
  True on success, false on failure.

## setBondOrder()

bool setBondOrder | ( | Index | bondId,
|  | unsigned char | order )

Set the order of a bond in the molecule.

Parameters

  bondId | The bond's index.
  order | The new order of the bond.

Returns
  True on success, false on failure.

## hasCustomElements()

bool hasCustomElements | ( |  | ) | const

Returns
  True if custom elements exist in the molecule.

Note
  Custom element atomic numbers lie between CustomElementMin and CustomElementMax.

## setBondPair()

bool setBondPair | ( | Index | bondId,
|  | const std::pair< Index, Index > & | pair )

Set the bonded atoms for a bond.

Parameters

  bondId | The bond to modify.
  pair | The new bond pair.

Returns
  True on success, false otherwise.

Note
  If needed, pair will be modified to ensure that the first atom index is less than the second.

## bondOrder()

unsigned char bondOrder | ( | Index | bondId | ) | const

Get the order of a bond.

Parameters

  bondId | The id of the bond.

Returns
  The bond order.

## setAtomicNumbers()

bool setAtomicNumbers | ( | const Core::Array< unsigned char > & | nums | ) |

Replace the current array of atomic numbers.

Parameters

  nums | The new atomic number array. Must be of length atomCount().

Returns
  True on success, false otherwise.

## setAtomicNumber()

bool setAtomicNumber | ( | Index | atomId,
|  | unsigned char | atomicNumber )

Set the atomic number of a single atom.

Parameters

  atomId | The index of the atom to modify.
  atomicNumber | The new atomic number.

Returns
  True on success, false otherwise.

## addConstraint() [1/2]

void addConstraint | ( | Real | Value,
|  | Index | a,
|  | Index | b,
|  | Index | c = MaxIndex,
|  | Index | d = MaxIndex )

Freeze or unfreeze an atom for optimization

## addConstraint() [2/2]

void addConstraint | ( | Constraint & | c | ) |

Freeze or unfreeze an atom for optimization

## removeConstraint()

void removeConstraint | ( | Index | a,
|  | Index | b,
|  | Index | c = MaxIndex,
|  | Index | d = MaxIndex )

Freeze or unfreeze an atom for optimization

## clearConstraints()

void clearConstraints | ( |  | ) |

Freeze or unfreeze an atom for optimization

## setConstraints()

void setConstraints | ( | const std::vector< Core::Constraint > & | constraints | ) |

Freeze or unfreeze an atom for optimization

## constraints() [1/2]

std::vector< Core::Constraint > & constraints | ( |  | ) |

Freeze or unfreeze an atom for optimization

## constraints() [2/2]

const std::vector< Core::Constraint > & constraints | ( |  | ) | const

Freeze or unfreeze an atom for optimization

## setFrozenAtom()

void setFrozenAtom | ( | Index | atomId,
|  | bool | frozen )

Freeze or unfreeze an atom for optimization

## frozenAtom()

bool frozenAtom | ( | Index | atomId | ) | const

Returns
  whether the specified atom is frozen

## frozenAtomAxis()

bool frozenAtomAxis | ( | Index | atomId,
|  | int | axis ) const

Parameters

  atomId | The index of the atom to check
  axis | The axis to check (0 = x, 1 = y, 2 = z)

Returns
  whether the specified axis of the specified atom is frozen

## setFrozenAtomAxis()

void setFrozenAtomAxis | ( | Index | atomId,
|  | int | axis,
|  | bool | frozen )

Freeze or unfreeze X, Y, or Z coordinate of an atom for optimization

Parameters

  atomId | The index of the atom to modify.
  axis | The axis to freeze (0, 1, or 2 for X, Y, or Z)
  frozen | True to freeze, false to unfreeze

## frozenAtomMask()

Eigen::VectorXd frozenAtomMask | ( |  | ) | const

Returns
  the frozen status of atoms (i.e., 3*N array of 1.0 or 0.0) 0.0 means the atom is frozen, 1.0 means the atom is not frozen. (i.e., multiply this mask with gradients to freeze atoms)

## composition()

std::map< unsigned char, size_t > composition | ( |  | ) | const

Returns
  a map of components and count.

## formulaComposition()

std::map< std::string, size_t > formulaComposition | ( |  | ) | const

Returns
  a map of element symbols (including isotopes like D, T, 13C) to their count. Handles unit cell fractional contributions for atoms at corners (1/8), edges (1/4), and faces (1/2).

## getAtomBonds()

Array< std::pair< Index, Index > > getAtomBonds | ( | Index | index | ) | const

Returns
  the atom pairs for all bonds to the atom indexed at index.

## getAtomOrders()

Array< unsigned char > getAtomOrders | ( | Index | index | ) | const

Returns
  the bond orders for all bonds to the atom indexed at index.

## removeBonds()

bool removeBonds | ( | Index | atom | ) |

Remove bonds to atom

## boundingBox()

void boundingBox | ( | Vector3 & | boxMin,
|  | Vector3 & | boxMax,
|  | const double | radius = 1.0 ) const

Calculte and return bounding box of the whole molecule or selected atoms only.

Parameters

  boxMin | [out] the minimum corner (first end of the box diagonal)
  boxMax | [out] the maximum corner (second end of the box diagonal)
  radius | [in] radius of a single sphere

## Member Data Documentation

## m_elements

ElementMask m_elements

protected

Which elements this molecule contains (e.g., for force fields)

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

- core/molecule.h