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