comparison column_maker.py @ 8:02026300aa45 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/column_maker commit 276e05a2c72c031318eef8c57deebbbde822b538"
author iuc
date Tue, 09 Mar 2021 18:33:10 +0000
parents 427903d47026
children 6595517c2dd8
comparison
equal deleted inserted replaced
7:427903d47026 8:02026300aa45
8 8
9 import argparse 9 import argparse
10 import json 10 import json
11 import re 11 import re
12 import sys 12 import sys
13 # functions that may be used in the compute expression 13 # Functions that may be used in the compute expression
14 from math import ( # noqa: F401 14 from math import ( # noqa: F401
15 ceil, 15 ceil,
16 exp, 16 exp,
17 floor, 17 floor,
18 log, 18 log,
19 log10, 19 log10,
20 sqrt 20 sqrt,
21 ) 21 )
22 22
23 from numpy import format_float_positional # noqa: F401 23 from numpy import format_float_positional # noqa: F401
24 24
25 parser = argparse.ArgumentParser() 25 parser = argparse.ArgumentParser()
139 139
140 valid_expr = True 140 valid_expr = True
141 try: 141 try:
142 exec(code) 142 exec(code)
143 except Exception as e: 143 except Exception as e:
144 out.close()
145 if str(e).startswith('invalid syntax'): 144 if str(e).startswith('invalid syntax'):
146 valid_expr = False 145 valid_expr = False
147 sys.exit('Expression "%s" likely invalid. See tool tips, syntax and examples.' % expr) 146 sys.exit('Expression "%s" likely invalid. See tool tips, syntax and examples.' % expr)
148 else: 147 else:
149 sys.exit(str(e)) 148 sys.exit(str(e))
149 finally:
150 out.close()
150 151
151 if valid_expr: 152 if valid_expr:
152 out.close()
153 valid_lines = total_lines - skipped_lines 153 valid_lines = total_lines - skipped_lines
154 print('Creating column %d with expression %s' % (in_columns + 1, expr)) 154 print('Creating column %d with expression %s' % (in_columns + 1, expr))
155 if valid_lines > 0: 155 if valid_lines > 0:
156 print('kept %4.2f%% of %d lines.' % (100.0 * lines_kept / valid_lines, 156 print('kept %4.2f%% of %d lines.' % (100.0 * lines_kept / valid_lines,
157 total_lines)) 157 total_lines))