dt_Handle pattern, molecule, pathset, container;
dt_Integer slen, pcount, acount, bocunt;
dt_String str;
/* Read SMARTS in. */
pattern = dt_smartin(2, "Oa");
/* Optimized for matches on typical molecules. */
str = dt_smarts_opt(&slen, 2, "aO", 0);
printf("The optimized SMARTS expression is %.*s.\n", slen, str);
/* The aromatic oxygen pattern and hydroquinone have
matching paths. */
molecule = dt_smilin(12, "Oc1ccc(O)cc1");
pathset = dt_match(pattern, molecule, 0);
/* There are two oxygen-aromatic paths in hydroquinone. */
pcount = dt_count(pathset, TYP_PATH);
printf("There are %d oxygen-aromatic atom paths in hydroquinone.\n", pcount);
/* The oxygen-aromatic path contains 2 atoms and 1 bond. */
acount = dt_count(pathset, TYP_ATOM);
bcount = dt_count(pathset, TYP_BOND);
printf("The oxygen-aromatic path contains %d atoms and %d bond.\n",
acount/pcount, bcount/pcount);
/* The pathset refers to the molecule as its base. */
if (dt_base(pathset) == molecule)
printf("You can access the molecule through the pathset.\n");
/* Stream the pathset. */
container = dt_stream(pathset, TYP_PATH);
{
dt_Handle path1, pathX, container2, object;
dt_Integer uid;
int i, j;
i=0;
while (NULL_OB != (pathX = dt_next(container))) {
if (0 == i)
path1 = pathX;
i++;
j=0;
container2 = dt_stream(pathX, TYP_ANY);
while (NULL_OB != (object = dt_next(container2))) {
j++;
str = dt_typename(&slen, object);
uid = dt_uid(object);
printf("Path %d object %d is type %.*s with uid %d\n",
i, j, slen, str, uid+1);
}
}
}
dt_reset(container);
pathX = dt_next(container);
if (pathX == path1)
printf("Reset is like rewind.\n");
if (dt_base(pathX) == molecule)
printf("You can access the molecule through the path.\n");
(selected output)
Path 1 object 1 is type atom with uid 1
Path 1 object 2 is type bond with uid 1
Path 1 object 3 is type atom with uid 2
Path 2 object 1 is type atom with uid 6
Path 2 object 2 is type bond with uid 6
Path 2 object 3 is type atom with uid 5
The optimized SMARTS expression is Oa.
There are 2 oxygen-aromatic atom paths in hydroquinone.
The oxygen-aromatic path contains 2 atoms and 1 bond.
You can access the molecule through the pathset.
Path 1 object 1 is type atom with uid 1
Path 1 object 2 is type bond with uid 1
Path 1 object 3 is type atom with uid 2
Path 2 object 1 is type atom with uid 6
Path 2 object 2 is type bond with uid 6
Path 2 object 3 is type atom with uid 5
Reset is like rewind.
You can access the molecule through the path.
|