comparison filters.py @ 9:69b08fc9557c draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit daa9af57fe07ee83a45ddc9f855716f9d14a8e12"
author iuc
date Sat, 12 Sep 2020 01:21:45 +0000
parents cd2a99849f8b
children 6544e4b87a4f
comparison
equal deleted inserted replaced
8:59278960a2e7 9:69b08fc9557c
30 self.func = lambda i, l: self.select_columns(l, cols) 30 self.func = lambda i, l: self.select_columns(l, cols)
31 elif filter_dict['filter'] == 'replace': 31 elif filter_dict['filter'] == 'replace':
32 p = filter_dict['pattern'] 32 p = filter_dict['pattern']
33 r = filter_dict['replace'] 33 r = filter_dict['replace']
34 c = int(filter_dict['column']) - 1 34 c = int(filter_dict['column']) - 1
35 self.func = lambda i, l: '\t'.join( 35 if 'add' not in filter_dict\
36 [x if j != c else re.sub(p, r, x) 36 or filter_dict['add'] not in ['prepend',
37 for j, x in enumerate(l.split('\t'))]) 37 'append',
38 'before',
39 'after']:
40 self.func = lambda i, l: '\t'.join(
41 [x if j != c else re.sub(p, r, x)
42 for j, x in enumerate(l.split('\t'))])
43 else:
44 a = 0 if filter_dict['add'] == 'prepend'\
45 else min(0, c - 1) if filter_dict['add'] == 'before'\
46 else c + 1 if filter_dict['add'] == 'after'\
47 else None
48 self.func = lambda i, l: self.replace_add(l, p, r, c, a)
38 elif filter_dict['filter'] == 'prepend_line_num': 49 elif filter_dict['filter'] == 'prepend_line_num':
39 self.func = lambda i, l: '%d\t%s' % (i, l) 50 self.func = lambda i, l: '%d\t%s' % (i, l)
40 elif filter_dict['filter'] == 'append_line_num': 51 elif filter_dict['filter'] == 'append_line_num':
41 self.func = lambda i, l: '%s\t%d' % (l.rstrip('\r\n'), i) 52 self.func = lambda i, l: '%s\t%d' % (l.rstrip('\r\n'), i)
42 elif filter_dict['filter'] == 'prepend_text': 53 elif filter_dict['filter'] == 'prepend_text':
66 next = __next__ 77 next = __next__
67 78
68 def select_columns(self, line, cols): 79 def select_columns(self, line, cols):
69 fields = line.split('\t') 80 fields = line.split('\t')
70 return '\t'.join([fields[x] for x in cols]) 81 return '\t'.join([fields[x] for x in cols])
82
83 def replace_add(self, line, pat, rep, col, pos):
84 fields = line.rstrip('\r\n').split('\t')
85 i = pos if pos else len(fields)
86 val = ''
87 if col < len(fields) and re.search(pat, fields[col]):
88 val = re.sub(pat, rep, fields[col]).replace('\t', ' ')
89 return '\t'.join(fields[:i] + [val] + fields[i:])
71 90
72 def normalize(self, line, split_cols, sep): 91 def normalize(self, line, split_cols, sep):
73 lines = [] 92 lines = []
74 fields = line.rstrip('\r\n').split('\t') 93 fields = line.rstrip('\r\n').split('\t')
75 split_fields = dict() 94 split_fields = dict()
PKMc] deeptools_compute_matrix_operations-3909b643c81c/static/images/GC_bias_simulated_reads_2L.pngUTh}[PKMSKHsS deeptools_compute_matrix_operations-3909b643c81c/static/images/QC_GCplots_input.pngUTh}[PKMc-Q Odeeptools_compute_matrix_operations-3909b643c81c/static/images/QC_fingerprint.pngUTh}[PKMo=)b =gdeeptools_compute_matrix_operations-3909b643c81c/static/images/QC_multiBamSummary_humanSamples.pngUTh}[PKM%YR vdeeptools_compute_matrix_operations-3909b643c81c/static/images/QC_plotCoverage.pngUTh}[PKM%u=T vdeeptools_compute_matrix_operations-3909b643c81c/static/images/bamCompare_output.pngUTh}[PKM I^ɊU ą deeptools_compute_matrix_operations-3909b643c81c/static/images/bamCoverage_output.pngUTh}[PKMa?V deeptools_compute_matrix_operations-3909b643c81c/static/images/bamFP_galaxy_output.pngUTh}[PKM3 mQ[ edeeptools_compute_matrix_operations-3909b643c81c/static/images/bamPEFragmentSize_output.pngUTh}[PKMz;iW Ddeeptools_compute_matrix_operations-3909b643c81c/static/images/bigwigCompare_output.pngUTh}[PKMGEUZW !deeptools_compute_matrix_operations-3909b643c81c/static/images/computeGCBias_output.pngUTh}[PKMiAJ5_ )deeptools_compute_matrix_operations-3909b643c81c/static/images/computeMatrix_advancedOutput.pngUTh}[PK .+