annotate iedb_api.py @ 0:fe3c43451319 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
author iuc
date Fri, 28 Feb 2020 18:09:34 -0500
parents
children 6cf84410cb2e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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}
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
30 all_methods = set(mhci_methods + mhcii_methods +
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
31 mhcnp_methods + bcell_methods)
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
32 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
33 '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
34 '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
35 '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
36 '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
37
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
38
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
39 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
40 alleles = []
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
41 lengths = []
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
42 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
43 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
44 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
45 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
46 if allele:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
47 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
48 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
49 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
50 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
51 elif lengths:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
52 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
53 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
54 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
55 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
56 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
57 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
58
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
59
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
60 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
61 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
62 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
63 params = dict()
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
64 if method:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
65 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
66 if proteasome:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
75 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
76 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
77 if debug:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
78 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
79 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
80 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
81 response = None
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
82 try:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
83 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
84 timeout=timeout)
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
85 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
86 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
87 if debug:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
88 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
89 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
90 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
91 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
92 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
93 ''.join(data))
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
94 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
95 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
96 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
97 ("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
98 continue
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
99 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
100 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
101 ("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
102 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
103 continue
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
104 if seqid:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
105 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
106 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
107 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
108 break
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
109 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
110 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
111 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
112 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
113 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
114 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
115 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
116 (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
117 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
118 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
119 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
120 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
121 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
122 return results
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
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
125 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
126 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
127 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
128 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
129 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
130
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
131
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
132 def __main__():
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
133 # 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
134 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
135 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
136 default='mhci',
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
137 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
138 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
139 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
140 action="append",
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
141 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
142 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
143 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
144 default='recommended',
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
145 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
146 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
147 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
148 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
149 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
150 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
151 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
152 action="append",
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
153 default=[],
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
154 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
155 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
156 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
157 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
158 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
159 action="append",
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
160 default=[],
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
161 help='lengths 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
162 '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
163 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
164 type=int,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
165 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
166 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
167 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
168 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
169 help='Input file for peptide sequences ' +
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
170 '(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
171 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
172 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
173 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
174 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
175 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
176 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
177 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
178 default=None,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
179 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
180 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
181 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
182 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
183 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
184 type=int,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
185 default=600,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
186 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
187 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
188 type=int,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
189 default=5,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
190 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
191 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
192 type=int,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
193 default=300,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
194 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
195 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
196 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
197 default=False,
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
198 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
199 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
200
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
201 aapat = '^[ABCDEFGHIKLMNPQRSTVWY]+$'
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
202
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
203 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
204 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
205 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
206
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
207 if not (args.sequence or args.input):
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
208 warn_err('NO Sequences given: ' +
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
209 '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
210 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
211
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
212 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
213 try:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
214 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
215 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
216 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
217 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
218 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
219 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
220
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
221 # params
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
222 alleles = []
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
223 lengths = []
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
224 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
225 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
226 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
227 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
228 (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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 args.prediction
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
240
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
241 # results
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
242 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
243
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 try:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
265 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
266 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
267 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
268 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
269 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
270 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
271 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
272 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
273 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
274 else: # fasta
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
275 seqid = None
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
276 seq = ''
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 seq = ''
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
287 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 fh.close()
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
296 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
297 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
298
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
299 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
300 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
301 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
302 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
303 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
304 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
305 try:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
306 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
307 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
308 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
309 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
310 else:
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
311 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
312 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
313 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
314 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
315 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
316
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
317
fe3c43451319 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iedb_api commit 9aaa7c6c7241db52681b12939ebd908902830ef1"
iuc
parents:
diff changeset
318 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
319 __main__()