{"id":17,"date":"2012-09-14T10:58:42","date_gmt":"2012-09-14T09:58:42","guid":{"rendered":"http:\/\/nextmovesoftware.com\/blog\/?p=17"},"modified":"2012-09-20T09:55:44","modified_gmt":"2012-09-20T08:55:44","slug":"using-python-for-batch-conversion-of-chemsketch-files-to-mol-files","status":"publish","type":"post","link":"https:\/\/nextmovesoftware.com\/blog\/2012\/09\/14\/using-python-for-batch-conversion-of-chemsketch-files-to-mol-files\/","title":{"rendered":"Using Python for batch conversion of ChemSketch files to Mol files"},"content":{"rendered":"<p>There are several tools out there for batch conversion of chemical file formats. However, you may not have access to those tools or else a particular file format may not be supported. Sometimes your only option is to open each file in the original software, and export it as a more useful file format. When dealing with a large number of files, this can be quite tedious or just impossible.<\/p>\n<p>Recently, faced with the challenge of converting 100s of ChemSketch files to Mol files, myself and Daniel looked up the literature (i.e. googled the web) and found that Rajarshi Guha has <a href=\"http:\/\/blog.rguha.net\/?p=549\">described<\/a> how to automate ChemDraw using the Python module WATSUP. Unfortunately this no longer seems to be available. Rich Apodaca has described an <a href=\"http:\/\/metamolecular.com\/blog\/2011\/07\/18\/chembot-convert-chemdraw-cdx-files-into-png-images-using-applescript\/\">alternative approach<\/a> using AppleScript but this does not work so well on Windows.<\/p>\n<p>Instead we used a Python library, <a href=\"http:\/\/code.google.com\/p\/pywinauto\/\">pywinauto<\/a>, to automate the process of using the ChemSketch GUI to <em>File\/Open<\/em> the ChemSketch file and <em>File\/Export<\/em> a Mol file. The script is shown below. The trickiest part is choosing the delays so that the process runs as fast as possible without failing (due to a ChemSketch operation taking longer than expected):<\/p>\n<p><script src=\"https:\/\/gist.github.com\/3721106.js?file=chemsketchauto.py\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several tools out there for batch conversion of chemical file formats. However, you may not have access to those tools or else a particular file format may not be supported. Sometimes your only option is to open each file in the original software, and export it as a more useful file format. When &hellip; <a href=\"https:\/\/nextmovesoftware.com\/blog\/2012\/09\/14\/using-python-for-batch-conversion-of-chemsketch-files-to-mol-files\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using Python for batch conversion of ChemSketch files to Mol files<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":5,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":22,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions\/22"}],"wp:attachment":[{"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nextmovesoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}