Hi Jan,

I don't think there is a way to say "this atom has to be the same type as
that atom" in a SMARTS, but a clunky alternative would be by enumerating
all the elements of interest within a big recursive SMARTS. I hope it won't
be every element in the periodic table! For example, let's say you only
care about C, O, and F:

In [6]: patt = Chem.MolFromSmarts('[C;$(C(C)C),$(C(O)O),$(C(F)F)]')

In [7]: mols = [Chem.MolFromSmiles(s) for s in 'CCC CCO OCO FCF FCO
CCF'.split()]

In [8]: [Chem.MolToSmiles(m) for m in mols if m.HasSubstructMatch(patt)]
Out[8]: ['CCC', 'OCO', 'FCF']

Hope this helps,
Ivan


On Fri, Jul 24, 2020 at 10:07 AM Jan Halborg Jensen <jhjen...@chem.ku.dk>
wrote:

> Is there a way to find a [C]([#X])[#X] pattern, where X=X, that finds
> C(C)C, C(O)O, C(F)F, etc., but not C(C)O, etc.?
>
> Best regards, Jan
>
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to