Mercurial > repos > jjohnson > sqlite_to_tabular
comparison sqlite_to_tabular.xml @ 0:cf32fc695e72 draft
planemo upload for repository https://github.com/jj-umn/galaxytools/tree/master/sqlite_to_tabular commit 64a950cafd655311c99a54f96a27b49f0bdf2731-dirty
| author | jjohnson |
|---|---|
| date | Thu, 21 Jan 2016 09:35:35 -0500 |
| parents | |
| children | 78e9570fbe08 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:cf32fc695e72 |
|---|---|
| 1 <?xml version="1.0"?> | |
| 2 <tool id="sqlite_to_tabular" name="SQLite to tabular" version="0.0.1"> | |
| 3 <description>for SQL query</description> | |
| 4 <stdio> | |
| 5 <exit_code range="1:" level="fatal" description="Error" /> | |
| 6 </stdio> | |
| 7 <command interpreter="python"><![CDATA[ | |
| 8 sqlite_to_tabular.py | |
| 9 --sqlitedb="$sqlitedb" | |
| 10 --query_file="$query_file" | |
| 11 $no_header | |
| 12 --output="$query_results" | |
| 13 ]]></command> | |
| 14 <configfiles> | |
| 15 <configfile name="query_file"> | |
| 16 $sqlquery | |
| 17 </configfile> | |
| 18 </configfiles> | |
| 19 <inputs> | |
| 20 <param name="sqlitedb" type="data" format="sqlite" label="SQLite Database"/> | |
| 21 <param name="sqlquery" type="text" area="True" size="120x20" label="SQL query"> | |
| 22 <validator type="regex">^(?im)\s*SELECT\s.*\sFROM\s.*$</validator> | |
| 23 <sanitizer sanitize="False"/> | |
| 24 </param> | |
| 25 <param name="no_header" type="boolean" truevalue="-n" falsevalue="" checked="False" label="Omit column headers"/> | |
| 26 </inputs> | |
| 27 <outputs> | |
| 28 <data name="query_results" format="tabular" /> | |
| 29 </outputs> | |
| 30 <tests> | |
| 31 <test> | |
| 32 <param name="sqlitedb" ftype="sqlite" value="testdb.sqlite" /> | |
| 33 <param name="sqlquery" value="SELECT first_name, last_name, age FROM contacts WHERE first_name = 'Sam'" /> | |
| 34 <output name="query_results"> | |
| 35 <assert_contents> | |
| 36 <has_text text="Smith" /> | |
| 37 <not_has_text text="Doe" /> | |
| 38 </assert_contents> | |
| 39 </output> | |
| 40 </test> | |
| 41 </tests> | |
| 42 <help><![CDATA[ | |
| 43 Outputs the results of a query on a SQLite_ Database as a tabular file. | |
| 44 | |
| 45 In addition to the standard SQLite_functions_ regular_expression_ functions are included. | |
| 46 | |
| 47 For example, with SQLite table "customers": | |
| 48 | |
| 49 =========== ========== ========== ===================== ========== ============ | |
| 50 #CustomerID FirstName LastName Email BirthDate Phone | |
| 51 =========== ========== ========== ===================== ========== ============ | |
| 52 1 John Smith John.Smith@yahoo.com 1968-02-04 626 222-2222 | |
| 53 2 Steven Goldfish goldfish@fishhere.net 1974-04-04 323 455-4545 | |
| 54 3 Paula Brown pb@herowndomain.org 1978-05-24 416 323-3232 | |
| 55 4 James Smith jim@supergig.co.uk 1980-10-20 416 323-8888 | |
| 56 =========== ========== ========== ===================== ========== ============ | |
| 57 | |
| 58 :: | |
| 59 | |
| 60 matching: re_match('pattern',column) | |
| 61 | |
| 62 SELECT FirstName, LastName | |
| 63 FROM customers | |
| 64 WHERE re_match('^.*\.(net|org)$',Email) | |
| 65 | |
| 66 Results: | |
| 67 | |
| 68 =========== ========== | |
| 69 #FirstName LastName | |
| 70 =========== ========== | |
| 71 Steven Goldfish | |
| 72 Paula Brown | |
| 73 =========== ========== | |
| 74 | |
| 75 | |
| 76 :: | |
| 77 | |
| 78 searching: re_search('pattern',column) | |
| 79 substituting: re_sub('pattern','replacement,column) | |
| 80 | |
| 81 SELECT FirstName, LastName, re_sub('^\d{2}(\d{2})-(\d\d)-(\d\d)','\3/\2/\1',BirthDate) as "DOB" | |
| 82 FROM customers | |
| 83 WHERE re_search('[hp]er',Email) | |
| 84 | |
| 85 Results: | |
| 86 | |
| 87 =========== ========== ========== | |
| 88 #FirstName LastName DOB | |
| 89 =========== ========== ========== | |
| 90 Steven Goldfish 04/04/74 | |
| 91 Paula Brown 24/05/78 | |
| 92 James Smith 20/10/80 | |
| 93 =========== ========== ========== | |
| 94 | |
| 95 | |
| 96 | |
| 97 .. _Regular_expression: https://docs.python.org/release/2.7/library/re.html | |
| 98 .. _SQLite: http://www.sqlite.org/index.html | |
| 99 .. _SQLite_functions: http://www.sqlite.org/docs.html | |
| 100 | |
| 101 ]]></help> | |
| 102 </tool> |
