Skip to content

Commit

Permalink
Porechop: No barplots if no data.
Browse files Browse the repository at this point in the history
Closes #1850
  • Loading branch information
ewels committed Feb 8, 2023
1 parent bd976bb commit 0bb3f82
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Table code now tolerates lambda function calls with bad data ([#1739](https://github.com/ewels/MultiQC/issues/1739))
- Beeswarm plot now saves data to `multiqc_data`, same as tables ([#1861](https://github.com/ewels/MultiQC/issues/1861))
- Don't print DOI in module if it's set to an empty string.

### New Modules

Expand All @@ -23,6 +24,9 @@
- Fix bug that broke the module with paired-end data ([#1845](https://github.com/ewels/MultiQC/issues/1845))
- **HUMID**
- Fix bug that prevent HUMID stats files from being parsed ([#1856](https://github.com/ewels/MultiQC/issues/1856))
- **Porechop**
- Don't render bar graphs if no samples had any adapters trimmed ([#1850](https://github.com/ewels/MultiQC/issues/1850))
- Added report section listing samples that had no adapters trimmed

## [MultiQC v1.14](https://github.com/ewels/MultiQC/releases/tag/v1.14) - 2023-01-08

Expand Down
1 change: 1 addition & 0 deletions multiqc/modules/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(
self.doi_link = ""
if type(self.doi) is str:
self.doi = [self.doi]
self.doi = [i for i in self.doi if i != ""]
if len(self.doi) > 0:
doi_links = []
for doi in self.doi:
Expand Down
28 changes: 24 additions & 4 deletions multiqc/modules/porechop/porechop.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
anchor="porechop",
href="https://github.com/rrwick/Porechop",
info="a tool for finding and removing adapters from Oxford Nanopore reads.",
doi="",
# doi="", # No DOI available
)

# Find and load reports
Expand All @@ -38,9 +38,11 @@ def __init__(self):
self.write_data_file(self.porechop_data, "porechop")

self.porechop_general_stats()
self.start_trim_barplot()
self.end_trim_barplot()
self.middle_split_barplot()
if max(len(v) for v in self.porechop_data.values()) > 1:
self.start_trim_barplot()
self.end_trim_barplot()
self.middle_split_barplot()
self.no_adapters_found()

def parse_logs(self, logfile):
"""Parsing Logs. Note: careful of ANSI formatting log"""
Expand Down Expand Up @@ -241,3 +243,21 @@ def middle_split_barplot(self):
description="Shows the number of reads that were split due to adapter being present in middle of read.",
plot=bargraph.plot(self.porechop_data, cats, config),
)

def no_adapters_found(self):
"""Show any samples that did not have any trimming"""
no_adapters = []
for s_name in self.porechop_data:
if len(self.porechop_data[s_name]) == 1:
no_adapters.append(s_name)
if len(no_adapters):
self.add_section(
name="No adapters found",
anchor="porechop-noadapters",
description="The following samples did not have any adapters found - output reads were unchanged from input reads:",
content=f"""
<ul>
<li><code>{'</code></li><li><code>'.join(no_adapters)}</code></li>
</ul>
""",
)
2 changes: 1 addition & 1 deletion multiqc/utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def dois_tofile():
# Collect DOIs
dois = {"MultiQC": ["10.1093/bioinformatics/btw354"]}
for mod in modules_output:
if mod.doi is not None and mod.doi != []:
if mod.doi is not None and mod.doi != "" and mod.doi != []:
dois[mod.anchor] = mod.doi
# Write to a file
fn = "multiqc_citations.{}".format(config.data_format_extensions[config.data_format])
Expand Down

0 comments on commit 0bb3f82

Please sign in to comment.