I am interested in obtaining fragments, or sub structures, that contain 4 non-hydrogen atoms within a larger molecule.
The closest example to accomplishing this is referenced from https://iwatobipen.wordpress.com/2020/08/12/get-and-draw-molecular-fragment-with-user-defined-path-rdkit-memo/
I used their work but I don't believe "ALL" 4 atom substructures are found within their methodology. They use the concept of "radius" around centered atoms. This doesn't distinguish all possible substructures I am looking for.
Does anyone have suggestions for improving this code to obtaining my goal or a differing direction to go for future work?
I followed the method presented by the link above. Various substructures are presented but not 'ALL' 4 atom fragments are specified when running this method.
Substructure example I don't see using this methodology but I believe I should see at radii 1 or radii 2.1]1
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import AllChem
AllChem.SetPreferCoordGen(True)
def getSubmolRadN(mol, radius):
atoms=mol.GetAtoms()
submols=[]
for atom in atoms:
env=Chem.FindAtomEnvironmentOfRadiusN(mol, radius, atom.GetIdx())
amap={}
submol=Chem.PathToSubmol(mol, env, atomMap=amap)
subsmi=Chem.MolToSmiles(submol, rootedAtAtom=amap[atom.GetIdx()], canonical=False)
submols.append(Chem.MolFromSmiles(subsmi, sanitize=False))
return submols
mol = Chem.MolFromSmiles('C=C(S)C(N)(O)C')
submols = getSubmolRadN(mol,1)
Draw.MolsToGridImage(submols, highlightAtomLists=[[0] for _ in range(len(submols))], molsPerRow=5)
submols = getSubmolRadN(mol,2)
Draw.MolsToGridImage(submols, highlightAtomLists=[[0] for _ in range(len(submols))], molsPerRow=5)
submols = getSubmolRadN(mol,3)
Draw.MolsToGridImage(submols, highlightAtomLists=[[0] for _ in range(len(submols))], molsPerRow=5)