def filter_fastq(input_file,output_file,downweight_number,ctot,gtoa):
"""
Takes a Fastq file as input and weights the quality of the bases down
at the start and the end of the reads.
"""
in_iterator = SeqIO.parse(input_file,'fastq')
input_records=list(in_iterator)
for i, record in enumerate(input_records):
change_bases_c = None
change_bases_t = None
temp_qual = record.letter_annotations['phred_quality']
if(ctot):
change_bases_c = [check_c_2_t(nuc) and i < downweight_number for i, nuc in enumerate(record.seq)]
if(gtoa):
change_bases_t = [check_g_2_a(nuc) and (len(record.seq)-i) <= downweight_number for i, nuc in enumerate(record.seq)]
new_qual =downweight_quality(temp_qual, change_bases_c ,change_bases_t)
input_records[i].letter_annotations['phred_quality']=new_qual
handle = file(output_file,'wt')
SeqIO.write(input_records, handle, "fastq")
评论列表
文章目录