Python Web Service Client

The Python web service API makes it easy to run queries in SynBioMine directly from Python programs. You can use the Python API to construct any query you could run from web interface and fetch the results in a number of structured formats, including native Python data structures, and TSV and CSV strings.


  • Prerequisites

    You should install the Python webservice client library module to get started. You can install it directly from: PyPi (the Python Package Index). This is a public repository of thousands of modules. To install the InterMine python client library type the following command into a shell:

    > sudo easy_install intermine

    This module is pure Python with no external dependencies, so long as your Python is 2.6 or newer. If you have 2.5 (which will be the case if you run Mac OS 10.5 - ie. Leopard), you will need to run the following command (we also recommend upgrading - see here):

    > sudo easy_install simplejson

    The client library has been tested on Python 2.5, 2.6 & 2.7, on Linux, Windows and Mac OS X, and like all our code is open-source, licensed under the LGPL. For information on the API visit our introduction to the webservices: http://intermine.readthedocs.org/en/latest/web-services/.

    For other installation options, and a general guide to usage, please see here: http://pythonhosted.org/intermine/

  • Examples of using the downloaded script

    On each Template Query page and the QueryBuilder there is a link to get Python code to run that particular query using the web service API. Just click the link, save the generated Python script in a file and execute it. You can use the generated code as a starting point for your own programs.

    You can run the downloaded script by running the following command in a shell:

    > python path/to/downloaded/script.py

    If you get an error saying ImportError: no module named intermine.webservice or similar, then see 'Prerequisites' above. Feel free to edit the script - these are designed to be spring-boards to help you get where you want to. For further documentation, please read the detailed API documentation at http://pythonhosted.org/intermine/

    For a good reference to getting started in Python, visit the Python Beginners Guide .