Explicit "implicit hydrogen" count and kekulisation now merged
At the start of the year (or was it last year?), I said to Geoff that
I felt that the single major problem with OB was its handling of
implicit hydrogens. And he called my bluff. :-)
Well, "the fix" has now been merged. Everything should be faster but
also more correct. As this is a major change, I encourage you to put
the library through its paces, and if you find any problems, please
file them and I'll sort them out. Radical support is still in the
process of being revived so you might experience some weirdness there
still. Feel free to report bugs if unsure.
There is no longer a "floating valence". Any OBAtom must have its
implicit hydrogen count set, or else it defaults to zero. A function
is provided to set the value based on typical valence (but you should
never need to use this as a user). Previously, you could create a bond
between any two atoms and the number of implicit hydrogens would
'adjust' automatically. Now you will need to decrement the implicit
hydrogen count yourself (there should be a shortcut function to do
this, but I can't remember if I've added this already).
There is no downside to this approach really - it's how almost all
other cheminformatics toolkits work since the dawn of time (though
OPSIN also uses this approach but apparently this fits with how IUPAC
names work). The floating valence was prone to getting the hydrogen
count wrong on occassion and made it difficult to, well, control the
hydrogen count without resort to a whole lot of atom flags.
The rewrite of kekulisation is more straightforward, and should be
transparent to the user, except that things that can't be kekulised
won't be kekulised.
Two new options have been added to SMILES:
1. -aa keep aromaticity as read (i.e. don't reperceive) - potential
speed boost for databases
e.g. obabel -:cc -aa -osmi # gives 'cc' (don't do this at home)
2. -xk write Kekule smiles (note: not canonical unless I do more work)
e.g. obabel -:c1ccccc1 -osmi -xk # gives C1C=CC=CC=1