babel.h File Reference

Detailed Description

Definition of the minimalistic Cuik-OpenBabel interface.

See Also
babel.cpp

Definition in file babel.h.

Typedefs

typedef void TBondIterator
 Iterator over the neighbours of a given atom. More...
 
typedef void TMolecule
 The molecule handler type. More...
 

Functions

TMoleculeReadMolecule (char *fname)
 Reads the molecule information from a file. More...
 
void WriteMolecule (char *fname, TMolecule *m)
 Writes the molecule information to a file. More...
 
unsigned int nAtoms (TMolecule *ml)
 Number of atoms in a molecule. More...
 
unsigned int GetAtomicNumber (unsigned int na, TMolecule *ml)
 Returns the atomic number of a given atom. More...
 
unsigned int GetAtomResidue (unsigned int na, TMolecule *ml)
 Returns the residue of a given atom. More...
 
char GetAtomChain (unsigned int na, TMolecule *ml)
 Returns a char identifying the chain of the atom. More...
 
boolean IsAtomInProline (unsigned int na, TMolecule *ml)
 Identifies atoms in proline residues. More...
 
double VdWRadius (unsigned int na, TMolecule *ml)
 Returns the Van der Waals radius for a given atom. More...
 
boolean HasBond (unsigned int na1, unsigned int na2, TMolecule *ml)
 Determines is a given bond exists. More...
 
void AddBond (unsigned int na1, unsigned int na2, TMolecule *ml)
 Adds a bond between two atoms. More...
 
void RemoveBond (unsigned int na1, unsigned int na2, TMolecule *ml)
 Removes a bond between two atoms. More...
 
unsigned int GetFirstNeighbour (unsigned int na, boolean *fix, TBondIterator **it, TMolecule *ml)
 Gets the identifier of the first neighbour for a given atom in a molecule. More...
 
unsigned int GetNextNeighbour (unsigned int na, boolean *fix, TBondIterator *it, TMolecule *ml)
 Gets the identifier of the next neighbour for a given atom in a molecule. More...
 
void DeleteBondIterator (TBondIterator *it)
 Deletes the bond iterator defined in GetFirstNeighbour. More...
 
void GetAtomCoordinates (double *pos, TMolecule *ml)
 Gets the positions of the atoms in the molecule. More...
 
void SetAtomCoordinates (double *pos, TMolecule *ml)
 Sets the positions of the atoms in the molecule. More...
 
double ComputeEnergy (TMolecule *ml)
 Computes the potential energy of a molecule. More...
 
void DeleteMolecule (TMolecule *ml)
 Destructor. More...
 

Typedef Documentation

typedef void TBondIterator

Iterator over the neighbours of a given atom.

Definition at line 26 of file babel.h.

typedef void TMolecule

This is a dummy type used to hold a reference to the molecule information.

Definition at line 33 of file babel.h.

Function Documentation

TMolecule* ReadMolecule ( char *  fname)

Initializes the molecule information from a file.

This function also sets up the force field to be used for energy computations. For small molecules (less than 100 atoms) we use the MMFF94 force field. For larger ones we use the Generalized Amber Force Field (GAFF). The idea is that larger molecules correspond to proteins where the GAFF is more accurate.

Parameters
fnameName of the file from where to read the molecule information. The format of the file is deduced from the extension. All the formats available to OpenBabel can be used.
Returns
The molecule handler.

Definition at line 46 of file babel.cpp.

References TMolInfo::ff, and TMolInfo::mol.

Referenced by InitBioWorld().

void WriteMolecule ( char *  fname,
TMolecule m 
)

Stores the molecule information into a file (eg. a pdb).

Parameters
fnameThe name fo the file where to store the information. The format of the file is deduced from the extension. All the formats available to OpenBabel can be used.
mThe molecule to save.

Definition at line 79 of file babel.cpp.

References Error(), and TMolInfo::mol.

Referenced by SaveBioWorldBioInfo().

unsigned int nAtoms ( TMolecule ml)

Number of atoms in a molecule.

Parameters
mlThe molecule to query.
Returns
The number of atoms in a molecule.

Definition at line 100 of file babel.cpp.

References TMolInfo::mol.

Referenced by GetMoleculeBasicInfo().

unsigned int GetAtomicNumber ( unsigned int  na,
TMolecule ml 
)

Returns the atomic number of a given atom.

Parameters
naThe atom whose atomic number is queried.
mlThe molecule to query.
Returns
The atomic number of the atom.

Definition at line 109 of file babel.cpp.

References TMolInfo::mol.

Referenced by AdjustBioWorldGeometry(), Atoms2Transforms(), DetectLinksAndJointsFromResidues(), and InitWorldFromMolecule().

unsigned int GetAtomResidue ( unsigned int  na,
TMolecule ml 
)

Returns the number of the residue including the given atom.

Parameters
naThe atom whose residue is queried.
mlThe molecule to query.
Returns
The number of the residue including the atom or NO_UINT if the atom is not in a residue.

Definition at line 121 of file babel.cpp.

References TMolInfo::mol, and NO_UINT.

Referenced by Atoms2Transforms(), and DetectLinksAndJointsFromResidues().

char GetAtomChain ( unsigned int  na,
TMolecule ml 
)

Returns a char identifying the chain of the atom (A B C...). Only works for atoms in residues.

Parameters
naThe atom whose chain is queried.
mlThe molecule to query.
Returns
The chain or '-' if the atom is not in a residue.

Definition at line 138 of file babel.cpp.

References TMolInfo::mol.

Referenced by DetectLinksAndJointsFromResidues().

boolean IsAtomInProline ( unsigned int  na,
TMolecule ml 
)

Identifies atoms in proline residues.

Parameters
naThe atom to query.
mlThe molecule to query.
Returns
TRUE if the atom is in a proline.

Definition at line 155 of file babel.cpp.

References FALSE, and TMolInfo::mol.

Referenced by DetectLinksAndJointsFromResidues().

double VdWRadius ( unsigned int  na,
TMolecule ml 
)

Returns the Van der Waals radius for a given atom.

This is used for representation purposes.

The returned value is the standard VdW radius, that can be different from the VdW parameters used in the force field. Thus, this parameter can be adjusted (scaled down) if you want use this radius to radpidly discard high-energy conformations.

Parameters
naThe atom whose neighbours are to be queried.
mlThe molecule to query.
Returns
The Van der Waals radius.

Definition at line 172 of file babel.cpp.

References TMolInfo::mol.

Referenced by GetMoleculeBasicInfo(), and InitWorldFromMolecule().

boolean HasBond ( unsigned int  na1,
unsigned int  na2,
TMolecule ml 
)

Determines if a bond between a given pair of atoms exists.

Parameters
na1The index of the first atom (num. from 0).
na2The index of the second atom (num. from 0).
mlThe molecule to query.
Returns
TRUE if the bond exits.

Definition at line 184 of file babel.cpp.

References FALSE, TMolInfo::mol, and TRUE.

Referenced by Atoms2Transforms(), and ReadRigidsAndHinges().

void AddBond ( unsigned int  na1,
unsigned int  na2,
TMolecule ml 
)

Adds a simple bond between the two given atoms. If the bond already exists it is re-added (probably OpenBabel takes care of removing duplicates). To ensure no duplicates are introduced use HasBond before adding it.

Parameters
na1The index of the first atom to bond (num. from 0).
na2The index of the second atom to bond (num. from 0).
mlThe molecule to modify.

Definition at line 209 of file babel.cpp.

References TMolInfo::mol.

Referenced by ReadRigidsAndHinges().

void RemoveBond ( unsigned int  na1,
unsigned int  na2,
TMolecule ml 
)

Removes a bond between the two given atoms. No check is done on whether the bond actually exists.

Parameters
na1The index of the first atom to bond (num. from 0).
na2The index of the second atom to bond (num. from 0).
mlThe molecule to modify.

Definition at line 218 of file babel.cpp.

References TMolInfo::mol.

Referenced by InitBioWorld().

unsigned int GetFirstNeighbour ( unsigned int  na,
boolean fix,
TBondIterator **  it,
TMolecule ml 
)

Gets the identifier of the first neighbour of a given atom in the molecule.

Parameters
naThe atom whose neighbours are to be queried.
fixTRUE if the bond is fixed (it does not allow any rotation).
itIterator over the bonds of this atoms. To be used in subsequent calls to GetNextNeighbour.
mlThe molecule to query.
Returns
The identifier of the first neighbour of the given atom.

Definition at line 244 of file babel.cpp.

References FALSE, TMolInfo::mol, and NO_UINT.

Referenced by AdjustBioWorldGeometry(), Atoms2Transforms(), DetectLinksAndJoints(), DetectLinksAndJointsFromResidues(), DetectLinksAndJointsFromRigidsAndHinges(), GetMoleculeBasicInfo(), and InitWorldFromMolecule().

unsigned int GetNextNeighbour ( unsigned int  na,
boolean fix,
TBondIterator it,
TMolecule ml 
)

Gets the identifier of the next neighbour of a given atom in the molecule.

Parameters
naThe atom whose neighbours are to be queried.
fixTRUE if the bond is fixed (it does not allow any rotation).
itIterator over the bonds of this atoms created in GetNextNeighbour. Note that if the atom identifier (na) is not the same as that used when calling GetNextNeighbour the behavior is undefined.
mlThe molecule to query.
Returns
The identifier of the next neighbour of the given atom. NO_UINT if there are no more neighbours.

Definition at line 271 of file babel.cpp.

References FALSE, TMolInfo::mol, and NO_UINT.

Referenced by AdjustBioWorldGeometry(), Atoms2Transforms(), DetectLinksAndJoints(), DetectLinksAndJointsFromResidues(), DetectLinksAndJointsFromRigidsAndHinges(), GetMoleculeBasicInfo(), and InitWorldFromMolecule().

void DeleteBondIterator ( TBondIterator it)
void GetAtomCoordinates ( double *  pos,
TMolecule ml 
)

Gets the 3D positions of the atoms in the molecule.

The space for the buffer must be allocated externally before using this function.

This is typically used only once, after reading the molecule from file to have access to the "default" atom positions. After this we typically call SetAtomCoordinates so that the molecule and our system share the same vector of atom position.

Parameters
posBuffer where to store the positions (size 3*num_atoms)
mlThe molecule to query.

Definition at line 308 of file babel.cpp.

References TMolInfo::mol.

Referenced by GetAtomPositions().

void SetAtomCoordinates ( double *  pos,
TMolecule ml 
)

Sets the 3D positions of the atoms in the molecule.

Note that this only need to be done once. The molecule store a pointer to the given array of positions that can be latter on modified externally.

Parameters
posBuffer from where to get the positions (size 3*num_atoms)
mlThe molecule to query.

Definition at line 325 of file babel.cpp.

References TMolInfo::mol.

Referenced by BioWordSetAtomPositionsFromConformation(), and InitBioWorld().

double ComputeEnergy ( TMolecule ml)

Computes the potential energy of a molecule according the the MMFF94 force field.

The different conformations are defined by directly editing the vector of 3D positions of atoms given to the molecule using SetAtomCoordinates.

Parameters
mlThe molecule to query.
Returns
The energy value.

Definition at line 334 of file babel.cpp.

References Error(), TMolInfo::ff, and TMolInfo::mol.

Referenced by BioWorldEnergy().

void DeleteMolecule ( TMolecule ml)

Molecule information destructor.

Parameters
mlThe molecule to delete.

Definition at line 353 of file babel.cpp.

Referenced by DeleteBioWorld().