On Jan 14, 2019, at 13:36, Andrew Dalke <da...@dalkescientific.com> wrote:
> I think the more correct solution is to ensure that OBConversion always 
> starts with an initial output Index of 1 instead of 0. 
> 
> I don't know where that might be done. Could someone provide advice?

I think I've found it.

OBConversion() was designed to convert between the input and output using an 
intermediate "ChemObject".

The Convert() function calls a function which gets the ChemObject(), and as a 
side-effect, increments the Index. Thus, during conversion the Index starts at 
1.

The WriteString() and WriteFile() methods bypass the Convert() step to write a 
molecule object directly. These don't call Convert(), so don't pre-increment 
the Index, leaving it as 0.

Many of the formats test for Index == 1 for initialization, like the FPS 
format, which crashes if the initialization isn't done.

I have a patched version which appears to fix the problem (though it may not be 
the best solution).

I've submitted it to https://github.com/openbabel/openbabel/issues/1922 and 
will work on a pull request based on my patch.

Further discussion will be in the issue tracker.

Cheers,

                                Andrew
                                da...@dalkescientific.com




_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to