1
2
3
4
5 """
6 Classes for parsing 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
15
17 """
18 The general purpose consumer for the AlignAceScanner.
19
20 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.
21 """
23 self.motifs=[]
24 self.current_motif=None
25 self.param_dict = None
26
29
31 par_name = line.split("=")[0].strip()
32 par_value = line.split("=")[1].strip()
33 self.param_dict[par_name]=par_value
34
37
39 seq_name = line.split("\t")[1]
40 self.seq_dict.append(seq_name)
41
46
50
52 self.current_motif.score = float(line.split()[-1])
53
56
59
62
65
67 """Parses AlignAce data into a sequence of Motifs.
68 """
73
75 """parse(self, handle)"""
76 self._scanner.feed(handle, self._consumer)
77 return self._consumer.motifs
78
79
81 """
82 The general purpose consumer for the CompareAceScanner.
83
84 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.
85 """
90
92 """Parses CompareAce output to usable form
93
94 ### so far only in a very limited way
95 """
100
101 - def parse(self, handle):
102 """parse(self, handle)"""
103 self._scanner.feed(handle, self._consumer)
104 return self._consumer.data
105