pckroon / pysmiles

A lightweight python-only library for reading and writing SMILES strings
Apache License 2.0
147 stars 21 forks source link

Bug Simpliefied Smiles of 1 atom #36

Closed fgrunewald closed 9 months ago

fgrunewald commented 9 months ago

In the current implementation the smile "O" translates yields just O with an hcount of 0. Shouldn't it yield an hcount of 1 and be the short form of water? Perhaps I'm missing some convention here.

pckroon commented 9 months ago
>>> g = read_smiles('O')
>>> g.nodes(data=True)
NodeDataView({0: {'element': 'O', 'charge': 0, 'aromatic': False, 'hcount': 2}})
fgrunewald commented 9 months ago

sorry my bad: I meant when using [O], but I guess the standard convention is then to take it as atomic.

pckroon commented 9 months ago

That's a fundamentally different smiles string. The brackets indicate that you're defining an atom and explicitly don't want the defaults (charge, valence, etc). In particular it sets the hcount to 0. [OH2] would be what you want. Or [OH3+], [OH-] for the charged ions