1
2
3
4
5
6 """Module to work with enzyme.dat file (DEPRECATED).
7
8 This module provides code to work with the enzyme.dat file from
9 Enzyme (OBSOLETE as of Biopython version 1.50).
10 http://www.expasy.ch/enzyme/
11
12 The functionality of Bio.Enzyme has moved to Bio.ExPASy.ExPASy;
13 please use that module instead of Bio.Enzyme. Bio.Enzyme is now
14 deprecated and will be removed in a future release of Biopython.
15 """
16
17 import warnings
18 import Bio
19 warnings.warn("Bio.Enzyme is deprecated, and will be removed in a"\
20 " future release of Biopython. Most of the functionality "
21 " is now provided by Bio.ExPASy.Enzyme. If you want to "
22 " continue to use Bio.Enzyme, please get in contact "
23 " via the mailing lists to avoid its permanent removal from"\
24 " Biopython.", Bio.BiopythonDeprecationWarning)
25
26 from Bio import File
27 from Bio.ParserSupport import *
28
30 """Scans Enzyme data (PRIVATE).
31
32 Tested with:
33 Release 33
34 """
35
36 - def feed(self, handle, consumer):
37 """feed(self, handle, consumer)
38
39 Feed in Enzyme data for scanning. handle is a file-like object
40 that contains keyword information. consumer is a Consumer
41 object that will receive events as the report is scanned.
42
43 """
44 if isinstance(handle, File.UndoHandle):
45 uhandle = handle
46 else:
47 uhandle = File.UndoHandle(handle)
48
49 while not is_blank_line(uhandle.peekline()):
50 self._scan_record(uhandle, consumer)
51
65
66 - def _scan_line(self, line_type, uhandle, event_fn,
67 exactly_one=None, one_or_more=None, any_number=None,
68 up_to_one=None):
86
89
92
95
99
102
105
108
112
116
119
120 _scan_fns = [
121 _scan_id,
122 _scan_de,
123 _scan_an,
124 _scan_ca,
125 _scan_cf,
126 _scan_cc,
127 _scan_di,
128 _scan_pr,
129 _scan_dr,
130 _scan_terminator
131 ]
133 - def __init__(self,tr_code='',sw_code=''):
134 self.tr_code = tr_code
135 self.sw_code = sw_code
136
138 return self.tr_code + ", " + self.sw_code
139
142 self.ID = ''
143 self.DE = []
144 self.AN = []
145 self.CA = ''
146 self.CF = []
147 self.CC = []
148 self.DI = []
149 self.PR = []
150 self.DR = []
151
153 if self.ID:
154 if self.DE:
155 return "%s (%s, %s)" % (self.__class__.__name__,
156 self.ID, self.DE[0])
157 else:
158 return "%s (%s)" % (self.__class__.__name__,
159 self.ID)
160 else:
161 return "%s ( )" % (self.__class__.__name__)
162
164 output = "ID: " + self.ID
165 output += " DE: " + repr(self.DE)
166 output += " AN: " + repr(self.AN)
167 output += " CA: '" + self.CA + "'"
168 output += " CF: " + repr(self.CF)
169 output += " CC: " + repr(self.CC)
170 output += " DI: " + repr(self.DI)
171 output += " PR: " + repr(self.PR)
172 output += " DR: %d Records" % len(self.DR)
173
174 return output
175
180
181 - def parse(self, handle):
188
190 - def __init__(self, handle, parser=None):
192
194 self._parser = RecordParser()
195 lines = []
196 while True:
197 line = self._uhandle.readline()
198 if not line: break
199 if line[:2] == '//':
200 break
201 lines.append(line)
202 if not lines:
203 return None
204 lines.append('//')
205 data = ''.join(lines)
206 if self._parser is not None:
207 return self._parser.parse(File.StringHandle(data))
208 return data
209
211 return iter(self.next, None)
212
217 self.enzyme_record.ID = id_info.split()[1]
223 self.enzyme_record.CA = ''.join([self.enzyme_record.CA, ca_info[2:].strip()])
240
243
245 good_data = dr_info[2:].strip()
246 pair_data = good_data.split(';')
247 for pair in pair_data:
248 if not pair: continue
249 data_record = DataRecord()
250 t1, t2 = pair.split(',')
251 data_record.tr_code, data_record.sw_code = \
252 t1.strip(), t2.strip()
253 self.enzyme_record.DR.append(data_record)
254
257