Skip to content

Commit

Permalink
add progress bar to read filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
jykr committed Oct 5, 2023
1 parent 32cc61a commit d591776
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions bean/mapping/GuideEditCounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,7 @@ def _check_names_filter_fastq(self, filter_by_qual=False):
)

R1_iter, R2_iter = self._get_fastq_iterators()
(
self.n_reads_after_filtering,
self.n_total_reads,
) = self._check_readname_match_and_filter_quality(
(self.n_reads_after_filtering) = self._check_readname_match_and_filter_quality(
R1_iter, R2_iter, filter_by_qual
)

Expand All @@ -768,9 +765,9 @@ def _check_readname_match_and_filter_quality(
R2_filtered = gzip.open(self.filtered_R2_filename, "wt+")

n_reads_after_filtering = 0
n_total_reads = 0
for R1_record, R2_record in zip(R1_iter, R2_iter):
n_total_reads += 1
for R1_record, R2_record in tqdm(
zip(R1_iter, R2_iter), total=self.n_total_reads
):
if R1_record.name != R2_record.name:
raise InputFileError(
"R1 and R2 read discordance in read {} and {}".format(
Expand Down Expand Up @@ -798,7 +795,7 @@ def _check_readname_match_and_filter_quality(
R1_filtered.write(R1_record.format("fastq"))
R2_filtered.write(R2_record.format("fastq"))

return n_reads_after_filtering, n_total_reads
return n_reads_after_filtering

def _write_start_log(self):
try:
Expand Down

0 comments on commit d591776

Please sign in to comment.