Mercurial > repos > recetox > query
comparison query.xml @ 0:0369de831b32 draft
"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/query commit e781279d988f26eff9ccfff898a7d8cc4f0ceafb"
| author | recetox |
|---|---|
| date | Wed, 09 Dec 2020 02:04:20 +0000 |
| parents | |
| children | 55ca5d902f62 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:0369de831b32 |
|---|---|
| 1 <tool id="query" name="Query" version="@TOOL_VERSION@"> | |
| 2 <macros> | |
| 3 <token name="@TOOL_VERSION@">0.1</token> | |
| 4 <xml name="formats"> | |
| 5 <option value="csv">csv</option> | |
| 6 <option value="tsv">tsv</option> | |
| 7 <option value="h5">h5</option> | |
| 8 <option value="feather">feather</option> | |
| 9 <option value="parquet">parquet</option> | |
| 10 <option value="sqlite">sqlite</option> | |
| 11 </xml> | |
| 12 <xml name="internal_name" token_format=""> | |
| 13 <when value="@FORMAT@"> | |
| 14 <param name="name" type="text" help="Specify the format's internal name of the table."/> | |
| 15 </when> | |
| 16 </xml> | |
| 17 </macros> | |
| 18 | |
| 19 <requirements> | |
| 20 <requirement type="package">click</requirement> | |
| 21 <requirement type="package">pyarrow</requirement> | |
| 22 <requirement type="package">pytables</requirement> | |
| 23 <requirement type="package">pandas</requirement> | |
| 24 <requirement type="package">pandasql</requirement> | |
| 25 <requirement type="package" version="3.7">python</requirement> | |
| 26 </requirements> | |
| 27 | |
| 28 <command><![CDATA[ | |
| 29 python '$__tool_directory__/query.py' | |
| 30 $config | |
| 31 ]]></command> | |
| 32 | |
| 33 <configfiles> | |
| 34 <configfile name="config"><![CDATA[ | |
| 35 #def filetype(data): | |
| 36 #if $data.is_of_type('h5') | |
| 37 #return 'hdf' | |
| 38 #elif $data.is_of_type('csv') | |
| 39 #return 'csv' | |
| 40 #elif $data.is_of_type('tsv', 'tabular') | |
| 41 #return 'tsv' | |
| 42 #elif $data.is_of_type('feather', 'arrow') | |
| 43 #return 'feather' | |
| 44 #elif $data.is_of_type('parquet') | |
| 45 #return 'parquet' | |
| 46 #elif $data.is_of_type('sqlite') | |
| 47 #return 'sqlite' | |
| 48 #end if | |
| 49 #end def | |
| 50 | |
| 51 #set $config = { | |
| 52 'tables': [ | |
| 53 { | |
| 54 'path': str($table.file), | |
| 55 'name': str($table.name) if $table.name else 't{}'.format(str($index)), | |
| 56 'format': str($table.format) if $table.format else $filetype($table.file) | |
| 57 } | |
| 58 for $index, $table in enumerate($tables) | |
| 59 ], | |
| 60 'query': str($query), | |
| 61 'result': { | |
| 62 'path': str($output), | |
| 63 'name': str($result.name) if str($result.format) in ('h5', 'hdf', 'sqlite') and $result.name else None, | |
| 64 'format': str($result.format) | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 #import json | |
| 69 #echo $json.dumps($config) | |
| 70 ]]></configfile> | |
| 71 </configfiles> | |
| 72 | |
| 73 <inputs> | |
| 74 <repeat name="tables" title="Table"> | |
| 75 <param name="file" type="data" format="csv,tsv,h5,feather,parquet,sqlite" label="File"/> | |
| 76 <param name="format" type="select" optional="true"> | |
| 77 <label>Force the file format</label> | |
| 78 <help>Force a particular file format to get around formats unknown to Galaxy, ie. Parquet.</help> | |
| 79 <expand macro="formats"/> | |
| 80 </param> | |
| 81 <param name="name" type="text" optional="true"> | |
| 82 <label>Table name</label> | |
| 83 <help>Choose an unique name for the table which then you may use in the SQL Query. By default tables will be named as: t0, t1, ...</help> | |
| 84 </param> | |
| 85 </repeat> | |
| 86 <param name="query" type="text" area="true"> | |
| 87 <label>SQL Query</label> | |
| 88 <help> | |
| 89 Type an arbitrary SQL SELECT to perform on the input tables. The input tables may be referred by their given names. | |
| 90 An example query is SELECT employees.name AS employee, emails.value AS email FROM one JOIN b ON employees.id = emails.employee, provided that the input tables are named employees and emails. | |
| 91 </help> | |
| 92 </param> | |
| 93 <conditional name="result"> | |
| 94 <param name="format" type="select"> | |
| 95 <label>SQL Query</label> | |
| 96 <help>Specify the file format of the query result.</help> | |
| 97 <expand macro="formats"/> | |
| 98 </param> | |
| 99 <expand macro="internal_name" format="h5"/> | |
| 100 <expand macro="internal_name" format="sqlite"/> | |
| 101 </conditional> | |
| 102 </inputs> | |
| 103 | |
| 104 <outputs> | |
| 105 <data name="output"> | |
| 106 <change_format> | |
| 107 <when input="result.format" value="h5" format="h5"/> | |
| 108 <when input="result.format" value="csv" format="csv"/> | |
| 109 <when input="result.format" value="tsv" format="tsv"/> | |
| 110 <when input="result.format" value="feather" format="feather"/> | |
| 111 <when input="result.format" value="parquet" format="parquet"/> | |
| 112 <when input="result.format" value="sqlite" format="sqlite"/> | |
| 113 </change_format> | |
| 114 </data> | |
| 115 </outputs> | |
| 116 | |
| 117 <tests> | |
| 118 <test> | |
| 119 <repeat name="tables"> | |
| 120 <param name="file" value="a.csv" ftype="csv"/> | |
| 121 <param name="name" value="a"/> | |
| 122 </repeat> | |
| 123 <repeat name="tables"> | |
| 124 <param name="file" value="b.csv" ftype="csv"/> | |
| 125 <param name="name" value="b"/> | |
| 126 </repeat> | |
| 127 <param name="query" value="SELECT a.x AS ax, a.y AS ay, a.z AS az, b.x AS bx, b.y AS by, b.z AS bz FROM a JOIN b ON a.x = b.x"/> | |
| 128 <conditional name="result"> | |
| 129 <param name="format" value="csv"/> | |
| 130 </conditional> | |
| 131 <output name="output" file="ab.csv" ftype="csv"/> | |
| 132 </test> | |
| 133 </tests> | |
| 134 </tool> |
