The problem is that even if you fix it in the readers, the hydrogens are ignored when passed to the code that does the kekulization. While this means that we are able (better than most others) to handle files (e.g. PDB) that don't have the hydrogens locations specified, none of us realized that all of the readers that support implicit hydrogens actually are capable of putting the hydrogens in the current positions themselves (apart from CML, depending on how the hydrogens are specified) and so the hydrogens should be put in the current place by the reader and then left untouched.
Anyway, that's just history. The bottom line is that the fix breaks the current API so no amount of command-line switches is going to help. I already have some code implemented to sort it out at the SMILES reader. If someone wants to take it forward beyond that, I can dig it up and check it in. - Noel On 10 December 2014 at 02:04, Oliver Stueker <revilo2...@users.sourceforge.net> wrote: > Hi Noel, > > Thanks for the response. > > Would it be hard to add a command line switch for the CML and/or SMILES > reader(s) to suppress any attempts to add implict hydrogens? > > I have structures coming from QM calculations and thefore I know all > hydrogens and don't want any to be added (even my SMILES have explicit > hydrogens). > Some of my structures have even free valencies and I want to make sure that > they get SMILES that are different from the hydrogenated analogs (e.g. > [Si][Si] vs. [SiH3][SiH3]). > > Currently I'm comparing the formula calculated by OB to the one from the QM > file to find cases where the structure gets messed up. It's a bit > frustrating that in those three cases from my previous mail the SMILES is > actually correct, but only the formula gets messed up. > > > Oliver > > > On Tuesday, December 9, 2014, Noel O'Boyle <baoille...@gmail.com> wrote: >> >> Hi Oliver, >> >> You are hitting an OB bug. The SMILES reader (among others) does not >> set the implicit hydrogen correctly. I've done some work on sorting >> this out, but it's kind of "on the long finger" now. >> >> Regards, >> - Noel >> >> On 9 December 2014 at 19:53, Oliver Stueker >> <revilo2...@users.sourceforge.net> wrote: >> > Hi, >> > >> > I'm trying to use OpenBabel (Open Babel 2.3.2 -- Jan 21 2014 -- 23:20:09 >> > from Ubuntu 14.04) >> > to generate normalized SMILES strings. >> > >> > I've noticed that for some cases, it generates wrong a formula (which I >> > want >> > to use as a sanity check). >> > >> > Here are the offending formulas that I have found so far: >> > >> > Formula SMILES Formula(obabel) >> > B2H6 [BH2]12[H][BH2]2[H]1 B2H8 >> > CHP [CH]=P CH2P >> > P4 [P]P1P=P1 H2P4 >> > >> > At the bottom are commands to verify the behaviour. >> > >> > As one can see the SMILES to SMILES conversion is correct as well as the >> > generated SDF file, >> > but the formula property has too many hydrogen atoms. >> > >> > Can someone figure out what exactly is going on there? >> > >> > Also please see the issues I have filed regarding the automatic >> > implication >> > of hydrogen atoms when reading CML files, that can't be turned off: >> > http://sourceforge.net/p/openbabel/bugs/947/ >> > http://sourceforge.net/p/openbabel/feature-requests/172/ >> > >> > >> > Thanks, >> > Oliver >> > >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[BH2]12[H][BH2]2[H]1" | obabel -i smi -o can >> > [BH2]12[H][BH2]1[H]2 >> > 1 molecule converted >> > ##### SMILES to SMILES: OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[BH2]12[H][BH2]2[H]1" | obabel -i smi --add formula -o sdf >> > ============================== >> > *** Open Babel Warning in WriteMolecule >> > No 2D or 3D coordinates exist. Stereochemical information will be >> > stored >> > using an Open Babel extension. To generate 2D or 3D coordinates instead >> > use >> > --gen2D or --gen3D. >> > >> > OpenBabel12041410482D >> > >> > 8 9 0 0 0 0 0 0 0 0999 V2000 >> > 0.0000 0.0000 0.0000 B 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 B 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 1 2 1 0 0 0 0 >> > 1 3 1 0 0 0 0 >> > 1 8 1 0 0 0 0 >> > 1 4 1 0 0 0 0 >> > 1 5 1 0 0 0 0 >> > 4 5 1 0 0 0 0 >> > 5 6 1 0 0 0 0 >> > 5 7 1 0 0 0 0 >> > 5 8 1 0 0 0 0 >> > M END >> >> <formula> >> > B2H8 >> > >> > $$$$ >> > 1 molecule converted >> > ##### SMILES to Formula: NOT OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[CH]=P" | obabel -i smi -o can >> > [CH]=P >> > 1 molecule converted >> > ##### SMILES to SMILES: OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[CH]=P" | obabel -i smi --add formula -o sdf >> > ============================== >> > *** Open Babel Warning in WriteMolecule >> > No 2D or 3D coordinates exist. Stereochemical information will be >> > stored >> > using an Open Babel extension. To generate 2D or 3D coordinates instead >> > use >> > --gen2D or --gen3D. >> > >> > OpenBabel12051413272D >> > >> > 3 2 0 0 0 0 0 0 0 0999 V2000 >> > 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 >> > 1 2 1 0 0 0 0 >> > 1 3 2 0 0 0 0 >> > M RAD 1 1 2 >> > M END >> >> <formula> >> > CH2P >> > >> > $$$$ >> > 1 molecule converted >> > ##### SMILES to Formula: NOT OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[P]P1P=P1" | obabel -i smi -o can >> > [P]P1P=P1 >> > 1 molecule converted >> > ##### SMILES to SMILES: OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > $ echo "[P]P1P=P1" | obabel -i smi -o sdf --add formula >> > ============================== >> > *** Open Babel Warning in WriteMolecule >> > No 2D or 3D coordinates exist. Stereochemical information will be >> > stored >> > using an Open Babel extension. To generate 2D or 3D coordinates instead >> > use >> > --gen2D or --gen3D. >> > >> > OpenBabel12091416012D >> > >> > 4 4 0 0 0 0 0 0 0 0999 V2000 >> > 0.0000 0.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 P 0 0 3 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 >> > 0.0000 0.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 >> > 1 2 1 0 0 0 0 >> > 2 4 1 1 0 0 0 >> > 2 3 1 1 0 0 0 >> > 3 4 2 0 0 0 0 >> > M RAD 1 1 3 >> > M END >> >> <formula> >> > H2P4 >> > >> > $$$$ >> > 1 molecule converted >> > ##### SMILES to Formula: NOT OK ##### >> > >> > ------------------------------------------------------------------------------------------------ >> > >> > > > > > -- > Sent from my mobile device. ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss