Created
June 9, 2014 16:01
-
-
Save nickloman/3345d05e3a4642b5306c to your computer and use it in GitHub Desktop.
fast5tofasta.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
from Bio import SeqIO | |
from StringIO import StringIO | |
import sys | |
keys = {'template' : '/Analyses/Basecall_2D_000/BaseCalled_template/Fastq', | |
'complement' : '/Analyses/Basecall_2D_000/BaseCalled_complement/Fastq', | |
'twodirections' : '/Analyses/Basecall_2D_000/BaseCalled_2D/Fastq'} | |
for fn in sys.argv[1:]: | |
hdf = h5py.File(fn, 'r') | |
for id, key in keys.iteritems(): | |
try: | |
fq = hdf[key][()] | |
rec = SeqIO.read(StringIO(fq), "fastq") | |
rec.id += "_" + id | |
SeqIO.write([rec], sys.stdout, "fasta") | |
except Exception, e: | |
pass | |
hdf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment