Repository 'sqlite_to_tabular'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/sqlite_to_tabular

Changeset 10:dfe38b7c34ed (2020-09-24)
Previous changeset 9:4678715f7147 (2020-09-12) Next changeset 11:bce29ec10b78 (2021-02-12)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit 67db58361546009a77b2cbd140967fbc634d425b"
modified:
load_db.py
added:
test-data/netMHC_summary_out1.tsv
test-data/netMHC_summary_out2.tsv
b
diff -r 4678715f7147 -r dfe38b7c34ed load_db.py
--- a/load_db.py Sat Sep 12 01:22:24 2020 +0000
+++ b/load_db.py Thu Sep 24 11:27:11 2020 +0000
[
@@ -189,6 +189,9 @@
             if linenum == 0 and firstlinenames:
                 col_names = [get_valid_column_name(name) or 'c%d' % (i + 1)
                              for i, name in enumerate(fields)]
+                # guarantee col_types in case of empty data
+                while len(col_types) < len(fields):
+                    col_types.append(None)
                 continue
             if linenum > max_lines:
                 break
@@ -210,23 +213,30 @@
     if not col_names:
         col_names = ['c%d' % i for i in range(1, len(col_types) + 1)]
     if column_names:
+        cnames = [cn.strip() for cn in column_names.split(',')]
         if load_named_columns:
             col_idx = []
-            cnames = []
-            for i, cname in enumerate(
-                    [cn.strip() for cn in column_names.split(',')]):
+            colnames = []
+            for i, cname in enumerate(cnames):
+                # guarantee col_types in case of empty data
+                if i >= len(col_types):
+                    col_types.append('TEXT')
                 if cname != '':
                     col_idx.append(i)
-                    cnames.append(cname)
+                    colnames.append(cname)
             col_types = [col_types[i] for i in col_idx]
-            col_names = cnames
+            col_names = colnames
         else:
-            for i, cname in enumerate(
-                    [cn.strip() for cn in column_names.split(',')]):
-                if cname and i < len(col_names):
-                    col_names[i] = cname
+            if col_names:
+                for i, cname in enumerate(cnames):
+                    if cname and i < len(col_names):
+                        col_names[i] = cname
+            else:
+                col_names = [x if x else 'c%d' % (i) for i, x in enumerate(cnames)]
     col_def = []
     for i, col_name in enumerate(col_names):
+        if i >= len(col_types):
+            col_types.append('TEXT')
         col_def.append('%s %s' % (col_names[i], col_types[i]))
     return col_names, col_types, col_def, col_idx
 
b
diff -r 4678715f7147 -r dfe38b7c34ed test-data/netMHC_summary_out1.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/netMHC_summary_out1.tsv Thu Sep 24 11:27:11 2020 +0000
b
@@ -0,0 +1,1 @@
+#pos peptide logscore affinity(nM) Bind Level Protein Name Allele
b
diff -r 4678715f7147 -r dfe38b7c34ed test-data/netMHC_summary_out2.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/netMHC_summary_out2.tsv Thu Sep 24 11:27:11 2020 +0000
b
@@ -0,0 +1,1 @@
+pos peptide logscore Allele