Mercurial > repos > fubar > jbrowse2
comparison maf2bed.py @ 61:e7a6f7a7148d draft
planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 6dde5ad41d63730085116ab2c9a9d3e500a760e4-dirty
author | fubar |
---|---|
date | Tue, 26 Mar 2024 00:52:34 +0000 |
parents | |
children | b1260bca5fdc |
comparison
equal
deleted
inserted
replaced
60:81d535970196 | 61:e7a6f7a7148d |
---|---|
1 #!/usr/bin/env python | |
2 # painfully converted from b0rken perl from | |
3 # https://unpkg.com/browse/jbrowse-plugin-mafviewer@1.0.6/dist/ | |
4 # license is Apache2_license.txt included here | |
5 | |
6 import sys | |
7 | |
8 id = 0 | |
9 buffer = '' | |
10 start = 0 | |
11 end = 0 | |
12 score = 0 | |
13 chrom = '' | |
14 | |
15 db = "%s." % sys.argv[1] | |
16 # Read input from stdin | |
17 for line in sys.stdin: | |
18 line = line.strip() | |
19 if not line: | |
20 continue | |
21 | |
22 line = line.split() | |
23 if line[0] == 's' and line[1].startswith(db): | |
24 chrom = line[1] | |
25 chrom = chrom.replace(db, '') | |
26 start = int(line[2]) | |
27 end = int(line[2]) + int(line[3]) | |
28 line = line[1:] | |
29 line = ':'.join(line) | |
30 temp = line | |
31 buffer = temp if buffer == '' else f"{buffer},{temp}" | |
32 elif line[0] == 'a': | |
33 score = int(line[1].split('=')[1]) | |
34 if id > 0: | |
35 sys.stdout.write('\t'.join([chrom, '%d' % start, '%d' % end, f"{sys.argv[1]}_{id}", '%d' % score, buffer])+ '\n') | |
36 id += 1 | |
37 buffer = '' | |
38 elif line[0] == 's': | |
39 line = line[1:] | |
40 line = ':'.join(line) | |
41 temp = line | |
42 buffer = temp if buffer == '' else f"{buffer},{temp}" | |
43 | |
44 sys.stdout.write('\t'.join([chrom, '%d' % start, '%d' % end, f"{sys.argv[1]}_{id}", '%d' % score, buffer]) + '\n') |