comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:5ff75eb1a893
1 <?xml version="1.0"?>
2 <tool id="jq" name="JQ" version="1.0">
3 <description>process JSON</description>
4 <requirements>
5 <requirement type="package" version="1.5">jq</requirement>
6 </requirements>
7 <command detect_errors="aggressive"><![CDATA[
8 JQ_BIN=`which jq` &&
9 cat '$input' | env -i JQ_BIN=\$JQ_BIN \$JQ_BIN -r -S '$filter $tsv' > '$output'
10 ]]></command>
11 <inputs>
12 <param name="input" label="JSON Input" type="data" format="json" />
13 <param name="filter" label="jq filter" type="text">
14 <sanitizer>
15 <valid>
16 <add value='"'/>
17 <add value="@"/>
18 <add value="|"/>
19 <add value="!"/>
20 <add value="="/>
21 <add value="$"/>
22 <add value="["/>
23 <add value="]"/>
24 <add value="{"/>
25 <add value="}"/>
26 <add value="("/>
27 <add value=")"/>
28 <add value="&lt;"/>
29 <add value="&gt;"/>
30 </valid>
31 </sanitizer>
32 </param>
33 <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"/>
34 </inputs>
35 <outputs>
36 <data format="json" name="output">
37 <change_format>
38 <when input="tsv" value="| @tsv" format="tabular" />
39 </change_format>
40 </data>
41 </outputs>
42 <tests>
43 <test>
44 <param name="input" value="list.json"/>
45 <param name="filter" value=".[] | [.foo, .bar]"/>
46 <param name="tsv" value="| @tsv"/>
47 <output name="output" file="out-1.json" />
48 </test>
49 <test>
50 <param name="input" value="list.json"/>
51 <param name="filter" value='{"a": env}'/>
52 <param name="tsv" value=""/>
53 <output name="output">
54 <assert_contents>
55 <has_text text="JQ_BIN"/>
56 <not_has_text text="GALAXY_CONFIG"/>
57 </assert_contents>
58 </output>
59 </test>
60 </tests>
61 <help><![CDATA[
62 JQ
63 ==
64
65 jq is a lightweight and flexible JSON processor.
66
67 Brief Examples
68 --------------
69
70 See `the manual <https://stedolan.github.io/jq/manual/>`__ for a much
71 more detailed guide on using JQ.
72
73 Select an Attribute
74 ~~~~~~~~~~~~~~~~~~~
75
76 Given an input like the following
77
78 ::
79
80 {"foo": 42, "bar": "less interesting data"}
81
82 To select just the value of ``foo``, supply the filter ``.foo``
83
84 Loop over an Array
85 ~~~~~~~~~~~~~~~~~~
86
87 Given an input like the following
88
89 ::
90
91 [{"foo": 1123}, {"foo": 6536}, {"foo": 5321}]
92
93 To select the values of ``foo``, supply the filter ``.[].foo`` or
94 ``.[] | .foo``. This will produce a file with one number per line.
95
96 If you wish to select multiple things:
97
98 ::
99
100 [{"foo": 1123, "bar": "a"}, {"foo": 6536, "bar": "b"}, {"foo": 5321, "bar": "c"}]
101
102 To select the values of ``foo`` AND ``bar``, supply the filter
103 ``.[] | [.foo, .bar]``. This will produce and output array like:
104
105 ::
106
107 [
108 [1123, "a"]
109 [6536, "b"]
110 [5321, "c"]
111 ]
112
113 A common next step is to turn this into a tabular output which more
114 Galaxy tools can work with. This can be done by checking the box for
115 tabular. This will invoke the JQ filter of ``@tsv`` at the end of the
116 processing chain, and produce a tabular file.
117
118 ]]></help>
119 <citations/>
120 </tool>