[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AllChem.GenerateDepictionMatching2DStructure gives flipped orientation #8124

Open
mc-robinson opened this issue Dec 19, 2024 · 0 comments
Open
Labels

Comments

@mc-robinson
Copy link

Hi, below is some code that works for most molecules, but struggles to align the included query_smiles

from rdkit import Chem
from rdkit.Chem import rdDepictor, rdCoordGen, AllChem

query_smiles = "Cn1cnc(CN2CC(C(N)=O)CCC2=O)c1-c1ncccn1"
template_mol_block = """
  Ketcher 12192413482D 1   1.00000     0.00000     0

  8  8  0  0  0  0  0  0  0  0999 V2000
   10.7840   -3.9992    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   10.7840   -4.9992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.6500   -5.4992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.5160   -4.9992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   12.5160   -3.9992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.6500   -3.4992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   11.6500   -2.4992    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    9.9180   -3.4992    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  6  1  0     0  0
  1  2  1  0     0  0
  2  3  1  0     0  0
  3  4  1  0     0  0
  4  5  1  0     0  0
  5  6  1  0     0  0
  6  7  2  0     0  0
  1  8  1  0     0  0
M  END

"""

mol = Chem.MolFromSmiles(query_smiles)
template = Chem.MolFromMolBlock(template_mol_block)
    
# first scale the template, usually defined by a molV3000
# scales to RDKit default size
rdDepictor.NormalizeDepiction(template, canonicalize=0)

# we now do the same for mol
# but need to compute 2D coords first since came from SMILES
AllChem.Compute2DCoords(mol)
rdDepictor.NormalizeDepiction(mol, canonicalize=0)

# now do the alignment
AllChem.GenerateDepictionMatching2DStructure(mol, template, acceptFailure=True)

gives the following:
template:
image

mol
image
(note the flipped orientation relative to the desired template orientation)

For examples of mols that align correctly, simply replace query_smiles above with one of the following SMILES:
"NC(=O)C1CCC(=O)N(Cc2cnn(-c3ccccn3)n2)C1"
"NC(=O)C1CCC(=O)N(Cc2cn(C3CCS(=O)(=O)CC3)nn2)C1"

image
image

(which match the desired template orientation)

rdkit version: 2023.09.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant