annotate SMART/Java/Python/structure/Interval.py @ 36:44d5973c188c

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 15:02:29 -0400
parents
children 169d364ddd91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
1 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
2 # Copyright INRA-URGI 2009-2010
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
3 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
4 # This software is governed by the CeCILL license under French law and
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
5 # abiding by the rules of distribution of free software. You can use,
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
6 # modify and/ or redistribute the software under the terms of the CeCILL
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
7 # license as circulated by CEA, CNRS and INRIA at the following URL
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
8 # "http://www.cecill.info".
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
9 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
10 # As a counterpart to the access to the source code and rights to copy,
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
11 # modify and redistribute granted by the license, users are provided only
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
12 # with a limited warranty and the software's author, the holder of the
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
13 # economic rights, and the successive licensors have only limited
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
14 # liability.
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
15 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
16 # In this respect, the user's attention is drawn to the risks associated
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
17 # with loading, using, modifying and/or developing or reproducing the
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
18 # software by the user in light of its specific status of free software,
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
19 # that may mean that it is complicated to manipulate, and that also
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
20 # therefore means that it is reserved for developers and experienced
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
21 # professionals having in-depth computer knowledge. Users are therefore
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
22 # encouraged to load and test the software's suitability as regards their
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
23 # requirements in conditions enabling the security of their systems and/or
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
24 # data to be ensured and, more generally, to use and operate it in the
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
25 # same conditions as regards security.
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
26 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
27 # The fact that you are presently reading this means that you have had
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
28 # knowledge of the CeCILL license and that you accept its terms.
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
29 #
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
30
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
31 from SMART.Java.Python.structure.Bins import *
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
32 from commons.core.coord.Range import Range
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
33
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
34 class Interval(Range):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
35 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
36 Store a genomic interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
37 @ivar name: name of the interval [optional]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
38 @type name: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
39 @ivar id: id of the interval [optional]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
40 @type id: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
41 @ivar bin: bin in which the interval should be if stored in a database [computed]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
42 @type bin: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
43 @ival tags: information about the transcript [optional]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
44 @type tags: dict
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
45 @ivar verbosity: verbosity
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
46 @type verbosity: int [default: 0]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
47 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
48
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
49 def __init__(self, interval = None, verbosity = 0):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
50 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
51 Constructor
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
52 @param interval: interval to be copied
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
53 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
54 @param verbosity: verbosity
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
55 @type verbosity: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
56 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
57 Range.__init__(self)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
58 self.name = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
59 self.id = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
60 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
61 self.verbosity = verbosity
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
62 self.tags = {}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
63 if interval != None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
64 self.copy(interval)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
65
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
66 #!!!! Warning: two methods getStart() and getEnd() give the information maximum and minimum in interval.!!!!#
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
67 #In case strand = "+", start < end; strand = "-", start > end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
68 def getStart(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
69 if self.start == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
70 return -1
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
71 if self.end == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
72 return self.start
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
73 return self.getMin()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
74
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
75
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
76 def getEnd(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
77 if self.end == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
78 return -1
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
79 if self.start == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
80 return self.end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
81 return self.getMax()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
82
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
83
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
84 def getChromosome(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
85 return self.getSeqname()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
86
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
87
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
88 def getDirection(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
89 return 1 if self.getStrand() == "+" else -1
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
90
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
91
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
92 def getName(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
93 return self.name
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
94
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
95
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
96 def isSet(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
97 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
98 Check if the interval is set
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
99 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
100 return self.getStart() == None and self.getEnd() == None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
101
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
102
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
103 def copy(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
104 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
105 Copy method
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
106 @param interval: interval to be copied
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
107 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
108 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
109 self.setStart(interval.getStart())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
110 self.setEnd(interval.getEnd())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
111 self.setChromosome(interval.getChromosome())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
112 self.setDirection(interval.getDirection())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
113 self.name = interval.name
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
114 self.id = interval.id
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
115 self.bin = interval.bin
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
116 self.tags = {}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
117 for tag in interval.tags:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
118 self.tags[tag] = interval.tags[tag]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
119 self.verbosity = interval.verbosity
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
120
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
121
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
122 def setName(self, name):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
123 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
124 Set the name
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
125 @param name: name of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
126 @type name: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
127 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
128 if len(name) > 100:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
129 name = name[:100]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
130 self.name = name
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
131
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
132
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
133 def setChromosome(self, chromosome=""):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
134 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
135 Set the chromosome
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
136 @param chromosome: chromosome on which the interval is
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
137 @type chromosome: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
138 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
139 if not chromosome:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
140 self.seqname = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
141 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
142 self.seqname = chromosome.replace(".", "_").replace("|", "_")
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
143
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
144
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
145 def setStart(self, start):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
146 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
147 Set the start point
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
148 Possibly reset bin
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
149 @param start: start point of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
150 @type start: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
151 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
152 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
153 direction = self.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
154 if self.start == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
155 self.start = start
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
156 elif self.end == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
157 self.end = start
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
158 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
159 if direction == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
160 self.start = start
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
161 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
162 self.end = start
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
163 if direction == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
164 self.start, self.end = min(self.start, self.end), max(self.start, self.end)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
165 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
166 self.start, self.end = max(self.start, self.end), min(self.start, self.end)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
167
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
168
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
169 def setEnd(self, end):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
170 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
171 Set the end point
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
172 Possibly reset bin
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
173 @param end: end point of the interval of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
174 @type end: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
175 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
176 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
177 direction = self.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
178 if self.end == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
179 self.end = end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
180 elif self.start == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
181 self.start = end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
182 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
183 if direction == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
184 self.end = end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
185 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
186 self.start = end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
187 if direction == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
188 self.start, self.end = min(self.start, self.end), max(self.start, self.end)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
189 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
190 self.start, self.end = max(self.start, self.end), min(self.start, self.end)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
191
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
192
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
193 def setSize(self, size):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
194 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
195 Possibly modify the end point
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
196 @param size: size of the transcript
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
197 @type size: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
198 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
199 if self.end == None and self.start != None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
200 self.setEnd(self.start + self.getSize() - 1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
201 elif self.start == None and self.end != None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
202 self.setStart(self.end - self.getSize() + 1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
203
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
204
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
205 def getSize(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
206 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
207 Get the size
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
208 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
209 return self.getEnd() - self.getStart() + 1
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
210
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
211
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
212 def _setDirection(self, direction):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
213 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
214 Set the direction of the interval (connection to Range)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
215 @param direction: direction of the transcript (+ / -)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
216 @type direction: int (1 or -1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
217 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
218 if direction * self.getDirection() < 0:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
219 self.reverse()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
220
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
221
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
222 def setDirection(self, direction):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
223 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
224 Set the direction of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
225 Possibly parse different formats
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
226 @param direction: direction of the transcript (+ / -)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
227 @type direction: int or string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
228 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
229 if type(direction).__name__ == 'int':
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
230 self._setDirection(direction / abs(direction))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
231 elif type(direction).__name__ == 'str':
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
232 if direction == "+":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
233 self._setDirection(1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
234 elif direction == "-":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
235 self._setDirection(-1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
236 elif direction == "1" or direction == "-1":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
237 self._setDirection(int(direction))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
238 elif direction.lower() == "plus":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
239 self._setDirection(1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
240 elif direction.lower() == "minus":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
241 self._setDirection(-1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
242 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
243 raise Exception("Cannot understand direction %s" % (direction))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
244 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
245 raise Exception("Cannot understand direction %s" % (direction))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
246
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
247
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
248 def extendStart(self, size):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
249 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
250 Extend the interval by the 5' end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
251 @param size: the size to be exended
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
252 @type size: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
253 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
254 if self.getDirection() == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
255 self.setStart(max(0, self.getStart() - size))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
256 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
257 self.setEnd(self.getEnd() + size)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
258 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
259
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
260
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
261 def extendEnd(self, size):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
262 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
263 Extend the interval by the 3' end
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
264 @param size: the size to be exended
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
265 @type size: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
266 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
267 if self.getDirection() == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
268 self.setEnd(self.getEnd() + size)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
269 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
270 self.setStart(max(0, self.getStart() - size))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
271 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
272
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
273
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
274 def restrictStart(self, size = 1):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
275 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
276 Restrict the interval by some nucleotides, start from its start position
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
277 Remove the exons
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
278 @param size: the size to be restricted to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
279 @type size: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
280 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
281 if self.getDirection() == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
282 self.setEnd(min(self.getEnd(), self.getStart() + size - 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
283 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
284 self.setStart(max(self.getStart(), self.getEnd() - size + 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
285 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
286
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
287
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
288 def restrictEnd(self, size = 1):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
289 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
290 Restrict the interval by some nucleotides, end from its end position
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
291 Remove the exons
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
292 @param size: the size to be restricted to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
293 @type size: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
294 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
295 if self.getDirection() == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
296 self.setStart(max(self.getStart(), self.getEnd() - size + 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
297 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
298 self.setEnd(min(self.getEnd(), self.getStart() + size - 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
299 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
300
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
301
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
302
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
303 def setTagValue(self, name, value):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
304 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
305 Set a tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
306 @param name: name of the tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
307 @type name: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
308 @param value: value of the tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
309 @type value: int or string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
310 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
311 self.tags[name] = value
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
312
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
313
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
314 def getTagNames(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
315 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
316 Get all the names of the tags
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
317 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
318 return self.tags.keys()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
319
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
320
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
321 def getTagValue(self, tag):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
322 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
323 Get the value of a tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
324 @param tag: name of a tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
325 @type tag: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
326 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
327 if tag not in self.tags:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
328 return None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
329 return self.tags[tag]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
330
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
331
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
332 def getTagValues(self, tagSep = "; ", fieldSep = " ", surrounder = ""):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
333 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
334 Get the formatted tag values
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
335 @param tagSep: separator between tags
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
336 @type tagSep: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
337 @param fieldSep: separator between tag name and tag value
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
338 @type fieldSep: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
339 @param surrounder: string which optionally surround values
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
340 @type surrounder: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
341 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
342 tags = []
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
343 for name, value in self.tags.iteritems():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
344 if value == None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
345 continue
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
346 if isinstance(value, basestring):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
347 tags.append("%s%s%s%s%s" % (name, fieldSep, surrounder, value.replace("'", "\\'"), surrounder))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
348 elif type(value) is int:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
349 tags.append("%s%s%s%i%s" % (name, fieldSep, surrounder, value, surrounder))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
350 elif type(value) is float:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
351 tags.append("%s%s%s%f%s" % (name, fieldSep, surrounder, value, surrounder))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
352 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
353 raise Exception("Do not know how to print '" + value + "'.")
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
354 if self.getName() != None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
355 tags.append("%s%s%s%s%s" % ("Name", fieldSep, surrounder, self.getName(), surrounder))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
356 return tagSep.join(tags)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
357
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
358
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
359 def setTagValues(self, tags, tagSep = "; ", fieldSep = " "):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
360 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
361 Set the tag values using given string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
362 @param tags: the tags, concatenated
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
363 @type tags: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
364 @param tagSep: separator between tags
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
365 @type tagSep: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
366 @param fieldSep: separator between tag name and tag value
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
367 @type fieldSep: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
368 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
369 if tags == "":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
370 self.tags = {}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
371 return
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
372 for splittedTag in tags.split(tagSep):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
373 if fieldSep not in splittedTag:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
374 raise Exception("Weird field '%s' in tags '%s'" % (splittedTag, tags))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
375 tag, value = splittedTag.split(fieldSep, 1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
376 if tag == "Name":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
377 self.setName(value)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
378 continue
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
379 try:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
380 intValue = int(value)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
381 self.tags[tag] = intValue
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
382 except ValueError:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
383 try:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
384 floatValue = float(value)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
385 self.tags[tag] = floatValue
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
386 except ValueError:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
387 self.tags[tag] = value
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
388
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
389
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
390 def deleteTag(self, tag):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
391 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
392 Remove a tag
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
393 @param tag: the tag to be removed
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
394 @type tag: string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
395 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
396 if tag in self.tags:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
397 del self.tags[tag]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
398
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
399
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
400 def setNbOccurrences(self, nbOccurrences):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
401 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
402 Set the number of occurrences of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
403 @param nbOccurrences: number of occurrences of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
404 @type nbOccurrences: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
405 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
406 self.setTagValue("nbOccurrences", nbOccurrences)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
407
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
408
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
409 def setOccurrence(self, occurrence):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
410 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
411 Set the occurrence of this interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
412 @param occurrence: an occurrence for this transcript
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
413 @type occurrence: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
414 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
415 self.setTagValue("occurrence", occurrence)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
416
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
417 def __eq__(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
418 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
419 Whether two intervals are equal (start and end at same position)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
420 @param interval: object to be compared to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
421 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
422 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
423 if not interval:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
424 return False
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
425 return self.getChromosome() == interval.getChromosome() and self.getStart() == interval.getStart() and self.getEnd() == interval.getEnd() and self.getDirection() == interval.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
426
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
427
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
428 def overlapWith(self, interval, nbNucleotides = 1):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
429 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
430 Whether two intervals overlap
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
431 @param interval: object to be compared to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
432 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
433 @param nbNucleotides: minimum number of nucleotides to declare and overlap
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
434 @type nbNucleotides: int
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
435 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
436 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
437 return False
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
438 return (min(self.getEnd(), interval.getEnd()) - max(self.getStart(), interval.getStart()) + 1 >= nbNucleotides)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
439
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
440 def isIncludeIn(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
441 return interval.include(self)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
442
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
443
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
444 def include(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
445 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
446 Whether this interval includes the other one
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
447 @param interval: object to be compared to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
448 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
449 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
450 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
451 return False
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
452 return ((self.getStart() <= interval.getStart()) and (self.getEnd() >= interval.getEnd()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
453
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
454
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
455 def getDifference(self, interval, sameStrand = False):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
456 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
457 Get the difference between this cluster and another one
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
458 @param interval: object to be compared to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
459 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
460 @param sameStrand: do the comparison iff the intervals are on the same strand
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
461 @type sameStrand: boolean
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
462 @return: a (possibly empty) list of intervals
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
463 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
464 newInterval = Interval()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
465 newInterval.copy(self)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
466 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
467 return [newInterval]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
468 if not self.overlapWith(interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
469 return [newInterval]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
470 if sameStrand and self.getDirection() != interval.getDirection():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
471 return [newInterval]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
472 intervals = []
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
473 if self.getStart() < interval.getStart():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
474 newInterval = Interval()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
475 newInterval.copy(self)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
476 newInterval.setEnd(min(self.getEnd(), interval.getStart() - 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
477 intervals.append(newInterval)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
478 if self.getEnd() > interval.getEnd():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
479 newInterval = Interval()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
480 newInterval.copy(self)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
481 newInterval.setStart(max(self.getStart(), interval.getEnd() + 1))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
482 intervals.append(newInterval)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
483 return intervals
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
484
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
485
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
486 def getIntersection(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
487 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
488 Get the intersection between this interval and another one
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
489 @param interval: object to be compared to
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
490 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
491 @return: an other interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
492 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
493 if not self.overlapWith(interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
494 return None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
495 newInterval = Interval()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
496 newInterval.setChromosome(self.getChromosome())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
497 newInterval.setDirection(self.getDirection())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
498 newInterval.setName("%s_intersect_%s" % (self.getName(), interval.getName()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
499 newInterval.setStart(max(self.getStart(), interval.getStart()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
500 newInterval.setEnd(min(self.getEnd(), interval.getEnd()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
501 return newInterval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
502
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
503
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
504 def getDistance(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
505 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
506 Get the distance between two intervals (a non-negative value)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
507 @param interval: another interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
508 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
509 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
510 if self.overlapWith(interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
511 return 0
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
512 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
513 raise Exception("Cannot get the distance between %s and %s" % (str(self), str(interval)))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
514 return min(abs(self.getStart() - interval.getEnd()), abs(self.getEnd() - interval.getStart()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
515
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
516
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
517 def getRelativeDistance(self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
518 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
519 Get the distance between two intervals (negative if first interval is before)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
520 @param interval: another interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
521 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
522 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
523 if self.overlapWith(interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
524 return 0
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
525 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
526 raise Exception("Cannot get the distance between %s and %s" % (str(self), str(interval)))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
527 if self.getEnd() < interval.getStart():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
528 distance = interval.getStart() - self.getEnd()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
529 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
530 distance = interval.getEnd() - self.getStart()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
531 distance *= self.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
532 return distance
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
533
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
534
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
535 def merge(self, interval, normalization = False):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
536 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
537 Merge two intervals
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
538 @param interval: another interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
539 @type interval: class L{Interval<Interval>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
540 @param normalization: whether the sum of the merge should be normalized wrt the number of mappings of each elements
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
541 @type normalization: boolean
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
542 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
543 if self.getChromosome() != interval.getChromosome():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
544 raise Exception("Cannot merge '%s' and '%s' for they are on different chromosomes." % (str(self), str(interval)))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
545 direction = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
546 if self.getStart() == self.getEnd():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
547 direction = interval.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
548 elif interval.getStart() == interval.getEnd():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
549 direction = self.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
550 elif self.getDirection() != interval.getDirection():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
551 raise Exception("Cannot merge '%s' and '%s' for they are on different strands." % (str(self), str(interval)))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
552 self.setStart(min(self.getStart(), interval.getStart()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
553 self.setEnd(max(self.getEnd(), interval.getEnd()))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
554 if direction != None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
555 self.setDirection(direction)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
556 nbElements = 0.0
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
557 for element in (self, interval):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
558 for tagName in ("nbElements", "nbOccurrences"):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
559 if tagName not in element.getTagNames():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
560 element.setTagValue(tagName, 1)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
561 nbElements += float(element.getTagValue("nbElements")) / float(element.getTagValue("nbOccurrences")) if normalization else float(element.getTagValue("nbElements"))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
562 self.setTagValue("nbElements", nbElements)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
563 self.bin = None
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
564 for tagName in ("identity", "nbOccurrences", "occurrence", "nbMismatches", "nbGaps", "rank", "evalue", "bestRegion"):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
565 if tagName in self.getTagNames():
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
566 del self.tags[tagName]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
567
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
568
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
569 def getBin(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
570 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
571 Get the bin of the interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
572 Computed on the fly
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
573 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
574 if self.bin == None:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
575 self.bin = getBin(self.getStart(), self.getEnd())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
576 return self.bin
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
577
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
578
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
579 def getBins(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
580 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
581 Get all the bin this interval could fall into
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
582 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
583 return getOverlappingBins(self.getStart(), self.getEnd())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
584
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
585
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
586 def getSqlVariables(cls):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
587 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
588 Get the properties of the object that should be saved in a database
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
589 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
590 variables = ["name", "chromosome", "start", "end", "direction", "tags", "bin"]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
591 return variables
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
592 getSqlVariables = classmethod(getSqlVariables)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
593
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
594
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
595 def setSqlValues(self, array):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
596 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
597 Set the values of the properties of this object as given by a results line of a SQL query
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
598 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
599 self.id = array[0]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
600 self.name = array[1].strip("'")
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
601 self.setChromosome(array[2].strip("'"))
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
602 self.setStart(array[3])
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
603 self.setEnd(array[4])
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
604 self.setDirection(array[5])
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
605 self.setTagValues(array[6].strip("'"), ";", "=")
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
606 self.bin = array[7]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
607
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
608
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
609 def getSqlValues(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
610 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
611 Get the values of the properties that should be saved in a database
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
612 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
613 values = dict()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
614 values["name"] = self.name
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
615 values["chromosome"] = self.getChromosome()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
616 values["start"] = self.getStart()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
617 values["end"] = self.getEnd()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
618 values["direction"] = self.getDirection()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
619 values["tags"] = self.getTagValues(";", "=")
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
620 values["bin"] = self.getBin()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
621 return values
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
622
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
623
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
624 def getSqlTypes(cls):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
625 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
626 Get the values of the properties that should be saved in a database
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
627 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
628 types = dict()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
629 types["name"] = "varchar"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
630 types["chromosome"] = "varchar"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
631 types["start"] = "int"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
632 types["end"] = "int"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
633 types["direction"] = "tinyint"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
634 types["tags"] = "varchar"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
635 types["bin"] = "int"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
636 return types
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
637 getSqlTypes = classmethod(getSqlTypes)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
638
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
639
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
640 def getSqlSizes(cls):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
641 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
642 Get the sizes of the properties that should be saved in a database
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
643 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
644 sizes = dict()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
645 sizes["name"] = 255
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
646 sizes["chromosome"] = 255
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
647 sizes["start"] = 11
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
648 sizes["end"] = 11
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
649 sizes["direction"] = 4
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
650 sizes["tags"] = 1023
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
651 sizes["bin"] = 11
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
652 return sizes
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
653 getSqlSizes = classmethod(getSqlSizes)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
654
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
655
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
656 def printCoordinates(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
657 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
658 Print start and end positions (depending on the direction of the interval)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
659 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
660 if self.getDirection() == 1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
661 return "%d-%d" % (self.getStart(), self.getEnd())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
662 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
663 return "%d-%d" % (self.getEnd(), self.getStart())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
664
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
665
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
666 def extractSequence(self, parser):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
667 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
668 Get the sequence corresponding to this interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
669 @param parser: a parser to a FASTA file
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
670 @type parser: class L{SequenceListParser<SequenceListParser>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
671 @return : a instance of L{Sequence<Sequence>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
672 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
673 return parser.getSubSequence(self.getChromosome(), self.getStart(), self.getEnd(), self.getDirection(), self.name)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
674
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
675
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
676 def extractWigData(self, parser):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
677 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
678 Get the data retrieved from a wig file
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
679 @param parser: a parser class to a WIG file
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
680 @type parser: class L{WigParser<WigParser>}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
681 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
682 data = parser.getRange(self.getChromosome(), self.getStart(), self.getEnd())
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
683 if self.getDirection() == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
684 if parser.strands:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
685 newData = {}
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
686 for strand in data:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
687 data[strand].reverse()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
688 newData[-strand] = data[strand]
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
689 data = newData
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
690 else:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
691 data.reverse()
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
692 return data
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
693
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
694
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
695 def __str__(self):
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
696 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
697 Output a simple representation of this interval
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
698 """
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
699 direction = "+"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
700 if self.getDirection() == -1:
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
701 direction = "-"
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
702 string = "%s:%d-%d (%s)" % (self.getChromosome(), self.getStart(), self.getEnd(), direction)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
703 if self.name != "":
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
704 string = "(%s) %s" % (self.name, string)
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
705 return string
44d5973c188c Uploaded
m-zytnicki
parents:
diff changeset
706