Mercurial > repos > jjohnson > iedb_api
annotate iedb_api.py @ 1:4a89ba6cfc63 draft
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
author | jjohnson |
---|---|
date | Tue, 25 Feb 2020 17:37:34 -0500 |
parents | 991424605492 |
children | 153d5fa7af53 |
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 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
9 from urllib.error import HTTPError |
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.parse import urlencode, unquote |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
11 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
|
12 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
13 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
|
14 '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
|
15 '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
|
16 '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
|
17 'pickpocket', 'netmhcstabpan'] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
18 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
|
19 '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
|
20 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
|
21 '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
|
22 'netmhccons', 'pickpocket'] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
23 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
|
24 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
|
25 '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
|
26 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
|
27 '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
|
28 '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
|
29 '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
|
30 '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
|
31 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
|
32 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
|
33 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
|
34 '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
|
35 '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
|
36 '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
|
37 'bcell': range(8, 16)} |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
38 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
39 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
40 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
|
41 sys.stderr.write(msg) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
42 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
|
43 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
|
44 |
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
45 |
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
46 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
|
47 # 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
|
48 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
|
49 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
|
50 default='mhci', |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
55 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
56 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
|
57 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
|
58 default='recommended', |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
67 default=[], |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
68 help='Alleles 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
|
69 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
|
70 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
71 default=[], |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
72 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
|
73 '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
|
74 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
|
75 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
76 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
77 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
|
78 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
|
79 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
80 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
|
81 '(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
|
82 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
|
83 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
84 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
|
85 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
|
86 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
87 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
|
88 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
|
89 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
96 default=600, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
97 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
|
98 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
|
99 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
100 default=5, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
101 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
|
102 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
|
103 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
104 default=300, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 default=False, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
109 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
|
110 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
|
111 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
112 aapat = '^[ABCDEFGHIKLMNPQRSTVWY]+$' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
113 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
114 if not args.allele and args.prediction != 'bcell': |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
115 warn_err('-a allele 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
|
116 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
117 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
|
118 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
|
119 '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
|
120 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
|
121 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
122 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
|
123 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
124 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
|
125 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
|
126 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
|
127 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
|
128 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
129 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
|
130 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
131 url = 'http://tools-cluster-interface.iedb.org/tools_api/%s/' %\ |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
132 args.prediction |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
133 len_param = 'length' if args.prediction != 'bcell' else 'window_size' |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
134 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
135 # TODO parse alleles from the args.alleles file |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
136 alleles = ','.join(args.allele) if args.prediction != 'bcell' else None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
137 lengths = ','.join(args.length) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
138 if args.prediction == 'bcell': |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
139 lengths = args.window_size |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
140 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
|
141 proteasome = args.proteasome if args.prediction == 'processcing' else None |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
142 global header |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
143 header = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
144 results = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
145 global header2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
146 header2 = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
147 results2 = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
148 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
149 sequence_text = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
150 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
151 def add_seq(seqid, seq): |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
152 sid = seqid if seqid else "peptide%d" % len(sequence_text) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
153 sequence_text.append(">%s\n%s" % (sid, seq)) |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
154 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
155 def query(url, seq, allele, length, seqid=None, method='recommended'): |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
156 global header |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
157 global header2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
158 params = dict() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
159 if method: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
160 params['method'] = method.encode() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
161 if proteasome: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
162 params['proteasome'] = proteasome.encode() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
163 params['sequence_text'] = seq.encode() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
164 if allele 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
|
165 params['allele'] = allele.encode() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
166 if length 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
|
167 params[len_param] = str(length).encode() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
168 req_data = urlencode(params) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
169 if args.debug: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
170 print('url %s %s' % (url, unquote(req_data)), file=sys.stderr) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
171 retries = max(0, args.retries) + 1 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
172 for retry in range(1, retries): |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
173 response = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
174 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
175 response = urlopen(url, data=req_data.encode('utf-8'), |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
176 timeout=args.timeout) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
177 if response and response.getcode() == 200: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
178 data = [line.decode() for line in response.readlines()] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
179 if args.debug: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
180 print(data, file=sys.stderr) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
181 rslts = results |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
182 for ln, line in enumerate(data): |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
183 if line.lower().find('invalid') >= 0: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
184 msg = '%s %s\n%s' % (url, unquote(req_data), |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
185 ''.join(data)) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
186 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
|
187 if line.find('eptide') > 0: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
188 header = "#%s%s" %\ |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
189 ("ID\t" if seqid else "", line) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
190 if args.debug: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
191 print(header, file=sys.stderr) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
192 continue |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
193 elif method == 'Bepipred' and line.find('Residue') > 0: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
194 header2 = "#%s%s" %\ |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
195 ("ID\t" if seqid else "", line) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
196 if args.debug: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
197 print(header2, file=sys.stderr) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
198 rslts = results2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
199 continue |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
200 if seqid: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
201 rslts.extend("%s\t%s" % (seqid, line)) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
202 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
203 rslts.extend(line) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
204 break |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
205 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
206 code = response.getcode() if response else 1 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
207 warn_err("Error connecting to IEDB server\n", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
208 exit_code=code) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
209 except HTTPError as e: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
210 code = None if retry < args.retries else e.code |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
211 warn_err("%d of %d Error connecting to IEDB server %s\n" % |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
212 (retry, retries, e), |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
213 exit_code=code) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
214 time.sleep(args.sleep) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
215 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
|
216 warn_err("Error connecting to IEDB server %s\n" % e, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
217 exit_code=3) |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
218 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
219 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
|
220 for i, seq in enumerate(args.sequence): |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
221 query(url, seq, alleles, lengths, seqid=None, method=method) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
222 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
|
223 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 fields = line.split('\t') |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
230 if len(fields) > col: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
231 seq = re.sub('[_*]', '', fields[col]) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
236 seqid = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
237 query(url, seq, alleles, lengths, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
238 seqid=seqid, method=method) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
239 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
240 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
|
241 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
|
242 else: # fasta |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
243 seqid = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
244 seq = '' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
245 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
|
246 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
|
247 if seqid and len(seq) > 0: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
248 query(url, seq, alleles, lengths, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
249 seqid=seqid, method=method) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
250 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
|
251 seq = '' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
252 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
253 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
|
254 if seqid and len(seq) > 0: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
255 query(url, seq, alleles, lengths, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
256 seqid=seqid, method=method) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
257 fh.close() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
258 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
|
259 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
|
260 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
261 if header: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
262 outputFile.write(header) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
263 for line in results: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
264 outputFile.write(line) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
265 if results2: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
266 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
|
267 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 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
|
272 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
273 outFile = sys.stdout |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
274 if header2: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
275 outFile.write(header2) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
276 for line in results2: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
277 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
|
278 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
279 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
280 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
|
281 __main__() |