Skip to content

Instantly share code, notes, and snippets.

@rkrishnasanka
Last active August 4, 2022 14:24
Show Gist options
  • Save rkrishnasanka/7c75f888978f78844b4b3e9a70ee680f to your computer and use it in GitHub Desktop.
Save rkrishnasanka/7c75f888978f78844b4b3e9a70ee680f to your computer and use it in GitHub Desktop.
epam Indigo Package Python Examples
from indigo import Indigo
from indigo.renderer import IndigoRenderer
from indigo.inchi import IndigoInchi
indigo_object = Indigo()
mol1 = indigo_object.loadMolecule("ONc1cccc1")
print(mol1.smiles())
indigo_renderer_object = IndigoRenderer(indigo_object)
indigo_renderer_object.renderToFile(mol1, "mol1.png")
# From inchi string:
# mol2 = indigo_object.loadMolecule("InChI=1S/C6H12O6/c1-2-4-6-5-3-1/h1-6H")
# indigo_renderer_object.renderToFile(mol2, "mol2.png")
indigo_inchi_object = IndigoInchi(indigo_object)
inchi_string = r"InChI=1S/C38H60O18/c1-16-11-37-9-5-20-35(2,7-4-8-36(20,3)34(50)55-32-29(49)26(46)23(43)18(13-40)52-32)21(37)6-10-38(16,15-37)56-33-30(27(47)24(44)19(14-41)53-33)54-31-28(48)25(45)22(42)17(12-39)51-31/h17-33,39-49H,1,4-15H2,2-3H3/t17-,18-,19-,20?,21?,22-,23-,24-,25+,26+,27+,28-,29-,30-,31+,32+,33+,35-,36-,37-,38+/m1/s1_c0"
mol3 = indigo_inchi_object.loadMolecule(inchi_string)
print(indigo_inchi_object.version())
print(indigo_inchi_object.getLog())
print(indigo_inchi_object.getWarning())
print(indigo_inchi_object.getInchiKey(inchi_string))
indigo_renderer_object.renderToFile(mol3, "mol3.png")
imgstring = indigo_renderer_object.renderToString(mol3)
print(imgstring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment