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

Source Code for Module Bio.Saf.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 SAF formatted files. 
 7   
 8  This is a huge regular regular expression for Saf, built using 
 9  the 'regular expressiona on steroids' capabilities of Martel. 
10   
11  #http://www.embl-heidelberg.de/predictprotein/Dexa/optin_safDes.html 
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.Align.Generic import Alignment 
29  import Bio.Alphabet 
30   
31   
32   
33  """Hold SAF data in a straightforward format. 
34   
35  classes: 
36  o Record - All of the information in an Saf record. 
37  """ 
38   
39 -class Record:
40 """Hold Saf information in a format similar to the original record. 41 42 The Record class is meant to make data easy to get to when you are 43 just interested in looking at Saf data. 44 45 Attributes: 46 alignment 47 48 """
49 - def __init__(self):
51
52 - def __str__( self ):
53 output = '' 54 sequences = self.alignment.get_all_seqs() 55 for sequence_record in sequences: 56 output = output + '%s\n' % sequence_record.description 57 # output = output + out_sequence( sequence_record.seq.data ) 58 output = output + out_sequence( sequence_record.seq.data ) 59 return output
60
61 -def out_sequence( seq ):
62 output = '' 63 for j in range( 0, len( seq ), 80 ): 64 output = output + '%s\n' % seq[ j: j + 80 ] 65 output = output + '\n' 66 return output
67