annotate SMART/Java/Python/structure/SubMapping.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
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.Interval import Interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 from commons.core.coord.Align import Align
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 class SubMapping(Align):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 A class that represents a part of a mapping, more precisely, a pair (target interval, query interval) that match together
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 @ivar targetInterval: the target interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 @type targetInterval: class L{Interval<Interval>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 @ivar queryInterval: the query interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 @type queryInterval: class L{Interval<Interval>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 @ivar size: size of this sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 @type size: int
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 @ivar tags: various information
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 @type tags: dict
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 __init__(self, subMapping = None):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 Constructor
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 @param subMapping: a sub-mapping to be copied
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 @type subMapping: class L{SubMapping<SubMapping>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 self.targetInterval = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 self.queryInterval = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 Align.__init__(self, self.queryInterval, self.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 self.size = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 self.tags = {}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 if subMapping != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 self.copy(subMapping)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 def __eq__(self, o):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 if o == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 areAlignAttributesEquals = Align.__eq__(self, o)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 return areAlignAttributesEquals and (self.targetInterval == o.targetInterval) and (self.queryInterval == o.queryInterval) and self.size == o.getSize() and self.tags == o.getTags()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 def getSuperAdress(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 return hex(id(super(Align, self)))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 # def setRangesAlignToRangesInterval(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 # self.range_query = super(Range, self.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 # self.range_subject = super(Range, self.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 def copy(self, subMapping):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 Copy method
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 @param subMapping: a sub-mapping to be copied
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 @type subMapping: class L{SubMapping<SubMapping>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 self.setQueryName(subMapping.getQueryName())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 self.setQueryStart(subMapping.getQueryStart())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 self.setQueryEnd(subMapping.getQueryEnd())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 self.setSubjectName(subMapping.getSubjectName())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 self.setSubjectStart(subMapping.getSubjectStart())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 self.setSubjectEnd(subMapping.getSubjectEnd())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 self.e_value = subMapping.getEvalue()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 self.score = subMapping.getScore()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 self.identity = subMapping.getIdentity()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 self.targetInterval.copy(subMapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 self.queryInterval.copy(subMapping.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 self.size = subMapping.size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 for tag in subMapping.tags:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 self.tags[tag] = subMapping.tags[tag]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 def setTargetInterval(self, interval):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 Set target interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 @param targetInterval: the target interval of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 @type targetInterval: class L{Interval<Interval>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 self.targetInterval.copy(interval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 def setQueryInterval(self, interval):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 Set query interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 @param queryInterval: the query interval of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 @type queryInterval: class L{Interval<Interval>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 self.queryInterval.copy(interval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 def setSize(self, size):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 Set the size of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 Possibly also target and query interval sizes, as well as number of mismatches
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 @param size: the size of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 @type size: int
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 self.size = size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 if "identity" in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 self.setTagValue("nbMismatches", self.size - round(self.size * self.getTagValue("identity") / 100.0))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 def getDirection(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 Get the direction of the alignment
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 return self.targetInterval.getDirection()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 def setDirection(self, direction):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 Set the direction of the alignment
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 @param direction: the directio of the alignment
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 type direction: int or string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 return self.targetInterval.setDirection(direction)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 def setTagValue(self, name, value):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 Set the value of a tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 @param name: name of the tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 @type name: string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 @param value: value of the tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 @type value: string or int
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 self.tags[name] = value
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 def getTagValue(self, name):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 Get the value of a tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 @param name: name of the tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 @type name: string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 @return: value of the tag
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 return self.tags[name]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 def getTagNames(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 Get all the names of the tags
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 @return: the names of the tags
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 return self.tags.keys()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 def getTargetInterval(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 return self.targetInterval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 def getQueryInterval(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 return self.queryInterval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 def getSize(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 return self.size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 def getTags(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 return self.tags
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 def setIdentity(self, identity):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 Set the percentage of identity of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 Possibly also set number of mismatches
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 @param identity: the percentage of identity of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 @type identity: float
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self.identity = identity
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 self.setTagValue("identity", identity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 if self.size != None and "nbMismatches" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 self.setTagValue("nbMismatches", self.size - round(self.size * self.getTagValue("identity") / 100.0))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 def setNbMismatches(self, nbMismatches):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 Set the number of mismatches of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 Possibly also set percentage of identity
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 @param nbMismatches: the number of mismatches of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 @type nbMismatches: int
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 self.nbMismatches = nbMismatches
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 if self.size != None and "identity" not in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 self.setTagValue("identity", (self.size - self.getTagValue("nbMismatches")) / float(self.size) * 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 def setNbGaps(self, nbGaps):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 Set the number of gaps of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 @param nbGaps: the number of gaps of the sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 @type nbGaps: int
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 self.setTagValue("nbGaps", nbGaps)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 def merge(self, subMapping):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 Merge two subMappings
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 @param subMapping: another sub-mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 @type subMapping: class L{SubMapping<SubMapping>}
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 self.targetInterval.merge(subMapping.targetInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 self.queryInterval.merge(subMapping.queryInterval)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 def printCoordinates(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 Print the coordinates of the sub-mapping (considering the direction)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 @return: a string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 if self.getDirection() == 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 return "%d-%d" % (self.targetInterval.getStart(), self.targetInterval.getEnd())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 return "%d-%d" % (self.targetInterval.getEnd(), self.targetInterval.getStart())
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 def __str__(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 Return a representation of this object
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 @return: a string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 if "match" in self.getTagNames() and not self.getTagValue("match"):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 return "%s ---" % self.queryName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 direction = "+"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 if self.getDirection() == -1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 direction = "-"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 string = "%s:%d-%d -- %s:%d-%d (%s)" % (self.targetInterval.getChromosome(), self.targetInterval.getStart(), self.targetInterval.getEnd(), self.queryInterval.name, self.queryInterval.getStart(), self.queryInterval.getEnd(), direction)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 if "nbMismatches" in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 string += "(%i mm)" % (self.getTagValue("nbMismatches"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 if "identity" in self.getTagNames():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 string += "(id: %i%%)" % (self.getTagValue("identity"))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 if self.targetInterval.getSize() != None and self.queryInterval.getSize() != None and self.size != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 string += "(sizes: %d, %d -> %d)" % (self.targetInterval.getSize(), self.queryInterval.getSize(), self.size)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 return string
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258