Mercurial > repos > jjohnson > iedb_api
annotate iedb_api.py @ 3:153d5fa7af53 draft
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 250d6261ba8c695446f845f2f31c6cca8d87a427-dirty"
author | jjohnson |
---|---|
date | Wed, 26 Feb 2020 16:27:06 -0500 |
parents | 4a89ba6cfc63 |
children | a14128950578 |
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)} |
0
991424605492
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit bbca4d5248b883344319e7a9f42c82d20a11cf0d"
jjohnson
parents:
diff
changeset
|
37 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
38 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 |
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 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
|
46 # 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
|
47 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
|
48 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
|
49 default='mhci', |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
54 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
55 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
|
56 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
|
57 default='recommended', |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
66 default=[], |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
67 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
|
68 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
|
69 action="append", |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
70 default=[], |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
71 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
|
72 '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
|
73 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
|
74 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
75 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
76 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
|
77 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
|
78 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
79 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
|
80 '(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
|
81 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
|
82 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
83 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
|
84 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
|
85 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
86 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
|
87 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
|
88 default=None, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
95 default=600, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
96 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
|
97 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
|
98 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
99 default=5, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
100 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
|
101 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
|
102 type=int, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
103 default=300, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 default=False, |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
108 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
|
109 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
|
110 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
111 aapat = '^[ABCDEFGHIKLMNPQRSTVWY]+$' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
112 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
113 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
|
114 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
|
115 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
116 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
|
117 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
|
118 '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
|
119 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
|
120 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
121 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
|
122 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 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
|
127 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
128 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
|
129 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
130 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
|
131 args.prediction |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
132 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
|
133 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
134 # 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 header = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
143 results = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
144 global header2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
145 header2 = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
146 results2 = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
147 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
148 sequence_text = [] |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
149 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
154 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
|
155 global header |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
156 global header2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
157 params = dict() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
158 if method: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
159 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
|
160 if proteasome: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 response = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
173 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 rslts = results |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 ''.join(data)) |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
185 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
|
186 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
|
187 header = "#%s%s" %\ |
3
153d5fa7af53
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 250d6261ba8c695446f845f2f31c6cca8d87a427-dirty"
jjohnson
parents:
1
diff
changeset
|
188 ("ID\t" if seqid else "", line) |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
189 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
|
190 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
|
191 continue |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
192 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
|
193 header2 = "#%s%s" %\ |
3
153d5fa7af53
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 250d6261ba8c695446f845f2f31c6cca8d87a427-dirty"
jjohnson
parents:
1
diff
changeset
|
194 ("ID\t" if seqid else "", line) |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
195 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
|
196 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
|
197 rslts = results2 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
198 continue |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
199 if seqid: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
200 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
|
201 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
202 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
|
203 break |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
204 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 (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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 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
|
222 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
235 seqid = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
236 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
|
237 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
|
238 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
239 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
|
240 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
|
241 else: # fasta |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
242 seqid = None |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
243 seq = '' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 seq = '' |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
251 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 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
|
256 fh.close() |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
257 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
|
258 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
|
259 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
260 if header: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 if results2: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
265 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
|
266 try: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 else: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
272 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
|
273 if header2: |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 |
1
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
278 |
4a89ba6cfc63
"planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/iedb_api commit 18698e056ccc2d6d37836bd22728e2d8765e92ec"
jjohnson
parents:
0
diff
changeset
|
279 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
|
280 __main__() |