1
2
3
4
5 """
6 Classes for pparsing AlignAce and CompareACE files
7 """
8
9
10 from Bio.ParserSupport import *
11 from Scanner import AlignAceScanner,CompareAceScanner
12 from Motif import Motif
13 from Bio.Alphabet import IUPAC
14 from Bio.Seq import Seq
15
16
18 """
19 The general purpose consumer for the AlignAceScanner.
20
21 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.
22 """
24 self.motifs=[]
25 self.current_motif=None
26 self.param_dict = None
27
30
32 par_name = line.split("=")[0].strip()
33 par_value = line.split("=")[1].strip()
34 self.param_dict[par_name]=par_value
35
38
40 seq_name = line.split("\t")[1]
41 self.seq_dict.append(seq_name)
42
47
51
53 self.current_motif.score = float(line.split()[-1])
54
57
60
63
66
68 """Parses AlignAce data into a sequence of Motifs.
69 """
74
76 """parse(self, handle)"""
77 self._scanner.feed(handle, self._consumer)
78 return self._consumer.motifs
79
80
82 """
83 The general purpose consumer for the CompareAceScanner.
84
85 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.
86 """
91
93 """Parses CompareAce output to usable form
94
95 ### so far only in a very limited way
96 """
101
102 - def parse(self, handle):
103 """parse(self, handle)"""
104 self._scanner.feed(handle, self._consumer)
105 return self._consumer.data
106