Mercurial > repos > iuc > enasearch_retrieve_data
annotate generate_macros.py @ 2:2f0210706f95 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:27 -0500 |
parents | cbc24be56f7b |
children |
rev | line source |
---|---|
0
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
2 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
3 import enasearch |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
4 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
5 spaces = ' ' |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
6 operator_names = { |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
7 "=": "equal", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
8 "!=": "different", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
9 "<": "lower", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
10 "<=": "equal or lower", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
11 ">": "higher", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
12 ">=": "equal or higher", |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
13 } |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
14 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
15 |
cbc24be56f7b
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): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
17 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
19 """ |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
20 if name is None: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
21 name = alternative_name |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
22 name = name.replace("&", "and") |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
23 return name |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
24 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
25 |
cbc24be56f7b
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): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
27 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
29 """ |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
31 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
32 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
33 def write_analysis_fields(): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
34 """ |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
35 Write the analysis fields |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
36 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
39 for f in fields: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
42 return s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
43 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
44 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
45 def write_display_options(): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
46 """ |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
47 Write the display options |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
48 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
52 for opt in options: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
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': |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
58 else: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
64 s += when_s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
65 return s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
66 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
67 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
68 def write_run_fields(): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
69 """ |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
70 Write the run fields |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
71 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
74 for f in fields: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
77 return s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
78 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
79 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
80 def write_taxonomy_results(): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
81 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
83 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
86 for f in fields: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
89 return s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
90 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
91 |
cbc24be56f7b
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): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
93 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
95 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
100 ft_parameters = {} |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
101 for t in ft: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
102 s = '' |
cbc24be56f7b
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]: |
cbc24be56f7b
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) |
cbc24be56f7b
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']: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
106 on = o |
cbc24be56f7b
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: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
108 on = operator_names[o] |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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]: |
cbc24be56f7b
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' |
cbc24be56f7b
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']) |
cbc24be56f7b
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]: |
cbc24be56f7b
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) |
cbc24be56f7b
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']: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
119 else: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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]: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
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]: |
cbc24be56f7b
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) |
cbc24be56f7b
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'])) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
130 ft_parameters[t] = s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
131 # Start adding the conditional |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
133 # Add result parameter |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
135 for r in res: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
138 for r in res: |
cbc24be56f7b
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) |
cbc24be56f7b
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'] |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
142 if not fts: |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
144 # Add combination operator |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
152 for f in ff: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
155 for f in ff: |
cbc24be56f7b
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 |
cbc24be56f7b
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() |
cbc24be56f7b
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: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
159 if f == 'location': |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
160 typ = 'Geospatial' |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
161 else: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
162 continue |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
164 s += ft_parameters[typ] |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
168 # Add display opt |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
173 for opt in options: |
cbc24be56f7b
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) |
cbc24be56f7b
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': |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
176 s += '>\n' |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
179 if opt == 'report': |
cbc24be56f7b
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) |
cbc24be56f7b
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']: |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
185 for f in sf: |
cbc24be56f7b
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']) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
189 else: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
190 s += '/>\n' |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
194 return s |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
195 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
196 |
cbc24be56f7b
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(): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
198 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
200 """ |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
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) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
207 return fts + cts |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
208 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
209 |
cbc24be56f7b
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): |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
211 """ |
cbc24be56f7b
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 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
213 """ |
cbc24be56f7b
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' |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
215 s += '<macros>\n' |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
216 s += write_analysis_fields() |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
217 s += write_display_options() |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
218 s += write_run_fields() |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
219 s += write_taxonomy_results() |
cbc24be56f7b
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() |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
221 s += '</macros>\n' |
cbc24be56f7b
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: |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
223 file.write(s) |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
224 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
225 |
cbc24be56f7b
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/enasearch/ commit 6eda25f5cccc0cf9be09c38a8b48d37aff56ed87
iuc
parents:
diff
changeset
|
226 if __name__ == '__main__': |
cbc24be56f7b
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") |