Loading...
Searching...
No Matches
OBTypeTable Class Reference

`#include <openbabel/data.h>`

Inheritance diagram for OBTypeTable:
[legend]

## Public Member Functions

| OBTypeTable (void)
| ~OBTypeTable ()
void | ParseLine (const char *)
size_t | GetSize ()
bool | SetFromType (const char *)
bool | SetToType (const char *)
bool | Translate (char *to, const char *from)
bool | Translate (std::string &to, const std::string &from)
std::string | Translate (const std::string &from)
std::string | GetFromType ()
std::string | GetToType ()
void | Init ()
void | SetReadDirectory (char *dir)
void | SetEnvironmentVariable (char *var)

## Protected Attributes

bool | _init
const char * | _dataptr
std::string | _filename
std::string | _dir
std::string | _subdir
std::string | _envvar

## Detailed Description

Atom Type Translation Table.

Molecular file formats frequently store information about atoms in an atom type field. Some formats store only the element for each atom, while others include hybridization and local environments, such as the Sybyl mol2 atom type field. The OBTypeTable class acts as a translation table to convert atom types between a number of different molecular file formats. The constructor for OBTypeTable automatically reads the text file types.txt. An instance of OBTypeTable (ttab) is declared external in data.cpp and is referenced as extern OBTypeTable ttab in mol.h. The following code demonstrates how to use the OBTypeTable class to translate the internal representation of atom types in an OBMol Internal to Sybyl Mol2 atom types.

ttab.SetFromType("INT");
ttab.SetToType("SYB");
OBAtom *atom;
vector<OBAtom*>::iterator i;
string src,dst;
for (atom = mol.BeginAtom(i);atom;atom = mol.EndAtom(i))
{
src = atom->GetType();
ttab.Translate(dst,src);
cout << "atom number " << atom->GetIdx() << "has mol2 type " << dst << endl;
}
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBAtom::GetIdx
unsigned int GetIdx() const
Definition atom.h:189
OpenBabel::OBAtom::GetType
char * GetType()
Definition atom.cpp:468
OpenBabel::ttab
OB_EXTERN OBTypeTable ttab
Definition data.h:225

Current atom types include (defined in the top line of the data file types.txt):

- INT (Open Babel internal codes)
- ATN (atomic numbers)
- HYB (hybridization)
- MMD (MacroModel)
- MM2 (MM2 force field)
- XYZ (element symbols from XYZ file format)
- ALC (Alchemy)
- HAD (H added)
- MCML (MacMolecule)
- C3D (Chem3D)
- SYB (Sybyl mol2)
- MOL (Sybyl mol)
- MAP (Gasteiger partial charge types)
- DRE (Dreiding)
- XED (XED format)
- DOK (Dock)
- M3D (Molecular Arts M3D)
- SBN (Sybyl descriptor types for MPD files)
- PCM (PC Model)

## Constructor & Destructor Documentation

## OBTypeTable()

OBTypeTable | ( | void |  | ) |

## ~OBTypeTable()

~OBTypeTable | ( |  | ) |

inline

## Member Function Documentation

## ParseLine()

void ParseLine | ( | const char * |  | ) |

virtual

Specified by particular table classes (parses an individual data line).

Reimplemented from OBGlobalDataBase.

## GetSize()

size_t GetSize | ( |  | ) |

inline virtual

Returns
  the number of atom types in the translation table

Reimplemented from OBGlobalDataBase.

## SetFromType()

bool SetFromType | ( | const char * | from | ) |

Set the initial atom type to be translated.

## SetToType()

bool SetToType | ( | const char * | to | ) |

Set the destination atom type for translation.

## Translate() [1/3]

bool Translate | ( | char * | to,
|  | const char * | from )

Translate atom types.

Translates atom types (to, from), checking for size of destination string and null-terminating as needed

Deprecated
  Because there is no guarantee on the length of an atom type you should consider using std::string instead

Referenced by Translate().

## Translate() [2/3]

bool Translate | ( | std::string & | to,
|  | const std::string & | from )

Translate atom types

Returns
  whether the translation was successful

## Translate() [3/3]

std::string Translate | ( | const std::string & | from | ) |

Translate atom types

Returns
  the translated atom type, or an empty string if not possible

## GetFromType()

std::string GetFromType | ( |  | ) |

Returns
  the initial atom type to be translated

## GetToType()

std::string GetToType | ( |  | ) |

Returns
  the destination atom type for translation

## Init()

void Init | ( |  | ) |

inherited

Read in the data file, falling back as needed.

Referenced by OBResidueData::AssignBonds(), OBBondTyper::AssignFunctionalGroupBonds(), OBAtomTyper::AssignHyb(), OBPhModel::AssignSeedPartialCharge(), OBAtomTyper::AssignTypes(), OBRingTyper::AssignTypes(), OBPhModel::CorrectForPH(), OBTypeTable::GetFromType(), OBRotorRules::GetRotorIncrements(), OBTypeTable::GetToType(), OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBTypeTable::SetFromType(), OBResidueData::SetResName(), OBTypeTable::SetToType(), OBTypeTable::Translate(), OBTypeTable::Translate(), and OBTypeTable::Translate().

## SetReadDirectory()

void SetReadDirectory | ( | char * | dir | ) |

inline inherited

Set the directory before calling Init().

## SetEnvironmentVariable()

void SetEnvironmentVariable | ( | char * | var | ) |

inline inherited

Set the environment variable to use before calling Init().

## Member Data Documentation

## _init

bool _init

protected inherited

Whether the data been read already.

Referenced by OBResidueData::AssignBonds(), OBBondTyper::AssignFunctionalGroupBonds(), OBAtomTyper::AssignHyb(), OBPhModel::AssignSeedPartialCharge(), OBAtomTyper::AssignTypes(), OBRingTyper::AssignTypes(), OBPhModel::CorrectForPH(), OBTypeTable::GetFromType(), OBRotorRules::GetRotorIncrements(), OBTypeTable::GetToType(), Init(), OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBGlobalDataBase(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), OBTypeTable::OBTypeTable(), OBTypeTable::SetFromType(), OBResidueData::SetResName(), OBTypeTable::SetToType(), OBTypeTable::Translate(), OBTypeTable::Translate(), and OBTypeTable::Translate().

## _dataptr

const char* _dataptr

protected inherited

Default data table if file is unreadable.

Referenced by Init(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBGlobalDataBase(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().

## _filename

std::string _filename

protected inherited

File to search for.

Referenced by Init(), OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), OBTypeTable::OBTypeTable(), and OBRotorRules::SetFilename().

## _dir

std::string _dir

protected inherited

Data directory for file if _envvar fails.

Referenced by OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), OBTypeTable::OBTypeTable(), and SetReadDirectory().

## _subdir

std::string _subdir

protected inherited

Subdirectory (if using environment variable).

Referenced by Init(), OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().

## _envvar

std::string _envvar

protected inherited

Environment variable to check first.

Referenced by Init(), OBAtomicHeatOfFormationTable::OBAtomicHeatOfFormationTable(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), OBTypeTable::OBTypeTable(), and SetEnvironmentVariable().

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

- data.h
- data.cpp