The Python web service API makes it easy to run queries in MouseMine 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.
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
For other installation options, and a general guide to usage, please see here: http://pythonhosted.org/intermine/
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
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 .