Automation Scripting for Scientists - How to Get Your Feet Wet with Programming in the Lab
Updated: Jul 12, 2020
Why would a scientist learn programming?
Do you like math? Do you like strategy games or puzzles by chance? My taste for these things made programming a rewarding hobby that has found it's way into my professional tool set. It's undeniably a good skill everywhere, but is it necessary for scientists? It's certainly useful as automation instruments continue becoming increasingly common to handle larger portions of a scientist's lab bench workflow.
There is a world of difference between software engineering and lab automation scripting, so don't let the complexity of computer program deter you. The truth is, you don't even need to know how to write code to engineer a software solution these days, even for complex applications. Sure you could write your own custom applications to handle workflow and data problems, but automation vendors are making that need obsolete by releasing their own streamlined scripting platforms.
OK, so how to go about learning this?
Rather than approaching programming head-on, I had better success in flirting with it through an intuitive off-the-shelf platform streamlined for a particular purpose. This includes scripting environments for essential lab automation technology. These scripting interfaces are largely user interface (UI) based and are streamlined drag and drop command options to provide an intuitive scripting toolkit.
Many of them will offer the same exact logic tools, which exist in some form in all programming languages. There are so many factors, but largely you just need to get over that usability learning curve to be able to experiment with the toolkit. Often this is just time spent, something that is inevitable for anyone who wants to learn lab automation scripting, even experienced programmers from other backgrounds. Above and Below are snapshots of what scripting environments look like for Hamilton and Tecan liquid handlers.
I've heard some scoff at the idea, but the common spreadsheet tool Excel is by far one of the most useful tools I used to learn programming. This is because it provides an intuitive interface to release a streamlined set of commands to the user for data manipulation. Now I use google to find examples of most of the issues that I come across. Actually I prefer Google Sheets (based totally on Excel), because they have a slick built-in 'query' function offering a more visually oriented way of getting one's feet wet with sequence query languages (SQL). I recommend this tutorial to explore that. This is another language that is very useful in working with lab data .
Useful and common tools in lab automation scripting
I'm not here to teach anyone to program, but below is a brief stab at some concepts that are crucial for lab automation scripting. If you understand these well, you are in a great position to begin using programming to solve problems in the lab and beyond. If any of these concepts sound unfamiliar, then you should work toward understanding them. I recommend doing so by picking a platform with a programming tool kit and experimenting. This is by no means a comprehensive list, but quite the opposite. These are basic and universal concepts.
variables - Algebra is the most basic tool that we start to use in helping learn scripting. The concept of variables in coding extends far beyond the use in algebra because they represent anything from numbers, to dates and time, to text blocks, more complex data objects, or even large sets of structured data.
reacting to conditions - Programmer tools like loops, if/else, while, try/catch are powerful and universal to most scripting environments. These tools allow us to control the flow of action depending on conditions that we set up, and are the building blocks of programming. Many introductory programming courses will explain what these tools are and how to use them.
methods - Method are protocols for computers and robots to follow. They are programmed using the tools described above (and many more) to define how the instrument will operate. Once the method has been written, it can be executed anytime to carry out that for which it was designed. Flexible methods use variables to represent crucial values, and this allows solutions that are flexible enough to handle a wide variety of conditions. Often these variables need to be defined for the method to function properly, so they are passed in as parameters at the time that the method is executed.
UI development - UI's allow for users to interface with the application, by providing necessary parameters or decisions required to run. Most scripting environments will provide a streamlined way to do this.Think of this as building a custom interface using a PowerPoint-esque environment that is tied to the scripting tools above allowing user interaction with the method.
worklist - this s a common term in the lab automation field for the instruction set that can be provided to the automation instrument in the form of a structured data set. These data sets are generated when then scientists designs the experiment, ideally by a software platform like LIMS that will provide a worklist as a file in the appropriate format (csv, xml, etc). This strategy is used to flexibly supply experiment parameters required to launch experiment methods. Data handling is an important part of lab automation, including the processing of these worklist instructions and the preparation of experiment result reports.
drivers - A device driver is a piece of software that makes device specific information available about how that device can be controlled programatically. In lab automation, devices are called upon in methods by referencing the instrument driver. This allows a single scripting interface allowing users to available device commands within their methods. Think of this driver as a translator for software instructions in the method into appropriate firmware commands that actually allow control of the instrument hardware. This means when the method executes, the instruments know exactly how to respond.
Do scientists really need to learn programming to stay relevant in the lab of the future?
You don't need to know much programming to get these lab automation instruments running on a basic level. Rather than fretting the daunting task of learning programming in order to remain relevant, just gain a general familiarity with the instruments themselves. If you understand how they work, then you will probably be keen to use them to make your life easier. If you learn how to use those scripting environments to control your instruments, you can use that as a platform to start learning about how the concepts above apply to problem solving and protocol development for these instruments. In doing this, you will be inadvertently learning programming skills that could further your career in other ways.
If this caches your interest, here are some other useful environments for scripting and software development that have been directly useful to me in lab automation:
windows scripting tools like command prompt and powershell are super useful for IT related processes automation
software development environment like visual studio and pycharm provide powerful platforms to solve issues, ranging from simple scripts to more complex applications.
visual basic scripting - automating interaction with Microsoft office applications
R and python scripting for big data analytics
So learning about automation scripting doesn't have to be as daunting as traditional programming, but there isn't really a ceiling here. The more programmer chops that one can develop, the more useful they become to labs as new technologies are embraced.
Where do you turn for help and to learn more programming chops?
There is so much invaluable educational content free and readily available on Youtube. Some people like myself prefer a more structured content style, so I used code academy and Pluralsight classes for a while. I found that trying to learn programming in a direct way like that was too daunting. It's so limitless! Learning more and more only made my wheels spin on all the possibilities. However, even thought I could accomplish the classes, concepts weren't sinking in. It wasn't until I started using these tool kits more practically that I started to figure things out.
These days, what is the quickest and most useful resource? Google. I find that the beauty of only being able to build simple software tools is that almost everything that you will be trying to do can be found on a reputable forum. Once you learn how to speak these programming languages, you begin to learn how to ask the right questions. Once you get to that point, you can readily find code and tutorial online that can be readily repurposed for your needs.
I recommend deciding on a project, and then find tutorials that can help you accomplish that project. Something that you are interested in is better for memory retention!