annotate SMART/Java/Python/ncList/NCListCursor.py @ 16:6135c3075bc5

Deleted selected files
author m-zytnicki
date Mon, 22 Apr 2013 11:09:41 -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 #! /usr/bin/env python
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 # Copyright INRA-URGI 2009-2010
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 import os, os.path, struct
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 from commons.core.parsing.GffParser import GffParser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 from SMART.Java.Python.misc.Progress import Progress
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 class Data(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 def __init__(self, hIndex, transcript, firstChildLIndex, lastChildLIndex, start, end):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 self.hIndex = hIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 self.transcript = transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 self.firstChildLIndex = firstChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 self.lastChildLIndex = lastChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 self.start = start
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 self.end = end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 class NCListCursor(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 def __init__(self, cursor = None, ncList = None, lIndex = 0, verbosity = 0):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 self._verbosity = verbosity
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 self._mainListData = []
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 if cursor:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 self.copy(cursor)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 self._ncList = ncList
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 self.setLIndex(lIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 def setLIndex(self, lIndex):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 self._lIndex = lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 self._parentGffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 self._parentLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 self._parentHIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 self._parentStart = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 self._parentEnd = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 self._firstSiblingLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 self._lastSiblingLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72 self._mainListIndex = lIndex if lIndex < self._ncList.getSizeFirstList() else None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 def precompute(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 self._mainListIndex = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 progress = Progress(self._ncList.getSizeFirstList(), "Precomputing data", self._verbosity)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 for i in range(self._ncList.getSizeFirstList()):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78 gffIndex, hIndex, parentLIndex, start, end = self._ncList.getLLineElements(i)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 transcript = self._ncList.getIntervalFromAdress(gffIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 firstChildLIndex, nbChildren = self._ncList.getHLineElements(hIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 lastChildLIndex = -1 if firstChildLIndex == -1 else firstChildLIndex + nbChildren-1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 self._mainListData.append(Data(hIndex, transcript, firstChildLIndex, lastChildLIndex, start, end))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 progress.inc()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 progress.done()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 def _updateFromMainListData(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87 if not self._mainListData or self._lIndex >= self._ncList.getSizeFirstList():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 #print "OUT"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90 if self._mainListIndex >= self._ncList.getSizeFirstList():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 self._hIndex = -1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 data = self._mainListData[self._mainListIndex]
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 self._hIndex = data.hIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 self._transcript = data.transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self._firstChildLIndex = data.firstChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 self._lastChildLIndex = data.lastChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 self._start = data.start
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 self._end = data.end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 return True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 def getLIndex(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 return self._lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 def _getCurrentData(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 self._gffIndex, self._hIndex, self._parentLIndex, self._start, self._end = self._ncList.getLLineElements(self._lIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 #print "-->", self._lIndex, "-->", self._gffIndex, self._hIndex, self._parentLIndex, self._start, self._end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 if self._end == -1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 raise Exception("Error")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 def _getParentData(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 if self._parentLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 self._parentGffIndex, self._parentHIndex, greatParentLIndex, self._parentStart, self._parentEnd = self._ncList.getLLineElements(self._parentLIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 def _getTranscript(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 if self._gffIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 self._transcript = self._ncList.getIntervalFromAdress(self._gffIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 def _getSiblingData(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 if self._parentHIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 self._getParentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 if self._parentHIndex == -1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 self._firstSiblingLIndex = 0
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 self._lastSiblingLIndex = self._ncList.getSizeFirstList() - 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 self._firstSiblingLIndex, nbSiblings = self._ncList.getHLineElements(self._parentHIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 self._lastSiblingLIndex = -1 if self._firstSiblingLIndex == -1 else self._firstSiblingLIndex + nbSiblings-1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 def _getChildrenData(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 if self._hIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 self._firstChildLIndex, nbChildren = self._ncList.getHLineElements(self._hIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 self._lastChildLIndex = -1 if self._firstChildLIndex == -1 else self._firstChildLIndex + nbChildren-1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 def getGffAddress(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 if self._gffIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 return self._gffIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 def getStart(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 if self._start == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 return self._start
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 def getEnd(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147 if self._end == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 return self._end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 def compare(self, cursor):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 return (self._lIndex == cursor._lIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 def getTranscript(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 if self.isOut():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 return None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 if self._transcript == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 self._getTranscript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 return self._transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 def isFirst(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 #print "is last: ", self._lIndex, self._ncList.getSizeFirstList(), self._lastSiblingLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 if self._lIndex < self._ncList.getSizeFirstList() - 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 return (self._lIndex == 0)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 if self._firstSiblingLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 self._getSiblingData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 return (self._lIndex == self._firstSiblingLIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 def isLast(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 #print "is last: ", self._lIndex, self._ncList.getSizeFirstList(), self._lastSiblingLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 if self._lIndex < self._ncList.getSizeFirstList() - 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 return (self._lIndex == self._ncList.getSizeFirstList() - 1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 if self._lastSiblingLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 self._getSiblingData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 return (self._lIndex == self._lastSiblingLIndex)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 def moveUp(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 if self._parentLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 self._lIndex = self._parentLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 self._updateFromMainListData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 self._hIndex = self._parentHIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 self._gffIndex = self._parentGffIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 self._parentLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 self._parentHIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 self._parentGffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 self._firstSiblingLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189 self._lastSiblingLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 self._firstChildLIndex = self._firstChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 self._lastChildLIndex = self._lastChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 self._start = self._parentStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 self._end = self._parentEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 self._parentStart = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 self._parentEnd = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 def moveRight(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 if self.isOut():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 return
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 #print "IN1", self
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 if self._lIndex < self._ncList.getSizeFirstList() - 1 and self._mainListIndex != None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 self._mainListIndex += 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 self._updateFromMainListData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 #print "IN2", self
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 self._lIndex += 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 #print "IN3", self
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 def moveNext(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 while not self.isOut() and self.isLast():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 if self.isTop():
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 self._lIndex = -1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 return
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 self.moveUp()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 #print "F1", self
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 self.moveRight()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 #print "F2", self
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 def moveMiddleSibling(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 if self._lIndex < self._ncList.getSizeFirstList() - 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 self._mainListIndex = (self._ncList.getSizeFirstList() - 1) / 2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 self._updateFromMainListData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 if self._lastSiblingLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 self._getSiblingData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 self._lIndex = (self._lastSiblingLIndex + self._firstSiblingLIndex) / 2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 def moveSibling(self, lIndex):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 if self._lIndex < self._ncList.getSizeFirstList() - 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 self._mainListIndex = lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 self._updateFromMainListData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 self._lIndex = lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 def moveLastSibling(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 if self._lIndex < self._ncList.getSizeFirstList() - 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 self._mainListIndex = self._ncList.getSizeFirstList() - 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 self._updateFromMainListData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 if self._lastSiblingLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258 self._getSiblingData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259 self._lIndex = self._lastSiblingLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268 def moveDown(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 if self._firstChildLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270 self._getChildrenData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 self._parentLIndex = self._lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272 self._parentHIndex = self._hIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 self._parentGffIndex = self._gffIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 self._lIndex = self._firstChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 self._lastSiblingLIndex = self._lastChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 self._hIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 self._gffIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 self._transcript = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 self._firstChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 self._lastChildLIndex = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 self._parentStart = self._start
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282 self._parentEnd = self._end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 self._start = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 self._end = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 def isOut(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287 return (self._lIndex == -1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289 def isTop(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 if self._parentLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 return (self._parentLIndex == -1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 def hasChildren(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 if self._hIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296 self._getCurrentData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 if self._hIndex == -1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 return False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 if self._firstChildLIndex == None:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 self._getChildrenData()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 return (self._firstChildLIndex != -1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 def copy(self, cursor):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 self._ncList = cursor._ncList
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305 self._lIndex = cursor._lIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 self._hIndex = cursor._hIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 self._gffIndex = cursor._gffIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 self._parentLIndex = cursor._parentLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 self._parentHIndex = cursor._parentHIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 self._parentGffIndex = cursor._parentGffIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311 self._transcript = cursor._transcript
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 self._firstSiblingLIndex = cursor._firstSiblingLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 self._lastSiblingLIndex = cursor._lastSiblingLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314 self._firstChildLIndex = cursor._firstChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 self._lastChildLIndex = cursor._lastChildLIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 self._mainListData = cursor._mainListData
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 self._mainListIndex = cursor._mainListIndex
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318 self._verbosity = cursor._verbosity
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319 self._parentStart = cursor._parentStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 self._parentEnd = cursor._parentEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321 self._start = cursor._start
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 self._end = cursor._end
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 def __str__(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 return "NC-list: %s, Lindex: %s, Hindex: %s, GFFindex: %s, start: %s, end: %s, parent Lindex: %s, parent Hindex: %s, parent GFFindex: %s, transcript: %s, last sibling: %s" % (self._ncList, self._lIndex, self._hIndex, self._gffIndex, self._start, self._end, self._parentLIndex, self._parentHIndex, self._parentGffIndex, self._transcript, self._lastSiblingLIndex)