With the recent release of BioGroovy 1.1, we added support for a number of web services. Web service providers like NCBI’s eUtils, EntrezAjax and JournalTOCs have requirements for tracking usage of their services. In some cases, a token must be passed along with each request that identifies the tool making the request, or a specific user email address.
To support this type of interaction, a BioGroovyConfig class was added. In this example, we’ll see how the EntrezGeneSlurper class takes advantage of BioGroovyConfig. In the constructor for EntrezGeneSlurper you’ll see the following snippet:
ConfigObject conf = BioGroovyConfig.getConfig();
this.tool = conf.eutils.tool
this.email = conf.eutils.email
The first line looks for a biogroovy.conf file in your ~/.biogroovy directory. If it doesn’t see a file there, it copies the default configuration into this directory, and throws an exception, letting the user know that they’ve failed to configure the biogroovy.conf file properly. The default configuration file does not contain any real identity information, and so it must be updated with real information in order to be used. Here’s an example of what the default file looks like:
eutils = [
tool : 'biogroovy',
The biogroovy.conf file is in reality a groovy file that is parsed as a groovy ConfigObject. In the first line, we’re declaring the eutils properties, tool and email that need to be sent with each request. In the second line we’re setting the journaltocs.userid property, and in the third line; the EntrezAjax userid. In each of these cases, you’ll need to replace these default values with your own values. The links in this paragraph will take you to the registration pages for these services.
After you’ve configured the biogroovy.conf file, you can run the EntrezGeneSlurperTest, and see the results.