annotate aragorn_out_to_gff3.py @ 2:358f58401cd6 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
author bgruening
date Wed, 26 Jul 2017 10:14:05 -0400
parents d788d1abe238
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
1 #!/usr/bin/env python
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
2 import sys
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
3
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
4 full_gene_model = False
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
5 if '--full' in sys.argv:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
6 full_gene_model = True
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
7
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
8 genome_id = None
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
9 stdin_data = []
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
10 KEY_ORDER = ('parent', 'source', 'type', 'start', 'end', 'score', 'strand',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
11 '8', 'quals')
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
12
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
13 # Table of amino acids
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
14 aa_table = {
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
15 'Ala' : 'A',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
16 'Arg' : 'R',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
17 'Asn' : 'N',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
18 'Asp' : 'D',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
19 'Cys' : 'C',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
20 'Gln' : 'Q',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
21 'Glu' : 'E',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
22 'Gly' : 'G',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
23 'His' : 'H',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
24 'Ile' : 'I',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
25 'Leu' : 'L',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
26 'Lys' : 'K',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
27 'Met' : 'M',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
28 'Phe' : 'F',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
29 'Pro' : 'P',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
30 'Ser' : 'S',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
31 'Thr' : 'T',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
32 'Trp' : 'W',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
33 'Tyr' : 'Y',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
34 'Val' : 'V',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
35 'Pyl' : 'O',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
36 'seC' : 'U',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
37 '???' : 'X' }
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
38
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
39 def output_line(gff3):
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
40 print '\t'.join(str(gff3[x]) for x in KEY_ORDER)
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
41
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
42 print '##gff-version 3'
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
43 for line in sys.stdin:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
44 if line.startswith('>'):
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
45 genome_id = line[1:].strip()
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
46 if ' ' in genome_id:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
47 genome_id = genome_id[0:genome_id.index(' ')]
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
48 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
49 data = line.split()
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
50 if len(data) == 5:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
51 # Parse data
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
52 strand = '-' if data[2].startswith('c') else '+'
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
53 start, end = data[2][data[2].index('[') + 1:-1].split(',')
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
54
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
55 gff3 = {
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
56 'parent': genome_id,
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
57 'source': 'aragorn',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
58 'start': int(start),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
59 'end': int(end),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
60 'strand': strand,
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
61 'score': '.',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
62 '8': '.',
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
63 }
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
64
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
65 aa_long = data[1][5:]
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
66 aa_short = aa_table[aa_long]
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
67 anticodon = data[4][1:data[4].index(")")].upper().replace("T", "U")
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
68 name = 'trn{}-{}'.format(aa_short, anticodon)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
69
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
70 if not full_gene_model:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
71 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
72 'type': 'tRNA',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
73 'quals': 'ID=tRNA{0}.{1};Name={name};product={2}'.format(genome_id, *data, name = name),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
74 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
75 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
76 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
77 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
78 'type': 'gene',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
79 'quals': 'ID=gene{0}.{1};Name={name};product={2}'.format(genome_id, *data, name = name),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
80 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
81 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
82 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
83 'type': 'tRNA',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
84 'quals': 'ID=tRNA{0}.{1};Parent=gene{0}.{1};Name={name};product={2}'.format(genome_id, *data, name = name),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
85 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
86 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
87
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
88 # If no introns
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
89 if ')i(' not in data[4]:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
90 gff3['type'] = 'exon'
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
91 gff3['quals'] = 'Parent=tRNA{0}.{1}'.format(genome_id, *data)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
92 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
93 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
94 intron_location = data[4][data[4].rindex('(') + 1:-1].split(',')
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
95 intron_start, intron_length = map(int, intron_location)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
96 if strand == '+':
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
97 original_end = gff3['end']
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
98 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
99 original_end = gff3['start']
1
d788d1abe238 Uploaded
bgruening
parents:
diff changeset
100
2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
101 # EXON
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
102 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
103 'type': 'exon',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
104 'quals': 'Parent=tRNA{0}.{1}'.format(genome_id, *data),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
105 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
106 if strand == '+':
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
107 gff3['end'] = gff3['start'] + intron_start - 2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
108 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
109 gff3['start'] = gff3['end'] - intron_start + 2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
110
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
111 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
112
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
113 # INTRON
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
114 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
115 'type': 'intron',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
116 'quals': 'Parent=tRNA{0}.{1}'.format(genome_id, *data),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
117 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
118 if strand == '+':
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
119 gff3['start'] = gff3['end'] + 1
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
120 gff3['end'] = gff3['start'] + intron_length + 2
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
121 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
122 gff3['end'] = gff3['start'] - 1
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
123 gff3['start'] = gff3['end'] - intron_length + 1
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
124
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
125 output_line(gff3)
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
126
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
127 # EXON
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
128 gff3.update({
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
129 'type': 'exon',
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
130 'quals': 'Parent=tRNA{0}.{1}'.format(genome_id, *data),
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
131 })
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
132 if strand == '+':
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
133 gff3['start'] = gff3['end'] + 1
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
134 gff3['end'] = original_end
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
135 else:
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
136 gff3['end'] = gff3['start'] - 1
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
137 gff3['start'] = original_end
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
138
358f58401cd6 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/rna_tools/trna_prediction commit cfb19d75629f02e0dea4475c16c016ed5510eb44
bgruening
parents: 1
diff changeset
139 output_line(gff3)