Package Bio :: Package SeqIO :: Module PhdIO
[hide private]
[frames] | no frames]

Source Code for Module Bio.SeqIO.PhdIO

 1  # Copyright 2008 by Peter Cock.  All rights reserved. 
 2  # 
 3  # This code is part of the Biopython distribution and governed by its 
 4  # license.  Please see the LICENSE file that should have been included 
 5  # as part of this package. 
 6   
 7  """Bio.SeqIO support for the "phd" file format. 
 8   
 9  PHD files are output by PHRED and used by PHRAP and CONSED. 
10   
11  You are expected to use this module via the Bio.SeqIO functions. 
12  See also the underlying Bio.Sequencing.Phd module.""" 
13   
14  from Bio.SeqRecord import SeqRecord 
15  from Bio.Sequencing import Phd 
16       
17  #This is a generator function! 
18 -def PhdIterator(handle) :
19 """Returns SeqRecord objects from a PHD file. 20 21 This uses the Bio.Sequencing.Phy module to do the hard work. 22 """ 23 24 phd_records = Phd.parse(handle) 25 for phd_record in phd_records: 26 #Convert the PHY record into a SeqRecord... 27 seq_record = SeqRecord(phd_record.seq, 28 id = phd_record.file_name, 29 name = phd_record.file_name) 30 #Just re-use the comments dictionary as the SeqRecord's annotations 31 seq_record.annotations = phd_record.comments 32 yield seq_record
33 #All done 34 35 if __name__ == "__main__" : 36 print "Quick self test" 37 handle = open("../../Tests/Phd/Phd1") 38 for record in PhdIterator(handle) : 39 print record 40 handle.close() 41 print "Done" 42