1 """Code to interact with Primer-related programs from EMBOSS (DEPRECATED).
2
3 Bio.Emboss.Primer has been deprecated, please use Bio.Emboss.Primer3 or
4 Bio.Emboss.PrimerSearch instead.
5
6 To parse primersearch output into a PrimerSearch.OutputRecord, use
7 from Bio.Emboss import PrimerSearch
8 handle = open('myprimersearchoutputfile.txt')
9 record = PrimerSearch.read(handle)
10
11 To parse primer3 output into a Primer3.Record, use
12 from Bio.Emboss import Primer3
13 handle = open('myprimer3outputfile.txt')
14 record = Primer3.read(handle)
15 """
16
17 import warnings
18 warnings.warn("""\
19 Bio.Emboss.Primer has been deprecated.
20 Please use Bio.Emboss.Primer3 or Bio.Emboss.PrimerSearch instead.
21
22 To parse primersearch output into a PrimerSearch.OutputRecord, use
23 from Bio.Emboss import PrimerSearch
24 handle = open('myprimersearchoutputfile.txt')
25 record = PrimerSearch.read(handle)
26
27 To parse primer3 output into a Primer3.Record, use
28 from Bio.Emboss import Primer3
29 handle = open('myprimer3outputfile.txt')
30 record = Primer3.read(handle)
31 """, DeprecationWarning)
32
33
34 import string
35 from xml.sax import handler
36
37
38 import Martel
39
40
41 from Bio.ParserSupport import AbstractConsumer
42 from Bio.ParserSupport import EventGenerator
43
44 import primersearch_format
45 import primer3_format
46
47
48
70
72 """Parse primersearch output into a PrimerSearchOutputRecord.
73 """
76
81
83 """Represent the information from a primersearch job.
84
85 amplifiers is a dictionary where the keys are the primer names and
86 the values are a list of PrimerSearchAmplifier objects.
87 """
90
92 """Represent a single amplification from a primer.
93 """
95 self.hit_info = ""
96 self.length = 0
97
99 """Get output from primersearch into a PrimerSearchOutputRecord
100 """
105
107
108 if self._cur_primer is not None and self._cur_amplifier is not None:
109 self.data.amplifiers[self._cur_primer].append(self._cur_amplifier)
110
115
119
122
124 self._cur_amplifier.length = int(amplifier_info)
125
128
130 """Scan output from the primersearch program.
131 """
133 self.interest_tags = ["primer_name", "amplifier",
134 "amplifier_sequence", "amplifier_length",
135 "end_record"]
136
137 expression = Martel.select_names(primersearch_format.record,
138 self.interest_tags)
139 self._parser = expression.make_parser(debug_level = debug)
140
141 - def feed(self, handle, consumer):
149
150
151
153 """Represent information from a primer3 run finding primers.
154
155 Members:
156
157 primers A list of primers that are generated (usually 5)
158 """
160 self.comments = ""
161 self.primers = []
162
164 """A primer set designed by Primer3.
165
166 Members:
167
168 size
169 forward_seq
170 forward_start
171 forward_length
172 forward_tm
173 forward_gc
174 reverse_seq
175 reverse_start
176 reverse_length
177 reverse_tm
178 reverse_gc
179 """
192
194 """Parse primer3 output into a Primer3Record.
195 """
198
199 - def parse(self, handle):
203
205 """Get output from prime3 into a Primer3Record
206 """
210
212
213 if self._cur_primer is not None:
214 self.data.primers.append(self._cur_primer)
215
218
222
225
228
231
234
237
240
243
246
249
252
255
258
261
264
267
270
273
276
278 """Scan output from the primer3 program.
279 """
281 self.interest_tags = ["comments", "single_primer_line",
282 "start_primer", "product_size",
283 "forward_start", "forward_length",
284 "forward_tm", "forward_gc", "forward_seq",
285 "reverse_start", "reverse_length",
286 "reverse_tm", "reverse_gc", "reverse_seq",
287 "internal_start", "internal_length",
288 "internal_tm", "internal_gc", "internal_seq",
289 "end_record"]
290
291 expression = Martel.select_names(primer3_format.record,
292 self.interest_tags)
293 self._parser = expression.make_parser(debug_level = debug)
294
295 - def feed(self, handle, consumer):
303
305 """Combine multiple lines of content separated by spaces.
306 """
307
308 stripped_line_list = map(string.strip, line_list)
309
310 return string.join(stripped_line_list, ' ')
311