annotate commons/core/sql/TableBinPathAdaptator.py @ 14:c79b9ae3f65f

Deleted selected files
author m-zytnicki
date Fri, 19 Apr 2013 10:13:11 -0400
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 # Copyright INRA (Institut National de la Recherche Agronomique)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 # http://www.inra.fr
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 # http://urgi.versailles.inra.fr
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 # This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 # abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 # modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 # license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 # "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 # As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 # modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 # with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 # economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 # liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 # In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 # with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 # software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 # that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 # therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 # professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 # encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 # requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 # data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 # same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 # The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 # knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 from commons.core.coord.Range import getIdx
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 from commons.core.sql.TablePathAdaptator import TablePathAdaptator
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 from commons.core.coord.PathUtils import PathUtils
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 ## Bin Adaptator for a path table.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 class TableBinPathAdaptator(TablePathAdaptator):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 ## Constructor
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 # @param db db instance
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 # @param tableName string table name (default = "")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 def __init__(self, db, tableName = ""):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 TablePathAdaptator.__init__(self, db, tableName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 self._table_idx = "%s_idx" % (self._table)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 ## Insert a path instance
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 # @param path a path instance
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 # @param delayed boolean indicating if the insert must be delayed (default = false)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 def insert( self, path, delayed = False ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 TablePathAdaptator.insert(self, path, delayed)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 self._escapeAntislash(path)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 idx = path.range_query.findIdx()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 max = path.range_query.getMax()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 min = path.range_query.getMin()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 strand = path.range_query.isOnDirectStrand()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 if delayed:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 sql_cmd = 'INSERT DELAYED INTO %s VALUES (%d,%d,"%s",%d,%d,%d)'\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 % (self._table_idx,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 path.id,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 idx,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 path.range_query.seqname,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 min,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 max,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 strand)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 sql_cmd = 'INSERT INTO %s VALUES (%d,%d,"%s",%d,%d,%d)'\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 % (self._table_idx,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 path.id,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 idx,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 path.range_query.seqname,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 min,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 max,\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 strand)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 self._iDb.execute(sql_cmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 ## Return a path instances list included in a given region using the bin scheme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 # @param contig string contig name
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 # @param start integer start coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 # @param end integer end coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 # @return lOutPath a path instances list
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 def getPathListIncludedInQueryCoord(self, contig, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 min_coord = min(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 max_coord = max(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 lpath = self.getChainListOverlappingQueryCoord(contig, start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 lOutPath = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 for i in lpath:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 if i.range_query.getMin() > min_coord and \
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 i.range_query.getMax() < max_coord:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 lOutPath.append(i)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 return lOutPath
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 ## Return a path instances list overlapping (and included) in a given region using the bin scheme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 # @param contig string contig name
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 # @param start integer start coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 # @param end integer end coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 # @return lOutPath a path instances list
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 def getPathListOverlappingQueryCoord(self, contig, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 min_coord = min(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 max_coord = max(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 lpath = self.getChainListOverlappingQueryCoord(contig, start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 lOutPath = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 for i in lpath:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 if ((i.range_query.getMin() <= min_coord and i.range_query.getMax() >= min_coord) or \
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 (i.range_query.getMin() >= min_coord and i.range_query.getMin() <= max_coord) or \
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 (i.range_query.getMin() <= min_coord and i.range_query.getMax() >= max_coord) or \
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 (i.range_query.getMin() >= min_coord and i.range_query.getMax() <= max_coord)) and \
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 (i.range_query.getSeqname() == contig):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 lOutPath.append(i)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 return lOutPath
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 ## Return a path instances list chain (by Id and Coord in chr) list overlapping a given region using the bin scheme
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 # @param contig string contig name
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 # @param start integer start coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 # @param end integer end coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 # @return lpath a path instances list
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 def getChainListOverlappingQueryCoord(self, contig, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 min_coord = min(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 max_coord = max(start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 sql_cmd = 'select distinct path from %s where contig="%s" and ('\
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 % (self._table + "_idx", contig)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 for bin_lvl in xrange(6, 2, -1):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 if getIdx(start,bin_lvl) == getIdx(end, bin_lvl):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 idx = getIdx(start, bin_lvl)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 sql_cmd += 'idx=%d' % (idx)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 idx1 = getIdx(min_coord, bin_lvl)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 idx2 = getIdx(max_coord, bin_lvl)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 sql_cmd += 'idx between %d and %d' % (idx1, idx2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 if bin_lvl > 3:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 sql_cmd += " or "
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 sql_cmd += ") and min<=%d and max>=%d;" % (max_coord, min_coord)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150 self._iDb.execute(sql_cmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 res = self._iDb.fetchall()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 lnum = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 for i in res:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 lnum.append( int(i[0]) )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 lpath = self.getPathListFromIdList(lnum)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 return lpath
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 ## Delete path corresponding to a given identifier number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 # @param num integer identifier number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 def deleteFromId(self, num):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 TablePathAdaptator.deleteFromId(self, num)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 sqlCmd='delete from %s where path=%d;' % (self._table_idx, num)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 self._iDb.execute(sqlCmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 ## Delete path corresponding to a given list of identifier number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 # @param lNum list list of integer identifier number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 def deleteFromIdList(self, lNum):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 if lNum == []:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 return
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 TablePathAdaptator.deleteFromIdList(self, lNum)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 sqlCmd = 'delete from %s where path=%d' % (self._table_idx, lNum[0])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 for i in lNum[1:]:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 sqlCmd += " or path=%d" % (i)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 sqlCmd += ";"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 self._iDb.execute(sqlCmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 ## Join two path by changing id number of id1 and id2 path to the least of id1 and id2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 # @param id1 integer id path number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 # @param id2 integer id path number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 # @return newId integer minimum of id1 id2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 # @note this method modify the ID even if this one not existing in the path table
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 def joinTwoPaths(self, id1, id2):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 TablePathAdaptator.joinTwoPaths(self, id1, id2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 if id1 < id2:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 newId = id1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 oldId = id2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 newId = id2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 oldId = id1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 sqlCmd = 'UPDATE %s SET path=%d WHERE path=%d' % (self._table_idx, newId, oldId)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 self._iDb.execute(sqlCmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 return newId
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 ## Get a new id number
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 # @return newId integer max Id in path table + 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 def getNewId(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 sqlCmd = 'select max(path) from %s;' % (self._table_idx)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 self._iDb.execute(sqlCmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 maxId = self._iDb.fetchall()[0][0]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 if maxId == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 maxId = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 newId = int(maxId) + 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 return newId
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 ## Give a list of Set instances included in a given region
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 # @param query string query name
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 # @param start integer start coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 # @param end integer end coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 # @return lSet list of Set instances
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 def getSetListIncludedInQueryCoord(self, query, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 lPath=self.getPathListIncludedInQueryCoord(query, start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 lSet = PathUtils.getSetListFromQueries(lPath)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 return lSet
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 ## Give a list of Set instances overlapping a given region
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 # @param query string query name
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 # @param start integer start coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 # @param end integer end coordinate
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 # @return lSet list of Set instances
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 def getSetListOverlappingQueryCoord(self, query, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 lPath = self.getPathListOverlappingQueryCoord(query, start, end)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 lSet = PathUtils.getSetListFromQueries(lPath)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 return lSet
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 ## Give a list of identifiers contained in the table
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 # @return lId integer list
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 def getIdList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 sqlCmd = "SELECT DISTINCT path from %s;" % (self._table_idx)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 lId = self._iDb.getIntegerListWithSQLCmd( sqlCmd )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 return lId
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 ## Give a list of the distinct query names present in the table
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 # @return lDistinctQueryNames string list
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 def getQueryList(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 lDistinctQueryNames = self._getDistinctTypeNamesList("query")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 return lDistinctQueryNames
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 def _getDistinctTypeNamesList( self, type ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 sqlCmd = "SELECT DISTINCT contig FROM %s" % ( self._table_idx )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 lDistinctTypeNames = self._iDb.getStringListWithSQLCmd(sqlCmd)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 return lDistinctTypeNames