annotate generate_macros.py @ 2:92e869104274 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/enasearch commit a0adc28145cce02ecaed3a90156ed54c4385d1a0"
author iuc
date Tue, 21 Jan 2020 19:05:45 -0500
parents 34d21959dc25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
1 #!/usr/bin/env python
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
2
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
3 import enasearch
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
4
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
5 spaces = ' '
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
6 operator_names = {
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
7 "=": "equal",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
8 "!=": "different",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
9 "<": "lower",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
10 "<=": "equal or lower",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
11 ">": "higher",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
12 ">=": "equal or higher",
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
13 }
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
14
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
15
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
16 def format_name(name, alternative_name):
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
17 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
18 Format name to remove None name and & in name
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
19 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
20 if name is None:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
21 name = alternative_name
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
22 name = name.replace("&", "and")
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
23 return name
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
24
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
25
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
26 def sort_by_name(dict):
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
27 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
28 Sort a dictionary on the values
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
29 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
30 return sorted(dict, key=dict.get)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
31
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
32
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
33 def write_analysis_fields():
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
34 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
35 Write the analysis fields
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
36 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
37 s = '%s<xml name="analysis_fields">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
38 fields = enasearch.get_returnable_fields(result="analysis", verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
39 for f in fields:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
40 s += '%s<option value="%s">%s</option>\n' % (2 * spaces, f, f)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
41 s += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
42 return s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
43
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
44
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
45 def write_display_options():
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
46 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
47 Write the display options
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
48 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
49 s = '%s<xml name="display_options">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
50 when_s = '%s<xml name="when_display_options">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
51 options = enasearch.get_display_options(verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
52 for opt in options:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
53 s += '%s<option value="%s">%s</option>\n' % (2 * spaces, opt, options[opt]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
54 when_s += '%s<when value="%s">\n' % (2 * spaces, opt)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
55 if opt == 'fasta' or opt == 'fastq':
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
56 when_s += '%s<param name="range_start" argument="--subseq_range" type="integer" optional="true" label="Start integer for subsequences"/>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
57 when_s += '%s<param name="range_stop" argument="--subseq_range" type="integer" optional="true" label="Stop integer for subsequences"/>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
58 else:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
59 when_s += '%s<param argument="--offset" type="integer" optional="true" label="First record to get"/>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
60 when_s += '%s<param argument="--length" type="integer" optional="true" label="Number of records to retrieve"/>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
61 when_s += '%s</when>\n' % (2 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
62 s += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
63 when_s += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
64 s += when_s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
65 return s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
66
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
67
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
68 def write_run_fields():
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
69 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
70 Write the run fields
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
71 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
72 s = '%s<xml name="run_fields">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
73 fields = enasearch.get_returnable_fields(result="read_run", verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
74 for f in fields:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
75 s += '%s<option value="%s">%s</option>\n' % (2 * spaces, f, f)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
76 s += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
77 return s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
78
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
79
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
80 def write_taxonomy_results():
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
81 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
82 Write the possible taxonomy results
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
83 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
84 s = '%s<xml name="taxonomy_results">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
85 fields = enasearch.get_taxonomy_results(verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
86 for f in fields:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
87 s += '%s<option value="%s">%s</option>\n' % (2 * spaces, f, fields[f]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
88 s += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
89 return s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
90
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
91
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
92 def write_result_parameters(fts=False):
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
93 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
94 Write the parameters that are dependant of results
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
95 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
96 res = enasearch.get_results(verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
97 options = enasearch.get_display_options(verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
98 ft = enasearch.get_filter_types(verbose=False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
99 # Format the filter type related parameters
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
100 ft_parameters = {}
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
101 for t in ft:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
102 s = ''
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
103 if 'operators' in ft[t]:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
104 s = '%s<param name="operation" type="select" label="Operator">\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
105 for o in ft[t]['operators']:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
106 on = o
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
107 if o in operator_names:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
108 on = operator_names[o]
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
109 s += '%s<option value="%s">%s</option>\n' % (8 * spaces, on, on)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
110 s += '%s</param>\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
111 if 'value' in ft[t]:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
112 value_format = 'float' if t == 'Number' else 'text'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
113 s += '%s<param name="value" type="%s" value="" label="%s"/>\n' % (7 * spaces, value_format, ft[t]['value'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
114 elif 'values' in ft[t]:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
115 s += '%s<param name="value" type="select" label="Value">\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
116 for v in ft[t]['values']:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
117 s += '%s<option value="%s">%s</option>\n' % (8 * spaces, v, v)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
118 s += '%s</param>\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
119 else:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
120 s += '%s<conditional name="op">\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
121 s += '%s<param name="operation" type="select" label="Operation">\n' % (8 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
122 for op in ft[t]:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
123 s += '%s<option value="%s">%s</option>\n' % (9 * spaces, op, ft[t][op]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
124 s += '%s</param>\n' % (8 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
125 for op in ft[t]:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
126 s += '%s<when value="%s">\n' % (8 * spaces, op)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
127 s += '%s<param name="values" type="text" value="" label="%s" help="Values separated by simple comma"/>\n' % (9 * spaces, ",".join(ft[t][op]['parameters']))
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
128 s += '%s</when>\n' % (8 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
129 s += '%s</conditional>\n' % (7 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
130 ft_parameters[t] = s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
131 # Start adding the conditional
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
132 s = '%s<conditional name="res">\n' % (2 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
133 # Add result parameter
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
134 s += '%s<param argument="--result" type="select" label="Result to return">\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
135 for r in res:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
136 s += '%s<option value="%s">%s</option>\n' % (4 * spaces, r, res[r]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
137 s += '%s</param>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
138 for r in res:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
139 sf = enasearch.get_sortable_fields(r)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
140 ff = res[r]['filter_fields']
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
141 s += '%s<when value="%s">\n' % (3 * spaces, r)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
142 if not fts:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
143 s += '%s<repeat name="queries" title="Add a query">\n' % (4 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
144 # Add combination operator
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
145 s += '%s<param name="combination_operation" type="select" label="Combination operation">\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
146 s += '%s<option value="AND">AND</option>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
147 s += '%s<option value="OR">OR</option>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
148 s += '%s<option value="NOT">NOT</option>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
149 s += '%s</param>\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
150 s += '%s<conditional name="filter_field">\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
151 s += '%s<param name="field" type="select" label="Field to query">\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
152 for f in ff:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
153 s += '%s<option value="%s">%s</option>\n' % (7 * spaces, f, ff[f]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
154 s += '%s</param>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
155 for f in ff:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
156 # Add the correct parameter given the type of field
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
157 typ = ff[f]['type'].capitalize()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
158 if typ not in ft_parameters:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
159 if f == 'location':
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
160 typ = 'Geospatial'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
161 else:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
162 continue
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
163 s += '%s<when value="%s">\n' % (6 * spaces, f)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
164 s += ft_parameters[typ]
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
165 s += '%s</when>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
166 s += '%s</conditional>\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
167 s += '%s</repeat>\n' % (4 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
168 # Add display opt
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
169 s += '%s<conditional name="display_opt">\n' % (4 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
170 s += '%s<param argument="--display" type="select" label="Display option to specify the display format">\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
171 s += '%s<expand macro="display_options"/>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
172 s += '%s</param>\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
173 for opt in options:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
174 s += '%s<when value="%s"' % (5 * spaces, opt)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
175 if opt != 'fasta' and opt != 'fastq':
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
176 s += '>\n'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
177 s += '%s<param argument="--offset" type="integer" optional="true" label="First record to get"/>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
178 s += '%s<param argument="--length" type="integer" optional="true" label="Number of records to retrieve"/>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
179 if opt == 'report':
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
180 s += '%s<param argument="--fields" type="select" multiple="true" label="Fields to return">\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
181 for f in res[r]['returnable_fields']:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
182 s += '%s<option value="%s">%s</option>\n' % (7 * spaces, f, f)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
183 s += '%s</param>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
184 s += '%s<param argument="--sortfields" type="select" optional="true" multiple="true" label="Fields to sort the results">\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
185 for f in sf:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
186 s += '%s<option value="%s">%s</option>\n' % (7 * spaces, f, sf[f]['description'])
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
187 s += '%s</param>\n' % (6 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
188 s += '%s</when>\n' % (5 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
189 else:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
190 s += '/>\n'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
191 s += '%s</conditional>\n' % (4 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
192 s += '%s</when>\n' % (3 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
193 s += '%s</conditional>\n' % (2 * spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
194 return s
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
195
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
196
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
197 def write_search_data_parameters():
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
198 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
199 Write the parameters for search_data
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
200 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
201 fts = '%s<xml name="free_text_search">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
202 fts += write_result_parameters(True)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
203 fts += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
204 cts = '%s<xml name="conditional_text_search">\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
205 cts += write_result_parameters(False)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
206 cts += '%s</xml>\n' % (spaces)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
207 return fts + cts
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
208
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
209
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
210 def generate_search_macros(filepath):
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
211 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
212 Generate the content of the macro file
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
213 """
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
214 s = '<?xml version="1.0" ?>\n'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
215 s += '<macros>\n'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
216 s += write_analysis_fields()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
217 s += write_display_options()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
218 s += write_run_fields()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
219 s += write_taxonomy_results()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
220 s += write_search_data_parameters()
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
221 s += '</macros>\n'
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
222 with open(filepath, "w") as file:
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
223 file.write(s)
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
224
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
225
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
226 if __name__ == '__main__':
34d21959dc25 planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff changeset
227 generate_search_macros("search_macros.xml")