def check_filters(fast5_file, min_length, min_mean_qual, min_qual_window, window_size):
try:
hdf5_file = h5py.File(fast5_file, 'r')
names = get_hdf5_names(hdf5_file)
basecall_location = get_best_fastq_hdf5_location(hdf5_file, names)
if basecall_location:
fastq_str = hdf5_file[basecall_location].value
try:
parts = fastq_str.split(b'\n')
seq, quals = parts[1], parts[3]
except IndexError:
fastq_str, seq, quals = '', '', ''
if not fastq_str or not seq:
return False, 0
if min_mean_qual and get_mean_qscore(quals) < min_mean_qual:
return False, 0
if min_length and len(seq) < min_length:
return False, 0
if min_qual_window and get_min_window_qscore(quals, window_size) < min_qual_window:
return False, 0
return True, len(seq)
except (IOError, RuntimeError):
pass
return False, 0
评论列表
文章目录