Skip to content

Commit

Permalink
Merge pull request #134 from rhpvorderman/release_0.7.1
Browse files Browse the repository at this point in the history
Release 0.7.1
  • Loading branch information
rhpvorderman committed Apr 17, 2024
2 parents af3f835 + 9c94f49 commit a284b91
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 14 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- docs
- lint
- pedantic_compile
- html5validator
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -49,15 +50,15 @@ jobs:
os: ["ubuntu-latest"]
include:
# Macos X86
- os: "macos-13"
python-version: "3.8"
- os: "macos-13"
python-version: "3.12"
# Macos ARM m1
- os: "macos-latest"
python-version: "3.8"
- os: "macos-latest"
python-version: "3.12"
# Macos ARM m1
- os: "macos-14"
python-version: "3.10"
- os: "macos-14"
python-version: "3.12"
- os: "windows-latest"
python-version: "3.8"
- os: "windows-latest"
Expand Down Expand Up @@ -97,12 +98,12 @@ jobs:
deploy:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ${{ matrix.os }}
needs: [package-checks, test]
needs: [package-checks, test, test-arch]
strategy:
matrix:
os:
- ubuntu-latest
- macos-13
- macos-14
- macos-latest
- windows-latest
cibw_archs_linux: ["x86_64"]
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Changelog
.. This document is user facing. Please word the changes in such a way
.. that users understand how the changes affect the new version.
version 0.7.1
-----------------
+ Fix a small visual bug in the report sidebar.
+ PyGAL report htmls are now fully HTML5 compliant. HTML5 validation has been
made a part of the integration testing.

version 0.7.0
-----------------
+ Image files can now be saved as SVG files.
Expand Down
55 changes: 48 additions & 7 deletions src/sequali/report_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ def create_toc(content: str):
if header_level != current_level:
if header_level > current_level:
for i in range(header_level - current_level):
toc.write('<ul class="toc_list">')
toc.write('<li><ul class="toc_list">')
else:
for i in range(current_level - header_level):
toc.write("</ul>")
toc.write("</ul></li>")
current_level = header_level
toc.write(f'<li><a class="toclink" href="#{id}">{header}</a></li>')
if current_level > 0:
Expand All @@ -152,8 +152,51 @@ def create_toc(content: str):
return toc.getvalue()


def make_series_unique(svg: str) -> str:
"""
Processes a PyGAL SVG to have unique serie IDs to fix
https://github.com/Kozea/pygal/issues/563.
"""
# TODO: Remove this once a fix is released in PyGAL and the PyGAL
# requirement is updated.
svg_element: xml.etree.ElementTree.Element = xml.etree.ElementTree.fromstring(svg)
if not svg_element.tag.endswith("svg"):
raise ValueError("This is not a svg xml")
namespace = svg_element.tag.rstrip("svg")
xml.etree.ElementTree.register_namespace("", namespace.strip("{}"))
chart_id = svg_element.attrib["id"]
for element in svg_element.iter():
if not element.tag == f"{namespace}g":
continue
id = element.get("id")
# Find activate-serie elements and append chart-id to their name to
# make them unique.
if id and id.startswith("activate-serie"):
element.set("id", f"{id}-{chart_id}")
continue

# Individual series have a class attribute serie-<NUMBER> format.
# Append the chart_id to make these unique.
cls = element.get("class")
if cls and "serie-" in cls:
classifiers = cls.split()
for classifier in classifiers:
if classifier.startswith("serie-"):
to_replace = classifier
break
else: # No break
raise RuntimeError("serie classifier should exist")
classifiers.remove(to_replace)
new_classifier = f"{to_replace}-{chart_id}"
classifiers.append(new_classifier)
element.set("class", " ".join(classifiers))
return xml.etree.ElementTree.tostring(
svg_element, encoding="unicode", method="xml")


def figurize_plot(plot: pygal.Graph):
svg_unicode = plot.render(is_unicode=True)
svg_unicode = make_series_unique(svg_unicode)
svg_tree: xml.etree.ElementTree.Element = (
xml.etree.ElementTree.fromstring(svg_unicode))
svg_id = svg_tree.get("id")
Expand Down Expand Up @@ -425,7 +468,7 @@ def distribution_table(self):
def to_html(self):
return f"""
{html_header("Sequence length distribution", 1)}
<p>{self.distribution_table()}</p>
{self.distribution_table()}
{figurize_plot(self.plot())}
"""

Expand Down Expand Up @@ -678,7 +721,7 @@ def plot(self) -> pygal.Graph:
def to_html(self) -> str:
return f"""
{html_header("Per sequence average quality scores", 1)}
<p>{self.quality_scores_table()}</p>
{self.quality_scores_table()}
{figurize_plot(self.plot())}
"""

Expand Down Expand Up @@ -1121,7 +1164,6 @@ def to_html(self):
estimate the duplication rate. See
<a href="https://sequali.readthedocs.io/#duplication-estimation-module">
the documentation</a> for a complete explanation.</p>
<p>
<table>
<tr>
<td>Fingerprint front sequence length</td>
Expand Down Expand Up @@ -1158,7 +1200,6 @@ def to_html(self):
<td style="text-align:right;">{self.remaining_fraction:.2%}</td>
</tr>
</table>
</p>
"""
return f"""
{html_header("Duplication percentages", 1)}
Expand Down Expand Up @@ -1683,6 +1724,7 @@ def write_html_report(report_modules: Iterable[ReportModule],
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
{SEQUALI_REPORT_JS_CONTENT}
</script>
Expand All @@ -1692,7 +1734,6 @@ def write_html_report(report_modules: Iterable[ReportModule],
<style>
{SEQUALI_REPORT_CSS_CONTENT}
</style>
<meta charset="utf-8">
<title>{os.path.basename(filename)}: Sequali Report</title>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions src/sequali/static/sequali_report.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
body {
font-family: sans;
width:100%;
margin: 0px;
}

/* Use h2 header settings for h1 etc. to have more understated headers. */
Expand Down
11 changes: 11 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,14 @@ commands=
# -a rebuilds everything. -W turns warnings into errors.
# --keep-going makes sure we see al the errors that are there in one go.
sphinx-build -a -W -n --keep-going docs docs/_build


[testenv:html5validator]
deps=html5validator
allowlist_externals=bash
mkdir
commands=
mkdir -p reports
bash -c 'for FILE in tests/data/*.fastq tests/data/*.fastq.gz tests/data/*.bam; do sequali --outdir reports $FILE; done'
# || exit 1 needed to force crashes when html5validator fails with 255
bash -c 'html5validator -- reports/*.html || exit 1'

0 comments on commit a284b91

Please sign in to comment.