<- Back | Index | Forward ->

Example SMARTS code in C

smart = "CC[N,C]";
pat = dt_smartin(strlen(smart), smart);

smiles = "OCCCN";      /* made-up molecule */
mol = dt_smilin(strlen(smiles), smiles);

pathset = dt_match(pat, mol, 0);
if (pathset != NULL_OB) {
  paths = dt_stream(pathset, TYP_PATH);

  while ( (path = dt_next(paths)) != NULL_OB) {
    atoms = dt_stream(path, TYP_ATOM);

    while ( (atom = dt_next(atoms)) != NULL_OB) {
      s = dt_symbol(&len, atom);
      printf("%*s ", len, s);
    }

    printf("\n");
  }

  dt_dealloc(pathset);
}
dt_dealloc(mol);
dt_dealloc(pat);