Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 0 division error in fastp module. #1489

Merged
merged 2 commits into from
Nov 7, 2021

Conversation

bjohnnyd
Copy link
Contributor

@bjohnnyd bjohnnyd commented Jul 10, 2021

Fixes issue where a division by 0 occurs if there are 0 reads in input fastq.

Additional fix on top of #1451 which updates CHANGELOG.md in 797674f.

fixes #1466
fixes #1444

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md has been updated

@bjohnnyd
Copy link
Contributor Author

bjohnnyd commented Jul 11, 2021

@ewels one thing to add is that this additional fix causes the warning to be reported twice. Would it be better to add the s_name to the warnings so that it is clear it refers to the same input sample/fastq? Essentially it would be: FastQ input file for sample <s_name> has zero raw reads.

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my phone so a bit tricky to review properly, but looks good - thanks! 👍🏻

Please just add to the log message which sample had zero reads. If the sample makes it through to the report (isn't skipped) and shows zero reads, then no log message is needed.

@@ -232,6 +232,8 @@ def parse_fastp_log(self, f):
) * 100.0
except KeyError:
log.debug("Could not calculate 'pct_adapter': {}".format(f["fn"]))
except ZeroDivisionError:
log.warning("FastQ input file has zero raw reads")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please log the sample name here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I'd be inclined to just merge this with the catch / log message above.. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to either report once per sample or report the sample in the message. What is your opinion of adding a pass instead of logging sample?

Using the data from #1499 and MultiQC build from 2dd31c1 results in the following:

  /// MultiQC 🔍 | v1.12.dev0

|           multiqc | Search path : /home/johnny/data/testing/multiqc_fastp_bug/PCRblank.fastp.json
|         searching | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 1/1
|             fastp | FastQ input file has zero raw reads
|             fastp | FastQ input file has zero raw reads
|             fastp | Found 1 reports
|           multiqc | Compressing plot data
|           multiqc | Report      : report/multiqc_report.html
|           multiqc | Data        : report/multiqc_data
|           multiqc | MultiQC complete

which I think is confusing given that it is one sample.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sample does make it into the report.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Yup, I think that we're saying the same thing here - as it is the error message is a bit confusing (repeated, sample is still there).

So I was suggesting that we log the same name (no longer repeated) or just merge with the statement above (debug so not in the main console output unless verbose, also specifies what is going wrong and the sample name). I think I'll go for the latter if that's ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked in fe471c6

@ewels
Copy link
Member

ewels commented Jul 27, 2021

Does this also fix #1499 ?

@ewels ewels linked an issue Nov 7, 2021 that may be closed by this pull request
@ewels ewels enabled auto-merge November 7, 2021 21:35
@ewels ewels merged commit 13bed18 into MultiQC:master Nov 7, 2021
@ewels ewels mentioned this pull request Nov 7, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants