Mercurial > repos > bgruening > jbrowse2
comparison maf2bed.py @ 0:53c2be00bb6f draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 0a86c88a95b0d1cc49d84544136de6556b95320f
author | bgruening |
---|---|
date | Wed, 05 Jun 2024 08:15:49 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:53c2be00bb6f |
---|---|
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') |