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

Hicpro: fix parsing scientific notation in hicpro-ashic. Thanks @Just-Roma #2126

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
### Module updates

- **FastQC**: Add top overrepresented sequences table ([#2075](https://github.com/ewels/MultiQC/pull/2075))
- **HiCPro**: fix parsing scientific notation in hicpro-ashic. Thanks @Just-Roma ([#2126](https://github.com/ewels/MultiQC/pull/2126))
- **Picard**: MarkDuplicates: Fix parsing mixed strings/numbers, account for missing trailing `0` ([#2083](https://github.com/ewels/MultiQC/pull/2083), [#2094](https://github.com/ewels/MultiQC/pull/2094))
- **WhatsHap**: Process truncated input with no ALL chromosome ([#2095](https://github.com/ewels/MultiQC/pull/2095))

Expand Down
16 changes: 13 additions & 3 deletions multiqc/modules/hicpro/hicpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self):
self.add_section(
name="Capture analysis",
anchor="hicpro-cap",
description="Selection of interactions overlaping the targeted region(s).",
description="Selection of interactions overlapping the targeted region(s).",
helptext="""
Description of capture efficiency. Valid interactions with either two (capture-capture) or
one (capture-reporter) interactors overlapping with the target(s) are reported.""",
Expand All @@ -159,7 +159,18 @@ def parse_hicpro_stats(self, f, rsection):
s = l.split("\t")
if s[0] in self.hicpro_data[s_name]:
log.debug("Duplicated keys found! Overwriting: {}".format(s[0]))
self.hicpro_data[s_name][s[0]] = int(s[1])
# Try to convert the extracted value to a number and store it in hicpro_data.
# try-block is used to prevent program crash, because there is no
# guarantee that the value (s[1]) can be always converted to integer.
try:
self.hicpro_data[s_name][s[0]] = int(s[1])
except ValueError:
# Convert to float (also works for inf and scientific (exponential) notation).
try:
self.hicpro_data[s_name][s[0]] = float(s[1])
# Otherwise just store the value as is.
except ValueError:
self.hicpro_data[s_name][s[0]] = s[1]

def hicpro_stats_table(self):
"""Add HiC-Pro stats to the general stats table"""
Expand Down Expand Up @@ -300,7 +311,6 @@ def hicpro_mapping_chart(self):
config = {
"id": "hicpro_mapping_stats_plot",
"title": "HiC-Pro: Mapping Statistics",
"ylab": "# Reads",
"ylab": "# Reads: Read 1",
"data_labels": [
{"name": "Read 1", "ylab": "# Reads: Read 1"},
Expand Down