Macs in Chemistry

Insanely Great Science

Scripting is a fundamental lab skill

 

I was very much struck by this blog post on the Cryptogenomicon blog, in particular the comment that biologists need to be able to script.

The most important thing I want you to take away from this talk tonight is that writing scripts in Perl or Python is both essential and easy, like learning to pipette. Writing a script is not software programming. To write scripts, you do not need to take courses in computer science or computer engineering. Any biologist can write a Perl script. A Perl or Python script is not much different from writing a protocol for yourself. The way you get started is that someone gives you one that works, and you learn how to tweak it to do more of what you need. After a while, you'll find you're writing your own scripts from scratch.

I'd probably expand that to say that in most scientific disciplines being able to script is extremely useful. Whilst Perl has been (and maybe still is) a preferred scripting language for biologists I suspect that python is now the “lingua franca” for scientific scripting. I've given a couple of talks recently on the use of open source tools for drug discovery and I asked the audience for a show of hands for different programming/scripting languages and Python seems to be by far the most widespread. Indeed one of the key features that determines the selection of a program is that it provides a scripting interface that allows it to be integrated into a scientific workflow.

I'd also add that scripting does not have to result in some major software program, often the most useful scripts are those that do very simple things that just make life easier. The most popular download on this site is the applescript that simply prints the clipboard, it allows you select a piece of text from a page, copy, then print, no opening another application to paste it into.

Another example of everyday scripts are the Safari extensions, not sure what the structure of a named drug on a web page is, select the name and right click (or control click) and an option appears to search for the highlighted drug on ChemSpider and as if by magic a small window opens displaying the structure. Pretty neat and the beauty is that it only involves a small amount of javascript programming, all the heavy lifting has been done by Apple who provide the Safari extension framework and the ChemSpider folks who provide the database and web service.

Pasted Graphic

Similarly the Chemical Identifier Resolver script makes use of the Chemical Identifier Resolver (CIR) by the CADD Group at the NCI/NIH to convert a huge variety of chemical identifiers into a structure.

I’d also echo the view that you don’t need to have attended a computer science course, I very firmly believe in “cut and paste” school of programming. Take an existing script and modify it to see how it works, then customise it to solve a problem that you have.

In addition to the Applescripts section the “Hints and Tutorials” section of this site includes many more scripts that use Python, Python, javascript etc., you are free to use any as starting points, if you feel they maybe generally useful I’d be happy to add them to the site.

blog comments powered by Disqus