rdkit / homebrew-rdkit

Homebrew formula for rdkit
44 stars 19 forks source link

HasSubstructMatch not working properly #35

Closed ravenlocke closed 7 years ago

ravenlocke commented 8 years ago

Hi all,

I'm a little new to rdkit, so apologies if this is an issue that's either been noted before, or just a result of me doing something completely wrong!

Essentially, I'm just using substructure matching to compare two bonds, but the version that I acquired via home-brew seems to struggle with the following example. This has worked with other versions (e.g., the version I have on a linux VM, which I think I built from source), but not this one:

import rdkit rdkit.version '2016.03.3' import rdkit.Chem as Chem x = Chem.MolFromSmarts('[#15]-[#8-]') y = Chem.MolFromSmarts('[#15]-[#8-]') x.HasSubstructMatch(y) False y.HasSubstructMatch(x) False

Unless I misunderstand how these functions are meant to work, I believe this should return True, not False?

greglandrum commented 8 years ago

To do query-query comparisons correctly (well, mostly correctly), you need to use the useQueryQueryMatches argument to HasSubstrutMatch(). Here's an example on my linux box, the homebrew install should work the same:

In [13]: x = Chem.MolFromSmarts('[#15]-[#8-]')

In [14]: y = Chem.MolFromSmarts('[#15]-[#8-]')

In [15]: x.HasSubstructMatch(y)
Out[15]: False

In [16]: x.HasSubstructMatch(y,useQueryQueryMatches=True)
Out[16]: True