Perl Client Libraries for InterMine Web Services
See InterMinePerl for installation instructions.
Purpose
The InterMine Perl library includes a client for the InterMine web service.
Installation
The InterMine webservice client libraries are available on CPAN:
# The following command will download and install the library
sudo cpan Webservice::InterMine
These modules are actively developed and released in line with the main InterMine release cycle. The activity charts below show the frequency of updates to the main CPAN repositories on a monthly basis:
The code is also available for download from GitHub:
git clone git://github.com/FlyMine/intermine-ws-perl.git
And for downloading directly from intermine.org:
wget 'http://www.intermine.org/lib/perl-webservice-client-0.9700.tar.gz'
And from CPAN:
wget 'http://search.cpan.org/CPAN/authors/id/I/IN/INTERMINE/Webservice-InterMine-0.9700.tar.gz'
Once downloaded, it will need unpacking (if in .tar.gz format), and installing:
perl Build.PL
./Build test
sudo ./Build install
Installed Scripts
Installing the modules also installs two simple scripts for your convenience:
- run-im-query - Run a query by loading xml from a file
- run-im-template - Run a template by passing a set of parameters
Documentation for these scripts can be found by using the man command, or passing the -h flag.
Examples
This script is an example of constructing a complex query and retrieving the results as a multi-dimensional array:
(see also Cookbook recipe 5)
#!/usr/bin/perl use strict; use warnings; # We always recommend the latest module version. use Webservice::InterMine 0.9703 'flymine'; # A query object can be obtained from the Webservice::InterMine module my $query = Webservice::InterMine->new_query(class => 'Gene'); # The view specifies the output columns - here we pass in a list of strings $query->add_views(qw/ symbol organism.shortName microArrayResults.affyCall microArrayResults.enrichment microArrayResults.mRNASignal microArrayResults.tissue.name /); # Constraints can be expressed declaratively $query->add_constraint( path => 'Gene.microArrayResults', type => 'FlyAtlasResult', ); my $body_parts = ['Adult carcass', 'Adult eye', 'Adult fat body', 'Adult heart']; # They can also be called using a more natural syntax. $query->add_constraint('microArrayResults.tissue.name', 'ONE OF', $body_parts); # Queries are iterable objects, and they return one result row per iteration while (my $row = <$query>) { my @columns = @$row; # process the data here # ... }
The following is an example of using the Perl client to query a template (saved query form):
(see also: Cookbook Template Recipe 1)
#!/usr/bin/perl use strict; use warnings; use Webservice::InterMine 0.9703 'flymine'; # Description: Find all screen results for a specified amplicon from a specified # DRSC RNAi screen. Result types can be: not screened, not a hit, weak, medium # or strong hit. (Data Source: DRSC). # Requesting non-existant templates returns undef my $template = Webservice::InterMine->template('AmpliconScreen_RNAiResults') or die 'Could not find template'; # The show_with method displays a readable table to standard output - it is a good way # of initially investigating results by eye. $template->show_with( # A: RNAiScreenHit.rnaiScreen.publication.pubMedId - from the RNAi screen # published in this paper: opA => '=', valueA => '16452979', # B: RNAiScreenHit.pcrProduct - Show all results for the following amplicon opB => 'LOOKUP', valueB => 'DRSC04651', );
Generated Code Examples
You do not have to write your own code - you can get the webapp for your preferred webservice to generate the code for you - simply click on one of the code generation links at the bottom of any query-builder or template-form page:
Other clients
We also have client libraries for:
Attachments
-
template_do_codegen.png
(68.5 KB) -
added by alex 12 months ago.
-
querybuilder_do_codegen.png
(96.1 KB) -
added by alex 12 months ago.


