#include <openbabel/data.h>
Public Member Functions | |
OBTypeTable (void) | |
~OBTypeTable () | |
void | ParseLine (const char *) |
unsigned int | 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 |
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. Just as OBElementTable, 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; }
Current atom types include (defined in the top line of the data file types.txt):
OBTypeTable | ( | void | ) |
~OBTypeTable | ( | ) | [inline] |
void ParseLine | ( | const char * | ) | [virtual] |
Specified by particular table classes (parses an individual data line).
Reimplemented from OBGlobalDataBase.
unsigned int GetSize | ( | ) | [inline, virtual] |
bool SetFromType | ( | const char * | from | ) |
bool SetToType | ( | const char * | to | ) |
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
Referenced by OBAtom::GetType().
bool Translate | ( | std::string & | to, | |
const std::string & | from | |||
) |
Translate atom types
std::string Translate | ( | const std::string & | from | ) |
Translate atom types
std::string GetFromType | ( | ) |
std::string GetToType | ( | ) |
void Init | ( | ) | [inherited] |
Read in the data file, falling back as needed.
Referenced by OBAromaticTyper::AssignAromaticFlags(), OBResidueData::AssignBonds(), OBBondTyper::AssignFunctionalGroupBonds(), OBAtomTyper::AssignHyb(), OBAtomTyper::AssignImplicitValence(), OBPhModel::AssignSeedPartialCharge(), OBRingTyper::AssignTypes(), OBAtomTyper::AssignTypes(), OBAtomTyper::CorrectAromaticNitrogens(), OBElementTable::CorrectedBondRad(), OBElementTable::CorrectedVdwRad(), OBPhModel::CorrectForPH(), OBElementTable::GetAllredRochowElectroNeg(), OBElementTable::GetAtomicNum(), OBElementTable::GetCovalentRad(), OBElementTable::GetElectronAffinity(), OBElementTable::GetElectroNeg(), OBIsotopeTable::GetExactMass(), OBTypeTable::GetFromType(), OBElementTable::GetIonization(), OBElementTable::GetMass(), OBElementTable::GetMaxBonds(), OBElementTable::GetName(), OBElementTable::GetNumberOfElements(), OBElementTable::GetRGB(), OBRotorRules::GetRotorIncrements(), OBElementTable::GetSymbol(), OBTypeTable::GetToType(), OBElementTable::GetVdwRad(), OBTypeTable::SetFromType(), OBResidueData::SetResName(), OBTypeTable::SetToType(), and OBTypeTable::Translate().
void SetReadDirectory | ( | char * | dir | ) | [inline, inherited] |
Set the directory before calling Init().
void SetEnvironmentVariable | ( | char * | var | ) | [inline, inherited] |
Set the environment variable to use before calling Init().
bool _init [protected, inherited] |
Whether the data been read already.
Referenced by OBAromaticTyper::AssignAromaticFlags(), OBResidueData::AssignBonds(), OBBondTyper::AssignFunctionalGroupBonds(), OBAtomTyper::AssignHyb(), OBAtomTyper::AssignImplicitValence(), OBPhModel::AssignSeedPartialCharge(), OBRingTyper::AssignTypes(), OBAtomTyper::AssignTypes(), OBAtomTyper::CorrectAromaticNitrogens(), OBElementTable::CorrectedBondRad(), OBElementTable::CorrectedVdwRad(), OBPhModel::CorrectForPH(), OBElementTable::GetAllredRochowElectroNeg(), OBElementTable::GetAtomicNum(), OBElementTable::GetCovalentRad(), OBElementTable::GetElectronAffinity(), OBElementTable::GetElectroNeg(), OBIsotopeTable::GetExactMass(), OBTypeTable::GetFromType(), OBElementTable::GetIonization(), OBElementTable::GetMass(), OBElementTable::GetMaxBonds(), OBElementTable::GetName(), OBElementTable::GetNumberOfElements(), OBElementTable::GetRGB(), OBRotorRules::GetRotorIncrements(), OBElementTable::GetSymbol(), OBTypeTable::GetToType(), OBElementTable::GetVdwRad(), OBGlobalDataBase::Init(), OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), OBTypeTable::OBTypeTable(), OBTypeTable::SetFromType(), OBResidueData::SetResName(), OBTypeTable::SetToType(), and OBTypeTable::Translate().
const char* _dataptr [protected, inherited] |
Default data table if file is unreadable.
Referenced by OBGlobalDataBase::Init(), OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().
std::string _filename [protected, inherited] |
File to search for.
Referenced by OBGlobalDataBase::Init(), OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().
std::string _dir [protected, inherited] |
Data directory for file if _envvar fails.
Referenced by OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().
std::string _subdir [protected, inherited] |
Subdirectory (if using environment variable).
Referenced by OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().
std::string _envvar [protected, inherited] |
Environment variable to check first.
Referenced by OBGlobalDataBase::Init(), OBAromaticTyper::OBAromaticTyper(), OBAtomTyper::OBAtomTyper(), OBBondTyper::OBBondTyper(), OBElementTable::OBElementTable(), OBIsotopeTable::OBIsotopeTable(), OBPhModel::OBPhModel(), OBResidueData::OBResidueData(), OBRingTyper::OBRingTyper(), OBRotorRules::OBRotorRules(), and OBTypeTable::OBTypeTable().