annotate commons/core/parsing/BlatParser.py @ 68:85e80c21b1f7 draft

Uploaded
author m-zytnicki
date Mon, 16 Nov 2015 12:00:32 -0500
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 # 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 import sys
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 ## this class can parse a Blat results output file
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 #
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 class BlatParser(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 def __init__(self, match='', mismatch='', repMatch='', N='', QGapCount='', QGapBases='', TGapCount='', TGapBases='', strand='', QName='', QSize='', QStart='', QEnd='', TName='', TSize='', TStart='', TEnd='', blockCount='', blockSizes='', qStarts='', tStarts=''):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 self._match = match
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 self._mismatch = mismatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 self._repMatch = repMatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 self._N = N
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 self._QGapCount = QGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 self._QGapBases = QGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 self._TGapCount = TGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 self._TGapBases = TGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 self._strand = strand
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 self._QName = QName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 self._QSize = QSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 self._QStart = QStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 self._QEnd = QEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 self._TName = TName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 self._TSize = TSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 self._TStart = TStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 self._TEnd = TEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 self._blockCount = blockCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57 self._blockSizes = blockSizes
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 self._qStarts = qStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 self._tStarts = tStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 def __eq__(self, o):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62 return self._TName == o._TName and self._TSize == o._TSize and self._TStart == o._TStart and self._TEnd == o._TEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64 def setMatch(self, match):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 self._match = match
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67 def setMismatch(self, mismatch):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 self._mismatch = mismatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 def setRepMatch(self, repMatch):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 self._repMatch = repMatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 def setN(self, N):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 self._N = N
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 def setQGapCount(self, QGapCount):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77 self._QGapCount = QGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 def setQGapBases(self, QGapBases):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80 self._QGapBases = QGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 def setTGapCount(self, TGapCount):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83 self._TGapCount = TGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85 def setTGapBases(self, TGapBases):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 self._TGapBases = TGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 def setStrand(self, strand):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 self._strand = strand
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 def setQName(self, QName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 self._QName = QName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 def setQSize(self, QSize):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95 self._QSize = QSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 def setQStart(self, QStart):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 self._QStart = QStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 def setQEnd(self, QEnd):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101 self._QEnd = QEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 def setTName(self, TName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104 self._TName = TName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 def setTSize(self, TSize):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 self._TSize = TSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 def setTStart(self, TStart):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 self._TStart = TStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 def setTEnd(self, TEnd):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113 self._TEnd = TEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115 def setBlockCount(self, blockCount):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 self._blockCount = blockCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 def setBlockSizes(self, blockSizes):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 self._blockSizes = blockSizes
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 def setQStarts(self, qStarts):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 self._qStarts = qStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124 def setTStarts(self, tStarts):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 self._tStarts = tStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 def getMatch(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128 return self._match
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 def getMismatch(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 return self._mismatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133 def getRepMatch(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 return self._repMatch
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 def getN(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 return self._N
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 def getQGapCount(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 return self._QGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 def getQGapBases(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 return self._QGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 def getTGapCount(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 return self._TGapCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 def getTGapBases(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 return self._TGapBases
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 def getStrand(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 return self._strand
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 def getQName(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 return self._QName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157 def getQSize(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 return self._QSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160 def getQStart(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 return self._QStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 def getQEnd(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 return self._QEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 def getTName(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 return self._TName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 def getTSize(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 return self._TSize
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 def getTStart(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173 return self._TStart
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 def getTEnd(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176 return self._TEnd
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 def getBlockCount(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 return self._blockCount
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181 def getBlockSizes(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 return self._blockSizes
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 def getQStarts(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 return self._qStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 def getTStarts(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 return self._tStarts
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 def setAttributes(self, lResults, iCurrentLineNumber):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 error = False
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 if lResults[0] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 self.setMatch(lResults[0])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 sys.stderr.write("WARNING: The field Match is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 if lResults[1] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 self.setMismatch(lResults[1])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 sys.stderr.write("WARNING: The field Mismatch is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 if lResults[2] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 self.setRepMatch(lResults[2])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 sys.stderr.write("WARNING: The field RepMatch is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 if lResults[3] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 self.setN(lResults[3])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 sys.stderr.write("WARNING: The field N is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 if lResults[4] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218 self.setQGapCount(lResults[4])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 sys.stderr.write("WARNING: The field QGapCount is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 if lResults[5] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 self.setQGapBases(lResults[5])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 sys.stderr.write("WARNING: The field QGapBases is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 if lResults[6] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 self.setTGapCount(lResults[6])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232 sys.stderr.write("WARNING: The field TGapCount is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 if lResults[7] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 self.setTGapBases(lResults[7])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238 sys.stderr.write("WARNING: The field TGapBases is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 if lResults[8] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 self.setStrand(lResults[8])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 sys.stderr.write("WARNING: The field Strand is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 if lResults[9] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 self.setQName(lResults[9])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 sys.stderr.write("WARNING: The field QName is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 if lResults[10] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 self.setQSize(lResults[10])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 sys.stderr.write("WARNING: The field QSize is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259 if lResults[11] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 self.setQStart(lResults[11])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 sys.stderr.write("WARNING: The field QStart is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 if lResults[12] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 self.setQEnd(lResults[12])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268 sys.stderr.write("WARNING: The field QEnd is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 if lResults[13] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272 self.setTName(lResults[13])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 sys.stderr.write("WARNING: The field TName is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 if lResults[14] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 self.setTSize(lResults[14])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 sys.stderr.write("WARNING: The field TSize is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 if lResults[15] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 self.setTStart(lResults[15])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 sys.stderr.write("WARNING: The field TStart is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289 if lResults[16] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 self.setTEnd(lResults[16])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 sys.stderr.write("WARNING: The field TEnd is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 if lResults[17] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296 self.setBlockCount(lResults[17])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 sys.stderr.write("WARNING: The field BlockCount is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 if lResults[18] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302 self.setBlockSizes(lResults[18])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 sys.stderr.write("WARNING: The field BlockSizes is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 if lResults[19] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 self.setQStarts(lResults[19])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310 sys.stderr.write("WARNING: The field QStarts is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 if lResults[20] != '':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314 self.setTStarts(lResults[20])
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 sys.stderr.write("WARNING: The field TStarts is empty in blat file in line %s\n" % iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 error = True
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319 if error == True:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 self._setAllToNull()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 def setAttributesFromString(self, blatLine, iCurrentLineNumber ="", fieldSeparator ="\t"):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 blatLine = blatLine.rstrip()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 lBlatLineItem = blatLine.split(fieldSeparator)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 if not len(lBlatLineItem) == 21:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 sys.stderr.write("WARNING: The line %s is not valid blat line (%s columns -> 21 columns needed)\n" % (iCurrentLineNumber, len(lBlatLineItem)))
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328 self.setAttributes(lBlatLineItem, iCurrentLineNumber)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
330 def _setAllToNull(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
331 self._match = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
332 self._mismatch = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
333 self._repMatch = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
334 self._N = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
335 self._QGapCount = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
336 self._QGapBases = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
337 self._TGapCount = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
338 self._TGapBases = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
339 self._strand = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
340 self._QName = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
341 self._QSize = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
342 self._QStart = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
343 self._QEnd = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
344 self._TName = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
345 self._TSize = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
346 self._TStart = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
347 self._TEnd = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
348 self._blockCount = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
349 self._blockSizes = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
350 self._qStarts = ''
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
351 self._tStarts = ''