Dear Pablo,

You might do something along these lines:

from  rdkit  import  Chem

smi  =  "[H]C([H])O"

params  =  Chem.SmilesParserParams()

params.sanitize  =  True
params.removeHs  =  False
mol  =  Chem.MolFromSmiles(smi,  params)
for  a  in  mol.GetAtoms():
    if  a.GetNumImplicitHs():
        print("Wrong valence for atom {0:s}{1:d}".format(a.GetSymbol(),  
a.GetIdx()))

Wrong valence for atom C 1
Wrong valence for atom O 3
HTH, cheers
p.

On 11/05/2020 13:33, Pablo Ramos wrote:

Dear all,

I am trying to catch an error every time that a smiles associated to a mol object does not exist. To do this, I want to use sanitize function: if the smiles is incorrect I will get my error.

My smiles with *explicit hydrogens* is the next one: [H]C([H])O

I want it to provide an error since valences do not match the ones specified for Carbon and Oxygen beingHydrogens already explicit: C_val = 4 ; O_val = 2

However, sanitizing this object creates automatically the missing Hydrogens providing a valid smiles: [H]OC([H])([H])[H] and therefore it assumes the smiles is correct.

Is there any way to specify that my Hydrogens are already explicit during sanitazion so I get my error message?

Thank you so much J

Best regards,

*Pablo Ramos*

Ph.D. at Covestro Deutschland AG

        

covestro.com <http://www.covestro.com/>

*Telephone*

+49 214 6009 7356

        

Covestro Deutschland AG

COVDEAG-Chief Commer-PUR-R&D-EMEA-PMD

B103, R164

51365 Leverkusen, Germany

_pablo.ramos@covestro.com_



_______________________________________________
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