Handle rdkit molobjects with String/BytesIO #RDKit #memo

This post has no new topics but just for my memo. I often want to read and write molecule ad hoc without writing them to file objects.

RDKit has two kinds of SDF reader one is SDMolSupplier and the other is ForwardSDMolSupplier and has a SDF writer SDWriter.

SDWriter supports StringIO and Forward SDSupplier supports BytesIO. So I can handle rdkit mol objects without writing sd files.

Here is an example.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
view raw sio_bio.ipynb hosted with ❤ by GitHub

I think this approach will be useful for creating web app which has SDF up-loader and returns files with some kinds of chemoinformatics operations :-)


Published by iwatobipen

I'm medicinal chemist in mid size of pharmaceutical company. I love chemoinfo, cording, organic synthesis, my family.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: