comparison 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
comparison
equal deleted inserted replaced
1:253d531a0193 2:20d69a062da3
22 cols.append( (coldesc['name'], colid, i == 0) ) 22 cols.append( (coldesc['name'], colid, i == 0) )
23 ++i 23 ++i
24 24
25 elif dbtype == 'inhouse': 25 elif dbtype == 'inhouse':
26 # Get field for chromatographic column name 26 # Get field for chromatographic column name
27 col_field = 'col' 27 col_field = 'chromcol'
28 if dbfields is not None: 28 if dbfields is not None:
29 fields = dict(u.split("=") for u in dbfields.split(",")) 29 fields = dict(u.split("=") for u in dbfields.split(","))
30 if 'col' in fields: 30 if 'chromcol' in fields:
31 col_field = fields['col'] 31 col_field = fields['chromcol']
32 32
33 # Get all column names from file 33 # Get all column names from file
34 with open(dburl.get_file_name(), 'rb') as dbfile: 34 with open(dburl if isinstance(dburl, str) else dburl.get_file_name(), 'rb') as dbfile:
35 reader = csv.reader(dbfile, delimiter = "\t", quotechar='"') 35 reader = csv.reader(dbfile, delimiter = "\t", quotechar='"')
36 header = reader.next() 36 header = reader.next()
37 i = header.index(col_field) 37 if col_field in header:
38 allcols = [] 38 i = header.index(col_field)
39 for row in reader: 39 allcols = []
40 col = row[i] 40 for row in reader:
41 if col not in allcols: 41 col = row[i]
42 allcols.append(col) 42 if col not in allcols:
43 for i, c in enumerate(allcols): 43 allcols.append(col)
44 cols.append( (c, c, i == 0) ) 44 for i, c in enumerate(allcols):
45 cols.append( (c, c, i == 0) )
45 46
46 return cols 47 return cols
47 48
48 ######## 49 ########
49 # MAIN # 50 # MAIN #