Daylight v4.9
Release Date: 1 February 2008


dt_smarts_opt - optimize a SMARTS expression

Generic Prototype

dt_smarts_opt(dt_String, dt_Boolean) => dt_String

C Prototype

#include "dt_smarts.h"

dt_String dt_smarts_opt(dt_Integer *len, dt_Integer strlen, dt_string smarts, dt_Integer vmatch)

FORTRAN Prototype

include ''

integer*4 dt_f_smarts_opt(smarts, vmatch, string)

character*() smarts
logical vmatch
character*() string


Interprets the string as a SMARTS expression. Returns a SMARTS string which is equivalent in meaning to the given SMARTS, but that has been reordered to permit quicker matches on typical molecules. The optimized SMARTS is guaranteed to match the exact same sets of objects as the original, although pathsets returned may have their atoms and bonds in different orders.

The parameter vmatch, if TRUE, indicates that the optimization should be performed for use by dt_vmatch(3). Otherwise, the optimization will be performed for use by dt_match(3) and dt_umatch(3). In practical terms, optimizing for dt_match() or dt_umatch() means that the head atom of the optimized string may not be the same as that of the original string, whereas optimizing for dt_vmatch(3) means that the head atom in the SMARTS will not change during the optimization.

The algorithm is based upon rules generated from a database of "typical" organic molecules. Hence, it is not possible to guarantee that the returned string will actually match faster that the original string.

For a reaction pattern, the vmatch parameter may not be set to TRUE (a vector match of a reaction pattern is not allowed).

Return Value

Returns a SMARTS string. The returned string is a newly-allocated string and belongs to the caller. Returns the invalid string if the given SMARTS expression is invalid or is a reaction SMARTS for a vector match.

Related Topics

dt_alloc_pathset(3) dt_alloc_vbind(3) dt_getval(3) dt_match(3) dt_name(3) dt_setval(3) dt_smartin(3) dt_umatch(3) dt_vmatch(3)