1
2
3
4
5
6 """
7 This module provides code to work with the enzyme.dat file from
8 Enzyme (OBSOLETE as of Biopython version 1.50).
9 http://www.expasy.ch/enzyme/
10
11 The functionality of Bio.Enzyme has moved to Bio.ExPASy.Enzyme;
12 please use that module instead of Bio.Enzyme. Most likely, Bio.Enzyme
13 will be deprecated in a future release of Biopython.
14
15
16 Classes:
17 _Scanner Scans Enzyme data.
18
19 """
20
21 from Bio import File
22 from Bio.ParserSupport import *
23
25 """Scans Enzyme data.
26
27 Tested with:
28 Release 33
29 """
30
31 - def feed(self, handle, consumer):
32 """feed(self, handle, consumer)
33
34 Feed in Enzyme data for scanning. handle is a file-like object
35 that contains keyword information. consumer is a Consumer
36 object that will receive events as the report is scanned.
37
38 """
39 if isinstance(handle, File.UndoHandle):
40 uhandle = handle
41 else:
42 uhandle = File.UndoHandle(handle)
43
44 while not is_blank_line(uhandle.peekline()):
45 self._scan_record(uhandle, consumer)
46
60
61 - def _scan_line(self, line_type, uhandle, event_fn,
62 exactly_one=None, one_or_more=None, any_number=None,
63 up_to_one=None):
81
84
87
90
94
97
100
103
107
111
114
115 _scan_fns = [
116 _scan_id,
117 _scan_de,
118 _scan_an,
119 _scan_ca,
120 _scan_cf,
121 _scan_cc,
122 _scan_di,
123 _scan_pr,
124 _scan_dr,
125 _scan_terminator
126 ]
128 - def __init__(self,tr_code='',sw_code=''):
129 self.tr_code = tr_code
130 self.sw_code = sw_code
131
133 return self.tr_code + ", " + self.sw_code
134
137 self.ID = ''
138 self.DE = []
139 self.AN = []
140 self.CA = ''
141 self.CF = []
142 self.CC = []
143 self.DI = []
144 self.PR = []
145 self.DR = []
146
148 if self.ID:
149 if self.DE:
150 return "%s (%s, %s)" % (self.__class__.__name__,
151 self.ID, self.DE[0])
152 else:
153 return "%s (%s)" % (self.__class__.__name__,
154 self.ID)
155 else:
156 return "%s ( )" % (self.__class__.__name__)
157
159 output = "ID: " + self.ID
160 output += " DE: " + repr(self.DE)
161 output += " AN: " + repr(self.AN)
162 output += " CA: '" + self.CA + "'"
163 output += " CF: " + repr(self.CF)
164 output += " CC: " + repr(self.CC)
165 output += " DI: " + repr(self.DI)
166 output += " PR: " + repr(self.PR)
167 output += " DR: %d Records" % len(self.DR)
168
169 return output
170
175
176 - def parse(self, handle):
183
185 - def __init__(self, handle, parser=None):
187
189 self._parser = RecordParser()
190 lines = []
191 while 1:
192 line = self._uhandle.readline()
193 if not line: break
194 if line[:2] == '//':
195 break
196 lines.append(line)
197 if not lines:
198 return None
199 lines.append('//')
200 data = string.join(lines,'')
201 if self._parser is not None:
202 return self._parser.parse(File.StringHandle(data))
203 return data
204
206 return iter(self.next, None)
207
212 self.enzyme_record.ID = id_info.split()[1]
218 self.enzyme_record.CA = string.join([self.enzyme_record.CA,ca_info[2:].strip()],'')
235
238
240 good_data = dr_info[2:].strip()
241 pair_data = good_data.split(';')
242 for pair in pair_data:
243 if not pair: continue
244 data_record = DataRecord()
245 t1, t2 = pair.split(',')
246 data_record.tr_code, data_record.sw_code = \
247 t1.strip(), t2.strip()
248 self.enzyme_record.DR.append(data_record)
249
250 def terminator(self,schwarzenegger):
251 pass
252