changeset 11:6544e4b87a4f draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit d624cde6382bc326a5ae318482e16e643ef7d7d1"
author iuc
date Fri, 12 Feb 2021 21:20:08 +0000
parents 9cc411a62277
children 37cde8134c6a
files filter_tabular.xml filters.py test-data/filtered_customers_results.tsv
diffstat 3 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/filter_tabular.xml	Thu Sep 24 11:27:38 2020 +0000
+++ b/filter_tabular.xml	Fri Feb 12 21:20:08 2021 +0000
@@ -1,4 +1,4 @@
-<tool id="filter_tabular" name="Filter Tabular" version="3.1.0">
+<tool id="filter_tabular" name="Filter Tabular" version="3.1.2">
     <description></description>
 
     <macros>
@@ -128,6 +128,15 @@
                     <param name="add" value="append"/>
                 </conditional>
             </repeat>
+            <repeat name="linefilters">
+                <conditional name="filter">
+                    <param name="filter_type" value="replace"/>
+                    <param name="column" value="c6"/>
+                    <param name="regex_pattern" value="^(\d+)-(\d+)-(\d+)$"/>
+                    <param name="regex_replace" value="\1"/>
+                    <param name="add" value="prepend"/>
+                </conditional>
+            </repeat>
             <output name="output" file="filtered_customers_results.tsv"/>
         </test>
     </tests>
--- a/filters.py	Thu Sep 24 11:27:38 2020 +0000
+++ b/filters.py	Fri Feb 12 21:20:08 2021 +0000
@@ -82,7 +82,7 @@
 
     def replace_add(self, line, pat, rep, col, pos):
         fields = line.rstrip('\r\n').split('\t')
-        i = pos if pos else len(fields)
+        i = pos if pos is not None else len(fields)
         val = ''
         if col < len(fields) and re.search(pat, fields[col]):
             val = re.sub(pat, rep, fields[col]).replace('\t', ' ')
--- a/test-data/filtered_customers_results.tsv	Thu Sep 24 11:27:38 2020 +0000
+++ b/test-data/filtered_customers_results.tsv	Fri Feb 12 21:20:08 2021 +0000
@@ -1,4 +1,4 @@
-1	John	Smith	John.Smith@yahoo.com	yahoo.com	1968-02-04	626 222-2222	com
-2	Steven	Goldfish	goldfish@fishhere.net	fishhere.net	1974-04-04	323 455-4545	net
-3	Paula	Brown	pb@herowndomain.org	herowndomain.org	1978-05-24	416 323-3232	org
-4	James	Smith	jim@supergig.co.uk	supergig.co.uk	1980-10-20	416 323-8888	
+1968	1	John	Smith	John.Smith@yahoo.com	yahoo.com	1968-02-04	626 222-2222	com
+1974	2	Steven	Goldfish	goldfish@fishhere.net	fishhere.net	1974-04-04	323 455-4545	net
+1978	3	Paula	Brown	pb@herowndomain.org	herowndomain.org	1978-05-24	416 323-3232	org
+1980	4	James	Smith	jim@supergig.co.uk	supergig.co.uk	1980-10-20	416 323-8888