Skip to Content
Bioinformatics with Python Cookbook - Second Edition
book

Bioinformatics with Python Cookbook - Second Edition

by Tiago Antao
November 2018
Intermediate to advanced
360 pages
9h 36m
English
Packt Publishing
Content preview from Bioinformatics with Python Cookbook - Second Edition

How to do it...

Let's take a look at the following steps:

  1. First, let's define a function to get the data on REST, as shown in the following code:
import requestsdef do_request(service, a1=None, a2=None, a3=None, **kwargs):    server = 'http://api.gbif.org/v1'    params = ''    for a in [a1, a2, a3]:        if a is not None:            params += '/' + a    req = requests.get('%s/%s%s' % (server, service, params),        params=kwargs, headers={'Content-Type': 'application/json'})    if not req.ok:        req.raise_for_status()    return req.json()
  1. Then, look at how many species records refer to the word bear. Remember that this is actually more general than species. You will also get records for all kinds of taxonomic ranks with the following code:
req = do_request('species', 'search', ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bioinformatics with Python Cookbook

Bioinformatics with Python Cookbook

Tiago Antao

Publisher Resources

ISBN: 9781789344691Supplemental Content