Hi Marton,

This is a tricky one because the code is actually doing the right thing.
For situations where you have molecules that differ from each other only in
atom or bond types, I'd suggest using some of the fuzzy MCS functionality
that the RDKit provides.
In your case you could tell the MCS code to ignore atom types:

ps = rdFMCS.MCSParameters()
ps.AtomCompareParameters.RingMatchesRingOnly = True
ps.SetAtomTyper(rdFMCS.AtomCompare.CompareAny)
mcs = rdFMCS.FindMCS([mol1,mol2],ps)


Here's a gist showing what that does:
https://gist.github.com/greglandrum/82d9a86acb3b00d3bb1df502779a5810

-greg


On Thu, Oct 25, 2018 at 11:48 PM Márton Vass <marciavassklan...@gmail.com>
wrote:

> Hi all,
> I'm trying to draw two similar molecules with slightly different scaffolds
> in the same orientation. I can't define a pattern to use
> for GenerateDepictionMatching2DStructure, so I was instead trying to get
> the MCS of the two molecules, get the coordinates of the MCS from the first
> molecule, and use those to depict the second with coordMap, similarly as in
> http://ctr.wikia.com/wiki/Align_the_depiction_using_a_fixed_substructure.
> This gives the required result most of the time, but in some cases the MCS
> has a symmetry element and then the image ends up with distorted rings. Is
> there a way to force rings to be drawn as they should be even when a
> coordMap is used? Please find the code below. Thanks,
> Márton
>
> from rdkit import Chem
> from rdkit import Geometry
> from rdkit.Chem import AllChem
> from rdkit.Chem import rdFMCS
> from rdkit.Chem import Draw
> mol1=Chem.MolFromSmiles("CC1=C2C=C(N)C=CC2=CC(Cl)=N1")
> mol2=Chem.MolFromSmiles("CC1=C2C=C(N)C=CC2=NC(Cl)=C1")
> mcs=Chem.MolFromSmarts(rdFMCS.FindMCS([mol1,mol2]).smartsString)
> AllChem.Compute2DCoords(mol1)
> match1=mol1.GetSubstructMatch(mcs)
> match2=mol2.GetSubstructMatch(mcs)
> coords=[mol1.GetConformer().GetAtomPosition(x) for x in match1]
> coords2D = [Geometry.Point2D(pt.x,pt.y) for pt in coords]
> coordDict={}
> for i,coord in enumerate(coords2D):
>     coordDict[match2[i]] = coord
> AllChem.Compute2DCoords(mol2,coordMap=coordDict)
> Draw.MolsToGridImage([mol1,mol2],subImgSize=(250,250),molsPerRow=2)
> _______________________________________________
> 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