[Rdkit-discuss] problem when doing Chem.MolFromSmiles()
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Chencheng F. <s8c...@st...> - 2019-03-13 10:53:10
|
Hello everyone,
I meet a problem that I don’t understand how it happens and how to solve it.
First, I generate an rdkit_object from reading a mol file(Porphyrin molecule). Then generate Smiles from the rdkit_object and save the Smiles string in a parameter. Then use the parameter to generate rdkit_object. The code works well until now. However, if I directly try to generate rdkit_object from the Smiles string, it will return SMILES Parse Error:syntax error for input.
I appreciate very much for your help!
Have a good day!
Best wishes
Cheng
The mol file is:
Code is:
from __future__ import print_function
import rdkit
from rdkit import Chem
from rdkit.Chem import AllChem
Corefile='Porphyrin.mol'
core_rdkit_object=Chem.MolFromMolFile(Corefile)
core_smiles=Chem.MolToSmiles(core_rdkit_object)
print('core_smiles',core_smiles)
core=Chem.MolFromSmiles(core_smiles)
print('rdkit_object',core)
coreh=Chem.AddHs(core)
AllChem.EmbedMolecule(coreh)
print(Chem.MolToMolBlock(coreh))
core_smiles_2='C1=C/C2=C/c3ccc4n3[Zn]n3/c(cc/c3=C/C3=N/C(=C\4)C=C3)=C\C1=N2'
core=Chem.MolFromSmiles(core_smiles_2)
print(core)
coreh=Chem.AddHs(core)
AllChem.EmbedMolecule(coreh)
print(Chem.MolToMolBlock(coreh))
Error is:
core_smiles C1=C/C2=C/c3ccc4n3[Zn]n3/c(cc/c3=C/C3=N/C(=C\4)C=C3)=C\C1=N2
rdkit_object. <rdkit.Chem.rdchem.Mol object at 0x2ab4209e1b40>
[11:50:20] UFFTYPER: Unrecognized atom type: Zn1+2 (9)
[11:50:20] SMILES Parse Error: syntax error for input: 'C1=C/C2=C/c3ccc4n3[Zn]n3/c(cc/c3=C/C3=N/C(=C)C=C3)=C\C1=N2'
None
Traceback (most recent call last):
File "test-generate_core.py", line 21, in <module>
coreh=Chem.AddHs(core)
Boost.Python.ArgumentError: Python argument types in
rdkit.Chem.rdmolops.AddHs(NoneType)
did not match C++ signature:
AddHs(RDKit::ROMol mol, bool explicitOnly=False, bool addCoords=False, boost::python::api::object onlyOnAtoms=None, bool addResidueInfo=False)
|