Package Bio :: Package SeqIO :: Module QualityIO :: Class FastqPhredWriter
[hide private]
[frames] | no frames]

Class FastqPhredWriter

source code

                     object --+        
                              |        
      Interfaces.SequenceWriter --+    
                                  |    
Interfaces.SequentialSequenceWriter --+
                                      |
                                     FastqPhredWriter

Class to write standard FASTQ format files (using PHRED quality scores).

Although you can use this class directly, you are strongly encouraged to use the Bio.SeqIO.write() function instead via the format name "fastq" or the alias "fastq-sanger". For example, this code reads in a standard Sanger style FASTQ file (using PHRED scores) and re-saves it as another Sanger style FASTQ file:

>>> from Bio import SeqIO
>>> record_iterator = SeqIO.parse(open("Quality/example.fastq"), "fastq")
>>> with open("Quality/temp.fastq", "w") as out_handle:
...     SeqIO.write(record_iterator, out_handle, "fastq")
3

You might want to do this if the original file included extra line breaks, which while valid may not be supported by all tools. The output file from Biopython will have each sequence on a single line, and each quality string on a single line (which is considered desirable for maximum compatibility).

In this next example, an old style Solexa/Illumina FASTQ file (using Solexa quality scores) is converted into a standard Sanger style FASTQ file using PHRED qualities:

>>> from Bio import SeqIO
>>> record_iterator = SeqIO.parse(open("Quality/solexa_example.fastq"), "fastq-solexa")
>>> with open("Quality/temp.fastq", "w") as out_handle:
...     SeqIO.write(record_iterator, out_handle, "fastq")
5

This code is also called if you use the .format("fastq") method of a SeqRecord, or .format("fastq-sanger") if you prefer that alias.

Note that Sanger FASTQ files have an upper limit of PHRED quality 93, which is encoded as ASCII 126, the tilde. If your quality scores are truncated to fit, a warning is issued.

P.S. To avoid cluttering up your working directory, you can delete this temporary file now:

>>> import os
>>> os.remove("Quality/temp.fastq")
Instance Methods [hide private]
 
write_record(self, record)
Write a single FASTQ record to the file.
source code

Inherited from Interfaces.SequentialSequenceWriter: __init__, write_file, write_footer, write_header, write_records

Inherited from Interfaces.SequenceWriter: clean

Inherited from Interfaces.SequenceWriter (private): _get_seq_string

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

write_record(self, record)

source code 

Write a single FASTQ record to the file.

Overrides: Interfaces.SequentialSequenceWriter.write_record