Mercurial > repos > iuc > ena_upload
comparison check_remote.py @ 4:26ccb678abc8 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ena_upload commit ba358013c83e7dfffec895946d36585f237e54c5"
author | iuc |
---|---|
date | Tue, 19 Oct 2021 15:57:14 +0000 |
parents | |
children | 4aab5ae907b6 |
comparison
equal
deleted
inserted
replaced
3:59bb6d34fca6 | 4:26ccb678abc8 |
---|---|
1 import json | |
2 | |
3 import requests | |
4 | |
5 URL = "https://www.ebi.ac.uk/ena/portal/api/search" | |
6 | |
7 | |
8 def check_remote_entry(entry_type, query_dict, out_format='json'): | |
9 ''' | |
10 Checks if an entry with that alias exists in the ENA repos | |
11 entry_type = [study | sample | experiment | run] | |
12 ''' | |
13 assert entry_type in ['study', 'sample', 'experiment', 'run'] | |
14 params_dict = {} | |
15 query_str = ' AND '.join(['%s=%s' % (key, value) for (key, value) in query_dict.items()]) | |
16 params_dict['query'] = query_str | |
17 params_dict['result'] = 'read_' + entry_type | |
18 params_dict['fields'] = entry_type + '_alias' | |
19 params_dict['format'] = out_format | |
20 response = requests.post(URL, data=params_dict) | |
21 if response.content != b'': | |
22 return json.loads(response.content) | |
23 return [] |