annotate iedb_api.py @ 4:a14128950578 draft default tip

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