Mercurial > repos > jjohnson > query_tabular
comparison query_tabular.xml @ 4:afdbc7198353 draft
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
author | jjohnson |
---|---|
date | Thu, 21 Jan 2016 08:09:36 -0500 |
parents | ffa5e34a55c1 |
children | 727620f718c2 |
comparison
equal
deleted
inserted
replaced
2:ffa5e34a55c1 | 4:afdbc7198353 |
---|---|
4 <requirements> | 4 <requirements> |
5 </requirements> | 5 </requirements> |
6 <stdio> | 6 <stdio> |
7 <exit_code range="1:" /> | 7 <exit_code range="1:" /> |
8 </stdio> | 8 </stdio> |
9 <configfiles> | |
10 <configfile name="query_file"> | |
11 $sqlquery | |
12 </configfile> | |
13 </configfiles> | |
14 <command interpreter="python"><![CDATA[ | 9 <command interpreter="python"><![CDATA[ |
15 query_tabular.py | 10 query_tabular.py |
16 #if $save_db | 11 #if $save_db |
17 -s $sqlitedb | 12 -s $sqlitedb |
18 #else | 13 #else |
19 -s $workdb | 14 -s $workdb |
20 #end if | 15 #end if |
21 #for $i,$tbl in enumerate($tables): | 16 -j $table_json |
22 #if $tbl.table_name | 17 #* |
23 #set $tname = $tbl.table_name | 18 ## #for $i,$tbl in enumerate($tables): |
24 #else | 19 ## #if $tbl.table_name |
25 #set $tname = 't' + str($i + 1) | 20 ## #set $tname = $tbl.table_name |
26 #end if | 21 ## #else |
27 #if $tbl.col_names: | 22 ## #set $tname = 't' + str($i + 1) |
28 #set $col_names = ':' + str($tbl.col_names) | 23 ## #end if |
29 #else | 24 ## #if $tbl.col_names: |
30 #set $col_names = '' | 25 ## #set $col_names = ':' + str($tbl.col_names) |
31 #end if | 26 ## #else |
32 -t ${tbl.table}=${tname}${$col_names} | 27 ## #set $col_names = '' |
33 #end for | 28 ## #end if |
29 ## -t ${tbl.table}=${tname}${$col_names} | |
30 ## #end for | |
31 *# | |
34 #if $sqlquery: | 32 #if $sqlquery: |
35 -Q "$query_file" | 33 -Q "$query_file" |
36 $no_header | 34 $no_header |
37 -o $output | 35 -o $output |
38 #end if | 36 #end if |
39 ]]></command> | 37 ]]></command> |
38 <configfiles> | |
39 <configfile name="query_file"> | |
40 $sqlquery | |
41 </configfile> | |
42 <configfile name="table_json"> | |
43 #import json | |
44 #set $jtbldef = dict() | |
45 #set $jtbls = [] | |
46 #set $jtbldef['tables'] = $jtbls | |
47 #for $i,$tbl in enumerate($tables): | |
48 #set $jtbl = dict() | |
49 #set $jtbl['file_path'] = str($tbl.table) | |
50 #if $tbl.table_name | |
51 #set $tname = str($tbl.table_name) | |
52 #else | |
53 #set $tname = 't' + str($i + 1) | |
54 #end if | |
55 #set $jtbl['table_name'] = $tname | |
56 #if $tbl.col_names: | |
57 #set $col_names = str($tbl.col_names) | |
58 #else | |
59 #set $col_names = '' | |
60 #end if | |
61 #set $jtbl['column_names'] = $col_names | |
62 #if str($tbl.skip_lines) != '': | |
63 #set $jtbl['comment_lines'] = $tbl.skip_lines | |
64 #elif $tbl.table.metadata.comment_lines > 0: | |
65 #set $jtbl['comment_lines'] = int($tbl.table.metadata.comment_lines) | |
66 #end if | |
67 #set $jtbls += [$jtbl] | |
68 #end for | |
69 #echo $json.dumps($jtbldef) | |
70 </configfile> | |
71 </configfiles> | |
40 <inputs> | 72 <inputs> |
41 <param name="workdb" type="hidden" value="workdb.sqlite" label=""/> | 73 <param name="workdb" type="hidden" value="workdb.sqlite" label=""/> |
42 <repeat name="tables" title="Add tables" min="1"> | 74 <repeat name="tables" title="Add tables" min="1"> |
43 <param name="table" type="data" format="tabular" label="Dataset"/> | 75 <param name="table" type="data" format="tabular" label="Dataset"/> |
44 <param name="table_name" type="text" value="" optional="true" label="Table name"> | 76 <param name="table_name" type="text" value="" optional="true" label="Table name"> |
50 --> | 82 --> |
51 <param name="col_names" type="text" value="" optional="true" label="Column names"> | 83 <param name="col_names" type="text" value="" optional="true" label="Column names"> |
52 <help>By default, table columns will be named: c1,c2,c3,...,cn</help> | 84 <help>By default, table columns will be named: c1,c2,c3,...,cn</help> |
53 <validator type="regex" message="A List of separated by commas: Column names should start with a letter and may contain additional letters, digits, and underscores">^([A-Za-z]\w*)?(,([A-Za-z]\w*)?)*$</validator> | 85 <validator type="regex" message="A List of separated by commas: Column names should start with a letter and may contain additional letters, digits, and underscores">^([A-Za-z]\w*)?(,([A-Za-z]\w*)?)*$</validator> |
54 </param> | 86 </param> |
87 <param name="skip_lines" type="integer" value="" min="0" optional="true" label="Skip lines" help="Leave blank to use the datatype comment lines metadata" /> | |
55 </repeat> | 88 </repeat> |
56 <param name="sqlquery" type="text" area="true" size="10x80" value="" optional="true" label="SQL Query"> | 89 <param name="sqlquery" type="text" area="true" size="10x80" value="" optional="true" label="SQL Query"> |
57 <help>By default, tables will be named: t1,t2,...,tn</help> | 90 <help>By default, tables will be named: t1,t2,...,tn</help> |
58 <sanitizer sanitize="False"/> | 91 <sanitizer sanitize="False"/> |
59 <validator type="regex" message="">^(?i)\s*select\s+.*\s+from\s+.*$</validator> | 92 <validator type="regex" message="">^(?i)\s*select\s+.*\s+from\s+.*$</validator> |
61 <param name="no_header" type="boolean" truevalue="-n" falsevalue="" checked="False" label="Omit column headers"/> | 94 <param name="no_header" type="boolean" truevalue="-n" falsevalue="" checked="False" label="Omit column headers"/> |
62 | 95 |
63 <param name="save_db" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Save the sqlite database"/> | 96 <param name="save_db" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Save the sqlite database"/> |
64 </inputs> | 97 </inputs> |
65 <outputs> | 98 <outputs> |
66 <data format="sqlite" name="sqlitedb" label="sqlite"> | 99 <data format="sqlite" name="sqlitedb" label="sqlite db of ${on_string}"> |
67 <filter>save_db or not (sqlquery and len(sqlquery) > 0)</filter> | 100 <filter>save_db or not (sqlquery and len(sqlquery) > 0)</filter> |
68 </data> | 101 </data> |
69 <data format="tabular" name="output" label="query results"> | 102 <data format="tabular" name="output" label="query results on ${on_string}"> |
70 <filter>sqlquery and len(sqlquery) > 0</filter> | 103 <filter>sqlquery and len(sqlquery) > 0</filter> |
71 </data> | 104 </data> |
72 </outputs> | 105 </outputs> |
73 <tests> | 106 <tests> |
74 | 107 |
82 <param name="table" ftype="tabular" value="sales.tsv"/> | 115 <param name="table" ftype="tabular" value="sales.tsv"/> |
83 <param name="table_name" value="sales"/> | 116 <param name="table_name" value="sales"/> |
84 <param name="col_names" value="CustomerID,Date,SaleAmount"/> | 117 <param name="col_names" value="CustomerID,Date,SaleAmount"/> |
85 </repeat> | 118 </repeat> |
86 <param name="sqlquery" value="SELECT FirstName,LastName,sum(SaleAmount) as "TotalSales" FROM customers join sales on customers.CustomerID = sales.CustomerID GROUP BY customers.CustomerID ORDER BY TotalSales DESC"/> | 119 <param name="sqlquery" value="SELECT FirstName,LastName,sum(SaleAmount) as "TotalSales" FROM customers join sales on customers.CustomerID = sales.CustomerID GROUP BY customers.CustomerID ORDER BY TotalSales DESC"/> |
87 <output name="output" file="sales_results.tsv"/> | 120 <output name="output" file="sales_results.tsv"/> |
88 </test> | 121 </test> |
89 | 122 |
90 <test> | 123 <test> |
91 <repeat name="tables"> | 124 <repeat name="tables"> |
92 <param name="table" ftype="tabular" value="customers.tsv"/> | 125 <param name="table" ftype="tabular" value="customers.tsv"/> |
94 </repeat> | 127 </repeat> |
95 <repeat name="tables"> | 128 <repeat name="tables"> |
96 <param name="table" ftype="tabular" value="sales.tsv"/> | 129 <param name="table" ftype="tabular" value="sales.tsv"/> |
97 </repeat> | 130 </repeat> |
98 <param name="sqlquery" value="SELECT FirstName,LastName,sum(t2.c3) as "TotalSales" FROM t1 join t2 on t1.c1 = t2.c1 GROUP BY t1.c1 ORDER BY TotalSales DESC;"/> | 131 <param name="sqlquery" value="SELECT FirstName,LastName,sum(t2.c3) as "TotalSales" FROM t1 join t2 on t1.c1 = t2.c1 GROUP BY t1.c1 ORDER BY TotalSales DESC;"/> |
99 <output name="output" file="sales_results.tsv"/> | 132 <output name="output" file="sales_results.tsv"/> |
133 </test> | |
134 | |
135 <test> | |
136 <repeat name="tables"> | |
137 <param name="table" ftype="tabular" value="customers.tsv"/> | |
138 <param name="col_names" value=",FirstName,LastName,,BirthDate,"/> | |
139 </repeat> | |
140 <param name="sqlquery" value="select FirstName,LastName,re_sub('^\d{2}(\d{2})-(\d\d)-(\d\d)','\3/\2/\1',BirthDate) as "DOB" from t1 WHERE re_search('[hp]er',c4)"/> | |
141 <output name="output" file="regex_results.tsv"/> | |
100 </test> | 142 </test> |
101 | 143 |
102 <test> | 144 <test> |
103 <repeat name="tables"> | 145 <repeat name="tables"> |
104 <param name="table" ftype="tabular" value="IEDB.tsv"/> | 146 <param name="table" ftype="tabular" value="IEDB.tsv"/> |
109 <param name="table" ftype="tabular" value="netMHC_summary.tsv"/> | 151 <param name="table" ftype="tabular" value="netMHC_summary.tsv"/> |
110 <param name="table_name" value="mhc_summary"/> | 152 <param name="table_name" value="mhc_summary"/> |
111 <param name="col_names" value="pos,peptide,logscore,affinity,Bind_Level,Protein,Allele"/> | 153 <param name="col_names" value="pos,peptide,logscore,affinity,Bind_Level,Protein,Allele"/> |
112 </repeat> | 154 </repeat> |
113 <param name="sqlquery" value="select iedb.ID,iedb.peptide,iedb.start,iedb.end,iedb.percentile_rank,mhc_summary.logscore,mhc_summary.affinity,mhc_summary.Bind_Level from iedb left outer join mhc_summary on iedb.peptide = mhc_summary.peptide order by affinity,Bind_Level"/> | 155 <param name="sqlquery" value="select iedb.ID,iedb.peptide,iedb.start,iedb.end,iedb.percentile_rank,mhc_summary.logscore,mhc_summary.affinity,mhc_summary.Bind_Level from iedb left outer join mhc_summary on iedb.peptide = mhc_summary.peptide order by affinity,Bind_Level"/> |
114 <output name="output" file="query_results.tsv"/> | 156 <output name="output" file="query_results.tsv"/> |
115 </test> | 157 </test> |
116 | 158 |
117 </tests> | 159 </tests> |
118 <help><![CDATA[ | 160 <help><![CDATA[ |
119 ============= | 161 ============= |
205 Column names: ,FirstName,LastName,,BirthDate | 247 Column names: ,FirstName,LastName,,BirthDate |
206 | 248 |
207 Results in the following data base table | 249 Results in the following data base table |
208 | 250 |
209 =========== ========== ========== ===================== ========== ============ | 251 =========== ========== ========== ===================== ========== ============ |
210 #c1 FirstName LastName c4 BithDate c6 | 252 #c1 FirstName LastName c4 BirthDate c6 |
211 =========== ========== ========== ===================== ========== ============ | 253 =========== ========== ========== ===================== ========== ============ |
212 1 John Smith John.Smith@yahoo.com 1968-02-04 626 222-2222 | 254 1 John Smith John.Smith@yahoo.com 1968-02-04 626 222-2222 |
213 2 Steven Goldfish goldfish@fishhere.net 1974-04-04 323 455-4545 | 255 2 Steven Goldfish goldfish@fishhere.net 1974-04-04 323 455-4545 |
214 3 Paula Brown pb@herowndomain.org 1978-05-24 416 323-3232 | 256 3 Paula Brown pb@herowndomain.org 1978-05-24 416 323-3232 |
215 4 James Smith jim@supergig.co.uk 1980-10-20 416 323-8888 | 257 4 James Smith jim@supergig.co.uk 1980-10-20 416 323-8888 |
216 =========== ========== ========== ===================== ========== ============ | 258 =========== ========== ========== ===================== ========== ============ |
217 | 259 |
260 Regular_expression_ functions are included for: | |
261 | |
262 :: | |
263 | |
264 matching: re_match('pattern',column) | |
265 | |
266 SELECT t1.FirstName, t1.LastName | |
267 FROM t1 | |
268 WHERE re_match('^.*\.(net|org)$',c4) | |
269 | |
270 Results: | |
271 | |
272 =========== ========== | |
273 #FirstName LastName | |
274 =========== ========== | |
275 Steven Goldfish | |
276 Paula Brown | |
277 =========== ========== | |
278 | |
279 | |
280 :: | |
281 | |
282 searching: re_search('pattern',column) | |
283 substituting: re_sub('pattern','replacement,column) | |
284 | |
285 SELECT t1.FirstName, t1.LastName, re_sub('^\d{2}(\d{2})-(\d\d)-(\d\d)','\3/\2/\1',BirthDate) as "DOB" | |
286 FROM t1 | |
287 WHERE re_search('[hp]er',c4) | |
288 | |
289 Results: | |
290 | |
291 =========== ========== ========== | |
292 #FirstName LastName DOB | |
293 =========== ========== ========== | |
294 Steven Goldfish 04/04/74 | |
295 Paula Brown 24/05/78 | |
296 James Smith 20/10/80 | |
297 =========== ========== ========== | |
298 | |
299 .. _Regular_expression: https://docs.python.org/release/2.7/library/re.html | |
218 .. _SQLite: http://www.sqlite.org/index.html | 300 .. _SQLite: http://www.sqlite.org/index.html |
219 | 301 |
220 ]]></help> | 302 ]]></help> |
221 </tool> | 303 </tool> |