Hi All, I’m working with some generated SMARTS and get some errors related to charges on nitrogens. This following script exemplifies the behavior I did not expect. Why does the nitrogen charge gets different, depending on if other SMARTS properties are set for that atom?? m1 has the explicit charge on N, but not m2
Best Regards Esben import rdkit print(rdkit.__version__) from rdkit import Chem m1 = Chem.MolFromSmarts("O=[N+1](-[O-])-[C:2]") m2 = Chem.MolFromSmarts("O=[N+1;D3](-[O-])-[C:2]") a = m1.GetAtomWithIdx(1) print("Smarts 1: N charge %i"%a.GetFormalCharge()) a = m2.GetAtomWithIdx(1) print("Smarts 2: N charge %i"%a.GetFormalCharge()) print("Smarts 1 as smarts %s"%Chem.MolToSmarts(m1)) print("Smarts 2 as smarts %s"%Chem.MolToSmarts(m2)) print("Smarts 1 as smiles %s"%Chem.MolToSmiles(m1)) print("Smarts 2 as smiles %s"%Chem.MolToSmiles(m2)) Chem.MolFromSmiles(Chem.MolToSmiles(m1)) Chem.MolFromSmarts(Chem.MolToSmarts(m1)) Chem.MolFromSmarts(Chem.MolToSmarts(m2)) #These fails with error: Explicit valence for atom # 1 N, 4, is greater than permitted m2.UpdatePropertyCache() Chem.MolFromSmiles(Chem.MolToSmiles(m2)) 2019.03.2 Smarts 1: N charge 1 Smarts 2: N charge 0 Smarts 1 as smarts O=[N&+](-[O&-])-[C:2] Smarts 2 as smarts O=[N&+&D3](-[O&-])-[C:2] Smarts 1 as smiles O=[N+]([O-])[CH3:2] Smarts 2 as smiles O=N([O-])[CH3:2] --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-1-f0121281240c> in <module> 18 Chem.MolFromSmarts(Chem.MolToSmarts(m2)) 19 #These fails with error: Explicit valence for atom # 1 N, 4, is greater than permitted ---> 20 m2.UpdatePropertyCache() 21 Chem.MolFromSmiles(Chem.MolToSmiles(m2)) ValueError: Sanitization error: Explicit valence for atom # 1 N, 4, is greater than permitted [ ]: ________________________________ Confidentiality Notice: This message is private and may contain confidential and proprietary information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorized use or disclosure of the contents of this message is not permitted and may be unlawful.
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss