ggasoftware / indigo

Indigo: a cheminformatics toolkit. Bingo: RDBMS data cartridge for Oracle, MS SQL Server, and PostgreSQL
https://lifescience.opensource.epam.com/indigo
47 stars 15 forks source link

Unable to get INCHIKEY value for an inchi string #11

Closed abhimanyusirohi closed 9 years ago

abhimanyusirohi commented 9 years ago

The following code returns a NULL pointer for inchikey:

    int mol = indigoLoadMoleculeFromString("C1CCCCC1");
    const char* inchi = indigoInchiGetInchi(mol);   // InChI=1S/C6H12/c1-2-4-6-5-3-1/h1-6H2
    const char* inchik = indigoInchiGetInchiKey(inchi); // NULL pointer

The problem lies in indigoInchiGetInchiKey method of indigo_inchi_api.cpp file. The passed in inchi_string is somehow assigned to self.tmp_string which is cleared for output in IndigoInchi::InChIKey method of indigo_inchi_core.cpp.

abhimanyusirohi commented 9 years ago

Answered in the forum. The fix is to NOT use the "const char_" returned by _indigoInchiGetInchi* method and use a copy. https://groups.google.com/d/topic/indigo-bugs/Bxj7DF1IWfM/discussion