Created
May 14, 2015 22:39
-
-
Save mpkocher/2c6fa8afd0e82a2d8d3e to your computer and use it in GitHub Desktop.
Bam Records to Fasta
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
from pbcore.io import FastaReader, BamReader | |
def to_records(reader_klass, transform_func, file_name): | |
with reader_klass(file_name) as r: | |
for record in r: | |
yield transform_func(record) | |
def bam_record_to_fasta_record(b_record): | |
# fill me in here | |
return b_record | |
def bam_or_fasta(file_name): | |
reader = FastaReader | |
t_func = lambda x: x | |
if file_name.endswith(".bam"): | |
reader = BamReader | |
t_func = bam_record_to_fasta_record | |
return to_records(reader, t_func, file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment