-
Notifications
You must be signed in to change notification settings - Fork 53
Using RESTful web services
In this tutorial you will learn how to query CellBase web services using different technologies and programming languages. You are encouraged to visit RESTful Web Services documentation to understand and learn how CellBase web services have been designed and implemented.
There are several public CellBase RESTful servers you can use. In this tutorial we will use EMBL-EBI CellBase host URL www.ebi.ac.uk/cellbase/webservices/rest but you can change it by any other host. You can also follow the Download and Installation and Load Data Models tutorials and install your own RESTful server, then you can use localhost:8080/cellbase/webservices/rest.
Technologies and programming languages:
- [curl](Using RESTful web services#using-curl)
- [Python](Using RESTful web services#using-python)
- [Java](Using RESTful web services#using-java)
- [R](Using RESTful web services#using-r)
- [Javscript](Using RESTful web services#using-javascript)
curl is a command line tool and library for transferring data with URL syntax. It supports many different protocols including HTTP what allows to use it to query data.
- Get information of Human genes located in Chromosome 3 between coordinates 55 and 100000; execute
curl http://www.ebi.ac.uk/cellbase/webservices/rest/v3/hsapiens/genomic/region/3:55-100000/gene
- Get all Human variants associated with beta-Thalassemia:
curl http://www.ebi.ac.uk/cellbase/webservices/rest/v3/hsapiens/genomic/variant/beta_Thalassemia/phenotype
- Get information for all Drosophila Melanogaster chromosomes:
curl http://wwwdev.ebi.ac.uk/cellbase/webservices/rest/v3/dmelanogaster/genomic/chromosome/all
Python is a general programming language that lets you work quickly and integrate systems more effectively. You can easily query RESTful web services using urllib2 library. This snippet retrieves all the human genes in a particular region.
#!/usr/bin/python
import urllib2
import json
import zlib
url = 'http://wwwdev.ebi.ac.uk/cellbase/webservices/rest/v3/hsapiens/genomic/region/3:1104666-1166667/gene'
req = urllib2.Request(url)
req.add_header("Accept-Encoding", "gzip")
response = urllib2.urlopen(req)
json_data = response.read()
data = zlib.decompress(json_data, 16+zlib.MAX_WBITS)
data = json.loads(data)
print data
#!/usr/bin/python
import urllib2 import json import zlib
url = 'http://wwwdev.ebi.ac.uk/cellbase/webservices/rest/v3/hsapiens/genomic/region/3:1104666-1166667/gene' req = urllib2.Request(url) req.add_header("Accept-Encoding", "gzip")
response = urllib2.urlopen(req) json_data = response.read()
data = zlib.decompress(json_data, 16+zlib.MAX_WBITS) data = json.loads(data)
print data
##### Using JavaScript