Mercurial > repos > iuc > filter_tabular
comparison filters.py @ 11:6544e4b87a4f draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/query_tabular commit d624cde6382bc326a5ae318482e16e643ef7d7d1"
author | iuc |
---|---|
date | Fri, 12 Feb 2021 21:20:08 +0000 |
parents | 69b08fc9557c |
children | 4d5aae46f850 |
comparison
equal
deleted
inserted
replaced
10:9cc411a62277 | 11:6544e4b87a4f |
---|---|
80 fields = line.split('\t') | 80 fields = line.split('\t') |
81 return '\t'.join([fields[x] for x in cols]) | 81 return '\t'.join([fields[x] for x in cols]) |
82 | 82 |
83 def replace_add(self, line, pat, rep, col, pos): | 83 def replace_add(self, line, pat, rep, col, pos): |
84 fields = line.rstrip('\r\n').split('\t') | 84 fields = line.rstrip('\r\n').split('\t') |
85 i = pos if pos else len(fields) | 85 i = pos if pos is not None else len(fields) |
86 val = '' | 86 val = '' |
87 if col < len(fields) and re.search(pat, fields[col]): | 87 if col < len(fields) and re.search(pat, fields[col]): |
88 val = re.sub(pat, rep, fields[col]).replace('\t', ' ') | 88 val = re.sub(pat, rep, fields[col]).replace('\t', ' ') |
89 return '\t'.join(fields[:i] + [val] + fields[i:]) | 89 return '\t'.join(fields[:i] + [val] + fields[i:]) |
90 | 90 |