Skip to content

Commit

Permalink
Use a TrueType font for plotting sequence names with last/dotplot. (#…
Browse files Browse the repository at this point in the history
…7404)

* Use a TrueType font for plotting sequence names with `last/dotplot`.

The `last-dotplot` command normally picks scalable fonts by default but
did not manage to do so on the conda install in the images.  Therefore I
hardcode the path (which is likely to change when the images are
updated).

Not using a scalable font prevents users from changing the font size
using the command-line argument `-s` of `last-dotplot`.

In addition, I found that the CI tests did not check the outputted
images, and corrected that too in this commit.

* Pin pillow version and query conda for its base directory.

Thanks: Leon Hafner

* Avoid unbound variable error, thanks to ChatGPT

* Try a different way to find pillow's TrueType font in conda.

* Fix typo

* Try finding a font in the open-fonts package.

* Desperate attempt to pull the information

* Bingo!

* Unpin pillow
  • Loading branch information
charles-plessy authored Feb 3, 2025
1 parent 256a6dd commit ea8c309
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 23 deletions.
1 change: 1 addition & 0 deletions modules/nf-core/last/dotplot/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ channels:

dependencies:
- bioconda::last=1608
- conda-forge::open-fonts=0.7.0
7 changes: 5 additions & 2 deletions modules/nf-core/last/dotplot/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process LAST_DOTPLOT {

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/db/db0b5de918238f07ec1ca668be942397da85e26aa582f8927ac37c70896303cf/data'
: 'community.wave.seqera.io/library/last:1608--f41c047f7dc37e30'}"
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/a3/a35d17772276115874eda45f17b05407c9855ecec8c11d39cce49f0028f44cfb/data'
: 'community.wave.seqera.io/library/last_open-fonts:f1048938520a62ad'}"

input:
tuple val(meta), path(maf), path(annot_b)
Expand All @@ -26,7 +26,10 @@ process LAST_DOTPLOT {
def annot_a_arg = annot_a ? "-a ${annot_a}" : ''
def annot_b_arg = annot_b ? "-b ${annot_b}" : ''
"""
TTF=/home/ubuntu/conda_pkgs_dir/open-fonts-0.7.0-1/fonts/open-fonts/DejaVuSansMono-Regular.ttf
[ -e "\$TTF" ] || TTF="/opt/conda/fonts/open-fonts/DejaVuSansMono-Regular.ttf"
last-dotplot \\
-f \$TTF \\
$args \\
$annot_a_arg \\
$annot_b_arg \\
Expand Down
9 changes: 3 additions & 6 deletions modules/nf-core/last/dotplot/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() },
{ assert process.out.png.get(0).get(1).endsWith("test.png") }
{ assert snapshot(process.out).match() }
)
}

Expand All @@ -58,8 +57,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() },
{ assert process.out.gif.get(0).get(1).endsWith("test.gif") }
{ assert snapshot(process.out).match() }
)
}

Expand All @@ -85,8 +83,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() },
{ assert process.out.png.get(0).get(1).endsWith("test.png") }
{ assert snapshot(process.out).match() }
)
}

Expand Down
111 changes: 96 additions & 15 deletions modules/nf-core/last/dotplot/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,38 +1,119 @@
{
"sarscov2 - contigs - genome - gif": {
"content": [
[
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
{
"0": [
[
{
"id": "test"
},
"test.gif:md5,cec730f1d060a82553cefe2311708bad"
]
],
"1": [

],
"2": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
],
"gif": [
[
{
"id": "test"
},
"test.gif:md5,cec730f1d060a82553cefe2311708bad"
]
],
"png": [

],
"versions": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
"nextflow": "24.10.4"
},
"timestamp": "2025-01-21T09:18:32.629314"
"timestamp": "2025-02-03T09:27:56.241408"
},
"sarscov2 - contigs - genome - png - stub": {
"content": [
[
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
{
"0": [

],
"1": [
[
{
"id": "test"
},
"test.png:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
],
"gif": [

],
"png": [
[
{
"id": "test"
},
"test.png:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
"nextflow": "24.10.4"
},
"timestamp": "2025-01-21T09:18:48.084683"
"timestamp": "2025-01-31T09:55:40.665796"
},
"sarscov2 - contigs - genome - png": {
"content": [
[
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
{
"0": [

],
"1": [
[
{
"id": "test"
},
"test.png:md5,005267881455bdab7c8bd87ec27060f8"
]
],
"2": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
],
"gif": [

],
"png": [
[
{
"id": "test"
},
"test.png:md5,005267881455bdab7c8bd87ec27060f8"
]
],
"versions": [
"versions.yml:md5,143ef48514afd0c39da64d8f11fd18f7"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
"nextflow": "24.10.4"
},
"timestamp": "2025-01-21T09:18:17.971205"
"timestamp": "2025-02-03T09:27:41.83809"
}
}

0 comments on commit ea8c309

Please sign in to comment.