bool OESmartsLexReplace(std::string &smarts,
                        const std::vector<std::pair<std::string,std::string> > &bindings)

Replaces all the instances of $varname in the SMARTS pattern smarts with the variables as defined by the mapping in bindings.

The following code demonstrates how to use SmartsLexReplace.

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

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

int main()
  OEGraphMol mol;
  OESmilesToMol(mol, "c1ccccc1Cl chlorobenzene");

  vector<pair<string, string> > bindings;

  bindings.push_back( make_pair( "halogen" , "[$smallhals,$largehals]" ) );
  bindings.push_back( make_pair( "smallhals" , "[F,Cl]" ) );
  bindings.push_back( make_pair( "largehals" , "[Br,I]" ) );

  string smarts("c[$halogen]");
  OESmartsLexReplace(smarts, bindings);
  OEThrow.Info("SMARTS = %s", smarts.c_str());

  OESubSearch subsrch(smarts.c_str());

  OEPrepareSearch(mol, subsrch);
  if (subsrch.SingleMatch(mol))
    OEThrow.Info("Match to %s", mol.GetTitle());

  return 0;

The output of the above code snippet is the following:

SMARTS = c[$([$([F,Cl]),$([Br,I])])]
Match to chlorobenzene