Table Of Contents

This Page

How Do I?

This page presents goal-orientated documentation of the features of the web-service API. ie. it is a collection of answers to the question “How do I do {x}?”.

In all the examples below, the www.flymine.org website will be used as a reference. Common tools used in examples will be curl, and the client libraries published in perl, python, ruby and javascript.

To access personal resources (those that are not available publically, and only accessible in the web-application after logging in), you will need to provide an authentication token.

How Do I Get A Listing of My Lists?

You simply need to make a GET request to the /lists resource:

curl -H 'Accept: application/tsv' http://beta.flymine.org/beta/service/lists

The above request will show only public lists. To see yours as well, provide an authentication token:

curl -H 'Accept: application/tsv' http://beta.flymine.org/beta/service/lists?token=$TOKEN

To do something similar in Perl:

use 5.12.0;
use Webservice::InterMine 1.0301;

my $TOKEN   = undef; # provide a token to see your lists.
my $flymine = get_service('www.flymine.org/query', $TOKEN);

say for $flymine->lists;

Or Python:

from intermine.webservice import Service
TOKEN = None # supply a token to see your own lists.

flymine = Service('www.flymine.org/query', token = TOKEN)

for l in flymine.get_all_lists():
  print l

Or Ruby:

require 'intermine/service'
TOKEN = nil # supply a token to see your own lists.

flymine = Service.new('www.flymine.org/query', TOKEN)
flymine.lists.each do |list|
  puts list
end

Or javascript:

var util      = require('util');
var intermine = require('imjs');

var flymine = new intermine.Service({
  root: 'www.flymine.org/query',
  token: null // supply a token to see your own lists.
});

flymine.fetchLists().done(function(lists) {
  lists.forEach(function(list) {
    console.log(util.format("%s: ( %d %ss )", list.name, list.size, list.type));
  });
});

How Do I Get a Summary of a Gene?

You need to make a request to the query/results resource:

You can make either a GET or a POST request - it may be better to make POST requests if your query gets large. The query format must be provided as an XML document in the InterMine PathQuery XML format, and to write meaningful queries you will need to know a bit about the data model. For these reasons we recommend you consider using the client libraries below. But if you do want to make the request using a tool such as curl, it would look like this:

QUERY='<query model="genomic"
   view="Gene.symbol Gene.name Gene.primaryIdentifier Gene.length Gene.chromosome.primaryIdentifier
         Gene.chromosomeLocation.start Gene.chromosomeLocation.end">
      <constraint path="Gene.symbol" op="=" value="eve"/>
      </query>'
curl --data-urlencode query="$QUERY" http://www.flymine.org/query/service/query/results

This can be done much more concisely using the other tools, such as the Perl client libaries. Notice that here the library uses introspection of the data model to provide the appropriate fields.:

use 5.12.0;
use Webservice::InterMine 1.0301;

my $flymine = get_service('www.flymine.org/query');
my $eve = $flymine->select('Gene.*')->where(symbol => 'eve')->first;

say $eve->{name};
say $eve;

Similar faclities are available in the Python client:

from intermine.webservice import Service

flymine = Service('www.flymine.org/query')
eve = flymine.model.Gene.where(symbol = 'eve').first()

print(eve.name)
print(eve)

And in Ruby:

require 'intermine/service'

flymine = Service.new('www.flymine.org/query')
eve = flymine.query('Gene').select('*').where( :symbol => 'eve' ).first

puts eve.name
puts eve

And in JavaScript:

var intermine = require('imjs');

var flymine = new intermine.Service({root: 'www.flymine.org/query'});
var search = flymine.find('Gene', 'eve');

// Only expecting a single match, but the method
// yields a list of matches.
search.done(function(matches) {
  matches.forEach(function(gene) {
    console.log(gene.name);
    console.log(gene);
  });
});