Mercurial > repos > bgruening > glimmer_extract
annotate glimmer_glimmer_to_gff.py @ 2:3186204e3146 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 274d1f6804bfd0362fdcd2383bfdb32ca8fd634e"
author | iuc |
---|---|
date | Sun, 20 Mar 2022 10:08:06 +0000 |
parents | 239a68a49505 |
children |
rev | line source |
---|---|
0
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
1 #!/usr/bin/env python |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
2 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
3 """ |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
4 Input: Glimmer3 prediction |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
5 Output: GFF3 file |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
6 Return a GFF3 file with the genes predicted by Glimmer3 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
7 Bjoern Gruening |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
8 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
9 Note: Its not a full-fledged GFF3 file, its a really simple one. |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
10 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
11 """ |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
12 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
13 import re |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
14 import sys |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
15 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
16 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
17 def __main__(): |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
18 input_file = open(sys.argv[1], 'r') |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
19 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
20 print('##gff-version 3\n') |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
21 for line in input_file: |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
22 line = line.strip() |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
23 if line[0] == '>': |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
24 header = line[1:] |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
25 else: |
1
239a68a49505
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
iuc
parents:
0
diff
changeset
|
26 (id, start, end, frame, score) = re.split(r'\s+', line) |
0
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
27 if int(end) > int(start): |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
28 strand = '+' |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
29 else: |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
30 strand = '-' |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
31 (start, end) = (end, start) |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
32 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
33 rest = 'frame=%s;score=%s' % (frame, score) |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
34 print('\t'.join([header, 'glimmer_prediction', 'predicted_gene', start, end, '.', strand, '.', rest])) |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
35 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
36 |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
37 if __name__ == "__main__": |
5631611d5bb8
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
bgruening
parents:
diff
changeset
|
38 __main__() |