Back to index

python-biopython  1.60
Classes | Functions
Bio.SeqIO.PhdIO Namespace Reference

Classes

class  PhdWriter

Functions

def PhdIterator
def _test

Function Documentation

def Bio.SeqIO.PhdIO._test ( ) [private]
Run the Bio.SeqIO.PhdIO module's doctests.

This will try and locate the unit tests directory, and run the doctests
from there in order that the relative paths used in the examples work.

Definition at line 147 of file PhdIO.py.

00147 
00148 def _test():
00149     """Run the Bio.SeqIO.PhdIO module's doctests.
00150 
00151     This will try and locate the unit tests directory, and run the doctests
00152     from there in order that the relative paths used in the examples work.
00153     """
00154     import doctest
00155     import os
00156     if os.path.isdir(os.path.join("..", "..", "Tests")):
00157         print "Runing doctests..."
00158         cur_dir = os.path.abspath(os.curdir)
00159         os.chdir(os.path.join("..", "..", "Tests"))
00160         assert os.path.isfile("Phd/phd1")
00161         doctest.testmod()
00162         os.chdir(cur_dir)
00163         del cur_dir
00164         print "Done"
        
def Bio.SeqIO.PhdIO.PhdIterator (   handle)
Returns SeqRecord objects from a PHD file.

This uses the Bio.Sequencing.Phd module to do the hard work.

Definition at line 61 of file PhdIO.py.

00061 
00062 def PhdIterator(handle):
00063     """Returns SeqRecord objects from a PHD file.
00064 
00065     This uses the Bio.Sequencing.Phd module to do the hard work.
00066     """
00067     phd_records = Phd.parse(handle)
00068     for phd_record in phd_records:
00069         #Convert the PHY record into a SeqRecord...
00070         #The "filename" can contain spaces, e.g. 'HWI-EAS94_4_1_1_602_99 1'
00071         #from unit test example file phd_solexa.
00072         #This will cause problems if used as the record identifier
00073         #(e.g. output for FASTQ format).
00074         name = phd_record.file_name.split(None, 1)[0]
00075         seq_record = SeqRecord(phd_record.seq,
00076                                id = name, name = name,
00077                                description= phd_record.file_name)
00078         #Just re-use the comments dictionary as the SeqRecord's annotations
00079         seq_record.annotations = phd_record.comments
00080         #And store the qualities and peak locations as per-letter-annotation
00081         seq_record.letter_annotations["phred_quality"] = \
00082                 [int(site[1]) for site in phd_record.sites]
00083         try:
00084             seq_record.letter_annotations["peak_location"] = \
00085                     [int(site[2]) for site in phd_record.sites]
00086         except IndexError:
00087             # peak locations are not always there according to
00088             # David Gordon (the Consed author)
00089             pass
00090         yield seq_record 
00091     #All done