1
2
3
4
5 """
6 Consumers for AlignACE and CompareACE parsers.
7 """
8
10 """Scannner for AlignACE output
11
12 Methods:
13 feed Feed data into the scanner.
14
15 The scanner generates (and calls the consumer) the following types of events:
16
17 noevent - blank line
18
19 version - AlignACE version number
20 command_line - AlignACE command line string
21 parameters - the begining of the parameters
22 parameter - the line containing a parameter
23 sequences - the begining of the sequences list
24 sequence - line containing the name of the input sequence (and a respective number)
25 motif - the begining of the motif (contains the number)
26 motif_hit - one hit for a motif
27 motif_mask - mask of the motif (space - gap, asterisk - significant position)
28 motif_score - MAP score of the motif - approx. N * log R, where R == (num. of actual occur.) / (num. of occur. expected by random.)
29
30 """
31 - def feed(self, handle, consumer):
32 """S.feed(handle, consumer)
33
34 Feed in a AlignACE report for scanning. handle is a file-like
35 object that contains the AlignACE report. consumer is a Consumer
36 object that will receive events as the report is scanned.
37 """
38 consumer.version(handle.readline())
39 consumer.command_line(handle.readline())
40 for line in handle:
41 if line.strip() == "":
42 consumer.noevent(line)
43 elif line[:4]=="Para":
44 consumer.parameters(line)
45 elif line[0]=="#":
46 consumer.sequence(line)
47 elif "=" in line:
48 consumer.parameter(line)
49 elif line[:5]=="Input":
50 consumer.sequences(line)
51 elif line[:5]=="Motif":
52 consumer.motif(line)
53 elif line[:3]=="MAP":
54 consumer.motif_score(line)
55 elif len(line.split("\t"))==4:
56 consumer.motif_hit(line)
57 elif "*" in line:
58 consumer.motif_mask(line)
59 else:
60 raise ValueError(line)
61
63 """Scannner for CompareACE output
64
65 Methods:
66 feed Feed data into the scanner.
67
68 The scanner generates (and calls the consumer) the following types of events:
69
70 motif_score - CompareACE score of motifs
71
72 ###### TO DO #############3
73 extend the scanner to include other, more complex outputs.
74 """
75 - def feed(self, handle, consumer):
76 """S.feed(handle, consumer)
77
78 Feed in a CompareACE report for scanning. handle is a file-like
79 object that contains the CompareACE report. consumer is a Consumer
80 object that will receive events as the report is scanned.
81 """
82 consumer.motif_score(handle.readline())
83