Thank you Noel.
I wanted to get the canonical SMILES, without changing the aromaticity of
the input SMILES:

mol = pybel.readstring('smi', 'O=C(NCCN(C)C)C1=CC=CN2C(=O)c3ccccc3(N=C12)')
mol.write(opt={"k": True, 'c':True})
'CN(CCNC(=O)C1=CC=CN2C1=NC1C=CC=CC=1C2=O)C\t\n'
mol.write(opt={'c':True})
'CN(CCNC(=O)c1cccn2c1nc1ccccc1c2=O)C\t\n'

Furthermore, can you explain me this:

mol = pybel.readstring('smi', "O=C(NCCN(C)C)c1cccc2C(=O)c3ccccc3(Oc12)")
sma = pybel.Smarts("c1cccc2Cc3ccccc3(Oc12)")
sma.obsmarts.Match(mol.OBMol, True)
False

Thank you again
Thomas

Il giorno ven 17 feb 2023 alle ore 18:37 Noel O'Boyle <baoille...@gmail.com>
ha scritto:

> Hi Thomas,
>
> OB does not sanitize molecules when reading from SMILES (or any other
> format). By default it writes aromatic SMILES though, but it sounds like
> you want Kekule SMILES - see the obabel -Hsmi for the list of options. In
> this case you want 'k':
>
> $ obabel -:"O=C1C=COC(=C1(O))C" -xk -osmi
> O=C1C=COC(=C1O)C
>
> In Python, this is something like mol.write(opt={"k:" True}).
>
> Neither does it add Hs. A SMILES string exactly specifies the number of Hs
> on each atom; this is preserved on reading/writing. If you could provide
> information on a specific case, we could explain what's happening more
> clearly.
>
> Regards
> Noel
>
>
> On Fri, 17 Feb 2023 at 16:18, Thomas <odioidenti...@gmail.com> wrote:
>
>> Is there an option to avoid sanitization of a molecule when reading from
>> SMILES?
>> For example I'd like the SMILES to remain unchanged if I read and write
>> it:
>>
>> mol = pybel.readstring('smi', 'O=C1C=COC(=C1(O))C')
>> mol.write()
>> O=c1ccoc(c1O)C
>>
>> Beside kekulization issues, other unwanted sanitizations are the addition
>> of Hs if I generate the molecule from SMILES fragments (partial SMILES)
>>
>> Thank you
>> Thomas
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> OpenBabel-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>>
>
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to