OEDetectMonomers

Attention

This is a preliminary API and may be improved based on user feedback. It is currently available in C++ and Python.

bool OEDetectMonomers(OEMolBase& mol, const OEMonomerSet& monomers)
bool OEDetectMonomers(OEMolBase& mol, const OEMonomerSet& monomers,
                      const std::string& codeSet)

Detects the monomers defined in the specified monomer set in the given molecule. The function returns true if all atoms in the molecule are part of the defined monomers and false otherwise.

mol

The molecule (OEMolBase) to be searched for monomers.

monomers

The monomer set (OEMonomerSet) that stores the monomers that are being detected.

code-set

The code set to use for detecting monomers, if not specified the primary code-set of the monomer set will be used.

The detected monomers are stored on the molecule as groups (OEGroupBase).

Example

#include <iterator>
#include <string>
#include <vector>

#include <openeye.h>
#include <oesystem.h>
#include <oechem.h>

using namespace OESystem;
using namespace OEChem;

int main()
{
  // read monomer set
  OEMonomerSet monomers;
  OELoadOpenEyeMonomerSet(monomers);

  // generate HELM
  OEGraphMol mol;
  const std::string smiles =
      "CC[C@H](C)[C@H]1C(=O)N[C@H](C(=O)N[C@H](C(=O)N[C@@H](CSSC[C@@H](C(=O)N[C@H]"
      "(C(=O)N1)Cc2ccc(cc2)O)N)C(=O)N3CCC[C@H]3C(=O)N[C@@H](CC(C)C)C(=O)NCC(=O)N)CC(=O)N)CCC(=O)N";
  OESmilesToMol(mol, smiles);
  OEDetectMonomers(mol, monomers);

  std::cout << "Number of monomers detected: " << OECount(mol, OEHasGroupType(OEGroupType::Monomer)) << std::endl;

  std::vector<std::string> monomer_codes;
  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);
      monomer_codes.push_back(monomerData.GetCode("OpenEye"));
    }
  }
  std::copy(monomer_codes.begin(), monomer_codes.end(), std::ostream_iterator<std::string>(std::cout, " "));
  std::cout << std::endl;

  return 0;
}

See also