Skip to content

Commit 17b4b40

Browse files
committed
Fixes for example tools and linting inputs of booleans.
1 parent 223757d commit 17b4b40

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

docs/writing/seqtk_seq_v5.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#if $mask_regions
1414
-M $mask_regions
1515
#end if
16-
#if $sample
16+
#if $sample.sample
1717
-f $sample.fraction
1818
-s $sample.seed
1919
#end if
@@ -30,7 +30,7 @@
3030
value="255" min="0" max="255" help="(-X)" />
3131
<param name="mask_regions" type="data" label="Mask regions in BED"
3232
format="bed" help="(-M)" optional="true" />
33-
<conditional>
33+
<conditional name="sample">
3434
<param name="sample" type="boolean" label="Sample fraction of sequences" />
3535
<when value="true">
3636
<param name="fraction" label="Fraction" type="float" value="1.0"

docs/writing/seqtk_seq_v6.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#if $settings.mask_regions
1515
-M $settings.mask_regions
1616
#end if
17-
#if $settings.sample
17+
#if $settings.sample.sample
1818
-f $settings.sample.fraction
1919
-s $settings.sample.seed
2020
#end if
@@ -40,7 +40,7 @@
4040
value="255" min="0" max="255" help="(-X)" />
4141
<param name="mask_regions" type="data" label="Mask regions in BED"
4242
format="bed" help="(-M)" optional="true" />
43-
<conditional>
43+
<conditional name="sample">
4444
<param name="sample" type="boolean" label="Sample fraction of sequences" />
4545
<when value="true">
4646
<param name="fraction" label="Fraction" type="float" value="1.0"

planemo_ext/galaxy/tools/linters/inputs.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,41 @@ def lint_inputs(tool_xml, lint_ctx):
2626
lint_ctx.warn("Param input [%s] with no format specified - 'data' format will be assumed.", param_name)
2727
# TODO: Validate type, much more...
2828

29+
def find_list(elem, expression):
30+
matching = elem.findall(expression)
31+
if matching is None:
32+
return []
33+
else:
34+
return matching
35+
2936
conditional_selects = tool_xml.findall("./inputs//conditional")
3037
for conditional in conditional_selects:
31-
select = conditional.find('./param[@type="select"]') or []
32-
boolean = conditional.find('./param[@type="boolean"]') or []
38+
booleans = find_list(conditional, "./param[@type='boolean']")
39+
selects = find_list(conditional, "./param[@type='select']")
3340
# Should conditionals ever not have a select?
34-
if not len(select) and not len(boolean):
41+
if not len(selects) and not len(booleans):
3542
lint_ctx.warn("Conditional without <param type=\"select\" /> or <param type=\"boolean\" />")
3643
continue
3744

38-
if len(select):
45+
for select in selects:
3946
select_options = select.findall('./option[@value]')
4047
if any(['value' not in option.attrib for option in select_options]):
4148
lint_ctx.error("Option without value")
4249

4350
select_option_ids = [option.attrib.get('value', None) for option in select_options]
44-
else:
51+
52+
for boolean in booleans:
4553
select_option_ids = [
46-
boolean.attrib.get('truevalue', 'True'),
47-
boolean.attrib.get('falsevalue', 'False')
54+
boolean.attrib.get('truevalue', 'true'),
55+
boolean.attrib.get('falsevalue', 'false')
4856
]
4957

5058
whens = conditional.findall('./when')
5159
if any(['value' not in when.attrib for when in whens]):
5260
lint_ctx.error("When without value")
5361

54-
when_ids = [when.attrib.get('value', None) for when in whens]
62+
when_ids = [w.attrib.get('value', None) for w in whens]
63+
when_ids = [i.lower() if i in ["True", "False"] else i for i in when_ids]
5564

5665
for select_id in select_option_ids:
5766
if select_id not in when_ids:

0 commit comments

Comments
 (0)