Permalink
Browse files

Improved output and test linters.

Mostly enhanced to recognize output collections but there are some other smaller enhancements there as well.
  • Loading branch information...
jmchilton committed Jun 28, 2015
1 parent a32d082 commit 334f2d46211070795a40781acfe948028cd42c30
@@ -1,25 +1,31 @@


def lint_output(tool_xml, lint_ctx):
outputs = tool_xml.findall("./outputs/data")
if not outputs:
lint_ctx.warn("Tool contains no outputs, most tools should produce outputs.")
return
outputs = tool_xml.findall("./outputs")
if len(outputs) == 0:
lint_ctx.warn("Tool contains no outputs section, most tools should produce outputs.")
if len(outputs) > 1:
lint_ctx.warn("Tool contains multiple output sections, behavior undefined.")

num_outputs = 0
for output in outputs:
for output in list(outputs[0]):
if output.tag not in ["data", "collection"]:
lint_ctx.warn("Unknown element found in outputs [%s]" % output.tag)
continue
num_outputs += 1
output_attrib = output.attrib
format_set = False
if "format" in output_attrib:
format_set = True
format = output_attrib["format"]
if format == "input":
lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.")
elif "format_source" in output_attrib:
format_set = True

if not format_set:
lint_ctx.warn("Tool data output doesn't define an output format.")

lint_ctx.info("%d output datasets found.", num_outputs)
if output.tag == "data":
format_set = False
if "format" in output_attrib:
format_set = True
format = output_attrib["format"]
if format == "input":
lint_ctx.warn("Using format='input' on output data, format_source attribute is less ambiguous and should be used instead.")
elif "format_source" in output_attrib:
format_set = True
if not format_set:
lint_ctx.warn("Tool data output doesn't define an output format.")
elif output.tag == "collection":
if "type" not in output_attrib:
lint_ctx.warn("Collection output with undefined 'type' found.")
lint_ctx.info("%d outputs found.", num_outputs)
@@ -16,7 +16,7 @@ def lint_tsts(tool_xml, lint_ctx):
if len(test.findall("assert_stdout")) > 0:
has_test = True

outputs = test.findall("output")
outputs = test.findall("output") + test.findall("output_collection")
if len(outputs) > 0:
has_test = True
if not has_test:
@@ -0,0 +1,36 @@
<tool id="collection_split_on_column" name="collection_split_on_column" version="1.0.0">
<command>
mkdir outputs; cd outputs; awk '{ print \$2 > \$1 ".tabular" }' $input1
</command>
<inputs>
<param name="input1" type="data" label="Input Table" help="Table to split on first column" format="tabular" />
</inputs>
<outputs>
<collection name="split_output" type="list" label="Table split on first column">
<discover_datasets pattern="__name_and_ext__" directory="outputs" />
</collection>
</outputs>
<tests>
<test>
<param name="input1" value="tinywga.fam" />
<output_collection name="split_output" type="list">
<element name="101">
<assert_contents>
<has_text_matching expression="^1\n2\n3\n$" />
</assert_contents>
</element>
<element name="1334">
<assert_contents>
<has_text_matching expression="^1\n10\n11\n12\n13\n2\n$" />
</assert_contents>
</element>
</output_collection>
</test>
</tests>
<help>
Some Awesome Help!
</help>
<citations>
<citation type="doi">10.1101/014043</citation>
</citations>
</tool>

0 comments on commit 334f2d4

Please sign in to comment.