annotate helper.py @ 11:5c6f33e20fcc default tip

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