Package Bio :: Package AlignAce :: Module Scanner
[hide private]
[frames] | no frames]

Source Code for Module Bio.AlignAce.Scanner

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