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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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