changeset 15:cf4397560712 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:34 +0000
parents 3a6b78c39dca
children
files filters.py load_db.py macros.xml query_tabular.xml
diffstat 4 files changed, 36 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/filters.py	Wed Sep 13 12:15:42 2023 +0000
+++ b/filters.py	Thu Jun 27 17:23:34 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:42 2023 +0000
+++ b/load_db.py	Thu Jun 27 17:23:34 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:42 2023 +0000
+++ b/macros.xml	Thu Jun 27 17:23:34 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()
--- a/query_tabular.xml	Wed Sep 13 12:15:42 2023 +0000
+++ b/query_tabular.xml	Thu Jun 27 17:23:34 2024 +0000
@@ -1,4 +1,4 @@
-<tool id="query_tabular" name="Query Tabular" version="3.3.1">
+<tool id="query_tabular" name="Query Tabular" version="3.3.2">
     <description>using sqlite sql</description>
 
     <macros>
@@ -37,6 +37,7 @@
 #set $jtbls = []
 #set $jtbldef['tables'] = $jtbls
 #for $i,$tbl in enumerate($tables):
+  #set $table = $tbl.table
   #set $jtbl = dict()
   #set $jtbl['file_path'] = str($tbl.table)
   #if $tbl.tbl_opts.table_name:
@@ -137,7 +138,7 @@
                           You can override the default names by entering a comma -separated list of names, e.g. ',name1,,,name2' would rename the second and fifth columns.
                     </help>
                     <sanitizer sanitize="False"/>
-                    <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>
+                    <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>
                 </param>
                 <param name="load_named_columns" type="boolean" truevalue="load_named_columns" falsevalue="" checked="false" label="Only load the columns you have named into database"/>
                 <param name="pkey_autoincr" type="text" value="" optional="true" label="Add an auto increment primary key column with this name"
@@ -148,7 +149,7 @@
                     <param name="unique" type="boolean" truevalue="yes" falsevalue="no" checked="False" label="This is a unique index"/>
                     <param name="index_columns" type="text" value="" label="Index on Columns">
                         <help>Create an index on the column names: e.g. for default column names:  c1  or c2,c4 ( use the names you gave for columns)</help>
-                        <validator type="regex" message="Column name, separated by commes if more than one">^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])(,([A-Za-z]\w*|"\S+.*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?)*$</validator>
+                        <validator type="regex" message="Column name, separated by commes if more than one">^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|\[\S+[^,"]*\])(,([A-Za-z]\w*|"\S+[^,"]"|`\S+[^,`]*`|\[\S+[^,"]*\])?)*$</validator>
                         <sanitizer sanitize="False"/>
                     </param>
                 </repeat>
@@ -192,7 +193,7 @@
     </outputs>
     <tests>
         <!-- Test 1 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="customers.tsv"/>
                 <section name="input_opts">
@@ -228,7 +229,7 @@
         </test>
 
         <!-- Test 2 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="customers.tsv"/>
                 <section name="input_opts">
@@ -259,7 +260,7 @@
         </test>
 
         <!-- Test 3 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="customers.tsv"/>
                 <section name="input_opts">
@@ -279,7 +280,7 @@
         </test>
 
         <!-- Test 4 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="IEDB.tsv"/>
                 <section name="input_opts">
@@ -315,7 +316,7 @@
         </test>
 
         <!-- Test 5 -->
-        <test>
+        <test expect_num_outputs="1">
             <section name="add_to_database">
                 <param name="withdb" ftype="sqlite" value="testdb.sqlite"/>
             </section>
@@ -365,7 +366,7 @@
         </test>
 
         <!-- Test 6 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="pets.tsv"/>
                 <section name="input_opts">
@@ -446,7 +447,7 @@
         </test>
 
         <!-- Test 7 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="psm_report.tsv"/>
                 <section name="input_opts">
@@ -472,7 +473,7 @@
         </test>
 
         <!-- Test 8 column_names_from_first_line -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="psm_report.tsv"/>
                 <section name="input_opts">
@@ -498,7 +499,7 @@
         </test>
 
         <!-- Test 9  modify database -->
-        <test>
+        <test expect_num_outputs="2">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="psm_report.tsv"/>
                 <section name="input_opts">
@@ -539,7 +540,7 @@
         </test>
 
         <!-- Test 10 column_names_from_first_line -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="netMHC_summary.tsv"/>
                 <section name="input_opts">
@@ -565,7 +566,7 @@
         </test>
 
         <!-- Test 11 -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="netMHC_summary.tsv"/>
                 <section name="input_opts">
@@ -592,7 +593,7 @@
         </test>
 
         <!-- Test 12 math functions -->
-        <test>
+        <test expect_num_outputs="1">
             <repeat name="tables">
                 <param name="table" ftype="tabular" value="math_input.tsv"/>
             </repeat>