openforcefield / smarty

Chemical perception tree automated exploration tool.
http://openforcefield.org
MIT License
19 stars 8 forks source link

Depicting molecules in python3 #245

Closed bannanc closed 7 years ago

bannanc commented 7 years ago

@davidlmobley found an issue yesterday in our scripts used to depict 2D molecules all done in jupyter notebook.

Old version used the following lines to return an image:

ofs = oechem.oeosstream()
oedepict.OERenderMolecule(ofs, 'png', disp)
ofs.flush()
return Image(data = "".join(ofs.str()))

The new version should do this instead (to be python3 compatible)

img = oedepict.OEImage(width, height)
oedepict.OERenderMolecule(img,disp)
return Image(oedepict.OEWriteImageToString("png",img))

Here are some of the locations where this type of code is used:

smarty/utilities/convert_frosst/parameter_usage.ipynb

open-forcefield-data/Model-Systems/SMIRFF_prototype/substrucDepict.ipynb

bannanc commented 7 years ago

I included this with pull request #232