annotate SMART/Java/Python/structure/Mapping.py @ 49:80a080dc3ee8

Deleted selected files
author m-zytnicki
date Fri, 13 Dec 2013 10:37:16 -0500
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 # Copyright INRA-URGI 2009-2010
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 # This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 # abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 # modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 # license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 # "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 # As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 # modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 # with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 # economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 # liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 # In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 # with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 # software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 # that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 # therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 # professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 # encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 # requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 # data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 # same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 # The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 # knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 from SMART.Java.Python.structure.SubMapping import SubMapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 from SMART.Java.Python.structure.Transcript import Transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 from SMART.Java.Python.structure.Interval import Interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 class Mapping(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 """A class that represents a mapping"""
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 def __init__(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 self.targetInterval = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 self.queryInterval = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 self.subMappings = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 self.size = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 self.transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 self.tags = {}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 def copy(self, mapping):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 for subMapping in mapping.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 newSubMapping = SubMapping(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 self.addSubMapping(newSubMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 self.targetInterval = Interval(mapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 self.queryInterval = Interval(mapping.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 self.size = mapping.size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 self.tags = {}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 for tag in mapping.tags:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 self.tags[tag] = mapping[tag]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 self.transcript.copy(mapping.transcript)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 def setTargetInterval(self, interval):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 self.targetInterval = Interval(interval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 if self.queryInterval != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 self.setDirection(self.targetInterval.getDirection() * self.queryInterval.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 def setQueryInterval(self, interval):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 self.queryInterval = Interval(interval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 if self.targetInterval != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 self.setDirection(self.targetInterval.getDirection() * self.queryInterval.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 def getQueryInterval(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 return self.queryInterval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 def addSubMapping(self, subMapping):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 subMappingCopy = SubMapping(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 self.subMappings.append(subMappingCopy)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 if self.targetInterval:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 self.targetInterval.setStart(min(self.targetInterval.getStart(), subMapping.targetInterval.getStart()))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 self.targetInterval.setEnd(max(self.targetInterval.getEnd(), subMapping.targetInterval.getEnd()))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 self.setTargetInterval(subMapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 if self.queryInterval:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 self.queryInterval.setStart(min(self.queryInterval.getStart(), subMapping.queryInterval.getStart()))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 self.queryInterval.setEnd(max(self.queryInterval.getEnd(), subMapping.queryInterval.getEnd()))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 self.setQueryInterval(subMapping.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 if self.getDirection() != 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 subMapping.setDirection(self.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 if self.size == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 self.size = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 if "identity" in subMapping.getTagNames() and "identity" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self.setTagValue("identity", subMapping.getTagValue("identity"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 elif "identity" in subMapping.getTagNames() and subMapping.size != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 self.setTagValue("identity", (self.getTagValue("identity") * self.size + subMapping.getTagValue("identity") * subMapping.size) / (self.size + subMapping.size))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 if subMapping.size != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 self.size += subMapping.size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 if "nbMismatches" in subMapping.getTagNames() and "nbMismatches" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 self.setTagValue("nbMismatches", subMapping.getTagValue("nbMismatches"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 elif "nbMismatches" in subMapping.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 self.setTagValue("nbMismatches", self.getTagValue("nbMismatches") + subMapping.getTagValue("nbMismatches"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 if "nbGaps" in subMapping.getTagNames() and "nbGaps" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 self.setTagValue("nbGaps", subMapping.getTagValue("nbGaps"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 elif "nbGaps" in subMapping.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 self.setTagValue("nbGaps", self.getTagValue("nbGaps") + subMapping.getTagValue("nbGaps"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 def setDirection(self, direction):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 for subMapping in self.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 subMapping.setDirection(direction)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 def getDirection(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 if not self.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 raise Exception("Error! Mapping '%s' has no submapping" % (self))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 return self.subMappings[0].getDirection()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 def setSize(self, size):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 self.size = size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 if "identity" in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 self.setTagValue("nbMismatches", self.size - round(self.size * self.getTagValue("identity") / 100.0))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 def setTagValue(self, name, value):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 self.tags[name] = value
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 self.transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 def getTagValue(self, name):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 return self.tags[name]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 def getTagNames(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 return self.tags.keys()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 def setIdentity(self, identity):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 self.setTagValue("identity", identity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 if self.size != None and "nbMismatches" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 nbMismatches = 0 if self.size == 0 else self.size - round(self.size * self.getTagValue("identity") / 100.0)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 self.setTagValue("nbMismatches", nbMismatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 def setNbOccurrences(self, nbOccurrences):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 self.setTagValue("nbOccurrences", nbOccurrences)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 def setNbMismatches(self, nbMismatches):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 self.setTagValue("nbMismatches", nbMismatches)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 if self.size != None and "identity" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 identity = 100 if self.size == 0 else (self.size - self.getTagValue("nbMismatches")) / float(self.size) * 100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 self.setTagValue("identity", identity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 def setNbGaps(self, nbGaps):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 self.setTagValue("nbGaps", nbGaps)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 def setRank(self, rank):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 self.setTagValue("rank", rank)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 def setEvalue(self, evalue):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 self.setTagValue("evalue", evalue)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 def setOccurrence(self, occurrence):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 self.setTagValue("occurrence", occurrence)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 def setBestRegion(self, bestRegion):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 self.setTagValue("bestRegion", bestRegion)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 def mergeExons(self, distance):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 previousSubMapping = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 subMappings = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 for subMapping in self.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 if previousSubMapping == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 subMappings.append(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 previousSubMapping = subMapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 targetDistance = subMapping.targetInterval.getDistance(previousSubMapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 queryDistance = subMapping.queryInterval.getDistance(previousSubMapping.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 if targetDistance <= distance:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self.setTagValue("nbGaps", self.getTagValue("nbGaps") + queryDistance)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 previousSubMapping.merge(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 subMappings.append(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 previousSubMapping = subMapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 self.subMappings = subMappings
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 def getTranscript(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 Extract a transcript from this mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 @return: a transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 if self.transcript != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 return self.transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 self.transcript = Transcript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 self.transcript.copy(self.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 self.transcript.setDirection(self.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 self.transcript.setName(self.queryInterval.getName())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 self.transcript.removeExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 if len(self.subMappings) > 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 for subMapping in self.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 self.transcript.addExon(subMapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 cpt = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 for exon in self.transcript.exons:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 exon.setDirection(self.transcript.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 exon.setName("%s-exon%d" % (self.transcript.getName(), cpt))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 exon.setChromosome(self.transcript.getChromosome())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 cpt += 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 self.transcript.setDirection(self.getDirection())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 self.transcript.sortExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 for tag in self.tags:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 if "bestRegion" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 self.transcript.setTagValue("bestRegion", "(self)")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 self.transcript.setTagValue(tag, self.getTagValue(tag))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 return self.transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 def getChromosome(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 if not self.subMappings:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 raise Exception("Error! Mapping '%s' has no submapping" % (self))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 return self.subMappings[0].targetInterval.getChromosome()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 def getErrorScore(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 return self.getTagValue("nbGaps") * 3 + self.getTagValue("nbMismatches") + (len(self.subMappings) - 1) * 0.1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 def printGBrowseReference(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 return self.getTranscript().printGBrowseReference()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 def printGBrowseLine(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 return self.getTranscript().printGBrowseLine()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 def printGBrowse(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 return self.getTranscript().printGBrowse()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 def printBed(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 return self.getTranscript().printBed()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 def __str__(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 return "%s ---- %s" % (str(self.getTranscript()), ", ". join([str(submapping) for submapping in self.subMappings]))