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 ##### > ------------------------------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > 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 > ------------------------------------------------------------------------------ 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