diff jq.xml @ 0:5ff75eb1a893 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jq commit 09e822fb844c9c724eb03dd12f352577ef404ea8
author iuc
date Tue, 04 Jul 2017 18:29:48 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jq.xml	Tue Jul 04 18:29:48 2017 -0400
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<tool id="jq" name="JQ" version="1.0">
+    <description>process JSON</description>
+    <requirements>
+        <requirement type="package" version="1.5">jq</requirement>
+    </requirements>
+    <command detect_errors="aggressive"><![CDATA[
+JQ_BIN=`which jq` &&
+cat '$input' | env -i JQ_BIN=\$JQ_BIN \$JQ_BIN -r -S '$filter $tsv' > '$output'
+    ]]></command>
+    <inputs>
+        <param name="input" label="JSON Input" type="data" format="json" />
+        <param name="filter" label="jq filter" type="text">
+            <sanitizer>
+                <valid>
+                    <add value='"'/>
+                    <add value="@"/>
+                    <add value="|"/>
+                    <add value="!"/>
+                    <add value="="/>
+                    <add value="$"/>
+                    <add value="["/>
+                    <add value="]"/>
+                    <add value="{"/>
+                    <add value="}"/>
+                    <add value="("/>
+                    <add value=")"/>
+                    <add value="&lt;"/>
+                    <add value="&gt;"/>
+                </valid>
+            </sanitizer>
+        </param>
+        <param name="tsv" label="Convert output to tabular" type="boolean" truevalue="| @tsv" falsevalue="" help="@tsv can be used normally, but this will automatically mark the output as tabular"/>
+    </inputs>
+    <outputs>
+        <data format="json" name="output">
+            <change_format>
+            <when input="tsv" value="| @tsv" format="tabular" />
+        </change_format>
+        </data>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input" value="list.json"/>
+            <param name="filter" value=".[] | [.foo, .bar]"/>
+            <param name="tsv" value="| @tsv"/>
+            <output name="output" file="out-1.json" />
+        </test>
+        <test>
+            <param name="input" value="list.json"/>
+            <param name="filter" value='{"a": env}'/>
+            <param name="tsv" value=""/>
+            <output name="output">
+                <assert_contents>
+                    <has_text text="JQ_BIN"/>
+                    <not_has_text text="GALAXY_CONFIG"/>
+                </assert_contents>
+            </output>
+        </test>
+    </tests>
+    <help><![CDATA[
+JQ
+==
+
+    jq is a lightweight and flexible JSON processor.
+
+Brief Examples
+--------------
+
+See `the manual <https://stedolan.github.io/jq/manual/>`__ for a much
+more detailed guide on using JQ.
+
+Select an Attribute
+~~~~~~~~~~~~~~~~~~~
+
+Given an input like the following
+
+::
+
+    {"foo": 42, "bar": "less interesting data"}
+
+To select just the value of ``foo``, supply the filter ``.foo``
+
+Loop over an Array
+~~~~~~~~~~~~~~~~~~
+
+Given an input like the following
+
+::
+
+    [{"foo": 1123}, {"foo": 6536}, {"foo": 5321}]
+
+To select the values of ``foo``, supply the filter ``.[].foo`` or
+``.[] | .foo``. This will produce a file with one number per line.
+
+If you wish to select multiple things:
+
+::
+
+    [{"foo": 1123, "bar": "a"}, {"foo": 6536, "bar": "b"}, {"foo": 5321, "bar": "c"}]
+
+To select the values of ``foo`` AND ``bar``, supply the filter
+``.[] | [.foo, .bar]``. This will produce and output array like:
+
+::
+
+    [
+        [1123, "a"]
+        [6536, "b"]
+        [5321, "c"]
+    ]
+
+A common next step is to turn this into a tabular output which more
+Galaxy tools can work with. This can be done by checking the box for
+tabular. This will invoke the JQ filter of ``@tsv`` at the end of the
+processing chain, and produce a tabular file.
+
+    ]]></help>
+    <citations/>
+</tool>