indigoX
Molecule Class Reference

#include <indigox/classes/molecule.hpp>

Classes

struct  Impl
 

Public Types

using MoleculeAngles = std::vector< Angle >
 Container for storing IXAngle instances. More...
 
using MoleculeAtoms = std::vector< Atom >
 Container for storing IXAtom instances. More...
 
using MoleculeBonds = std::vector< Bond >
 Container for storing IXBond instances. More...
 
using MoleculeDihedrals = std::vector< Dihedral >
 Container for storing IXDihedral instances. More...
 
using MoleculeResidues = std::vector< Residue >
 

Public Member Functions

 Molecule (std::string name)
 Default constructor. More...
 
 Molecule ()=default
 
 Molecule (Molecule &&)=default
 
 Molecule (const Molecule &)=default
 
 ~ Molecule ()=default
 
Angle GetAngle (uint32_t pos)
 Get the angle at position pos. More...
 
Angle GetAngle (const Atom &a, const Atom &b, const Atom &c)
 Get the angle between three atoms, if it exists. More...
 
Angle GetAngleID (int64_t id) const
 Get the angle with the given id. More...
 
const MoleculeAnglesGetAngles ()
 
Angle GetAngleTag (int64_t tag) const
 Get the first angle with the given tag. More...
 
Atom GetAtom (uint32_t pos) const
 Get the atom at position pos. More...
 
Atom GetAtomID (int64_t id) const
 Get the atom with the given id. More...
 
const MoleculeAtomsGetAtoms () const
 
Atom GetAtomTag (int64_t tag) const
 Get the first atom with the given tag. More...
 
Bond GetBond (uint32_t pos) const
 Get the bond at position pos. More...
 
Bond GetBond (const Atom &a, const Atom &b) const
 Get the bond between two atoms, if it exists. More...
 
Bond GetBondID (int64_t id) const
 Get the bond with the given id. More...
 
const MoleculeBondsGetBonds () const
 
Bond GetBondTag (int64_t tag) const
 Get the first bond with the given tag. More...
 
const graph::CondensedMolecularGraphGetCondensedGraph () const
 
Dihedral GetDihedral (uint32_t pos)
 Get the angle at position pos. More...
 
Dihedral GetDihedral (const Atom &a, const Atom &b, const Atom &c, const Atom &d)
 Get the dihedral between four atoms, it if exists. More...
 
Dihedral GetDihedralID (int64_t id) const
 Get the dihedral with the given id. More...
 
const MoleculeDihedralsGetDihedrals ()
 
Dihedral GetDihedralTag (int64_t tag) const
 Get the first dihedral with the given tag. More...
 
const ForcefieldGetForcefield () const
 
std::string GetFormula ()
 Get the molecular formula of the molecule. More...
 
const graph::MolecularGraphGetGraph () const
 Get the molecular graph for this molecule. More...
 
int32_t GetMolecularCharge () const
 Get the molecular charge of the molecule. More...
 
const std::string & GetName () const
 Get the name of the molecule. More...
 
Residue GetResidueID (int32_t id)
 
const MoleculeResiduesGetResidues ()
 
bool HasAngle (const Angle &angle) const
 Check if the angle is owned by this molecule. More...
 
bool HasAngle (const Atom &a, const Atom &b, const Atom &c)
 Check if an angle between three atoms exists in this molecule. More...
 
bool HasAtom (const Atom &atom) const
 Check if the atom is owned by this molecule. More...
 
bool HasBond (const Bond &bond) const
 Check if the bond is owned by this molecule. More...
 
bool HasBond (const Atom &a, const Atom &b) const
 Check if a bond between two atoms exists in this molecule. More...
 
bool HasDihedral (const Dihedral &dihedral) const
 Check if the dihedral is owned by this molecule. More...
 
bool HasDihedral (const Atom &a, const Atom &b, const Atom &c, const Atom &d)
 Check if a dihedral between four atoms exists in this molecule. More...
 
bool HasForcefield () const
 
void ModificationMade ()
 
Atom NewAtom ()
 Create a new atom owned by the molecule. More...
 
Atom NewAtom (const Element &element)
 Create a new atom of the given element for the molecule. More...
 
Atom NewAtom (const Element &element, double x, double y, double z)
 Create a new named atom of the given element for the molecule. More...
 
Bond NewBond (const Atom &a, const Atom &b)
 Create a bond between two atoms. More...
 
Dihedral NewDihedral (const Atom &a, const Atom &b, const Atom &c, const Atom &d)
 Create a dihedral between four atoms. More...
 
int64_t NumAngles ()
 Get the number of angles in the molecule. More...
 
int64_t NumAtoms () const
 Get the number of atoms in the molecule. More...
 
int64_t NumBonds () const
 Get the number of bonds in the molecule. More...
 
int64_t NumDihedrals ()
 Get the number of dihedrals in the molecule. More...
 
 operator bool () const
 
bool operator!= (const Molecule &mol) const
 
bool operator< (const Molecule &mol) const
 
bool operator<= (const Molecule &mol) const
 
Moleculeoperator= (Molecule &&)=default
 
Moleculeoperator= (const Molecule &)=default
 
bool operator== (const Molecule &mol) const
 
bool operator> (const Molecule &mol) const
 
bool operator>= (const Molecule &mol) const
 
void OptimiseChargeGroups ()
 
int64_t PerceiveAngles ()
 Determine angles in the molecule. More...
 
int64_t PerceiveDihedrals ()
 Determine dihedrals in the molecule. More...
 
int32_t PerceiveResidues ()
 
bool RemoveAtom (const Atom &atom)
 Remove an atom from the molecule. More...
 
bool RemoveBond (const Bond &bond)
 Remove a bond from the molecule. More...
 
bool RemoveBond (const Atom &a, const Atom &b)
 Remove a bond between two atoms. More...
 
void ReorderAtoms (MoleculeAtoms &new_order)
 
void ReserveAtoms (int64_t num)
 Reserve storage space for atoms. More...
 
void ReserveBonds (int64_t num)
 Reserve storage space for bonds. More...
 
void ResetForcefield (const Forcefield &ff)
 
void SetForcefield (const Forcefield &ff)
 
void SetMolecularCharge (int32_t q)
 Set the molecular charge of the molecule. More...
 
void SetName (std::string name)
 Set the name of the molecule. More...
 

Friends

class cereal::access
 Friendship allows serialisation. More...
 
std::ostream & operator<< (std::ostream &os, const Molecule &mol)
 

Member Typedef Documentation

◆ MoleculeAngles

using MoleculeAngles = std::vector<Angle>

Container for storing IXAngle instances.

A molecule takes ownership of all angles it contains.

◆ MoleculeAtoms

using MoleculeAtoms = std::vector<Atom>

Container for storing IXAtom instances.

A molecule takes ownership of all atoms it contains.

◆ MoleculeBonds

using MoleculeBonds = std::vector<Bond>

Container for storing IXBond instances.

A molecule takes ownership of all bonds it contains.

◆ MoleculeDihedrals

using MoleculeDihedrals = std::vector<Dihedral>

Container for storing IXDihedral instances.

A molecule takes ownership of all dihedrals it contains.

◆ MoleculeResidues

using MoleculeResidues = std::vector<Residue>

Constructor & Destructor Documentation

◆ Molecule() [1/4]

Molecule ( std::string  name)

Default constructor.

Is private to enforce that IXMolecules should only be used via the Molecule shared_ptr.

◆ Molecule() [2/4]

Molecule ( )
default

◆ Molecule() [3/4]

Molecule ( const Molecule )
default

◆ Molecule() [4/4]

Molecule ( Molecule &&  )
default

◆ ~ Molecule()

~ Molecule ( )
default

Member Function Documentation

◆ GetAngle() [1/2]

Angle GetAngle ( uint32_t  pos)

Get the angle at position pos.

Returns the angle at pos after a range check. If pos is not a valid index, returns an empty shared_ptr. Positioning of angles may change during normal operations. Angles are not re-percieved prior to retrieving the angle.

Parameters
posthe position of the angle to get.
Returns
the angle at pos or an empty shared_ptr.

◆ GetAngle() [2/2]

Angle GetAngle ( const Atom a,
const Atom b,
const Atom c 
)

Get the angle between three atoms, if it exists.

Searches for an angle between the three atoms and returns it. If no angle is found, the returned shared_ptr is empty. Angles are re-perceived prior to searching.

Parameters
a,b,cthe atoms to get the angle between. b is the central atom.
Returns
the angle between a and c centred on b.

◆ GetAngleID()

Angle GetAngleID ( int64_t  id) const

Get the angle with the given id.

Returns the angle with the given unique id. If no such angle is found returns an empty shared_ptr. As the unique id of any created angles will be unknown, angles are not re-percieved prior to searching.

Parameters
idthe unique id of the angle to retrieve.
Returns
the angle with the given id or an empty shared_ptr.

◆ GetAngles()

const MoleculeAngles& GetAngles ( )

◆ GetAngleTag()

Angle GetAngleTag ( int64_t  tag) const

Get the first angle with the given tag.

Returns the first angle with a tag matching that given. If no such angle is found, returns an empty shared_ptr. As tags are not set on creation of angles, angles are not re-percieved prior to searching.

Parameters
tagthe angle tag to search for.
Returns
the first angle with the tag or an empty shared_ptr.

◆ GetAtom()

Atom GetAtom ( uint32_t  pos) const

Get the atom at position pos.

Returns that atom at pos after a range check. If pos is not a valid index, returns an empty shared_ptr. Positioning of atoms may change during normal operations.

Parameters
posthe position of the atom to get.
Returns
the atom at pos or an empty shared_ptr.

◆ GetAtomID()

Atom GetAtomID ( int64_t  id) const

Get the atom with the given id.

Returns the atom with the given unique id. If no such atom is found returns an empty shared_ptr.

Parameters
idthe unique id of the atom to retrieve.
Returns
the atom with the given id or an empty shared_ptr.

◆ GetAtoms()

const MoleculeAtoms& GetAtoms ( ) const

◆ GetAtomTag()

Atom GetAtomTag ( int64_t  tag) const

Get the first atom with the given tag.

Returns the first atom with a tag matching that given. If no such atom is found, returns an empty shared_ptr.

Parameters
tagthe atom tag to search for.
Returns
the first atom with the tag or an empty shared_ptr.

◆ GetBond() [1/2]

Bond GetBond ( uint32_t  pos) const

Get the bond at position pos.

Returns that bond at pos after a range check. If pos is not a valid index, returns an empty shared_ptr. Positioning of bonds may change during normal operations.

Parameters
posthe position of the bond to get.
Returns
the bond at pos or an empty shared_ptr.

◆ GetBond() [2/2]

Bond GetBond ( const Atom a,
const Atom b 
) const

Get the bond between two atoms, if it exists.

Searches for a bond between a and b and returns it. If no bond is found, returns an empty shared_ptr.

Parameters
a,bthe atoms to get the bond between.
Returns
the bond between a and b or an empty shared_ptr.

◆ GetBondID()

Bond GetBondID ( int64_t  id) const

Get the bond with the given id.

Returns the bond with the given unique id. If no such bond is found returns an empty shared_ptr.

Parameters
idthe unique id of the bond to retrieve.
Returns
the bond with the given id or an empty shared_ptr.

◆ GetBonds()

const MoleculeBonds& GetBonds ( ) const

◆ GetBondTag()

Bond GetBondTag ( int64_t  tag) const

Get the first bond with the given tag.

Returns the first bond with a tag matching that given. If no such bond is found, returns an empty shared_ptr.

Parameters
tagthe bond tag to search for.
Returns
the first bond with the tag or an empty shared_ptr.

◆ GetCondensedGraph()

const graph::CondensedMolecularGraph& GetCondensedGraph ( ) const

◆ GetDihedral() [1/2]

Dihedral GetDihedral ( uint32_t  pos)

Get the angle at position pos.

Returns the dihedral at pos after a range check. If pos is not a valid index, returns an empty shared_ptr. Positioning of dihedrals may change during normal operations. Dihedrals are not re-perceived prior to retrieving the dihedral.

Parameters
posthe position of the dihedral to get.
Returns
the dihedral at pos or an empty shared_ptr.

◆ GetDihedral() [2/2]

Dihedral GetDihedral ( const Atom a,
const Atom b,
const Atom c,
const Atom d 
)

Get the dihedral between four atoms, it if exists.

Searches for a dihedral between the four atoms and returns it. If no dihedral is found, the returned shared_ptr is empty. Dihedrals are re-perceived prior to searching.

Parameters
a,b,c,dthe atoms to get the dihedral between.
Returns
the dihedral between a, b, c and d.

◆ GetDihedralID()

Dihedral GetDihedralID ( int64_t  id) const

Get the dihedral with the given id.

Returns the dihedral with the given unique id. If no such dihedral is found returns an empty shared_ptr. As the unique id of any created dihedrals will be unknown, dihedrals are not re-perceived prior to searching.

Parameters
idthe unique id of the dihedral to retrieve.
Returns
the dihedral with the given id or an empty shared_ptr.

◆ GetDihedrals()

const MoleculeDihedrals& GetDihedrals ( )

◆ GetDihedralTag()

Dihedral GetDihedralTag ( int64_t  tag) const

Get the first dihedral with the given tag.

Returns the first dihedral with a tag matching that given. If no such dihedral is found, returns an empty shared_ptr. As tags are not set on creation of dihedrals, dihedrals are not re-perceived prior to searching.

Parameters
tagthe dihedral tag to search for.
Returns
the first dihedral with the tag or an empty shraed_ptr.

◆ GetForcefield()

const Forcefield& GetForcefield ( ) const

◆ GetFormula()

std::string GetFormula ( )

Get the molecular formula of the molecule.

Determines the molecular formula of the molecule. The elements of the formula are arranged in the order: carbon, hydrogen and then alphabetically by atomic symbol. The resultant formula is cached and recalculated only when the IXMolecule::ATOM_ELEMENTS property has been modified.

Returns
the molecular formula of the molecule.

◆ GetGraph()

const graph::MolecularGraph& GetGraph ( ) const

Get the molecular graph for this molecule.

Returns
the molecular graph of this molecule.

◆ GetMolecularCharge()

int32_t GetMolecularCharge ( ) const

Get the molecular charge of the molecule.

Returns
the molecular charge of the molecule.

◆ GetName()

const std::string& GetName ( ) const

Get the name of the molecule.

Returns
the name of the molecule.

◆ GetResidueID()

Residue GetResidueID ( int32_t  id)

◆ GetResidues()

const MoleculeResidues& GetResidues ( )

◆ HasAngle() [1/2]

bool HasAngle ( const Angle angle) const

Check if the angle is owned by this molecule.

Parameters
anglethe angle to check for.
Returns
if the angle is owned by this molecule.

◆ HasAngle() [2/2]

bool HasAngle ( const Atom a,
const Atom b,
const Atom c 
)

Check if an angle between three atoms exists in this molecule.

If the Emergent::ANGLE_PERCEPTION property is set, angles are re-percieved prior to check for the existance of the angle. b is the central atom of the angle.

Parameters
a,b,cthe atoms the angle should be between.
Returns
if there is an angle between the three atoms.

◆ HasAtom()

bool HasAtom ( const Atom atom) const

Check if the atom is owned by this molecule.

Parameters
atomthe atom to check for.
Returns
if the atom is owned by this molecule.

◆ HasBond() [1/2]

bool HasBond ( const Bond bond) const

Check if the bond is owned by this molecule.

Parameters
bondthe bond to check for.
Returns
if the bond is owned by this molecule.

◆ HasBond() [2/2]

bool HasBond ( const Atom a,
const Atom b 
) const

Check if a bond between two atoms exists in this molecule.

Parameters
a,bthe atoms the bond should be between.
Returns
if there is a bond between the two atoms.

◆ HasDihedral() [1/2]

bool HasDihedral ( const Dihedral dihedral) const

Check if the dihedral is owned by this molecule.

Parameters
dihedralthe dihedral to check for.
Returns
if the dihedral is owned by this molecule.

◆ HasDihedral() [2/2]

bool HasDihedral ( const Atom a,
const Atom b,
const Atom c,
const Atom d 
)

Check if a dihedral between four atoms exists in this molecule.

If the Emergent::DIHEDRAL_PERCEPTION property is set, dihedrals are re-perceived prior to checking for the existance of the dihedral.

Parameters
a,b,c,dthe atoms the dihedral should be between.
Returns
if there is a dihedral between the four atoms.

◆ HasForcefield()

bool HasForcefield ( ) const

◆ ModificationMade()

void ModificationMade ( )

◆ NewAtom() [1/3]

Atom NewAtom ( )

Create a new atom owned by the molecule.

Returns
the new atom.

◆ NewAtom() [2/3]

Atom NewAtom ( const Element element)

Create a new atom of the given element for the molecule.

Parameters
elementthe element of the new atom.
Returns
the new atom.

◆ NewAtom() [3/3]

Atom NewAtom ( const Element element,
double  x,
double  y,
double  z 
)

Create a new named atom of the given element for the molecule.

Parameters
namethe name of the new atom.
elementthe element of the new atom.
Returns
the new atom.

◆ NewBond()

Bond NewBond ( const Atom a,
const Atom b 
)

Create a bond between two atoms.

To create a bond, both atoms need to be owned by the molecule and there cannot be an existing bond between the atoms. If either condition is not met, the returned shared_ptr is empty.

Parameters
a,bthe atoms to create a bond between.
Returns
the new bond.

◆ NewDihedral()

Dihedral NewDihedral ( const Atom a,
const Atom b,
const Atom c,
const Atom d 
)

Create a dihedral between four atoms.

Parameters
a,b,c,dthe atoms to create the dihedral between.
Returns
the new dihedral.

◆ NumAngles()

int64_t NumAngles ( )

Get the number of angles in the molecule.

If the Emergent::ANGLE_PERCEPTION property is set, angles are re-calculated prior to determining how many there are in the molecule.

Returns
the number of angles in the molecule.

◆ NumAtoms()

int64_t NumAtoms ( ) const

Get the number of atoms in the molecule.

Returns
the number of atoms in the molecule.

◆ NumBonds()

int64_t NumBonds ( ) const

Get the number of bonds in the molecule.

Returns
the number of bonds in the molecule.

◆ NumDihedrals()

int64_t NumDihedrals ( )

Get the number of dihedrals in the molecule.

If the CONNECTIVITY property has been modified, dihedrals are re-calculated prior to determining how many there are in the molecule.

Returns
the number of dihedrals in the molecule.

◆ operator bool()

operator bool ( ) const
inline

◆ operator!=()

bool operator!= ( const Molecule mol) const
inline

◆ operator<()

bool operator< ( const Molecule mol) const

◆ operator<=()

bool operator<= ( const Molecule mol) const
inline

◆ operator=() [1/2]

Molecule& operator= ( Molecule &&  )
default

◆ operator=() [2/2]

Molecule& operator= ( const Molecule )
default

◆ operator==()

bool operator== ( const Molecule mol) const

◆ operator>()

bool operator> ( const Molecule mol) const

◆ operator>=()

bool operator>= ( const Molecule mol) const
inline

◆ OptimiseChargeGroups()

void OptimiseChargeGroups ( )

◆ PerceiveAngles()

int64_t PerceiveAngles ( )

Determine angles in the molecule.

An angle is defined for each group of three connected atoms within a molecule. Subsequent calls to this method will only generate angles which have not been previously generated. Additionally, angles can only be removed by removing an atom or a bond.

Returns
the number of angles added.

◆ PerceiveDihedrals()

int64_t PerceiveDihedrals ( )

Determine dihedrals in the molecule.

A dihedral is defined for each group of four connected atoms within a molecule. Subsequent calls to this method will only generate dihedrals which have not been previously generated. Additionally, dihedrals can only be removed by removing an atom or bond.

Returns
the number of dihedrals added.

◆ PerceiveResidues()

int32_t PerceiveResidues ( )

◆ RemoveAtom()

bool RemoveAtom ( const Atom atom)

Remove an atom from the molecule.

In addition to removing the atom, any bonds to the atom are also removed. A removal will not occur if the atom is not owned by the molecule it is being removed from.

Parameters
atomthe atom to remove.
Returns
if a removal occured.

◆ RemoveBond() [1/2]

bool RemoveBond ( const Bond bond)

Remove a bond from the molecule.

A removal will not occur if the bond is not owned by the molecule it is being removed from. Reference to the bond is removed from both of the atoms of the bond.

Parameters
bondthe bond to remove.
Returns
if a removal occured.

◆ RemoveBond() [2/2]

bool RemoveBond ( const Atom a,
const Atom b 
)

Remove a bond between two atoms.

Parameters
a,bthe atoms to remove a bond between.
Returns
if removal occured.

◆ ReorderAtoms()

void ReorderAtoms ( MoleculeAtoms new_order)

◆ ReserveAtoms()

void ReserveAtoms ( int64_t  num)

Reserve storage space for atoms.

Reserves storage space for a minimum of num IXAtom instances. This is more efficient when building large molecules as the vector will not need to grow as more atoms are added.

Parameters
numthe number of IXAtoms to reserve space for.

◆ ReserveBonds()

void ReserveBonds ( int64_t  num)

Reserve storage space for bonds.

Reserves storage space for a minimum of num IXBond instances. This is more efficient when building large molecules as the vector will not need to grow as more bonds are added.

Parameters
numthe number of IXBonds to reserve space for.

◆ ResetForcefield()

void ResetForcefield ( const Forcefield ff)

◆ SetForcefield()

void SetForcefield ( const Forcefield ff)

◆ SetMolecularCharge()

void SetMolecularCharge ( int32_t  q)

Set the molecular charge of the molecule.

Sets the IXMolecule::ELECTRON_COUNT property as modified.

Parameters
qthe new charge to set.

◆ SetName()

void SetName ( std::string  name)

Set the name of the molecule.

Parameters
namethe new to set.

Friends And Related Function Documentation

◆ cereal::access

friend class cereal::access
friend

Friendship allows serialisation.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Molecule mol 
)
friend

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