changeset 15:90f657745fea draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit dd35055c76d86fe98985b5825c1751efb8208242
author iuc
date Thu, 27 Jun 2024 17:23:47 +0000
parents 557ec8d7087d
children
files filter_tabular.xml filters.py load_db.py macros.xml
diffstat 4 files changed, 33 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/filter_tabular.xml	Wed Sep 13 12:15:22 2023 +0000
+++ b/filter_tabular.xml	Thu Jun 27 17:23:47 2024 +0000
@@ -1,4 +1,4 @@
-<tool id="filter_tabular" name="Filter Tabular" version="3.3.0">
+<tool id="filter_tabular" name="Filter Tabular" version="3.3.1">
     <description></description>
 
     <macros>
@@ -16,10 +16,9 @@
         <configfile name="filter_json">
 #import json
 #set $dataset_name = $input.element_identifier
+#set $table=$input
 @LINEFILTERS@
-#if $input_filters:
 #echo $json.dumps($input_filters)
-#end if
         </configfile>
     </configfiles>
     <inputs>
@@ -166,6 +165,17 @@
             </repeat>
             <output name="output" file="filtered_IEDB.tsv"/>
         </test>
+        <test>
+            <param name="input" ftype="tabular" value="math_input.tsv"/>
+            <param name="comment_char" value="False"/>
+            <repeat name="linefilters">
+                <conditional name="filter">
+                    <param name="filter_type" value="skip"/>
+                    <param name="skiplines" value=""/>
+                </conditional>
+            </repeat>
+            <output name="output" file="math_input.tsv"/>
+        </test>
     </tests>
     <help><![CDATA[
 ==============
--- a/filters.py	Wed Sep 13 12:15:22 2023 +0000
+++ b/filters.py	Thu Jun 27 17:23:47 2024 +0000
@@ -11,7 +11,7 @@
     def __init__(self, source, filter_dict):
         self.source = source
         self.filter_dict = filter_dict
-        self.func = lambda i, l: l.rstrip('\r\n') if l else None
+        self.func = lambda i, line: line.rstrip('\r\n') if line else None
         self.src_lines = []
         self.src_line_cnt = 0
 
@@ -28,23 +28,23 @@
         if filter_dict['filter'] == 'regex':
             rgx = re.compile(filter_dict['pattern'])
             if filter_dict['action'] == 'exclude_match':
-                self.func = lambda i, l: l if not rgx.match(l) else None
+                self.func = lambda i, line: line if not rgx.match(line) else None
             elif filter_dict['action'] == 'include_match':
-                self.func = lambda i, l: l if rgx.match(l) else None
+                self.func = lambda i, line: line if rgx.match(line) else None
             elif filter_dict['action'] == 'exclude_find':
-                self.func = lambda i, l: l if not rgx.search(l) else None
+                self.func = lambda i, line: line if not rgx.search(line) else None
             elif filter_dict['action'] == 'include_find':
-                self.func = lambda i, l: l if rgx.search(l) else None
+                self.func = lambda i, line: line if rgx.search(line) else None
         elif filter_dict['filter'] == 'select_columns':
             cols = [int(c) - 1 for c in filter_dict['columns']]
-            self.func = lambda i, l: self.select_columns(l, cols)
+            self.func = lambda i, line: self.select_columns(line, cols)
         elif filter_dict['filter'] == 'select_column_slices':
             cols = [x if isinstance(x, int) else [y if y is not None else None for y in [xint(k) for k in x.split(':')]] for x in [xint(c) for c in filter_dict['columns']]]
             if all([isinstance(x, int) for x in cols]):
-                self.func = lambda i, l: self.select_columns(l, cols)
+                self.func = lambda i, line: self.select_columns(line, cols)
             else:
                 cols = [slice(x[0], x[1], x[2] if len(x) > 2 else None) if isinstance(x, list) else x for x in cols]
-                self.func = lambda i, l: self.select_slices(l, cols)
+                self.func = lambda i, line: self.select_slices(line, cols)
         elif filter_dict['filter'] == 'replace':
             p = filter_dict['pattern']
             r = filter_dict['replace']
@@ -54,32 +54,32 @@
                                               'append',
                                               'before',
                                               'after']:
-                self.func = lambda i, l: '\t'.join(
+                self.func = lambda i, line: '\t'.join(
                     [x if j != c else re.sub(p, r, x)
-                     for j, x in enumerate(l.split('\t'))])
+                     for j, x in enumerate(line.split('\t'))])
             else:
                 a = 0 if filter_dict['add'] == 'prepend'\
                     else min(0, c - 1) if filter_dict['add'] == 'before'\
                     else c + 1 if filter_dict['add'] == 'after'\
                     else None
-                self.func = lambda i, l: self.replace_add(l, p, r, c, a)
+                self.func = lambda i, line: self.replace_add(line, p, r, c, a)
         elif filter_dict['filter'] == 'prepend_line_num':
-            self.func = lambda i, l: '%d\t%s' % (i, l)
+            self.func = lambda i, line: '%d\t%s' % (i, line)
         elif filter_dict['filter'] == 'append_line_num':
-            self.func = lambda i, l: '%s\t%d' % (l.rstrip('\r\n'), i)
+            self.func = lambda i, line: '%s\t%d' % (line.rstrip('\r\n'), i)
         elif filter_dict['filter'] == 'prepend_text':
             s = filter_dict['column_text']
-            self.func = lambda i, l: '%s\t%s' % (s, l)
+            self.func = lambda i, line: '%s\t%s' % (s, line)
         elif filter_dict['filter'] == 'append_text':
             s = filter_dict['column_text']
-            self.func = lambda i, l: '%s\t%s' % (l.rstrip('\r\n'), s)
+            self.func = lambda i, line: '%s\t%s' % (line.rstrip('\r\n'), s)
         elif filter_dict['filter'] == 'skip':
             cnt = filter_dict['count']
-            self.func = lambda i, l: l if i > cnt else None
+            self.func = lambda i, line: line if i > cnt else None
         elif filter_dict['filter'] == 'normalize':
             cols = [int(c) - 1 for c in filter_dict['columns']]
             sep = filter_dict['separator']
-            self.func = lambda i, l: self.normalize(l, cols, sep)
+            self.func = lambda i, line: self.normalize(line, cols, sep)
 
     def __iter__(self):
         return self
--- a/load_db.py	Wed Sep 13 12:15:22 2023 +0000
+++ b/load_db.py	Thu Jun 27 17:23:47 2024 +0000
@@ -328,4 +328,4 @@
         c.close()
     except Exception as e:
         print('Failed: %s err: %s' % (index_def, e), file=sys.stderr)
-        raise(e)
+        raise e
--- a/macros.xml	Wed Sep 13 12:15:22 2023 +0000
+++ b/macros.xml	Thu Jun 27 17:23:47 2024 +0000
@@ -8,8 +8,8 @@
       #set $skip_lines = None
       #if str($fi.filter.skip_lines) != '':
         #set $skip_lines = int($fi.filter.skip_lines)
-      #elif $tbl.table.metadata.comment_lines and $tbl.table.metadata.comment_lines > 0:
-        #set $skip_lines = int($tbl.table.metadata.comment_lines)
+      #elif $table.metadata.comment_lines and int($table.metadata.comment_lines) > 0:
+        #set $skip_lines = int($table.metadata.comment_lines)
       #end if
       #if $skip_lines is not None:
         #set $filter_dict = dict()