annotate stderr_filter.py @ 0:1d1b9e1b2e2f draft

Uploaded
author petr-novak
date Thu, 19 Dec 2019 10:24:45 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
1 #!/usr/bin/env python3
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
2 '''
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
3 Purpose of this script is to filters some massages output
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
4 stderr to prevent galaxy to raise the error
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
5 '''
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
6 import sys
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
7
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
8 string_to_detect = [
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
9 'Karlin-Altschul parameters',
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
10 'slippage may introduce errors',
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
11 'Examining 5 or more matches is recommended',
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
12 'DeprecationWarning: The binary mode of fromstring is deprecated',
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
13 ]
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
14
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
15 string_to_remove = [
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
16 ('error', 'errour'),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
17 ('warning', 'alert')
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
18 ]
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
19 input_file = sys.argv[1]
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
20
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
21 with open(input_file) as f:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
22 for line in f:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
23 for s in string_to_detect:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
24 if s in line:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
25 new_line = "--" + line.lower()
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
26 for r in string_to_remove:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
27 new_line = new_line.replace(r[0], r[1])
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
28 line = new_line
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
29 print("parsed line:", line, file=sys.stderr)