On Wed, Nov 4, 2009 at 7:54 PM, Greg Landrum <[email protected]> wrote:
>
> On Wed, Nov 4, 2009 at 3:26 PM, Evgueni Kolossov <[email protected]> wrote:
>>
>> I found that SubstructMatch would not work if query is a fragment (with *
>> atoms).
>> Can you suggest solution for this problem?
>
> That's a bug. Dummy atoms (things with atomic number zero) that do not
> have an isotope specification should match anything. If you have a
> sourceforge account, please enter the bug, otherwise let me know and I
> will enter it.
After going back through the code and thinking about this for a while
I'm going to change my original answer: it's not a bug that standard
dummy atoms only match other dummy atoms. When I saw the "*" in the
original message I started thinking about the QueryAtoms produced by a
"*" in SMARTS, which definitely should (and do) match other dummies.
The behavior with standard Atoms is useful for things like flagging
attachment points of R groups on a scaffold. Here's an example:
[5] >>> f= Chem.MolFromSmiles('c1cccnc1*')
[6] >>> p = Chem.MolFromSmarts('c1cccnc1*')
[9] >>> m = Chem.MolFromSmiles('c1ccc(C)nc1*')
Matching using f, which has dummy Atoms only gives one match:
[10] >>> m.GetSubstructMatches(f)
Out[10]: ((0, 1, 2, 3, 5, 6, 7),)
But matching using p, which has a QueryAtom built from "*" matches twice:
[11] >>> m.GetSubstructMatches(p)
Out[11]: ((0, 1, 2, 3, 5, 6, 7), (2, 1, 0, 6, 5, 3, 4))
For your use case, I'd suggest replacing the dummies in your fragments
with QueryAtoms that have the appropriate query, something like this
(not tested):
//---------------------------------------------
#include <GraphMol/RDKitQueries.h>
void replaceDummies(RWMol *frag){
QueryAtom *qat = new QueryAtom();
qat->setQuery(makeAtomNullQuery());
for(unsigned int i=0;i<frag->getNumAtoms();++i){
if(frag->getAtomWithIdx(i)->getAtomicNum()==0){
frag->replaceAtom(i,qat);
}
}
delete qat;
}
//---------------------------------------------
I hope this helps,
-greg
------------------------------------------------------------------------------
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
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss