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