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   
24   
25  from Bio.Seq import Seq 
26  from Bio.NBRF.ValSeq import valid_sequence_dict 
27   
28   
29   
30  """Hold NBRF data in a straightforward format. 
31   
32  classes: 
33  o Record - All of the information in an NBRF record. 
34  """ 
35   
36 -class Record:
37 """Hold NBRF information in a format similar to the original record. 38 39 The Record class is meant to make data easy to get to when you are 40 just interested in looking at NBRF data. 41 42 Attributes: 43 sequence_type 44 sequence_name 45 comment 46 sequence 47 48 """
49 - def __init__(self):
50 self.sequence_type = '' 51 self.sequence_name = '' 52 self.comment = '' 53 self.sequence = Seq('')
54
55 - def __str__( self ):
56 sequence_type = valid_sequence_dict[ self.sequence_type ] 57 output = 'Sequence type %s\n' % sequence_type 58 output = output + 'Sequence name %s\n' % self.sequence_name 59 output = output + '%s\n' % self.comment 60 output = output + out_sequence( self.sequence.data ) 61 return output
62
63 -def out_sequence( seq ):
64 output = '' 65 for j in range( 0, len( seq ), 80 ): 66 output = output + '%s\n' % seq[ j: j + 80 ] 67 output = output + '\n' 68 return output
69