Mercurial > repos > bjoern-gruening > glimmer3
comparison glimmer3/glimmer2gff.py @ 0:e11e303c39a4 default tip
Uploaded
author | bjoern-gruening |
---|---|
date | Wed, 11 Jan 2012 09:34:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e11e303c39a4 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 Input: Glimmer3 prediction | |
5 Output: GFF3 file | |
6 Return a GFF3 file with the genes predicted by Glimmer3 | |
7 Bjoern Gruening | |
8 | |
9 Note: Its not a full-fledged GFF3 file, its a really simple one. | |
10 | |
11 """ | |
12 | |
13 import sys, re | |
14 | |
15 def __main__(): | |
16 input_file = open(sys.argv[1], 'r') | |
17 | |
18 print '##gff-version 3\n' | |
19 for line in input_file: | |
20 line = line.strip() | |
21 if line[0] == '>': | |
22 header = line[1:] | |
23 else: | |
24 (id, start, end, frame, score) = re.split('\s+', line) | |
25 if int(end) > int(start): | |
26 strand = '+' | |
27 else: | |
28 strand = '-' | |
29 (start, end) = (end, start) | |
30 | |
31 rest = 'frame=%s;score=%s' % (frame, score) | |
32 print '\t'.join([header, 'glimmer_prediction', 'predicted_gene', start, end, '.', strand, '.', rest]) | |
33 | |
34 | |
35 if __name__ == "__main__" : | |
36 __main__() |