1
2
3
4
5 """
6 Classes for pparsing AlignAce and CompareACE files
7 """
8
9 from Bio.ParserSupport import *
10 from Scanner import AlignAceScanner,CompareAceScanner
11 from Motif import Motif
12 from Bio.Alphabet import IUPAC
13 from Bio.Seq import Seq
14
16 """
17 The general purpose consumer for the AlignAceScanner.
18
19 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.
20 """
22 self.motifs=[]
23 self.current_motif=None
24 self.param_dict = None
25
28
30 par_name = line.split("=")[0].strip()
31 par_value = line.split("=")[1].strip()
32 self.param_dict[par_name]=par_value
33
36
38 seq_name = line.split("\t")[1]
39 self.seq_dict.append(seq_name)
40
45
49
51 self.current_motif.score = string.atof(line.split()[-1])
52
55
58
61
64
66 """Parses AlignAce data into a sequence of Motifs.
67 """
72
74 """parse(self, handle)"""
75 self._scanner.feed(handle, self._consumer)
76 return self._consumer.motifs
77
78
80 """
81 The general purpose consumer for the CompareAceScanner.
82
83 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.
84 """
89
91 """Parses CompareAce output to usable form
92
93 ### so far only in a very limited way
94 """
99
100 - def parse(self, handle):
101 """parse(self, handle)"""
102 self._scanner.feed(handle, self._consumer)
103 return self._consumer.data
104