annotate column_regex_substitution.py @ 0:12b740c4cbc1 draft default tip

planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
author blankenberg
date Fri, 07 Sep 2018 10:29:30 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
1 #!/usr/bin/env python
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
2 #Dan Blankenberg
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
3
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
4 """
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
5 A script for using regex substitutions on columns.
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
6 """
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
7
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
8 import optparse
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
9 import re
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
10 import sys
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
11 import string
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
12
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
13 VERSION = "0.0.1"
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
14
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
15 COLUMN_STRIP_VALUES = "".join( set( string.printable ) - set( string.digits ) - set(',') )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
16
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
17 def get_provided_columns( provided_value, column_offset ):
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
18 try:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
19 rval = sorted( map( lambda x: int( x.strip( COLUMN_STRIP_VALUES ) ) + column_offset, provided_value.split( ',' ) ) )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
20 except:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
21 rval = None
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
22 if rval:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
23 return rval
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
24 return None
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
25
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
26
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
27 def __main__():
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
28 parser = optparse.OptionParser()
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
29 parser.add_option('--pattern', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
30 help='pattern string')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
31 parser.add_option('--replacement', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
32 help='replacement string')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
33 parser.add_option('--input', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
34 help='Filename of input file')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
35 parser.add_option('--output', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
36 help='Filename of output file')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
37 parser.add_option('--delimiter', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
38 help='column delimiter')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
39 parser.add_option('--columns', action='store', default=None,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
40 help='columns to operate on')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
41 parser.add_option('--column_offset', action='store', default=0,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
42 help='offset to apply to columns index to force to zero-based')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
43 parser.add_option('--skip', action='store', default=0,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
44 help='Number of lines to skip')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
45 parser.add_option('--version', action='store_true', default=False,
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
46 help='Show version')
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
47
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
48 (options, args) = parser.parse_args()
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
49
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
50 if options.version:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
51 print "blankenberg_python_regex_substitution %s" % ( VERSION )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
52 sys.exit(0)
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
53
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
54 if None in [ options.pattern, options.replacement, options.output ]:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
55 parser.print_help()
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
56 sys.exit(1)
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
57
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
58 pattern = options.pattern
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
59 replacement = options.replacement
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
60 column_offset = int( options.column_offset )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
61 print "Pattern: %s\nReplacement: %s" % ( repr( pattern ), repr( replacement ) )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
62 pattern = re.compile( pattern )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
63 provided_columns = get_provided_columns( options.columns, column_offset )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
64 if provided_columns:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
65 column_str = ", ".join( map( lambda x: str( x - column_offset ), provided_columns ) )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
66 else:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
67 column_str = 'all'
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
68 print "With delimiter %s, on columns: %s" % ( repr( options.delimiter ), column_str )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
69 if options.delimiter is None:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
70 split_func = lambda x: [ x.rstrip( '\n\r' ) ]
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
71 join_char = ""
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
72 else:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
73 split_func = lambda x: x.rstrip( '\n\r' ).split( options.delimiter )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
74 join_char = options.delimiter
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
75 with open( options.input, 'rb' ) as fin:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
76 with open( options.output, 'w') as fout:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
77 for i, line in enumerate( fin ):
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
78 if i < options.skip:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
79 continue
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
80 line = split_func( line )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
81 field_count = len( line )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
82 if provided_columns:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
83 columns = provided_columns
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
84 else:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
85 columns = range( field_count )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
86 for j in columns:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
87 if j >= field_count:
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
88 break
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
89 line[ j ] = re.sub( pattern, replacement, line[ j ] )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
90 fout.write( "%s\n" % ( join_char.join( line ) ) )
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
91
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
92 if __name__ == "__main__":
12b740c4cbc1 planemo upload for repository https://github.com/blankenberg/tools-blankenberg/tree/master/tools/column_regex_substitution commit 78936dc6be1747303d4cbfd80d09e4cfd1cbf292
blankenberg
parents:
diff changeset
93 __main__()