Fastq to Fasta

Inspired by solutions posted at biostar, here is my contribution to this simple sequencing file format conversion.

## fastq_to_fa.py
import sys
from Bio.SeqIO.QualityIO import FastqGeneralIterator
for title, seq, qual in FastqGeneralIterator(sys.stdin) :
 print(">%s\\n%s" % (title,seq))

Usage:

 cat reads.fastq | fastq_to_fa.py

If you need to simply extract sequences…that is also simple!

## flattenFastq.py
for title, seq, qual in FastqGeneralIterator(sys.stdin) :
    print("%s" % (seq))

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.