BioGroovy and Grapes

As many Perl programmers know CPAN (the Comprehensive Perl Archive Network) is an invaluable repository for Perl modules.  You can easily download and install a module and add its functionality to your script.  In order for scripting languages like Groovy to gain some traction with the bioinformatics crowd there needs to be a similar repository for JARs.  Fortunately for Groovy there’s no need to reinvent the wheel. We can use Groovy’s packaging system (called Grape) with the existing ibiblio, and maven repositories, and you can even use your local maven repository.

To install a module on your local system you simply type: grape install
where group is the maven group id for the module, and module is the name of the module you want to install.  To figure out the group and module IDs you can visit the mvnrepository site.

Suppose you want to install the Lucene search engine library so that you can index some papers that you’ve downloaded.  You enter grape install org.apache.lucene lucene-core and the module is downloaded and installed locally.

This is nice if you know the dependencies, but what if you want to share your script with a colleague, how do you insure that all of the dependencies are downloaded?  You can use the @Grab annotation within your script.  This way, every time your script is run it resolves the dependencies prior to executing your script.  The snippet below shows all the code that you need to add to your script.

import org.apache.lucene.*;
@Grab(group=’org.apache.lucene’, module=’lucene-core’, version=’3.0.0′)
// lucene code goes here

NOTE: The BioJava 3 wiki page gives you an idea of the types of modules that are currently being developed.


About Mark Fortner

I write software for scientists doing drug discovery and cancer research. I'm interested in Design Thinking, Agile Software Development, Web Components, Java, Javascript, Groovy, Grails, MongoDB, Firebase, microservices, the Semantic Web Drug Discovery and Cancer Biology.
This entry was posted in Bioinformatics, Informatics and tagged , , . Bookmark the permalink.

One Response to BioGroovy and Grapes

  1. Will says:

    I loved it! I’m studying Groovy right now and i’m amazed with how much the language can be less bloated, compared to Java, and how the way it is built can bring new stuff, like Grape.

    Keep up the good work =)

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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