This problem (of InChI missing the stereo layer) seems to come down to line
303 of inchiformat.cpp:

    if (mol.GetDimension() == 3 || (mol.GetDimension()==2 &&
pConv->IsOption("s", pConv->OUTOPTIONS)!=NULL))
      TetStereoToWedgeHash(mol, updown, from);

If the molecule's dimension is set to 2, it skips the stereo layer of the
InChI. I don't think this is really a bug in the InChI code, but rather
somewhere else where the molecule's dimensionality is being changed when it
shouldn't.

For now I've just put a "pmol->SetDimension(3)" before I generate the
InChI, and it seems to solve the problem. Nothing like a good hack to come
back and bite me later!

Craig

On Wed, Oct 7, 2015 at 4:08 PM, Craig James <cja...@emolecules.com> wrote:

>
> On Wed, Oct 7, 2015 at 1:07 PM, Noel O'Boyle <baoille...@gmail.com> wrote:
>
>> Are you using the dev version? If not, sounds like a problem I fixed
>> earlier this year - see github closed issues from that period.
>>
>
> Noel, thanks for the suggestion. I downloaded and installed the latest
> code from git, but it made no difference. From the comments in your commit,
> the bug you fixed had to do with reading InChI strings, whereas mine is
> with writing them.
>
> Here is another oddity, no doubt related. If I use an SDF for input, it
> has the opposite effect: with all-zero coordinates, it doesn't print the
> stereo layer of InChI, but when I generate 2D coordinates (even though it's
> all flat in the Z axis), it prints the stereo layer of InChI.  (See the
> code below).
>
> Which leads to the question: exactly what is InChI looking for on an atom
> that makes it decide it's a stereo center? I'm digging through the code
> trying to find a clue, but I've made no progress so far.
>
> #include <string>
> #include <sstream>
>
> #include <openbabel/mol.h>
> #include <openbabel/obconversion.h>
> #include <openbabel/op.h>
>
> using namespace std;
> using namespace OpenBabel;
>
> int main(int argc, char **argv)
> {
>   char *smiles;
>   int smilen;
>
>   const char *sdf =
>     "\n"
>     " OpenBabel10071522293D\n"
>     "\n"
>     "  5  4  0  0  1  0  0  0  0  0999 V2000\n"
>     "    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0
>  0\n"
>     "    0.0000    0.0000    0.0000 C   0  0  2  0  0  0  0  0  0  0  0
>  0\n"
>     "    0.0000    0.0000    0.0000 H   0  0  0  0  0  0  0  0  0  0  0
>  0\n"
>     "    0.0000    0.0000    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0
>  0\n"
>     "    0.0000    0.0000    0.0000 Br  0  0  0  0  0  0  0  0  0  0  0
>  0\n"
>     "  1  2  1  0  0  0  0\n"
>     "  2  3  1  1  0  0  0\n"
>     "  2  4  1  0  0  0  0\n"
>     "  2  5  1  0  0  0  0\n"
>     "M  END\n"
>     "$$$$\n";
>
>   OBConversion *pconv_sdf = new OBConversion();
>   OBConversion *pconv_smi = new OBConversion();
>   OBConversion *pconv_ich = new OBConversion();
>   pconv_sdf->SetInFormat("sdf");
>   pconv_ich->SetOutFormat("inchi");
>   pconv_smi->SetOutFormat("can");
>
>   OBMol *pmol = new OBMol;;
>   pconv_sdf->ReadString(pmol, sdf);
>
>   cout << pconv_ich->WriteString(pmol, true) << "\n";
>   cout << pconv_smi->WriteString(pmol, true) << "\n";
>
>   OBOp* pOp = OBOp::FindType("gen2D");
>   pOp->Do(pmol);
>
>   cout << pconv_ich->WriteString(pmol, true) << "\n";
>   cout << pconv_smi->WriteString(pmol, true) << "\n";
> }
>
> And the output. Notice that the SMILES has the stereo info both before and
> after the gen2D, but the InChI only has it after.
>
> ==============================
> *** Open Babel Warning  in InChI code
>   #0 :Omitted undefined stereo
> InChI=1S/C2H4BrCl/c1-2(3)4/h2H,1H3
> C[C@@H](Br)Cl
> InChI=1S/C2H4BrCl/c1-2(3)4/h2H,1H3/t2-/m0/s1
> C[C@@H](Br)Cl
>
>
> Thanks,
> Craig
>
>
------------------------------------------------------------------------------
Full-scale, agent-less Infrastructure Monitoring from a single dashboard
Integrate with 40+ ManageEngine ITSM Solutions for complete visibility
Physical-Virtual-Cloud Infrastructure monitoring from one console
Real user monitoring with APM Insights and performance trend reports 
Learn More http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to