OEHelmToMol
Attention
This is a preliminary API and may be improved based on user feedback. It is currently available in C++ and Python.
bool OEHelmToMol(OEMolBase& mol, const std::string& helm,
const OEMonomerSet& monomers)
bool OEHelmToMol(OEMolBase& mol, const std::string& helm,
const OEMonomerSet& monomers,
OEHelmParsingResult& result)
Converts a HELM string into a molecule. The function will return true if the HELM string can be parsed and interpreted successfully, otherwise the function will return false and a given molecule will be cleared.
- mol
The constructed molecule (
OEMolBase).- helm
The HELM string that is parsed into the molecule.
- monomers
The monomer set (
OEMonomerSet) that stores the monomers that are used to interpret the HELM string.If the given monomer set supports multiple code sets,
OEHelmToMolautomatically selects the code set that contains all monomer codes needed to parse the HELM string.- result
Is specified, the
OEHelmParsingResultobject will store additional parsing information.
After constructing the molecule the following properties are perceived:
Rings are perceived by calling the
OEFindRingAtomsAndBondsfunction.The aromaticity is assigned by calling the
OEAssignAromaticFlagsfunction using theOEAroModel::OpenEyearomaticity model.The chirality is perceived by calling the
OEPerceiveChiralfunction.
Warning
The current implementation of HELM parsing algorithm does not support RNA polymers.
Example
#include <iomanip>
#include <openeye.h>
#include <oesystem.h>
#include <oechem.h>
using namespace OESystem;
using namespace OEChem;
int main()
{
// read monomer set
OEMonomerSet monomers;
OELoadOpenEyeMonomerSet(monomers);
// parse HELM
OEGraphMol mol;
const std::string helm = "PEPTIDE1{C.Y.I.Q.N.C.P.L.G.[am]}$PEPTIDE1,PEPTIDE1,1:R3-6:R3$$$";
OEHelmParsingResult result;
if (OEHelmToMol(mol, helm, monomers, result))
{ // successful parsing
std::cout << "Peptide SMILES: " << OEMolToSmiles(mol) << std::endl;
for (OEIter<OEGroupBase> gi = mol.GetGroups(OEHasGroupType(OEGroupType::Monomer)); gi; ++gi)
{
if (gi->HasData(OEProperty::Monomer))
{
const OEGroupBase* group = gi;
const OEMonomerData monomerData = group->GetData<OEMonomerData>(OEProperty::Monomer);
std::string code = monomerData.GetCode("OpenEye");
std::cout << "code=" << std::left << std::setw(6u) << code << " atoms=";
for (OEIter<OEAtomBase> ai = group->GetAtoms(); ai; ++ai)
std::cout << std::right << std::setw(2u) << ai->GetIdx() << OEGetAtomicSymbol(ai->GetAtomicNum()) << ' ';
std::cout << std::endl;
}
}
}
else
{ // failed parsing
std::cout << "Warning:" << result.GetWarning() << std::endl;
std::cout << helm << std::endl;
std::cerr << std::setfill('-') << std::setw(result.GetErrorPosition()) << "^" << std::endl;
}
return 0;
}
OEHelmToMol can parse HELM strings with embedded SMILES in various styles.
The examples below illustrate valid representations of eledoisin:
1PEPTIDE1{[N1[C@@H](CCC1=O)C([R2])=O].P.S.K.D.A.F.I.G.L.M.[am]}$$$$
2PEPTIDE1{[N1[C@@H](CCC1=O)C([*:2])=O].P.S.K.D.A.F.I.G.L.M.[am]}$$$$
3PEPTIDE1{[N1[C@@H](CCC1=O)C(*)=O |$;;;;;;;_R2;$|].P.S.K.D.A.F.I.G.L.M.[am]}$$$$
In case when the OEHelmToMol function successfully parses a HELM string
the atoms that are generated for a specific monomer are added to a molecule
as a group (OEGroupBase)
See also
[Zhang-2012] publications
OEGetHelmMonomerCodesfunctionOEGetHelmChainNamesfunctionOEMolToHelmfunction
OpenEye Python Cookbook Code Example