diff --git a/tools/query_tabular/.shed.yml b/tools/query_tabular/.shed.yml index 88f0716c1dc..f87c3012889 100644 --- a/tools/query_tabular/.shed.yml +++ b/tools/query_tabular/.shed.yml @@ -24,6 +24,7 @@ long_description: | owner: iuc remote_repository_url: https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular +homepage_url: https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular type: unrestricted auto_tool_repositories: name_template: "{{ tool_id }}" diff --git a/tools/query_tabular/filter_tabular.xml b/tools/query_tabular/filter_tabular.xml index f98fa014f5b..18ecd699954 100644 --- a/tools/query_tabular/filter_tabular.xml +++ b/tools/query_tabular/filter_tabular.xml @@ -1,4 +1,4 @@ - + @@ -16,10 +16,9 @@ #import json #set $dataset_name = $input.element_identifier +#set $table=$input @LINEFILTERS@ -#if $input_filters: #echo $json.dumps($input_filters) -#end if @@ -166,6 +165,17 @@ + + + + + + + + + + + 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 @@ def xint(x): '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 diff --git a/tools/query_tabular/load_db.py b/tools/query_tabular/load_db.py index 68d93fa3f60..a30f61277ac 100755 --- a/tools/query_tabular/load_db.py +++ b/tools/query_tabular/load_db.py @@ -328,4 +328,4 @@ def create_index(conn, table_name, index_name, index_columns, unique=False): c.close() except Exception as e: print('Failed: %s err: %s' % (index_def, e), file=sys.stderr) - raise(e) + raise e diff --git a/tools/query_tabular/macros.xml b/tools/query_tabular/macros.xml index 542316cd43c..57681a3cda6 100644 --- a/tools/query_tabular/macros.xml +++ b/tools/query_tabular/macros.xml @@ -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() diff --git a/tools/query_tabular/query_tabular.xml b/tools/query_tabular/query_tabular.xml index 321668d10f3..9314ad98d3e 100644 --- a/tools/query_tabular/query_tabular.xml +++ b/tools/query_tabular/query_tabular.xml @@ -1,4 +1,4 @@ - + using sqlite sql @@ -37,6 +37,7 @@ $sqlquery #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 @@ $sqlquery 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. - ^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?(,([A-Za-z]\w*|"\S+.*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?)*$ + ^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|\[\S+[^,"]*\])?(,([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|\[\S+[^,"]*\])?)*$ Create an index on the column names: e.g. for default column names: c1 or c2,c4 ( use the names you gave for columns) - ^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])(,([A-Za-z]\w*|"\S+.*"|`\S+[^,`]*`|[[]\S+[^,"]*[]])?)*$ + ^([A-Za-z]\w*|"\S+[^,"]*"|`\S+[^,`]*`|\[\S+[^,"]*\])(,([A-Za-z]\w*|"\S+[^,"]"|`\S+[^,`]*`|\[\S+[^,"]*\])?)*$ @@ -192,7 +193,7 @@ $sqlquery - +
@@ -228,7 +229,7 @@ $sqlquery - +
@@ -259,7 +260,7 @@ $sqlquery - +
@@ -279,7 +280,7 @@ $sqlquery - +
@@ -315,7 +316,7 @@ $sqlquery - +
@@ -365,7 +366,7 @@ $sqlquery
- +
@@ -446,7 +447,7 @@ $sqlquery - +
@@ -472,7 +473,7 @@ $sqlquery - +
@@ -498,7 +499,7 @@ $sqlquery - +
@@ -539,7 +540,7 @@ $sqlquery - +
@@ -565,7 +566,7 @@ $sqlquery - +
@@ -592,7 +593,7 @@ $sqlquery - + diff --git a/tools/query_tabular/sqlite_to_tabular.xml b/tools/query_tabular/sqlite_to_tabular.xml index ca0c04c85a0..459ca826bb5 100644 --- a/tools/query_tabular/sqlite_to_tabular.xml +++ b/tools/query_tabular/sqlite_to_tabular.xml @@ -1,5 +1,5 @@ - + for SQL query