Re: [Rdkit-discuss] Question of substructure "neighborhood"
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Wim D. <wim...@gm...> - 2023-06-30 23:22:23
|
Hi Joey,
I think the most straightforward way to do this is to use GetNeighbors() on
all atoms. See below for an example:
from rdkit import Chem
mol=Chem.MolFromSmiles("O1COc2c1ccc(CC(NC)C)c2")
substruct=Chem.MolFromSmarts("c1ccccc1")
a=mol.GetSubstructMatch(substruct)
print("substructure benzene can be found at atoms with idx",a)
extended_idx=set([])
for idx in a:
for n in mol.GetAtomWithIdx(idx).GetNeighbors():
nidx=n.GetIdx()
if nidx not in a and nidx not in extended_idx:
extended_idx.add(nidx)
print("neighboring atoms of substructure benzene are at idx",extended_idx)
print("idx of atoms in entire extended substructure
are",extended_idx.union(a))
if you'd like to include hydrogens in the extending of the substructure as
well you can add explicit hydrogens using mol=Chem.AddHs(mol)
best wishes,
wim
On Fri, Jun 30, 2023 at 11:07 PM Storer, Joey (J) via Rdkit-discuss <
rdk...@li...> wrote:
> Dear RDKit experts,
>
>
>
> Substructure search is working well these days. RDKit is wonderful.
>
>
>
> For subsequent QM calcs., I would like to get the “next atom over” or the
> “one-atom-neighborhood” surrounding a substructure.
>
>
>
> The result would be something bigger than the original substructure with
> open valence capped by Hydrogen.
>
>
>
> Thanks for your thoughts,
>
> Joey Storer
>
> Dow Inc.
>
> General Business
> _______________________________________________
> Rdkit-discuss mailing list
> Rdk...@li...
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
|