Skip to content

Commit

Permalink
Hicpro: fix parsing scientific notation in hicpro-ashic. Thanks @Just…
Browse files Browse the repository at this point in the history
…-Roma (#2126)

* Hicpro: fix parsing numbers is scientific notation. Thanks @Just-Roma

* [automated] Update CHANGELOG.md

---------

Co-authored-by: MultiQC Bot <multiqc-bot@seqera.io>
Co-authored-by: Phil Ewels <phil.ewels@seqera.io>
  • Loading branch information
3 people committed Oct 16, 2023
1 parent 38af35e commit 21aded9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 21aded9

Please sign in to comment.