Skip to content

Commit

Permalink
#1303 Return original format
Browse files Browse the repository at this point in the history
Fix indigo service v2
  • Loading branch information
AliaksandrDziarkach committed Oct 6, 2023
1 parent fa7e863 commit 35b4650
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion api/c/indigo/src/indigo_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,8 @@ CEXPORT const char* indigoGetOriginalFormat(int item)
return "unknown";
}
}
throw IndigoError("indigoSaveJson(): expected molecule or reaction, got %s", obj.debugInfo());
else
throw IndigoError("indigoSaveJson(): expected molecule, got %s", obj.debugInfo());
}
INDIGO_END(0);
}
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
4 changes: 3 additions & 1 deletion api/python/indigo/indigo/indigo_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def getOriginalFormat(self):
str: original format string
"""

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

def saveMolfile(self, filename):
"""Molecule method saves the structure into a Molfile
Expand Down
6 changes: 3 additions & 3 deletions core/indigo-core/molecule/src/base_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace indigo;

IMPL_ERROR(BaseMolecule, "molecule");

BaseMolecule::BaseMolecule():original_format(BaseMolecule::UNKNOWN)
BaseMolecule::BaseMolecule() : original_format(BaseMolecule::UNKNOWN)
{
_edit_revision = 0;
}
Expand Down Expand Up @@ -661,7 +661,7 @@ void BaseMolecule::clone(BaseMolecule& other, Array<int>* mapping, Array<int>* i
makeSubmolecule(other, *mapping, inv_mapping, skip_flags);
_meta.clone(other._meta);
name.copy(other.name);
other.original_format = original_format;
original_format = other.original_format;
copyProperties(other, *mapping);
}

Expand Down Expand Up @@ -694,7 +694,7 @@ void BaseMolecule::clone_KeepIndices(BaseMolecule& other, int skip_flags)
_meta.clone(other._meta);
_mergeWithSubmolecule_Sub(other, vertices, 0, mapping, edge_mapping, skip_flags);
name.copy(other.name);
other.original_format = original_format;
original_format = other.original_format;
copyProperties(other, mapping);
}

Expand Down
8 changes: 7 additions & 1 deletion utils/indigo-service/backend/service/v2/indigo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,13 @@ def get_response(md, output_struct_format, json_output, options, indigo):

if json_output:
return (
jsonify({"struct": output_mol, "format": output_struct_format}),
jsonify(
{
"struct": output_mol,
"format": output_struct_format,
"original_format": md.struct.getOriginalFormat(),
}
),
200,
{"Content-Type": "application/json"},
)
Expand Down

0 comments on commit 35b4650

Please sign in to comment.