annotate ebeye_urllib.py @ 2:6155fa39a899 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
author iuc
date Sat, 21 Jan 2017 14:40:54 -0500
parents e2e9fae080ad
children a1ef6c88ee37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
1 #!/usr/bin/env python
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
2 # ======================================================================
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
3 # Script derived from the EB-eye (REST) Python client available at
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
4 # http://www.ebi.ac.uk/Tools/webservices/services/eb-eye_rest
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
5 # and distributed under the Apache License
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
6 # ======================================================================
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
7 # Load libraries
2
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
8 import os
0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
9 import platform
2
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
10 import re
0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
11 import urllib
2
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
12 import urllib2
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
13 from gzip import GzipFile
0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
14 from optparse import OptionParser
2
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
15 from StringIO import StringIO
6155fa39a899 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 19ea4feff5ccf3744c549b9a67259947a1cb90ba
iuc
parents: 0
diff changeset
16
0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
17 from xmltramp2 import xmltramp
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
18
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
19 # Service base URL
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
20 baseUrl = 'http://www.ebi.ac.uk/ebisearch/ws/rest'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
21
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
22 # Debug level
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
23 debugLevel = 0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
24
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
25
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
26 # Debug print
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
27 def printDebugMessage(functionName, message, level):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
28 if(level <= debugLevel):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
29 print ('[' + functionName + '] ' + message)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
30
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
31
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
32 # User-agent for request.
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
33 def getUserAgent():
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
34 printDebugMessage('getUserAgent', 'Begin', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
35 urllib_agent = 'Python-urllib/%s' % urllib2.__version__
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
36 clientRevision = '$Revision: 2468 $'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
37 clientVersion = '0'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
38 if len(clientRevision) > 11:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
39 clientVersion = clientRevision[11:-2]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
40 user_agent = 'EBI-Sample-Client/%s (%s; Python %s; %s) %s' % (
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
41 clientVersion, os.path.basename(__file__),
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
42 platform.python_version(), platform.system(),
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
43 urllib_agent
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
44 )
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
45 printDebugMessage('getUserAgent', 'user_agent: ' + user_agent, 12)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
46 printDebugMessage('getUserAgent', 'End', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
47 return user_agent
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
48
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
49
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
50 # Wrapper for a REST (HTTP GET) request
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
51 def restRequest(url):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
52 printDebugMessage('restRequest', 'Begin', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
53 printDebugMessage('restRequest', 'url: ' + url, 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
54 # python 2
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
55 url = urllib.quote(url, safe="%/:=&?~#+!$,;'@()*[]")
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
56 # python 3
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
57 # url = urllib.request.quote(url, safe="%/:=&?~#+!$,;'@()*[]")
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
58
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
59 try:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
60 user_agent = getUserAgent()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
61 http_headers = {
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
62 'User-Agent': user_agent,
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
63 'Accept-Encoding': 'gzip'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
64 }
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
65 req = urllib2.Request(url, None, http_headers)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
66 resp = urllib2.urlopen(req)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
67 # python2
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
68 encoding = resp.info().getheader('Content-Encoding')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
69 # python3
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
70 # encoding = resp.info().__getitem__('Content-Encoding')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
71 result = None
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
72 if encoding is None or encoding == 'identity':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
73 # python2
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
74 result = resp.read()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
75 # python3
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
76 # result = str(resp.read(), 'utf-8')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
77 elif encoding == 'gzip':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
78 result = resp.read()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
79 printDebugMessage('restRequest', 'result: ' + str(result), 21)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
80 # python2
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
81 gz = GzipFile(
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
82 fileobj=StringIO(result),
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
83 mode="r")
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
84 result = gz.read()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
85 # python3
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
86 # result = str(gzip.decompress(result), 'utf-8')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
87 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
88 raise Exception('Unsupported Content-Encoding')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
89 resp.close()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
90 except urllib2.HTTPError as ex:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
91 raise ex
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
92 printDebugMessage('restRequest', 'result: ' + result, 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
93 printDebugMessage('restRequest', 'End', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
94 return result
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
95
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
96
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
97 def hasSubdomains(domainInfo):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
98 for dir in domainInfo._dir:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
99 if dir._name == 'subdomains':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
100 return True
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
101 return False
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
102
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
103
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
104 def extractUsefulFields(fieldInfos):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
105 searchable = []
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
106 retrievable = []
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
107
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
108 for fieldInfo in fieldInfos:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
109 if fieldInfo('id') == "$facets":
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
110 continue
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
111
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
112 options = fieldInfo['options']['option':]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
113 for option in options:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
114 if option("name") == "searchable" and str(option) == "true":
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
115 searchable.append(fieldInfo('id'))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
116 if option("name") == "retrievable" and str(option) == "true":
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
117 retrievable.append(fieldInfo('id'))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
118 return searchable, retrievable
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
119
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
120
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
121 def extractLowerLevelDomains(domainInfo, domains):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
122 if hasSubdomains(domainInfo):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
123 subdomains = domainInfo['subdomains']['domain':]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
124 for subdomain in subdomains:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
125 domains = extractLowerLevelDomains( subdomain, domains)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
126 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
127 searchable, retrievable = extractUsefulFields(
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
128 domainInfo['fieldInfos']['fieldInfo':])
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
129
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
130 domain_id = domainInfo('id')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
131 domains.setdefault(domain_id, {})
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
132 domains[domain_id]["name"] = domainInfo('name')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
133 domains[domain_id]["searchable_fields"] = sorted(searchable)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
134 domains[domain_id]["retrievable_fields"] = sorted(retrievable)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
135 return domains
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
136
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
137
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
138 # Get domain Hierarchy
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
139 def getDomainHierarchy():
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
140 requestUrl = baseUrl + '/allebi'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
141 xmlDoc = restRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
142 doc = xmltramp.parse(xmlDoc)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
143 allebi = doc['domains']['domain']
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
144 lower_level_domains = extractLowerLevelDomains(allebi, {})
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
145 printDebugMessage('getDomainHierarchy', 'End', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
146 return lower_level_domains
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
147
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
148
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
149 # Check if a databaseInfo matches a database name.
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
150 def is_database(dbInfo, dbName):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
151 printDebugMessage('is_database', 'Begin', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
152 retVal = False
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
153 if str(dbInfo.name) == dbName:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
154 retVal = True
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
155 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
156 for dbAlias in dbInfo.aliasList:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
157 if str(dbAlias) == dbName:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
158 retVal = True
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
159 printDebugMessage('is_database', 'retVal: ' + str(retVal), 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
160 printDebugMessage('is_database', 'End', 11)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
161 return retVal
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
162
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
163
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
164 # Get number of results
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
165 def getNumberOfResults(domain, query):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
166 printDebugMessage('getNumberOfResults', 'Begin', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
167 requestUrl = baseUrl + '/' + domain + '?query=' + query + '&size=0'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
168 printDebugMessage('getNumberOfResults', requestUrl, 2)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
169 xmlDoc = restRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
170 doc = xmltramp.parse(xmlDoc)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
171 numberOfResults = int(str(doc['hitCount']))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
172 printDebugMessage('getNumberOfResults', 'End', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
173 return numberOfResults
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
174
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
175
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
176 def makeRequest(requestUrl):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
177 xmlDoc = restRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
178 doc = xmltramp.parse(xmlDoc)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
179 entries = doc['entries']['entry':]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
180 formatted_output = printEntries(entries)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
181 return formatted_output
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
182
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
183
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
184 # Get search results
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
185 def getResults(domain, query, fields):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
186 numberOfResults = getNumberOfResults(domain, query)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
187 maximum_size = 100
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
188 quotient = numberOfResults / maximum_size
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
189 start = 0
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
190
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
191 printDebugMessage('getResults', 'Begin', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
192 request_output = "%s\tlink\n" % (fields.replace(",", "\t"))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
193 for i in range(quotient):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
194 start = maximum_size * i
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
195 requestUrl = baseUrl + '/' + domain + '?query=' + query
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
196 requestUrl += '&fields=' + fields + '&size=' + str(maximum_size)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
197 requestUrl += '&start=' + str(start) + '&fieldurl=true'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
198 request_output += makeRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
199
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
200 if (numberOfResults % 100) > 0:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
201 start = maximum_size * quotient
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
202 remainder = numberOfResults - start
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
203 requestUrl = baseUrl + '/' + domain + '?query=' + query
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
204 requestUrl += '&fields=' + fields + '&size=' + str(remainder)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
205 requestUrl += '&start=' + str(start) + '&fieldurl=true'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
206 request_output += makeRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
207
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
208 print(request_output)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
209
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
210
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
211 def printEntries(entries):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
212 output = ""
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
213 printDebugMessage('printEntries', 'Begin', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
214 for entry in entries:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
215 sep = ""
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
216 for field in entry['fields']['field':]:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
217 output += "%s" % (sep)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
218 fields = field['values']['value':]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
219 if len(fields) > 0:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
220 sub_sep = ""
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
221 for value in field['values']['value':]:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
222 output += "%s%s" % (sub_sep, value)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
223 sub_sep = ","
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
224 sep = "\t"
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
225
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
226 if hasFieldUrls(entry):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
227 output += "%s" % (sep)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
228 sub_sep = ""
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
229 for fieldurl in entry['fieldURLs']['fieldURL':]:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
230 output += "%s%s" % (sub_sep, str(fieldurl))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
231 sub_sep = ","
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
232 sep = "\t"
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
233 if hasViewUrls(entry):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
234 output += "%s" % (sep)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
235 sub_sep = ""
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
236 for viewurl in entry['viewURLs']['viewURL':]:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
237 output += "%s%s" % (sub_sep, str(viewurl))
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
238 sub_sep = ","
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
239 output += "\n"
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
240 printDebugMessage('printEntries', 'End', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
241 return output
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
242
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
243
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
244 def hasFieldUrls(entry):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
245 for dir in entry._dir:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
246 if dir._name == 'fieldURLs':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
247 return True
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
248 return False
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
249
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
250
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
251 def hasViewUrls(entry):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
252 for dir in entry._dir:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
253 if dir._name == 'viewURLs':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
254 return True
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
255 return False
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
256
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
257
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
258 def getRunLink(run_id):
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
259 printDebugMessage('getEntries', 'Begin', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
260 requestUrl = baseUrl + '/metagenomics_runs/entry/' + run_id + '?fieldurl=true'
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
261 printDebugMessage('getEntries', requestUrl, 2)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
262 xmlDoc = restRequest(requestUrl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
263 doc = xmltramp.parse(xmlDoc)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
264 entries = doc['entries']['entry':]
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
265 fieldURL = ''
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
266 for entry in entries:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
267 for fieldurl in entry['fieldURLs']['fieldURL':]:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
268 fieldURL += str(fieldurl)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
269 printDebugMessage('getEntries', 'End', 1)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
270 p = re.compile('http')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
271 fieldURL = p.sub('https', fieldURL)
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
272 print fieldURL
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
273
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
274
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
275 if __name__ == '__main__':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
276 # Usage message
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
277 usage = """
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
278 %prog getDomainHierarchy
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
279 %prog getResults <domain> <query> <fields>
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
280 %prog getRunLink <runId>
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
281 """
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
282
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
283 description = "Tools to query and download data from several EMBL-EBI databases"
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
284 description += "The searching tools are using the EB-eye search engine. "
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
285 description += "http://www.ebi.ac.uk/ebisearch/"
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
286 # Process command-line options
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
287 parser = OptionParser(
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
288 usage=usage,
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
289 description=description,
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
290 version='1.0')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
291 (options, args) = parser.parse_args()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
292
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
293 # No arguments, print usage
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
294 if len(args) < 1:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
295 parser.print_help()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
296
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
297 # Get domain hierarchy
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
298 elif args[0] == 'getDomainHierarchy':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
299 getDomainHierarchy()
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
300
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
301 # Get search results
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
302 elif args[0] == 'getResults':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
303 if len(args) < 4:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
304 print ('domain, query and fields should be given.')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
305 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
306 getResults(args[1], args[2], args[3])
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
307
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
308 # Get run link results
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
309 elif args[0] == 'getRunLink':
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
310 if len(args) < 2:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
311 print ('run id should be given.')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
312 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
313 getRunLink(args[1])
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
314
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
315 # Unknown argument combination, display usage
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
316 else:
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
317 print ('Error: unrecognised argument combination')
e2e9fae080ad planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
iuc
parents:
diff changeset
318 parser.print_help()