Mercurial > repos > iuc > iedb_api
annotate iedb_api.py @ 2:a09849898387 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit f4629adca2e0f6d5f0cdfea8e11ce65abf218adf"
author | iuc |
---|---|
date | Wed, 29 Jul 2020 17:29:56 -0400 |
parents | 6cf84410cb2e |
children | e95d3221b7f0 |
rev | line source |
---|---|
0
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
2 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
3 import argparse |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
4 import os.path |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
5 import re |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
6 import sys |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
7 import time |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
8 from urllib.error import HTTPError |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
9 from urllib.parse import unquote, urlencode |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
10 from urllib.request import urlopen |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
11 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
12 mhci_methods = ['recommended', 'consensus', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
13 'netmhcpan_ba', 'netmhcpan_el', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
14 'ann', 'smmpmbec', 'smm', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
15 'comblib_sidney2008', 'netmhccons', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
16 'pickpocket', 'netmhcstabpan'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
17 mhcii_methods = ['recommended', 'consensus', 'NetMHCIIpan', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
18 'nn_align', 'smm_align', 'comblib', 'tepitope'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
19 processing_methods = ['recommended', 'netmhcpan', 'ann', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
20 'smmpmbec', 'smm', 'comblib_sidney2008', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
21 'netmhccons', 'pickpocket'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
22 mhcnp_methods = ['mhcnp', 'netmhcpan'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
23 bcell_methods = ['Bepipred', 'Chou-Fasman', 'Emini', 'Karplus-Schulz', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
24 'Kolaskar-Tongaonkar', 'Parker', 'Bepipred-2.0'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
25 prediction_methods = {'mhci': mhci_methods, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
26 'mhcii': mhcii_methods, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
27 'processing': processing_methods, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
28 'mhcnp': mhcnp_methods, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
29 'bcell': bcell_methods} |
1
6cf84410cb2e
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 848c47fb29e9f1d319056a94a7dbd90129a4aafc"
iuc
parents:
0
diff
changeset
|
30 all_methods = set(mhci_methods + mhcii_methods + mhcnp_methods + bcell_methods) |
0
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
31 prediction_lengths = {'mhci': range(8, 16), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
32 'mhcii': range(11, 31), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
33 'processing': range(8, 15), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
34 'mhcnp': range(8, 12), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
35 'bcell': range(8, 16)} |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
36 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
37 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
38 def parse_alleles(allelefile, lengths): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
39 alleles = [] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
40 lengths = [] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
41 with open(allelefile, 'r') as fh: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
42 for i, line in enumerate(fh): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
43 fields = line.strip().split(',') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
44 allele = fields[0].strip() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
45 if allele: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
46 if len(fields) > 1: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
47 for alen in fields[1:]: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
48 alleles.append(allele) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
49 lengths.append(alen) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
50 elif lengths: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
51 for alen in str(lengths).split(','): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
52 alleles.append(allele) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
53 lengths.append(alen) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
54 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
55 alleles.append(allele) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
56 return (alleles, lengths) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
57 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
58 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
59 def query(url, prediction, seq, allele, length, results, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
60 seqid=None, method='recommended', proteasome=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
61 timeout=300, retries=3, sleep=300, debug=False): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
62 params = dict() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
63 if method: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
64 params['method'] = method.encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
65 if proteasome: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
66 params['proteasome'] = proteasome.encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
67 params['sequence_text'] = seq.strip().encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
68 if allele is not None: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
69 params['allele'] = allele.encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
70 if length is not None: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
71 if prediction == 'bcell': |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
72 params['window_size'] = str(length).encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
73 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
74 params['length'] = str(length).encode() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
75 req_data = urlencode(params) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
76 if debug: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
77 print('url %s %s' % (url, unquote(req_data)), file=sys.stderr) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
78 retries = max(0, retries) + 1 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
79 for retry in range(1, retries): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
80 response = None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
81 try: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
82 response = urlopen(url, data=req_data.encode('utf-8'), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
83 timeout=timeout) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
84 if response and response.getcode() == 200: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
85 data = [line.decode() for line in response.readlines()] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
86 if debug: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
87 print(data, file=sys.stderr) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
88 rslts = results['prediction']['entries'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
89 for ln, line in enumerate(data): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
90 if 'invalid' in line.lower() or 'tools_api.html' in line: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
91 msg = '%s %s\n%s' % (url, unquote(req_data), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
92 ''.join(data)) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
93 warn_err(msg, exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
94 if line.find('eptide') > 0: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
95 results['prediction']['header'] = "#%s%s" %\ |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
96 ("ID\t" if seqid else "", line) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
97 continue |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
98 elif method == 'Bepipred' and line.find('Residue') > 0: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
99 results['detail']['header'] = "#%s%s" %\ |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
100 ("ID\t" if seqid else "", line) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
101 rslts = results['detail']['entries'] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
102 continue |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
103 if seqid: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
104 rslts.extend("%s\t%s" % (seqid, line)) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
105 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
106 rslts.extend(line) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
107 break |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
108 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
109 code = response.getcode() if response else 1 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
110 warn_err("Error connecting to IEDB server\n", |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
111 exit_code=code) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
112 except HTTPError as e: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
113 code = None if retry < retries else e.code |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
114 warn_err("%d of %d Error connecting to IEDB server %s\n" % |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
115 (retry, retries, e), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
116 exit_code=code) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
117 time.sleep(sleep) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
118 except Exception as e: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
119 warn_err("Error connecting to IEDB server %s\n" % e, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
120 exit_code=3) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
121 return results |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
122 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
123 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
124 def warn_err(msg, exit_code=1): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
125 sys.stderr.write(msg) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
126 sys.stderr.flush() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
127 if exit_code: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
128 sys.exit(exit_code) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
129 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
130 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
131 def __main__(): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
132 # Parse Command Line |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
133 parser = argparse.ArgumentParser(description='', epilog='') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
134 parser.add_argument('-p', '--prediction', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
135 default='mhci', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
136 choices=prediction_methods.keys(), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
137 help='IEDB API prediction service') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
138 parser.add_argument('-s', '--sequence', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
139 action="append", |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
140 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
141 help='Peptide Sequence') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
142 parser.add_argument('-m', '--method', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
143 default='recommended', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
144 choices=all_methods, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
145 help='prediction method') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
146 parser.add_argument('-P', '--proteasome', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
147 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
148 choices=['immuno', 'constitutive'], |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
149 help='IEDB processing proteasome type') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
150 parser.add_argument('-a', '--allele', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
151 action="append", |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
152 default=[], |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
153 help='Alleles for which to make predictions') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
154 parser.add_argument('-A', '--allelefile', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
155 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
156 help='File of HLA alleles') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
157 parser.add_argument('-l', '--length', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
158 action="append", |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
159 default=[], |
1
6cf84410cb2e
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 848c47fb29e9f1d319056a94a7dbd90129a4aafc"
iuc
parents:
0
diff
changeset
|
160 help='lengths for which to make predictions, ' |
0
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
161 '1 per allele') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
162 parser.add_argument('-w', '--window_size', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
163 type=int, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
164 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
165 help='window_size for bcell prediction') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
166 parser.add_argument('-i', '--input', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
167 default=None, |
1
6cf84410cb2e
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 848c47fb29e9f1d319056a94a7dbd90129a4aafc"
iuc
parents:
0
diff
changeset
|
168 help='Input file for peptide sequences ' |
0
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
169 '(fasta or tabular)') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
170 parser.add_argument('-c', '--column', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
171 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
172 help='Peptide Column in a tabular input file') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
173 parser.add_argument('-C', '--id_column', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
174 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
175 help='ID Column in a tabular input file') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
176 parser.add_argument('-o', '--output', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
177 default=None, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
178 help='Output file for query results') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
179 parser.add_argument('-O', '--output2', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
180 default='iedb_results2', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
181 help='Output file for secondary query results') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
182 parser.add_argument('-t', '--timeout', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
183 type=int, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
184 default=600, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
185 help='Seconds to wait for server response') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
186 parser.add_argument('-r', '--retries', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
187 type=int, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
188 default=5, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
189 help='Number of times to retry server query') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
190 parser.add_argument('-S', '--sleep', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
191 type=int, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
192 default=300, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
193 help='Seconds to wait between retries') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
194 parser.add_argument('-d', '--debug', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
195 action='store_true', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
196 default=False, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
197 help='Turn on wrapper debugging to stderr') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
198 args = parser.parse_args() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
199 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
200 aapat = '^[ABCDEFGHIKLMNPQRSTVWY]+$' |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
201 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
202 if args.prediction != 'bcell': |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
203 if not args.allele and not args.allelefile: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
204 warn_err('-a allele or -A allelefile required\n', exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
205 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
206 if not (args.sequence or args.input): |
1
6cf84410cb2e
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 848c47fb29e9f1d319056a94a7dbd90129a4aafc"
iuc
parents:
0
diff
changeset
|
207 warn_err('NO Sequences given: ' |
0
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
208 'either -s sequence or -i input_file is required\n', |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
209 exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
210 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
211 if args.output is not None: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
212 try: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
213 outputPath = os.path.abspath(args.output) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
214 outputFile = open(outputPath, 'w') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
215 except Exception as e: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
216 warn_err("Unable to open output file: %s\n" % e, exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
217 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
218 outputFile = sys.stdout |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
219 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
220 # params |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
221 alleles = [] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
222 lengths = [] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
223 if args.prediction == 'bcell' and args.window_size is not None: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
224 lengths.append(str(args.window_size)) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
225 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
226 if args.allelefile: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
227 (alleles, lengths) = parse_alleles(args.allelefile, args.length) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
228 if args.allele: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
229 for i, allele in enumerate(args.allele): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
230 alleles.append(allele) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
231 alen = args.length[i] if i < len(args.length) else args.length[-1] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
232 lengths.append(alen) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
233 allele = ','.join(alleles) if alleles else None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
234 length = ','.join(lengths) if lengths else None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
235 method = args.method |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
236 proteasome = args.proteasome if args.prediction == 'processcing' else None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
237 url = 'http://tools-cluster-interface.iedb.org/tools_api/%s/' %\ |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
238 args.prediction |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
239 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
240 # results |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
241 results = {'prediction': {'header': None, 'entries': []}, 'detail': {'header': None, 'entries': []}} |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
242 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
243 if args.sequence: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
244 for i, seq in enumerate(args.sequence): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
245 seqid = 'pep_%d' % i |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
246 query(url, args.prediction, seq, allele, length, results, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
247 seqid=seqid, method=method, proteasome=proteasome, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
248 timeout=args.timeout, retries=args.retries, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
249 sleep=args.sleep, debug=args.debug) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
250 if args.input: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
251 try: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
252 fh = open(args.input, 'r') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
253 if args.column: # tabular |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
254 col = int(args.column) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
255 idcol = int(args.id_column) if args.id_column else None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
256 for i, line in enumerate(fh): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
257 fields = line.rstrip('\r\n').split('\t') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
258 if len(fields) > col: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
259 seq = re.sub('[_*]', '', fields[col].strip()) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
260 if re.match(aapat, seq): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
261 if idcol is not None and idcol < len(fields): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
262 seqid = fields[idcol] |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
263 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
264 seqid = 'pep_%d' % i |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
265 query(url, args.prediction, seq, allele, length, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
266 results, seqid=seqid, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
267 method=method, proteasome=proteasome, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
268 timeout=args.timeout, retries=args.retries, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
269 sleep=args.sleep, debug=args.debug) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
270 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
271 warn_err('Line %d, Not a peptide: %s\n' % (i, seq), |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
272 exit_code=None) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
273 else: # fasta |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
274 seqid = None |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
275 seq = '' |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
276 for i, line in enumerate(fh): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
277 if line.startswith('>'): |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
278 if seqid and len(seq) > 0: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
279 query(url, args.prediction, seq, allele, length, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
280 results, seqid=seqid, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
281 method=method, proteasome=proteasome, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
282 timeout=args.timeout, retries=args.retries, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
283 sleep=args.sleep, debug=args.debug) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
284 seqid = line[1:].strip() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
285 seq = '' |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
286 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
287 seq += line.strip() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
288 if seqid and len(seq) > 0: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
289 query(url, args.prediction, seq, allele, length, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
290 results, seqid=seqid, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
291 method=method, proteasome=proteasome, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
292 timeout=args.timeout, retries=args.retries, |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
293 sleep=args.sleep, debug=args.debug) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
294 fh.close() |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
295 except Exception as e: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
296 warn_err("Unable to open input file: %s\n" % e, exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
297 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
298 if results['prediction']['header']: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
299 outputFile.write(results['prediction']['header']) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
300 for line in results['prediction']['entries']: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
301 outputFile.write(line) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
302 if results['detail']['entries']: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
303 if args.output2: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
304 try: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
305 outPath = os.path.abspath(args.output2) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
306 outFile = open(outPath, 'w') |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
307 except Exception as e: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
308 warn_err("Unable to open output file: %s\n" % e, exit_code=1) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
309 else: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
310 outFile = sys.stdout |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
311 if results['detail']['header']: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
312 outFile.write(results['detail']['header']) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
313 for line in results['detail']['entries']: |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
314 outFile.write(line) |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
315 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
316 |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
317 if __name__ == "__main__": |
fe3c43451319
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff
changeset
|
318 __main__() |