Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1303 Return original format #1315

Merged
merged 11 commits into from
Oct 12, 2023
2 changes: 2 additions & 0 deletions api/c/indigo/indigo.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ CEXPORT int indigoRemove(int item);

/* Molecules, query molecules, SMARTS */

CEXPORT const char* indigoGetOriginalFormat(int item);

CEXPORT int indigoCreateMolecule(void);
CEXPORT int indigoCreateQueryMolecule(void);

Expand Down
24 changes: 24 additions & 0 deletions api/c/indigo/src/indigo_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3784,6 +3784,30 @@ CEXPORT int indigoCountComponentBonds(int molecule, int index)
INDIGO_END(-1);
}

CEXPORT const char* indigoGetOriginalFormat(int item)
{
INDIGO_BEGIN
{
IndigoObject& obj = self.getObject(item);
if (IndigoBaseMolecule::is(obj))
{
BaseMolecule& mol = obj.getBaseMolecule();
AliaksandrDziarkach marked this conversation as resolved.
Show resolved Hide resolved
switch (mol.original_format)
{
case BaseMolecule::SMARTS:
return "smarts";
case BaseMolecule::SMILES:
return "smiles";
default:
AliaksandrDziarkach marked this conversation as resolved.
Show resolved Hide resolved
return "unknown";
}
}
else
throw IndigoError("indigoSaveJson(): expected molecule, got %s", obj.debugInfo());
}
INDIGO_END(0);
}

CEXPORT int indigoCreateMolecule()
{
INDIGO_BEGIN
Expand Down
2 changes: 2 additions & 0 deletions api/python/indigo/indigo/indigo_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def __init__(self) -> None:
IndigoLib.lib.indigoIndex.argtypes = [c_int]
IndigoLib.lib.indigoRemove.restype = c_int
IndigoLib.lib.indigoRemove.argtypes = [c_int]
IndigoLib.lib.indigoGetOriginalFormat.restype = c_char_p
IndigoLib.lib.indigoGetOriginalFormat.argtypes = [c_int]
IndigoLib.lib.indigoSaveMolfileToFile.restype = c_int
IndigoLib.lib.indigoSaveMolfileToFile.argtypes = [c_int, c_char_p]
IndigoLib.lib.indigoMolfile.restype = c_char_p
Expand Down
11 changes: 11 additions & 0 deletions api/python/indigo/indigo/indigo_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ def remove(self):

return IndigoLib.checkResult(self._lib().indigoRemove(self.id))

def getOriginalFormat(self):
"""Molecule method return format molecule loaded from
AliaksandrDziarkach marked this conversation as resolved.
Show resolved Hide resolved

Returns:
str: original format string
"""

return IndigoLib.checkResultString(
self._lib().indigoGetOriginalFormat(self.id)
)

def saveMolfile(self, filename):
"""Molecule method saves the structure into a Molfile

Expand Down
Loading
Loading