14.2 Bond Stereochemistry

Stereochemistry around bonds can be specified in a similar fashion to stereochemistry about atom centers. The request for stereochemistry of a particular class can be made of an OEBondBase using the function HasStereoSpecified(unsigned int type). The type argument provided to HasStereoSpecified() indicates the type of stereochemistry requested, and must be one of the constants listed in the OEBondStereo namespace. The most commonly requested stereochemistry value of bonds is whether the configuration of two atoms around a non-rotatable bond is cis or trans. The following code sample demonstrates a loop over bonds which tests for bonds with associated stereochemistry, and retrieval of whether the neighboring atoms are cis or trans relative to one another.

#include "oechem.h"
#include <iostream>
#include <vector>

using namespace OESystem;
using namespace OEChem;
using namespace std;

int main()
{
  OEMol mol;
  OEParseSmiles(mol, "C/C=C/C");

  OEIter<OEBondBase> bond;
  for (bond = mol.GetBonds();bond;++bond)
  {
    if (bond->HasStereoSpecified(OEBondStereo::CisTrans))
    {
      OEIter<OEAtomBase> atom1,atom2;
      for (atom1 = bond->GetBgn()->GetAtoms();atom1;++atom1)
        if (atom1 != bond->GetEnd())
        {
          for (atom2 = bond->GetEnd()->GetAtoms();atom2;++atom2)
            if (atom2 != bond->GetBgn())
            {
              std::vector<OEAtomBase*> v;
              v.push_back(atom1);
              v.push_back(atom2);

              unsigned int stereovalue =
                bond->GetStereo(v,OEBondStereo::CisTrans);

              cerr << "Atoms: " << atom1->GetIdx() << " and ";
              cerr << atom2->GetIdx() << " are ";

              if (stereovalue == OEBondStereo::Cis)
                cerr << "cis" << endl;
              else if (stereovalue == OEBondStereo::Trans)
                cerr << "trans" << endl;
              else
                cerr << "neither cis nor trans" << endl;
            }
        }
    }
  }
  return 0;
}

Stereochemistry values can be associated with a bond using the SetStereo(const std::vector<OEAtomBase*> &,unsigned int type, unsigned int value) function. The STL vector must contain atoms which are connected to the atoms on either end of the bond on which stereochemistry is being set. The order of the atoms in the STL vector relative to the beginning and end of the bond does not matter. The first unsigned integer argument to the function is used to specify the type of stereochemistry (i.e. OEBondStereo::CisTrans). The second unsigned integer argument is used to set the value (i.e. OEBondStereo::Cis or OEBondStereo::Trans) to be associated with the stereochemistry type.