comparison get_sequences.py @ 7:d6bb417dc831 draft default tip

"planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/Ensembl-REST commit 17c65045b726d0695814bfe761e534f6521786f1"
author earlhaminst
date Tue, 20 Oct 2020 15:06:54 +0000
parents 70e4134eb0ed
children
comparison
equal deleted inserted replaced
6:70e4134eb0ed 7:d6bb417dc831
21 help='Expand the sequence upstream of the sequence by this many basepairs. Only available when using genomic sequence type') 21 help='Expand the sequence upstream of the sequence by this many basepairs. Only available when using genomic sequence type')
22 options, args = parser.parse_args() 22 options, args = parser.parse_args()
23 if options.input is None: 23 if options.input is None:
24 raise Exception('-i option must be specified') 24 raise Exception('-i option must be specified')
25 25
26 server = 'http://rest.ensembl.org' 26 server = 'https://rest.ensembl.org'
27 ext = 'sequence/id' 27 ext = 'sequence/id'
28 28
29 headers = {'Content-Type': 'text/x-fasta', 'Accept': 'text/x-fasta'} 29 headers = {'Content-Type': 'text/x-fasta', 'Accept': 'text/x-fasta'}
30 params = dict((k, getattr(options, k)) for k in ['type', 'expand_3prime', 'expand_5prime']) 30 params = dict((k, getattr(options, k)) for k in ['type', 'expand_3prime', 'expand_5prime'])
31 with open(options.input) as f: 31 with open(options.input) as f:
34 ids = [line.strip() for line in islice(f, 50)] 34 ids = [line.strip() for line in islice(f, 50)]
35 if not ids: 35 if not ids:
36 break 36 break
37 data = {'ids': ids} 37 data = {'ids': ids}
38 r = requests.post(urljoin(server, ext), params=params, headers=headers, 38 r = requests.post(urljoin(server, ext), params=params, headers=headers,
39 data=json.dumps(data)) 39 data=json.dumps(data), allow_redirects=False)
40 40
41 if not r.ok: 41 if not r.ok:
42 r.raise_for_status() 42 r.raise_for_status()
43 43
44 print(r.text) 44 print(r.text)