annotate GFFtools-GX/helper.py @ 3:ff2c2e6f4ab3

Uploaded version 2.0.0 of gfftools ready to import to local instance
author vipints
date Wed, 11 Jun 2014 16:29:25 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
1 #!/usr/bin/env python
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
2 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
3 Common utility functions
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
4 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
5
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
6 import os
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
7 import re
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
8 import sys
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
9 import gzip
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
10 import bz2
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
11 import numpy
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
12
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
13 def init_gene():
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
14 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
15 Initializing the gene structure
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
16 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
17
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
18 gene_det = [('id', 'f8'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
19 ('anno_id', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
20 ('confgenes_id', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
21 ('name', 'S25'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
22 ('source', 'S25'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
23 ('gene_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
24 ('alias', 'S15'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
25 ('name2', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
26 ('strand', 'S2'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
27 ('score', 'S15'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
28 ('chr', 'S15'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
29 ('chr_num', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
30 ('paralogs', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
31 ('start', 'f8'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
32 ('stop', 'f8'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
33 ('transcripts', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
34 ('transcript_type', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
35 ('transcript_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
36 ('transcript_status', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
37 ('transcript_valid', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
38 ('exons', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
39 ('exons_confirmed', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
40 ('cds_exons', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
41 ('utr5_exons', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
42 ('utr3_exons', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
43 ('tis', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
44 ('tis_conf', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
45 ('tis_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
46 ('cdsStop', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
47 ('cdsStop_conf', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
48 ('cdsStop_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
49 ('tss', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
50 ('tss_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
51 ('tss_conf', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
52 ('cleave', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
53 ('cleave_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
54 ('cleave_conf', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
55 ('polya', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
56 ('polya_info', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
57 ('polya_conf', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
58 ('is_alt', 'f8'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
59 ('is_alt_spliced', 'f8'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
60 ('is_valid', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
61 ('transcript_complete', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
62 ('is_complete', numpy.dtype),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
63 ('is_correctly_gff3_referenced', 'S5'),
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
64 ('splicegraph', numpy.dtype) ]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
65
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
66 return gene_det
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
67
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
68 def open_file(fname):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
69 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
70 Open the file (supports .gz .bz2) and returns the handler
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
71
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
72 @args fname: input file name for reading
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
73 @type fname: str
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
74 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
75
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
76 try:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
77 if os.path.splitext(fname)[1] == ".gz":
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
78 FH = gzip.open(fname, 'rb')
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
79 elif os.path.splitext(fname)[1] == ".bz2":
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
80 FH = bz2.BZ2File(fname, 'rb')
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
81 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
82 FH = open(fname, 'rU')
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
83 except Exception as error:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
84 sys.exit(error)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
85
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
86 return FH
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
87
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
88 def add_CDS_phase(strand, cds):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
89 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
90 Calculate CDS phase and add to the CDS exons
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
91
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
92 @args strand: feature strand information
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
93 @type strand: +/-
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
94 @args cds: coding exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
95 @type cds: numpy array [[int, int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
96 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
97
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
98 cds_region, cds_flag = [], 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
99 if strand == '+':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
100 for cdspos in cds:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
101 if cds_flag == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
102 cdspos = (cdspos[0], cdspos[1], 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
103 diff = (cdspos[1]-(cdspos[0]-1))%3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
104 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
105 xy = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
106 if diff == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
107 cdspos = (cdspos[0], cdspos[1], 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
108 elif diff == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
109 cdspos = (cdspos[0], cdspos[1], 2)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
110 xy = 2
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
111 elif diff == 2:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
112 cdspos = (cdspos[0], cdspos[1], 1)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
113 xy = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
114 diff = ((cdspos[1]-(cdspos[0]-1))-xy)%3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
115 cds_region.append(cdspos)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
116 cds_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
117 elif strand == '-':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
118 cds.reverse()
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
119 for cdspos in cds:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
120 if cds_flag == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
121 cdspos = (cdspos[0], cdspos[1], 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
122 diff = (cdspos[1]-(cdspos[0]-1))%3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
123 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
124 xy = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
125 if diff == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
126 cdspos = (cdspos[0], cdspos[1], 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
127 elif diff == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
128 cdspos = (cdspos[0], cdspos[1], 2)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
129 xy = 2
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
130 elif diff == 2:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
131 cdspos = (cdspos[0], cdspos[1], 1)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
132 xy = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
133 diff = ((cdspos[1]-(cdspos[0]-1))-xy)%3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
134 cds_region.append(cdspos)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
135 cds_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
136 cds_region.reverse()
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
137 return cds_region
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
138
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
139 def buildUTR(cc, ec, strand):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
140 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
141 Build UTR regions from a given set of CDS and exon coordiantes of a gene
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
142
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
143 @args cc: coding exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
144 @type cc: numpy array [[int, int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
145 @args ec: exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
146 @type ec: numpy array [[int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
147 @args strand: feature strand information
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
148 @type strand: +/-
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
149 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
150
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
151 utr5 = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
152 utr3 = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
153 if strand == '+':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
154 cds_s = cc[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
155 for ex in ec:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
156 if ex[0] <= cds_s and cds_s <= ex[1]:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
157 if ex[0] != cds_s:utr5.append((ex[0], cds_s-1))
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
158 break
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
159 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
160 utr5.append(ex)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
161 cds_e = cc[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
162 for i in range(len(ec)):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
163 i += 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
164 if ec[-i][0] <= cds_e and cds_e <= ec[-i][1]:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
165 if ec[-i][1] != cds_e:utr3.append((cds_e +1, ec[-i][1]))
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
166 break
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
167 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
168 utr3.append(ec[-i])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
169 utr3.reverse()
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
170 elif strand == '-':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
171 cds_s = cc[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
172 for i in range(len(ec)):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
173 i += 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
174 if ec[-i][0] <= cds_s and cds_s <= ec[-i][1]:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
175 if ec[-i][1] != cds_s:utr5.append((cds_s+1, ec[-i][1]))
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
176 break
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
177 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
178 utr5.append(ec[-i])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
179 utr5.reverse()
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
180 cds_e = cc[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
181 for ex in ec:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
182 if ex[0] <= cds_e and cds_e <= ex[1]:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
183 if ex[0] != cds_e:utr3.append((ex[0], cds_e-1))
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
184 break
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
185 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
186 utr3.append(ex)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
187 return utr5, utr3
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
188
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
189 def make_Exon_cod(strand_p, five_p_utr, cds_cod, three_p_utr):
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
190 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
191 Create exon cordinates from UTR's and CDS region
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
192
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
193 @args strand_p: feature strand information
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
194 @type strand_p: +/-
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
195 @args five_p_utr: five prime utr exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
196 @type five_p_utr: numpy array [[int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
197 @args cds_cod: coding exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
198 @type cds_cod: numpy array [[int, int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
199 @args three_p_utr: three prime utr exon coordinates
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
200 @type three_p_utr: numpy array [[int, int]]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
201 """
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
202
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
203 exon_pos = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
204 if strand_p == '+':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
205 utr5_start, utr5_end = 0, 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
206 if five_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
207 utr5_start, utr5_end = five_p_utr[-1][0], five_p_utr[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
208 cds_5start, cds_5end = cds_cod[0][0], cds_cod[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
209 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
210 if cds_5start-utr5_end == 0 or cds_5start-utr5_end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
211 jun_exon = [utr5_start, cds_5end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
212 if len(cds_cod) == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
213 five_prime_flag = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
214 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
215 five_p_utr = five_p_utr[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
216 five_prime_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
217 for utr5 in five_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
218 exon_pos.append(utr5)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
219 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
220 utr3_start, utr3_end = 0, 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
221 if three_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
222 utr3_start = three_p_utr[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
223 utr3_end = three_p_utr[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
224 if utr3_start-cds_5end == 0 or utr3_start-cds_5end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
225 jun_exon = [cds_5start, utr3_end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
226 three_prime_flag = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
227 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
228 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
229 three_p_utr = three_p_utr[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
230 three_prime_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
231 if five_prime_flag == 1 and three_prime_flag == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
232 exon_pos.append([utr5_start, utr3_end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
233 if five_prime_flag == 1 and three_prime_flag == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
234 exon_pos.append([utr5_start, cds_5end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
235 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
236 if five_prime_flag == 0 and three_prime_flag == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
237 exon_pos.append([cds_5start, utr3_end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
238 for cds in cds_cod:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
239 exon_pos.append(cds)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
240 for utr3 in three_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
241 exon_pos.append(utr3)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
242 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
243 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
244 five_p_utr = five_p_utr[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
245 cds_cod = cds_cod[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
246 for utr5 in five_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
247 exon_pos.append(utr5)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
248 exon_pos.append(jun_exon) if jun_exon != [] else ''
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
249 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
250 utr3_start, utr3_end = 0, 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
251 if three_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
252 utr3_start = three_p_utr[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
253 utr3_end = three_p_utr[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
254 cds_3start = cds_cod[-1][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
255 cds_3end = cds_cod[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
256 if utr3_start-cds_3end == 0 or utr3_start-cds_3end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
257 jun_exon = [cds_3start, utr3_end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
258 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
259 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
260 three_p_utr = three_p_utr[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
261 for cds in cds_cod:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
262 exon_pos.append(cds)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
263 exon_pos.append(jun_exon) if jun_exon != [] else ''
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
264 for utr3 in three_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
265 exon_pos.append(utr3)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
266 elif strand_p == '-':
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
267 utr3_start, utr3_end = 0, 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
268 if three_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
269 utr3_start = three_p_utr[-1][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
270 utr3_end = three_p_utr[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
271 cds_3start = cds_cod[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
272 cds_3end = cds_cod[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
273 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
274 if cds_3start-utr3_end == 0 or cds_3start-utr3_end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
275 jun_exon = [utr3_start, cds_3end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
276 if len(cds_cod) == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
277 three_prime_flag = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
278 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
279 three_p_utr = three_p_utr[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
280 three_prime_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
281 for utr3 in three_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
282 exon_pos.append(utr3)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
283 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
284 (utr5_start, utr5_end) = (0, 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
285 if five_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
286 utr5_start = five_p_utr[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
287 utr5_end = five_p_utr[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
288 if utr5_start-cds_3end == 0 or utr5_start-cds_3end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
289 jun_exon = [cds_3start, utr5_end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
290 five_prime_flag = 0
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
291 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
292 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
293 five_p_utr = five_p_utr[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
294 five_prime_flag = 1
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
295 if three_prime_flag == 1 and five_prime_flag == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
296 exon_pos.append([utr3_start, utr5_end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
297 if three_prime_flag == 1 and five_prime_flag == 0:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
298 exon_pos.append([utr3_start, cds_3end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
299 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
300 if three_prime_flag == 0 and five_prime_flag == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
301 exon_pos.append([cds_3start, utr5_end])
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
302 for cds in cds_cod:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
303 exon_pos.append(cds)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
304 for utr5 in five_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
305 exon_pos.append(utr5)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
306 else:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
307 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
308 three_p_utr = three_p_utr[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
309 cds_cod = cds_cod[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
310 for utr3 in three_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
311 exon_pos.append(utr3)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
312 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
313 exon_pos.append(jun_exon)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
314 jun_exon = []
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
315 (utr5_start, utr5_end) = (0, 0)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
316 if five_p_utr != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
317 utr5_start = five_p_utr[0][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
318 utr5_end = five_p_utr[0][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
319 cds_5start = cds_cod[-1][0]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
320 cds_5end = cds_cod[-1][1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
321 if utr5_start-cds_5end == 0 or utr5_start-cds_5end == 1:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
322 jun_exon = [cds_5start, utr5_end]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
323 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
324 cds_cod = cds_cod[:-1]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
325 five_p_utr = five_p_utr[1:]
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
326 for cds in cds_cod:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
327 exon_pos.append(cds)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
328 if jun_exon != []:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
329 exon_pos.append(jun_exon)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
330 for utr5 in five_p_utr:
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
331 exon_pos.append(utr5)
ff2c2e6f4ab3 Uploaded version 2.0.0 of gfftools ready to import to local instance
vipints
parents:
diff changeset
332 return exon_pos