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 warnings.warn("Bio.Enzyme is deprecated, and will be removed in a"\
19 " future release of Biopython. Most of the functionality "
20 " is now provided by Bio.ExPASy.Enzyme. If you want to "
21 " continue to use Bio.Enzyme, please get in contact "
22 " via the mailing lists to avoid its permanent removal from"\
23 " Biopython.", DeprecationWarning)
24
25 from Bio import File
26 from Bio.ParserSupport import *
27
29 """Scans Enzyme data (PRIVATE).
30
31 Tested with:
32 Release 33
33 """
34
35 - def feed(self, handle, consumer):
36 """feed(self, handle, consumer)
37
38 Feed in Enzyme data for scanning. handle is a file-like object
39 that contains keyword information. consumer is a Consumer
40 object that will receive events as the report is scanned.
41
42 """
43 if isinstance(handle, File.UndoHandle):
44 uhandle = handle
45 else:
46 uhandle = File.UndoHandle(handle)
47
48 while not is_blank_line(uhandle.peekline()):
49 self._scan_record(uhandle, consumer)
50
64
65 - def _scan_line(self, line_type, uhandle, event_fn,
66 exactly_one=None, one_or_more=None, any_number=None,
67 up_to_one=None):
85
88
91
94
98
101
104
107
111
115
118
119 _scan_fns = [
120 _scan_id,
121 _scan_de,
122 _scan_an,
123 _scan_ca,
124 _scan_cf,
125 _scan_cc,
126 _scan_di,
127 _scan_pr,
128 _scan_dr,
129 _scan_terminator
130 ]
132 - def __init__(self,tr_code='',sw_code=''):
133 self.tr_code = tr_code
134 self.sw_code = sw_code
135
137 return self.tr_code + ", " + self.sw_code
138
141 self.ID = ''
142 self.DE = []
143 self.AN = []
144 self.CA = ''
145 self.CF = []
146 self.CC = []
147 self.DI = []
148 self.PR = []
149 self.DR = []
150
152 if self.ID:
153 if self.DE:
154 return "%s (%s, %s)" % (self.__class__.__name__,
155 self.ID, self.DE[0])
156 else:
157 return "%s (%s)" % (self.__class__.__name__,
158 self.ID)
159 else:
160 return "%s ( )" % (self.__class__.__name__)
161
163 output = "ID: " + self.ID
164 output += " DE: " + repr(self.DE)
165 output += " AN: " + repr(self.AN)
166 output += " CA: '" + self.CA + "'"
167 output += " CF: " + repr(self.CF)
168 output += " CC: " + repr(self.CC)
169 output += " DI: " + repr(self.DI)
170 output += " PR: " + repr(self.PR)
171 output += " DR: %d Records" % len(self.DR)
172
173 return output
174
179
180 - def parse(self, handle):
187
189 - def __init__(self, handle, parser=None):
191
193 self._parser = RecordParser()
194 lines = []
195 while True:
196 line = self._uhandle.readline()
197 if not line: break
198 if line[:2] == '//':
199 break
200 lines.append(line)
201 if not lines:
202 return None
203 lines.append('//')
204 data = string.join(lines,'')
205 if self._parser is not None:
206 return self._parser.parse(File.StringHandle(data))
207 return data
208
210 return iter(self.next, None)
211
216 self.enzyme_record.ID = id_info.split()[1]
222 self.enzyme_record.CA = string.join([self.enzyme_record.CA,ca_info[2:].strip()],'')
239
242
244 good_data = dr_info[2:].strip()
245 pair_data = good_data.split(';')
246 for pair in pair_data:
247 if not pair: continue
248 data_record = DataRecord()
249 t1, t2 = pair.split(',')
250 data_record.tr_code, data_record.sw_code = \
251 t1.strip(), t2.strip()
252 self.enzyme_record.DR.append(data_record)
253
256