1 | #!/usr/bin/python2.6 |
---|
2 | |
---|
3 | """ |
---|
4 | Translate a maf file containing gap ambiguity characters as produced by |
---|
5 | 'maf_tile_2.py' to a new file in which "#" (contiguous) is replaced by "-" and |
---|
6 | all other types are replaces by "*". |
---|
7 | |
---|
8 | TODO: This could be much more general, should just take the translation table |
---|
9 | from the command line. |
---|
10 | |
---|
11 | usage: %prog < maf > maf |
---|
12 | """ |
---|
13 | |
---|
14 | from __future__ import division |
---|
15 | |
---|
16 | import psyco_full |
---|
17 | |
---|
18 | import sys |
---|
19 | |
---|
20 | import sys |
---|
21 | from bx.align import maf |
---|
22 | import string |
---|
23 | |
---|
24 | table = string.maketrans( "#=X@", "-***") |
---|
25 | |
---|
26 | def main(): |
---|
27 | |
---|
28 | maf_reader = maf.Reader( sys.stdin ) |
---|
29 | maf_writer = maf.Writer( sys.stdout ) |
---|
30 | |
---|
31 | for m in maf_reader: |
---|
32 | for c in m.components: |
---|
33 | c.text = c.text.translate( table ) |
---|
34 | maf_writer.write( m ) |
---|
35 | |
---|
36 | maf_writer.close() |
---|
37 | |
---|
38 | if __name__ == "__main__": |
---|
39 | main() |
---|