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