1
2
3
4
5
6 """Parsing AlignACE and CompareACE files: AlignAceParser,CompareAceParser
7 """
8
9 from Bio.Motif import Motif
10 from Bio.Alphabet import IUPAC
11 from Bio.Seq import Seq
12
13
16 self.motifs=[]
17 self.current_motif=None
18 self.param_dict = None
19
20
54
55
56
57
58 from Bio.ParserSupport import *
59 import Bio
60
61
63 """
64 The general purpose consumer for the AlignAceScanner (DEPRECATED).
65
66 Should be passed as the consumer to the feed method of the AlignAceScanner. After 'consuming' the file, it has the list of motifs in the motifs property.
67
68 This class is DEPRECATED; please use the read() function in this module
69 instead.
70 """
72 import warnings
73 warnings.warn("Bio.Motif.Parsers.AlignAce.AlignAceConsumer is deprecated; please use the read() function in this module instead.", Bio.BiopythonDeprecationWarning)
74 self.motifs=[]
75 self.current_motif=None
76 self.param_dict = None
77
80
82 par_name = line.split("=")[0].strip()
83 par_value = line.split("=")[1].strip()
84 self.param_dict[par_name]=par_value
85
88
90 seq_name = line.split("\t")[1]
91 self.seq_dict.append(seq_name)
92
97
101
103 self.current_motif.score = float(line.split()[-1])
104
107
110
113
116
118 """Parses AlignAce data into a sequence of Motifs (DEPRECATED)
119
120 This class is DEPRECATED; please use the read() function in this module
121 instead.
122 """
129
130 - def parse(self, handle):
131 """parse(self, handle)"""
132 self._scanner.feed(handle, self._consumer)
133 return self._consumer
134
136 """Scannner for AlignACE output (DEPRECATED).
137
138 Methods:
139 feed Feed data into the scanner.
140
141 The scanner generates (and calls the consumer) the following types of events:
142
143 noevent - blank line
144
145 version - AlignACE version number
146 command_line - AlignACE command line string
147 parameters - the begining of the parameters
148 parameter - the line containing a parameter
149 sequences - the begining of the sequences list
150 sequence - line containing the name of the input sequence (and a respective number)
151 motif - the begining of the motif (contains the number)
152 motif_hit - one hit for a motif
153 motif_mask - mask of the motif (space - gap, asterisk - significant position)
154 motif_score - MAP score of the motif - approx. N * log R, where R == (num. of actual occur.) / (num. of occur. expected by random.)
155
156 This class is DEPRECATED; please use the read() function in this module
157 instead.
158 """
160 import warnings
161 warnings.warn("Bio.Motif.Parsers.AlignAce.AlignAceScanner is deprecated; please use the read() function in this module instead.", Bio.BiopythonDeprecationWarning)
162
163 - def feed(self, handle, consumer):
164 """S.feed(handle, consumer)
165
166 Feed in a AlignACE report for scanning. handle is a file-like
167 object that contains the AlignACE report. consumer is a Consumer
168 object that will receive events as the report is scanned.
169 """
170 consumer.version(handle.readline())
171 consumer.command_line(handle.readline())
172 for line in handle:
173 if line.strip() == "":
174 consumer.noevent(line)
175 elif line[:4]=="Para":
176 consumer.parameters(line)
177 elif line[0]=="#":
178 consumer.sequence(line)
179 elif "=" in line:
180 consumer.parameter(line)
181 elif line[:5]=="Input":
182 consumer.sequences(line)
183 elif line[:5]=="Motif":
184 consumer.motif(line)
185 elif line[:3]=="MAP":
186 consumer.motif_score(line)
187 elif len(line.split("\t"))==4:
188 consumer.motif_hit(line)
189 elif "*" in line:
190 consumer.motif_mask(line)
191 else:
192 raise ValueError(line)
193
195 """Scannner for CompareACE output (DEPRECATED).
196
197 Methods:
198 feed Feed data into the scanner.
199
200 The scanner generates (and calls the consumer) the following types of events:
201
202 motif_score - CompareACE score of motifs
203
204 ###### TO DO #############3
205 extend the scanner to include other, more complex outputs.
206 """
210
211 - def feed(self, handle, consumer):
212 """S.feed(handle, consumer)
213
214 Feed in a CompareACE report for scanning. handle is a file-like
215 object that contains the CompareACE report. consumer is a Consumer
216 object that will receive events as the report is scanned.
217 """
218 consumer.motif_score(handle.readline())
219
220
222 """
223 The general purpose consumer for the CompareAceScanner (DEPRECATED).
224
225 Should be passed as the consumer to the feed method of the CompareAceScanner. After 'consuming' the file, it has the list of motifs in the motifs property.
226 """
230
233
235 """Parses CompareAce output to usable form
236
237 ### so far only in a very limited way
238 """
240 """__init__(self)"""
241 import warnings
242 warnings.warn("CompareAceParser and ComparAceConsumer are" \
243 +" deprecated, and will be removed in a future release of"\
244 +" Biopython. If you want to continue to use this code,"\
245 +" please get in contact with the Biopython developers via"\
246 +" the mailing lists to avoid its permanent removal from"\
247 +" Biopython. See also the Python built in set datatype.", \
248 Bio.BiopythonDeprecationWarning)
249 self._scanner = CompareAceScanner()
250 self._consumer = CompareAceConsumer()
251
252 - def parse(self, handle):
253 """parse(self, handle)"""
254 self._scanner.feed(handle, self._consumer)
255 return self._consumer.data
256