def _get_options(self, options, kwargs):
# this species parameter is added to the query, thus will
# change facet counts.
kwargs['species'] = self._cleaned_species(kwargs.get('species', None))
include_tax_tree = kwargs.pop('include_tax_tree', False)
if include_tax_tree:
headers = {'content-type': 'application/x-www-form-urlencoded',
'user-agent': "Python-requests_mygene.info/%s (gzip)"
% requests.__version__}
# TODO: URL as config param
res = requests.post('http://t.biothings.io/v1/taxon?ids=' +
','.join(['{}'.format(sid) for sid in
kwargs['species']]) +
'&expand_species=true', headers=headers)
if res.status_code == requests.codes.ok:
kwargs['species'] = res.json()
# this parameter is to add species filter without
# changing facet counts.
kwargs['species_facet_filter'] = self._cleaned_species(
kwargs.get('species_facet_filter', None), default_to_none=True)
options.kwargs = kwargs
return options
评论列表
文章目录