Package Bio :: Package NBRF :: Module Record
[hide private]
[frames] | no frames]

Source Code for Module Bio.NBRF.Record

 1  # Copyright 2001 by Katharine Lindner.  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  """Martel based parser to read NBRF formatted files. 
 7   
 8  This is a huge regular regular expression for NBRF, built using 
 9  the 'regular expressiona on steroids' capabilities of Martel. 
10   
11  http://www-nbrf.georgetown.edu/pirwww/pirhome.shtml 
12   
13   
14  Notes: 
15  Just so I remember -- the new end of line syntax is: 
16    New regexp syntax - \R 
17       \R    means "\n|\r\n?" 
18       [\R]  means "[\n\r]" 
19   
20  This helps us have endlines be consistent across platforms. 
21   
22  """ 
23  # standard library 
24  import string 
25   
26   
27  from Bio.Seq import Seq 
28  from Bio.NBRF.ValSeq import valid_sequence_dict 
29   
30   
31   
32  """Hold NBRF data in a straightforward format. 
33   
34  classes: 
35  o Record - All of the information in an NBRF record. 
36  """ 
37   
38 -class Record:
39 """Hold NBRF information in a format similar to the original record. 40 41 The Record class is meant to make data easy to get to when you are 42 just interested in looking at NBRF data. 43 44 Attributes: 45 sequence_type 46 sequence_name 47 comment 48 sequence 49 50 """
51 - def __init__(self):
52 self.sequence_type = '' 53 self.sequence_name = '' 54 self.comment = '' 55 self.sequence = Seq('')
56
57 - def __str__( self ):
58 sequence_type = valid_sequence_dict[ self.sequence_type ] 59 output = 'Sequence type %s\n' % sequence_type 60 output = output + 'Sequence name %s\n' % self.sequence_name 61 output = output + '%s\n' % self.comment 62 output = output + out_sequence( self.sequence.data ) 63 return output
64
65 -def out_sequence( seq ):
66 output = '' 67 for j in range( 0, len( seq ), 80 ): 68 output = output + '%s\n' % seq[ j: j + 80 ] 69 output = output + '\n' 70 return output
71