dan2097 / jna-inchi

Wrapper to access InChI from Java
GNU Lesser General Public License v2.1
7 stars 6 forks source link

DataSGroups #18

Closed reyh-EIS closed 2 years ago

reyh-EIS commented 2 years ago

I have an issue with DataSGroups. In my environment (accessing inchi.dll via old C interface) I always get valid output. With jna-inchi, I get only valid output without DataSGroups. Is this an issue on my side or can you reproduce this behaviour? test_IXA_DataSGroup.mol.txt test_IXA.mol.txt

dan2097 commented 2 years ago

I can reproduce this using test_IXA_DataSGroup.mol.txt

JnaInchi.molToInchi(molStr).getMessage() gives the following message from the IXA API: Could not interpret Molfile polymer data: M STY 1 1 DAT; M SAL 1 2 11 14; M SBL 1 1 15

In the C code for the IXA API, IXA_MOL_ReadMolfile calls

    mol_data = ReadMolfile( inp_file,
                            NULL,       /*    MOL_FMT_HEADER_BLOCK *OnlyHeaderBlock, */
                            &OnlyCtab,
                            0, /* bGetOrigCoord ... NULL != szCoord*/
                            1, /* treat_polymers */
                            pseudos_allowed,
                            NULL, /* *pname */
                            0,  /* lname */
                            NULL,   /* *Id */
                            NULL,   /* pSdfLabel */
                            NULL,   /* pSdfValue */
                            &err, error_string,
                            0 /*bNoWarnings */ );

which is hard coded to attempt to read polymer data from the S-groups (the treat_polymers flag).

My initial thoughts are that, at least using the IXA API, that there isn't an elegant fix as IXA_MOL_ReadMolfile doesn't give any control of the parameters it's sending to ReadMolfile. I'm slightly surprised that an uninterpretable S-group is treatd as an error rather than a warning.

dan2097 commented 2 years ago

I think it would be quite straightforward for me to use MakeINCHIFromMolfileText from the "classic" API instead, just did a quick prototype.

Am I right in saying that the expected behaviour is, for the default InchiOptions to give: InChI=1S/C21H19NO3/c1-24-21(23)15-9-6-14(7-10-15)8-11-20-22-18-12-16-4-2-3-5-17(16)13-19(18)25-20/h6-13H,2-5H2,1H3/b11-8+ (with a status of Warning with the explanation that polymer data was ignored)

Adding the flag InchiFlag.Polymers gives no InChI, a status of Error and the following explanation: Error 65 (no InChI; Could not interpret Molfile polymer data: M STY 1 1 DAT; M SAL 1 2 11 14; M SBL 1 1 15) inp