comparison __efetch_build_options.py @ 1:732a52c18758 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ncbi_entrez_eutils commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
author iuc
date Tue, 30 Oct 2018 19:11:26 -0400
parents 68cd8d564e0a
children b00212deaea7
comparison
equal deleted inserted replaced
0:68cd8d564e0a 1:732a52c18758
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Daniel Blankenberg 2 # Daniel Blankenberg
3 # Creates the options for tool interface 3 # Creates the options for tool interface
4 from __future__ import print_function
5
4 import re 6 import re
5 7
6 # http://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi 8 # http://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi
7 db_list = ''' 9 db_list = '''
8 <DbName>annotinfo</DbName> 10 <DbName>annotinfo</DbName>
162 for db_name in db_list: 164 for db_name in db_list:
163 db[db_name] = [] 165 db[db_name] = []
164 166
165 section = None 167 section = None
166 for line in help: 168 for line in help:
167 line = re.split('\s{2,}', line.strip()) 169 line = re.split(r'\s{2,}', line.strip())
168 # Ignore empties 170 # Ignore empties
169 if len(line) == 0: 171 if len(line) == 0:
170 continue 172 continue
171 # Section headers have one item 173 # Section headers have one item
172 elif len(line) == 1: 174 elif len(line) == 1:
212 214
213 FORMAT_OPTION_TPL = '''<option value="{name_type}">{name_type_human}</option>''' 215 FORMAT_OPTION_TPL = '''<option value="{name_type}">{name_type_human}</option>'''
214 216
215 format_names = {} 217 format_names = {}
216 218
217 print ''' <xml name="db"> 219 print(''' <xml name="db">
218 <conditional name="db"> 220 <conditional name="db">
219 <expand macro="dbselect" />''' 221 <expand macro="dbselect" />''')
220 for key in sorted(db): 222 for key in sorted(db):
221 format_options = [] 223 format_options = []
222 224
223 for (parent_format, format_modifier, description) in sorted(db[key]): 225 for (parent_format, format_modifier, description) in sorted(db[key]):
224 name_human = description 226 name_human = description
231 name_type_human=name_human, 233 name_type_human=name_human,
232 )) 234 ))
233 235
234 format_names[format_string] = format_modifier 236 format_names[format_string] = format_modifier
235 237
236 print WHEN_TPL.format( 238 print(WHEN_TPL.format(
237 format=key, 239 format=key,
238 format_options='\n '.join(format_options) 240 format_options='\n '.join(format_options)
239 ) 241 ))
240 242
241 print ''' </conditional> 243 print(''' </conditional>
242 </xml>''' 244 </xml>''')
243 245
244 CHANGE_FORMAT_TPL = ''' 246 CHANGE_FORMAT_TPL = '''
245 <xml name="efetch_formats"> 247 <xml name="efetch_formats">
246 <change_format> 248 <change_format>
247 {formats} 249 {formats}
262 264
263 whens.append(CHANGE_FORMAT_WHEN_TPL.format( 265 whens.append(CHANGE_FORMAT_WHEN_TPL.format(
264 key=k, value=v 266 key=k, value=v
265 )) 267 ))
266 268
267 print CHANGE_FORMAT_TPL.format(formats='\n '.join(whens)) 269 print(CHANGE_FORMAT_TPL.format(formats='\n '.join(whens)))