What Are SMARTS Expressions

Q

What are SMARTS expressions?

✍: FYIcenter.com

A

SMARTS expressions are divided into 3 types:

1. Atom Expressions - An expression that can be evaluated to an atom pattern using atom operations on atoms and atom expressions.

An atom expression must be enclosed in square brackets, if it is not a single simple atom symbol.

Here are some examples of atom expressions of a single atom operand by itself. No operator is used. The object molecule must have at least one atom matching the given atom pattern.

Atom  Description 
----  -----------
C     normal (aliphatic) carbon atom
[#6]  atom with 6 protons (carbon atom) 
c     aromatic carbon atom
[Ca]  calcium atom
[R]   any atom on any ring
[D3]  any atom connected with 3 explicit bonds 
[X3]  any atom connected with 3 total bonds (includes implicit H bonds)
[h2]  any atom connected with 2 implicit hydrogens
[H2]  any atom connected with 2 total hydrogens
a     any aromatic atom
*     any atom

Here are atom operators and their precedences:

Precedence   Operation    Description 
----------   ---------    -----------
4            [!e]         NOT operation, negate expression e
                          The object molecule must have no atom matching 
                          the given atom expression.      

3            [e1&e2]      AND operation, "e1" and "e2" are matched
                          The object molecule must have least one atom matching 
                          both given atom expressions.      

3            [e1e2]       AND operation, same as above, & omitted

2            [e1,e2]      OR operation, "e1" or "e2" is matched
                          The object molecule must have least one atom matching 
                          one of the given atom expressions. 

1            [e1;e2]      AND operation with lower precedence,
                          Same as "&" operation, but evaluated after ",".

2. Bond Expressions - An expression that can be evaluated to a bond pattern using bond operations on bonds and bond expressions.

Here are some examples of bond expressions of one bond operand by itself. No operator is used. The object molecule must have at least one bond matching the given bond pattern.

Bond  Description 
----  -----------
-     single bond (aliphatic), the default bond, can be omitted
=     double bond
#     triple bond
/     directional bond "up"
\     directional bond "down"1
/?    directional bond "up or unspecified"
\?    directional bond "down or unspecified"
:     aromatic bond
@     any ring bond
~     any bond

Here are bond operators and their precedences:

Precedence   Operation    Description 
----------   ---------    -----------
4            !e           NOT operation, negate expression e
                          The object molecule must have no bond matching 
                          the given bond expression.      

3            e1&e2        AND operation, "e1" and "e2" are matched
                          The object molecule must have least one bond matching 
                          both given bond expressions.      

3            e1e2         AND operation, same as above, & omitted

2            e1,e2        OR operation, take "e1" or "e2" is matched
                          The object molecule must have least one bond matching 
                          one of the given bond expressions. 

1            e1;e2        AND operation with lower precedence,
                          Same as "&" operation, but evaluated after ",".

3. Recursive SMARTS Expressions - An expression that can be evaluated to a SMARTS pattern using SMARTS operations on SMARTS and SMARTS expressions.

A SMARTS expression must be enclosed in brackets and prefixed with "$", if it is used in a SMARTS operation.

Here are SMARTS operators and their precedences:

Precedence   Operation    Description 
----------   ---------    -----------
4            !$(e)        NOT operation, negate expression e
                          The object molecule must not match the given 
                          SMARTS expression.      

3            $(e1)&$(e2)  AND operation, "e1" and "e2" are matched
                          The object molecule must have least one bond matching 
                          both given bond expressions.      

3            $(e1)$(e2)   AND operation, same as above, & omitted

2            $(e1),$(e2)  OR operation, take "e1" or "e2" is matched
                          The object molecule must have least one bond matching 
                          one of the given bond expressions. 

1            $(e1);$(e2)  AND operation with lower precedence,
                          Same as "&" operation, but evaluated after ",".

Here are some examples of using SMARTS expressions in "babel" commands:

 

Substructure Search with SMARTS Expressions

Substructure Search with Wildcard Bond "~"

Substructure Search with Open Babel

⇑⇑ Open Babel Tutorials

2020-06-08, 806🔥, 0💬