On Wed, Mar 5, 2014 at 4:03 PM, Toby Wright <toby.wri...@inhibox.com> wrote:
>
> This is probably related to the above so I thought I'd post it on this
> thread. I am noticing inconsistent behaviour when a molecule created via
> SMARTS that contains an 'or' statement has HasSubstructMatch called on it,
> as opposed to it being the argument to HasSubstructMatch. A simple example
> follows:
>
> > O_or_C = Chem.MolFromSmarts('[O,C]')
> > O = Chem.MolFromSmiles('O')
> > C = Chem.MolFromSmiles('C')
> > O_or_C.HasSubstructMatch(O)
> True
> > O_or_C.HasSubstructMatch(C)
> False
> > O.HasSubstructMatch(O_or_C)
> True
> > C.HasSubstructMatch(O_or_C)
> True
>
> We also see:
> > C_or_O = Chem.MolFromSmarts('[C,O]')
> > C_or_O.HasSubstructMatch(O)
> False
> > C_or_O.HasSubstructMatch(C)
> True
>
> so the order of elements in a SMARTS 'or' statement changes the behaviour,
> which is unexpected.
>
This is indeed related. This is a case I didn't cover above: the
SMILES/SMARTS match. The behavior above is expected from the point of view
of what's in the code, though I can understand how it may not make much
sense from the perspective of someone using the code. :-) The above should
probably return False in both cases.
In general, one should probably expect that using the HasSubstructMatch()
method of a molecule constructed from SMARTS is likely to produce "strange"
results. Getting a general purpose query--query matcher to work is, as far
as I can tell, a decidedly non-trivial problem.
-greg
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss