Andreas Maunz wrote: > Hello Craig, > > Craig A. James wrote on 11/16/2009 06:12 PM: >> You may be able to do this using recursive SMARTS. In a recursive >> SMARTS, an atom expression can itself be a whole SMARTS, ad infinitum. >> And since an atom can be an OR list of alternatives, you can have an >> atom that is "This OR that", where "this" and "that" are entire SMARTS >> expressions. I'm not sure if this is what you want, but it might be >> something like this: >> >> [#6]-[$([#6]),$([#6]-[#8])]=[#6] > > This reads: > > 1. (carbon) attached to > 2. ((a) a carbon OR (b) a carbon attached to an oxygen) attached to > 3. (an oxygen), > > whereas it is implicitly meant that in case of 2.(b) a branch occurs: > > 1.2.3. > C-C=C > | > O > > this is due to the semantics of a recursive expression as "a single atom > with special properties". > In case of 2.(b) the C has the special property of being > (branch-)connected to an O, compared to case 2.(a) > with no special properties for the C. > Am I right here? If yes, this would be the solution I was looking for.
Yes, that's right. > Another aspect of this specific example: > Case 2.(b) is a special case of 2.(a), so that every time 2.(b) matches, > 2.(a) also matches. > Therefore, in this case, 2.(b) is not needed at all and the expression > [#6]-[#6]=[#6] would have done the job as well. Exactly. This was just a toy example. In real life, your alternatives would be chemically meaningful, such as electronegativity or aromaticity, things that can't be easily expressed as a single atom expression. > In general, a recursive smarts is only necessary if the alternatives are > mutually exclusive. > Is this also correct? That's right. Simple atomic expressions are often sufficient, for example it's easy to write "halogens but not iodine" as [Cl,Br,F]. It's very rare to need a recursive SMARTS, but when you do, it's invaluable. One last thing to beware of. The recursive match is truly recursive, which means that only the "head" atom of the recursive expression is marked as "used" once the recursion finishes. For example, the smarts "C[$(CO)]O" would match the molecule "CCO". The recursive "CO" expression would match the center carbon, because it does in fact have an attached oxygen. But then the final "O" in the SMARTS would *also* match that same oxygen, because once match for [$(CO)] finished, the pattern matcher "forgot" about the oxygen, leaving only the central "C" is marked as the matched atom. Craig ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss