diff list-chrom-cols.py @ 2:20d69a062da3 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author prog
date Thu, 02 Mar 2017 08:55:00 -0500
parents 253d531a0193
children fb9c0409d85c
line wrap: on
line diff
--- a/list-chrom-cols.py	Sat Sep 03 17:02:01 2016 -0400
+++ b/list-chrom-cols.py	Thu Mar 02 08:55:00 2017 -0500
@@ -24,24 +24,25 @@
         
     elif dbtype == 'inhouse':
         # Get field for chromatographic column name
-        col_field = 'col'
+        col_field = 'chromcol'
         if dbfields is not None:
             fields = dict(u.split("=") for u in dbfields.split(","))
-            if 'col' in fields:
-                col_field = fields['col']
+            if 'chromcol' in fields:
+                col_field = fields['chromcol']
                 
         # Get all column names from file
-        with open(dburl.get_file_name(), 'rb') as dbfile:
+        with open(dburl if isinstance(dburl, str) else dburl.get_file_name(), 'rb') as dbfile:
             reader = csv.reader(dbfile, delimiter = "\t", quotechar='"')
             header = reader.next()
-            i = header.index(col_field)
-            allcols = []
-            for row in reader:
-                col = row[i]
-                if col not in allcols:
-                    allcols.append(col)
-            for i, c in enumerate(allcols):
-                cols.append( (c, c, i == 0) )
+            if col_field in header:
+                i = header.index(col_field)
+                allcols = []
+                for row in reader:
+                    col = row[i]
+                    if col not in allcols:
+                        allcols.append(col)
+                for i, c in enumerate(allcols):
+                    cols.append( (c, c, i == 0) )
     
     return cols