1 """Code to interact with various Primer-related programs from EMBOSS.
2 """
3
4 import string
5 from xml.sax import handler
6
7
8 import Martel
9 from Martel import RecordReader
10
11
12 from Bio.ParserSupport import AbstractConsumer
13 from Bio.ParserSupport import EventGenerator
14
15 import primersearch_format
16 import primer3_format
17
18
19
41
43 """Parse primersearch output into a PrimerSearchOutputRecord.
44 """
47
52
54 """Represent the information from a primersearch job.
55
56 amplifiers is a dictionary where the keys are the primer names and
57 the values are a list of PrimerSearchAmplifier objects.
58 """
61
63 """Represent a single amplification from a primer.
64 """
66 self.hit_info = ""
67 self.length = 0
68
70 """Get output from primersearch into a PrimerSearchOutputRecord
71 """
76
78
79 if self._cur_primer is not None and self._cur_amplifier is not None:
80 self.data.amplifiers[self._cur_primer].append(self._cur_amplifier)
81
86
90
93
95 self._cur_amplifier.length = int(amplifier_info)
96
99
101 """Scan output from the primersearch program.
102 """
104 self.interest_tags = ["primer_name", "amplifier",
105 "amplifier_sequence", "amplifier_length",
106 "end_record"]
107
108 expression = Martel.select_names(primersearch_format.record,
109 self.interest_tags)
110 self._parser = expression.make_parser(debug_level = debug)
111
112 - def feed(self, handle, consumer):
120
121
122
124 """Represent information from a primer3 run finding primers.
125
126 Members:
127
128 primers A list of primers that are generated (usually 5)
129 """
131 self.comments = ""
132 self.primers = []
133
135 """A primer set designed by Primer3.
136
137 Members:
138
139 size
140 forward_seq
141 forward_start
142 forward_length
143 forward_tm
144 forward_gc
145 reverse_seq
146 reverse_start
147 reverse_length
148 reverse_tm
149 reverse_gc
150 """
163
165 """Parse primer3 output into a Primer3Record.
166 """
169
170 - def parse(self, handle):
174
176 """Get output from prime3 into a Primer3Record
177 """
181
183
184 if self._cur_primer is not None:
185 self.data.primers.append(self._cur_primer)
186
189
193
196
199
202
205
208
211
214
217
220
223
226
229
232
235
238
241
244
247
249 """Scan output from the primer3 program.
250 """
252 self.interest_tags = ["comments", "single_primer_line",
253 "start_primer", "product_size",
254 "forward_start", "forward_length",
255 "forward_tm", "forward_gc", "forward_seq",
256 "reverse_start", "reverse_length",
257 "reverse_tm", "reverse_gc", "reverse_seq",
258 "internal_start", "internal_length",
259 "internal_tm", "internal_gc", "internal_seq",
260 "end_record"]
261
262 expression = Martel.select_names(primer3_format.record,
263 self.interest_tags)
264 self._parser = expression.make_parser(debug_level = debug)
265
266 - def feed(self, handle, consumer):
274
276 """Combine multiple lines of content separated by spaces.
277 """
278
279 stripped_line_list = map(string.strip, line_list)
280
281 return string.join(stripped_line_list, ' ')
282