Discussion:
[Open Babel] InChI Question
Hendrik Vennekate
2017-06-08 19:07:52 UTC
Permalink
Hello OpenBabel list,

a quick question regarding InChI support: on the corresponding wiki page it
reads, "Experimental InChI read support was added in version 2.1, although
this does not always support stereochemistry." Has this been improved
meanwhile?
In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not
seem to successfully reproduce the stereochemistry.

Any support is greatly appreciated.

Kind regards,

Hendrik
Noel O'Boyle
2017-06-08 19:30:09 UTC
Permalink
Hi there,

The wiki is out of date. Stereo works fine. What was the specific command
you used that you feel didn't work?

Noel

On 8 Jun 2017 8:08 p.m., "Hendrik Vennekate" <***@gmx.de> wrote:

Hello OpenBabel list,



a quick question regarding InChI support: on the corresponding wiki page it
reads, "Experimental InChI read support was added in version 2.1, although
this does not always support stereochemistry." Has this been improved
meanwhile?

In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not seem
to successfully reproduce the stereochemistry.



Any support is greatly appreciated.



Kind regards,



Hendrik

------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hendrik Vennekate
2017-06-08 20:37:35 UTC
Permalink
Hi Noel,

thanks for the quick reply. Actually, I was trying it through the library directly (approximately
like below):
using namespace OpenBabel;
OBConversion conversion;
conversion.SetInFormat("INCHI");
OBMol molecule;
conversion.ReadString(&molecule, "InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,
(H,5,6)/t2-/m1/s1");
std::map<std::string, std::string> options;
options["gen2D"] = "";
molecule.DoTransformations(&options, &conversion);
FOR_BONDS_OF_MOL(obbond, molecule)
cout << obbond->IsWedgeOrHash() << endl;
... and the output indicated that no bond was a wedge or hash, as I would have expected.

Alternatively, I put the above InChI string into a file and did the following:
obabel -i inchi /tmp/d-alanine.inchi -Otestout.mol
To the best of my understanding of the MOL format, the fourth column of the bond block
should contain the stereo info if any. The output bond block reads:
1 2 1 0 0 0 0
2 3 1 0 0 0 0
2 4 1 0 0 0 0
3 5 2 0 0 0 0
3 6 1 0 0 0 0
so all zeros.

Again, I'm curious what I'm missing...

Best wishes,

Hendrik
Post by Noel O'Boyle
Hi there,
The wiki is out of date. Stereo works fine. What was the specific command
you used that you feel didn't work?
Noel
Hello OpenBabel list,
a quick question regarding InChI support: on the corresponding wiki page it
reads, "Experimental InChI read support was added in version 2.1, although
this does not always support stereochemistry." Has this been improved
meanwhile?
In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not seem
to successfully reproduce the stereochemistry.
Any support is greatly appreciated.
Kind regards,
Hendrik
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Noel O'Boyle
2017-06-09 12:12:31 UTC
Permalink
The first question to check is whether we are reading the stereo correctly:

obabel -iinchi -:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1"
-osmi
C[***@H](C(=O)O)N

This SMILES does indeed represent D-Alanine.

The problem is that you have generated a 0D mol file:
e.g. obabel -iinchi
-:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1" -omol
...where the tetrahedral stereo is stored on the atom rather than on the bonds.

In other words, gen2D didn't work for you (all the atoms have 0
coordinates I'm guessing). I'm not familiar with DoTransformations,
but it should work fine via OBOp.FindType("gen2D") or so.

- Noel
Post by Hendrik Vennekate
Hi Noel,
thanks for the quick reply. Actually, I was trying it through the library
using namespace OpenBabel;
OBConversion conversion;
conversion.SetInFormat("INCHI");
OBMol molecule;
conversion.ReadString(&molecule,
"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1");
std::map<std::string, std::string> options;
options["gen2D"] = "";
molecule.DoTransformations(&options, &conversion);
FOR_BONDS_OF_MOL(obbond, molecule)
cout << obbond->IsWedgeOrHash() << endl;
... and the output indicated that no bond was a wedge or hash, as I would have expected.
obabel -i inchi /tmp/d-alanine.inchi -Otestout.mol
To the best of my understanding of the MOL format, the fourth column of the
bond block should contain the stereo info if any. The output bond block
1 2 1 0 0 0 0
2 3 1 0 0 0 0
2 4 1 0 0 0 0
3 5 2 0 0 0 0
3 6 1 0 0 0 0
so all zeros.
Again, I'm curious what I'm missing...
Best wishes,
Hendrik
Post by Noel O'Boyle
Hi there,
The wiki is out of date. Stereo works fine. What was the specific command
you used that you feel didn't work?
Noel
Hello OpenBabel list,
a quick question regarding InChI support: on the corresponding wiki page it
reads, "Experimental InChI read support was added in version 2.1, although
this does not always support stereochemistry." Has this been improved
meanwhile?
In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not seem
to successfully reproduce the stereochemistry.
Any support is greatly appreciated.
Kind regards,
Hendrik
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Hendrik Vennekate
2017-06-10 19:14:08 UTC
Permalink
Hi Noel,

thanks again for the quick reply and my apologies for my newb-ish mistakes in this field (on
an unrelated note: inspecting the code, I realized that if anything I should have checked
IsWedge() and IsHash() separately). So, IsChiral() is indeed true for the one relevant atom.

My goal in this, however, would have been to arrive at an OBMol with hash and/or wedge
bonds. It seems there is some way to accomplish that using what is around in
stereo/perception.cpp, but documentation seems to be rather scarce. I'm guessing I'll have to
eventually mimic what OBDepict::DrawMolecule() does (or TetStereoToWedgeHash() called
therein).

I'll keep exploring, but thanks again for clearing up that stereo-chemistry _is_ indeed
processed.

Best,

Hendrik
Post by Noel O'Boyle
obabel -iinchi
-:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1" -osmi
This SMILES does indeed represent D-Alanine.
e.g. obabel -iinchi
-:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1" -omol
...where the tetrahedral stereo is stored on the atom rather than on the bonds.
In other words, gen2D didn't work for you (all the atoms have 0
coordinates I'm guessing). I'm not familiar with DoTransformations,
but it should work fine via OBOp.FindType("gen2D") or so.
- Noel
Post by Hendrik Vennekate
Hi Noel,
thanks for the quick reply. Actually, I was trying it through the library
using namespace OpenBabel;
OBConversion conversion;
conversion.SetInFormat("INCHI");
OBMol molecule;
conversion.ReadString(&molecule,
"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1");
std::map<std::string, std::string> options;
options["gen2D"] = "";
molecule.DoTransformations(&options, &conversion);
FOR_BONDS_OF_MOL(obbond, molecule)
cout << obbond->IsWedgeOrHash() << endl;
... and the output indicated that no bond was a wedge or hash, as I would
have expected.
obabel -i inchi /tmp/d-alanine.inchi -Otestout.mol
To the best of my understanding of the MOL format, the fourth column of the
bond block should contain the stereo info if any. The output bond block
1 2 1 0 0 0 0
2 3 1 0 0 0 0
2 4 1 0 0 0 0
3 5 2 0 0 0 0
3 6 1 0 0 0 0
so all zeros.
Again, I'm curious what I'm missing...
Best wishes,
Hendrik
Post by Noel O'Boyle
Hi there,
The wiki is out of date. Stereo works fine. What was the specific command
you used that you feel didn't work?
Noel
Hello OpenBabel list,
a quick question regarding InChI support: on the corresponding wiki page it
reads, "Experimental InChI read support was added in version 2.1, although
this does not always support stereochemistry." Has this been improved
meanwhile?
In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not seem
to successfully reproduce the stereochemistry.
Any support is greatly appreciated.
Kind regards,
Hendrik
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Noel O'Boyle
2017-06-12 12:05:27 UTC
Permalink
I haven't looked at the specifics, but sounds like a good idea.

I plan to rewrite some of the stereo API in the near future, and will
keep your suggestion in mind. Ideally, it would be nice to have the
possibility of retaining the exact input stereo without reperception
or reassigning bond wedges or hashes. This would make reading SMILES
strings (for example) much faster.

- Noel
Ok, to sum up, OBDepictPrivate::SetWedgeAndHash(OBMol*) is the function I
want to use, which essentially amounts to copying it into my application.
This function seems to be "dead code" (in the sense that it is not
referenced anywhere) -- but still very useful for my scenario to have. Why
not make it a public function somewhere in stereo/stereo.h?
Best,
Hendrik
Post by Hendrik Vennekate
Hi Noel,
thanks again for the quick reply and my apologies for my newb-ish mistakes
in this field (on an unrelated note: inspecting the code, I realized that
if anything I should have checked IsWedge() and IsHash() separately). So,
IsChiral() is indeed true for the one relevant atom.
My goal in this, however, would have been to arrive at an OBMol with hash
and/or wedge bonds. It seems there is some way to accomplish that using
what is around in stereo/perception.cpp, but documentation seems to be
rather scarce. I'm guessing I'll have to eventually mimic what
OBDepict::DrawMolecule() does (or TetStereoToWedgeHash() called therein).
I'll keep exploring, but thanks again for clearing up that
stereo-chemistry
_is_ indeed processed.
Best,
Hendrik
Post by Noel O'Boyle
The first question to check is whether we are reading the stereo
obabel -iinchi
-:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1" -osmi
This SMILES does indeed represent D-Alanine.
e.g. obabel -iinchi
-:"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1" -omol
...where the tetrahedral stereo is stored on the atom rather than on the
bonds.
In other words, gen2D didn't work for you (all the atoms have 0
coordinates I'm guessing). I'm not familiar with DoTransformations,
but it should work fine via OBOp.FindType("gen2D") or so.
- Noel
Post by Hendrik Vennekate
Hi Noel,
thanks for the quick reply. Actually, I was trying it through the
library
using namespace OpenBabel;
OBConversion conversion;
conversion.SetInFormat("INCHI");
OBMol molecule;
conversion.ReadString(&molecule,
"InChI=1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1");
std::map<std::string, std::string> options;
options["gen2D"] = "";
molecule.DoTransformations(&options, &conversion);
FOR_BONDS_OF_MOL(obbond, molecule)
cout << obbond->IsWedgeOrHash() << endl;
... and the output indicated that no bond was a wedge or hash, as I
would
have expected.
Alternatively, I put the above InChI string into a file and did the
obabel -i inchi /tmp/d-alanine.inchi -Otestout.mol
To the best of my understanding of the MOL format, the fourth column
of
the
bond block should contain the stereo info if any. The output bond block
1 2 1 0 0 0 0
2 3 1 0 0 0 0
2 4 1 0 0 0 0
3 5 2 0 0 0 0
3 6 1 0 0 0 0
so all zeros.
Again, I'm curious what I'm missing...
Best wishes,
Hendrik
Post by Noel O'Boyle
Hi there,
The wiki is out of date. Stereo works fine. What was the specific
command
you used that you feel didn't work?
Noel
Hello OpenBabel list,
a quick question regarding InChI support: on the corresponding wiki
page
it
reads, "Experimental InChI read support was added in version 2.1,
although
this does not always support stereochemistry." Has this been improved
meanwhile?
In a little experiment with wikidata's InChI string for D-alanine
(1S/C3H7NO2/c1-2(4)3(5)6/h2H,4H2,1H3,(H,5,6)/t2-/m1/s1), I could not
seem
to successfully reproduce the stereochemistry.
Any support is greatly appreciated.
Kind regards,
Hendrik
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
--
Ahornstraße 12d
85774 Unterföhring
Telefon: (0176) 2298 7524
Loading...