Class FastqPhredWriter
source code
Interfaces.SequenceWriter --+
|
Interfaces.SequentialSequenceWriter --+
|
FastqPhredWriter
Class to write 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. For example, this code
reads in a FASTQ (PHRED) file and re-saves it as another FASTQ (PHRED)
file:
>>> from Bio import SeqIO
>>> record_iterator = SeqIO.parse(open("Quality/example.fastq"), "fastq")
>>> out_handle = open("Quality/temp.fastq", "w")
>>> SeqIO.write(record_iterator, out_handle, "fastq")
3
>>> out_handle.close()
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, a Solexa FASTQ file is converted into a standard
Sanger style FASTQ file using PHRED qualities:
>>> from Bio import SeqIO
>>> record_iterator = SeqIO.parse(open("Quality/solexa.fastq"), "fastq-solexa")
>>> out_handle = open("Quality/temp.fastq", "w")
>>> SeqIO.write(record_iterator, out_handle, "fastq")
1
>>> out_handle.close()
This code is also called if you use the .format("fastq")
method of a SeqRecord.
P.S. To avoid cluttering up your working directory, you can delete
this temporary file now:
>>> import os
>>> os.remove("Quality/temp.fastq")