Mercurial > repos > jjohnson > query_tabular
annotate query_tabular.xml @ 7:aa2409ae9dc0 draft
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
| author | jjohnson |
|---|---|
| date | Tue, 16 Feb 2016 09:33:46 -0500 |
| parents | b9a6b07d0d2e |
| children | 6d9c91071884 |
| rev | line source |
|---|---|
|
7
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
1 <tool id="query_tabular" name="Query Tabular" version="0.1.1"> |
| 0 | 2 <description>using sqlite sql</description> |
| 3 | |
| 4 <requirements> | |
| 5 </requirements> | |
| 6 <stdio> | |
| 7 <exit_code range="1:" /> | |
| 8 </stdio> | |
| 9 <command interpreter="python"><![CDATA[ | |
| 10 query_tabular.py | |
| 11 #if $save_db | |
| 12 -s $sqlitedb | |
| 13 #else | |
| 14 -s $workdb | |
| 15 #end if | |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
16 -j $table_json |
| 2 | 17 #if $sqlquery: |
| 18 -Q "$query_file" | |
| 1 | 19 $no_header |
| 0 | 20 -o $output |
| 21 #end if | |
| 22 ]]></command> | |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
23 <configfiles> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
24 <configfile name="query_file"> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
25 $sqlquery |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
26 </configfile> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
27 <configfile name="table_json"> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
28 #import json |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
29 #set $jtbldef = dict() |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
30 #set $jtbls = [] |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
31 #set $jtbldef['tables'] = $jtbls |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
32 #for $i,$tbl in enumerate($tables): |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
33 #set $jtbl = dict() |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
34 #set $jtbl['file_path'] = str($tbl.table) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
35 #if $tbl.table_name |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
36 #set $tname = str($tbl.table_name) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
37 #else |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
38 #set $tname = 't' + str($i + 1) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
39 #end if |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
40 #set $jtbl['table_name'] = $tname |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
41 #if $tbl.col_names: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
42 #set $col_names = str($tbl.col_names) |
|
7
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
43 #if $tbl.load_named_columns: |
|
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
44 #set $jtbl['load_named_columns'] = True |
|
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
45 #end if |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
46 #else |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
47 #set $col_names = '' |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
48 #end if |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
49 #set $jtbl['column_names'] = $col_names |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
50 #if str($tbl.skip_lines) != '': |
|
5
727620f718c2
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit eefe7cbd5c59de67db7574847bb91e4a404adc03-dirty
jjohnson
parents:
4
diff
changeset
|
51 #set $jtbl['comment_lines'] = int($tbl.skip_lines) |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
52 #elif $tbl.table.metadata.comment_lines > 0: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
53 #set $jtbl['comment_lines'] = int($tbl.table.metadata.comment_lines) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
54 #end if |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
55 #set $jtbls += [$jtbl] |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
56 #end for |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
57 #echo $json.dumps($jtbldef) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
58 </configfile> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
59 </configfiles> |
| 0 | 60 <inputs> |
| 61 <param name="workdb" type="hidden" value="workdb.sqlite" label=""/> | |
| 62 <repeat name="tables" title="Add tables" min="1"> | |
| 63 <param name="table" type="data" format="tabular" label="Dataset"/> | |
| 64 <param name="table_name" type="text" value="" optional="true" label="Table name"> | |
| 65 <help>By default, tables will be named: t1,t2,...,tn</help> | |
| 66 <validator type="regex" message="Table name should start with a letter and may contain additional letters, digits, and underscores">^[A-Za-z]\w*$</validator> | |
| 67 </param> | |
| 68 <param name="col_names" type="text" value="" optional="true" label="Column names"> | |
| 69 <help>By default, table columns will be named: c1,c2,c3,...,cn</help> | |
|
7
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
70 <sanitizer sanitize="False"/> |
|
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
71 <validator type="regex" message="A List of names separated by commas: Column names should start with a letter and may contain additional letters, digits, and underscores. Otherwise, the name must be eclosed in: double quotes, back quotes, or square brackets.">^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?(,([A-Za-z]\w*|"\S+.*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?)*$</validator> |
| 0 | 72 </param> |
|
7
aa2409ae9dc0
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 60d1a49c09f87c1c1ec6fecbe54aa226bdc695a7-dirty
jjohnson
parents:
6
diff
changeset
|
73 <param name="load_named_columns" type="boolean" truevalue="load_named_columns" falsevalue="" checked="false" label="Only load named columns into database"/> |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
74 <param name="skip_lines" type="integer" value="" min="0" optional="true" label="Skip lines" help="Leave blank to use the datatype comment lines metadata" /> |
| 0 | 75 </repeat> |
| 2 | 76 <param name="sqlquery" type="text" area="true" size="10x80" value="" optional="true" label="SQL Query"> |
| 0 | 77 <help>By default, tables will be named: t1,t2,...,tn</help> |
| 78 <sanitizer sanitize="False"/> | |
|
6
b9a6b07d0d2e
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit d6d5197b824f0019e73f22602ac7c5c5dba0ac91-dirty
jjohnson
parents:
5
diff
changeset
|
79 <validator type="regex" message="">^(?im)\s*select\s+.*\s+from\s+.*$</validator> |
| 0 | 80 </param> |
| 1 | 81 <param name="no_header" type="boolean" truevalue="-n" falsevalue="" checked="False" label="Omit column headers"/> |
| 82 | |
| 0 | 83 <param name="save_db" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Save the sqlite database"/> |
| 84 </inputs> | |
| 85 <outputs> | |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
86 <data format="sqlite" name="sqlitedb" label="sqlite db of ${on_string}"> |
| 2 | 87 <filter>save_db or not (sqlquery and len(sqlquery) > 0)</filter> |
| 0 | 88 </data> |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
89 <data format="tabular" name="output" label="query results on ${on_string}"> |
| 2 | 90 <filter>sqlquery and len(sqlquery) > 0</filter> |
| 0 | 91 </data> |
| 92 </outputs> | |
| 93 <tests> | |
| 94 | |
| 95 <test> | |
| 96 <repeat name="tables"> | |
| 97 <param name="table" ftype="tabular" value="customers.tsv"/> | |
| 98 <param name="table_name" value="customers"/> | |
| 99 <param name="col_names" value="CustomerID,FirstName,LastName,Email,DOB,Phone"/> | |
| 100 </repeat> | |
| 101 <repeat name="tables"> | |
| 102 <param name="table" ftype="tabular" value="sales.tsv"/> | |
| 103 <param name="table_name" value="sales"/> | |
| 104 <param name="col_names" value="CustomerID,Date,SaleAmount"/> | |
| 105 </repeat> | |
| 2 | 106 <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"/> |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
107 <output name="output" file="sales_results.tsv"/> |
| 0 | 108 </test> |
| 109 | |
| 110 <test> | |
| 111 <repeat name="tables"> | |
| 112 <param name="table" ftype="tabular" value="customers.tsv"/> | |
| 113 <param name="col_names" value=",FirstName,LastName,,DOB,"/> | |
| 114 </repeat> | |
| 115 <repeat name="tables"> | |
| 116 <param name="table" ftype="tabular" value="sales.tsv"/> | |
| 117 </repeat> | |
| 2 | 118 <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;"/> |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
119 <output name="output" file="sales_results.tsv"/> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
120 </test> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
121 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
122 <test> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
123 <repeat name="tables"> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
124 <param name="table" ftype="tabular" value="customers.tsv"/> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
125 <param name="col_names" value=",FirstName,LastName,,BirthDate,"/> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
126 </repeat> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
127 <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)"/> |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
128 <output name="output" file="regex_results.tsv"/> |
| 0 | 129 </test> |
| 130 | |
| 131 <test> | |
| 132 <repeat name="tables"> | |
| 133 <param name="table" ftype="tabular" value="IEDB.tsv"/> | |
| 134 <param name="table_name" value="iedb"/> | |
| 135 <param name="col_names" value="ID,allele,seq_num,start,end,length,peptide,method,percentile_rank,ann_ic50,ann_rank,smm_ic50,smm_rank,comblib_sidney2008_score,comblib_sidney2008_rank,netmhcpan_ic50,netmhcpan_rank"/> | |
| 136 </repeat> | |
| 137 <repeat name="tables"> | |
| 138 <param name="table" ftype="tabular" value="netMHC_summary.tsv"/> | |
| 139 <param name="table_name" value="mhc_summary"/> | |
| 140 <param name="col_names" value="pos,peptide,logscore,affinity,Bind_Level,Protein,Allele"/> | |
| 141 </repeat> | |
| 2 | 142 <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"/> |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
143 <output name="output" file="query_results.tsv"/> |
| 0 | 144 </test> |
| 145 | |
| 146 </tests> | |
| 147 <help><![CDATA[ | |
| 148 ============= | |
| 149 Query Tabular | |
| 150 ============= | |
| 151 | |
| 152 **Inputs** | |
| 153 | |
| 154 Loads tabular datasets into a SQLite_ data base. | |
| 155 | |
| 156 **Outputs** | |
| 157 | |
| 158 The results of a SQL query are output to the history as a tabular file. | |
| 159 | |
| 160 The SQLite_ data base can also be saved and output as a dataset in the history. | |
| 161 | |
| 162 | |
| 163 For help in using SQLite_ see: http://www.sqlite.org/docs.html | |
| 164 | |
| 165 **NOTE:** input for SQLite dates input field must be in the format: *YYYY-MM-DD* for example: 2015-09-30 | |
| 166 | |
| 167 See: http://www.sqlite.org/lang_datefunc.html | |
| 168 | |
| 169 **Example** | |
| 170 | |
| 171 Given 2 tabular datasets: *customers* and *sales* | |
| 172 | |
| 173 Dataset *customers* | |
| 174 | |
| 175 Table name: "customers" | |
| 176 | |
| 177 Column names: "CustomerID,FirstName,LastName,Email,DOB,Phone" | |
| 178 | |
| 179 =========== ========== ========== ===================== ========== ============ | |
| 180 #CustomerID FirstName LastName Email DOB Phone | |
| 181 =========== ========== ========== ===================== ========== ============ | |
| 182 1 John Smith John.Smith@yahoo.com 1968-02-04 626 222-2222 | |
| 183 2 Steven Goldfish goldfish@fishhere.net 1974-04-04 323 455-4545 | |
| 184 3 Paula Brown pb@herowndomain.org 1978-05-24 416 323-3232 | |
| 185 4 James Smith jim@supergig.co.uk 1980-10-20 416 323-8888 | |
| 186 =========== ========== ========== ===================== ========== ============ | |
| 187 | |
| 188 Dataset *sales* | |
| 189 | |
| 190 Table name: "sales" | |
| 191 | |
| 192 Column names: "CustomerID,Date,SaleAmount" | |
| 193 | |
| 194 ============= ============ ============ | |
| 195 #CustomerID Date SaleAmount | |
| 196 ============= ============ ============ | |
| 197 2 2004-05-06 100.22 | |
| 198 1 2004-05-07 99.95 | |
| 199 3 2004-05-07 122.95 | |
| 200 3 2004-05-13 100.00 | |
| 201 4 2004-05-22 555.55 | |
| 202 ============= ============ ============ | |
| 203 | |
| 204 The query | |
| 205 | |
| 206 :: | |
| 207 | |
| 208 SELECT FirstName,LastName,sum(SaleAmount) as "TotalSales" | |
| 209 FROM customers join sales on customers.CustomerID = sales.CustomerID | |
| 210 GROUP BY customers.CustomerID ORDER BY TotalSales DESC; | |
| 211 | |
| 212 Produces this tabular output: | |
| 213 | |
| 214 ========== ======== ========== | |
| 215 #FirstName LastName TotalSales | |
| 216 ========== ======== ========== | |
| 217 James Smith 555.55 | |
| 218 Paula Brown 222.95 | |
| 219 Steven Goldfish 100.22 | |
| 220 John Smith 99.95 | |
| 221 ========== ======== ========== | |
| 222 | |
| 223 | |
| 224 If the optional Table name and Column names inputs are not used, the query would be: | |
| 225 | |
| 226 :: | |
| 227 | |
| 228 SELECT t1.c2 as "FirstName", t1.c3 as "LastName", sum(t2.c3) as "TotalSales" | |
| 229 FROM t1 join t2 on t1.c1 = t2.c1 | |
| 230 GROUP BY t1.c1 ORDER BY TotalSales DESC; | |
| 231 | |
| 232 You can selectively name columns, e.g. on the customers input you could just name columns 2,3, and 5: | |
| 233 | |
| 234 Column names: ,FirstName,LastName,,BirthDate | |
| 235 | |
| 236 Results in the following data base table | |
| 237 | |
| 238 =========== ========== ========== ===================== ========== ============ | |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
239 #c1 FirstName LastName c4 BirthDate c6 |
| 0 | 240 =========== ========== ========== ===================== ========== ============ |
| 241 1 John Smith John.Smith@yahoo.com 1968-02-04 626 222-2222 | |
| 242 2 Steven Goldfish goldfish@fishhere.net 1974-04-04 323 455-4545 | |
| 243 3 Paula Brown pb@herowndomain.org 1978-05-24 416 323-3232 | |
| 244 4 James Smith jim@supergig.co.uk 1980-10-20 416 323-8888 | |
| 245 =========== ========== ========== ===================== ========== ============ | |
| 246 | |
|
4
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
247 Regular_expression_ functions are included for: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
248 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
249 :: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
250 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
251 matching: re_match('pattern',column) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
252 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
253 SELECT t1.FirstName, t1.LastName |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
254 FROM t1 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
255 WHERE re_match('^.*\.(net|org)$',c4) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
256 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
257 Results: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
258 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
259 =========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
260 #FirstName LastName |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
261 =========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
262 Steven Goldfish |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
263 Paula Brown |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
264 =========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
265 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
266 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
267 :: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
268 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
269 searching: re_search('pattern',column) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
270 substituting: re_sub('pattern','replacement,column) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
271 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
272 SELECT t1.FirstName, t1.LastName, re_sub('^\d{2}(\d{2})-(\d\d)-(\d\d)','\3/\2/\1',BirthDate) as "DOB" |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
273 FROM t1 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
274 WHERE re_search('[hp]er',c4) |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
275 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
276 Results: |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
277 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
278 =========== ========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
279 #FirstName LastName DOB |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
280 =========== ========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
281 Steven Goldfish 04/04/74 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
282 Paula Brown 24/05/78 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
283 James Smith 20/10/80 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
284 =========== ========== ========== |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
285 |
|
afdbc7198353
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/query_tabular commit 9ae87502ea7c3da33ecc453872c4eb2f41ecea4a-dirty
jjohnson
parents:
2
diff
changeset
|
286 .. _Regular_expression: https://docs.python.org/release/2.7/library/re.html |
| 0 | 287 .. _SQLite: http://www.sqlite.org/index.html |
| 288 | |
| 289 ]]></help> | |
| 290 </tool> |
