Skip to content

fix: Fastq screen missing PNG #4284

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

Merged
merged 18 commits into from
Jun 20, 2025
Merged

Conversation

tdayris
Copy link
Contributor

@tdayris tdayris commented Jun 20, 2025

This PR fixes the issue (on github actions and alpine-linux containers) with FastqScreen not finding GD::Graph::bars and not building PNG files. This also makes all IO optional, in case some architecture still have issues with PNG file.

Finally, I used with statement to handle temporary directory and its content.

PS: I unfortunately made the mistake to start this branch from my previous pyfaidx branch, so it's a bit noisy in the commit logs... Now that pyfaidx has been accepted, its a bit better to read.

QC

While the contributions guidelines are more extensive, please particularly ensure that:

  • test.py was updated to call any added or updated example rules in a Snakefile
  • input: and output: file paths in the rules can be chosen arbitrarily
  • wherever possible, command line arguments are inferred and set automatically (e.g. based on file extensions in input: or output:)
  • temporary files are either written to a unique hidden folder in the working directory, or (better) stored where the Python function tempfile.gettempdir() points to
  • the meta.yaml contains a link to the documentation of the respective tool or command under url:
  • conda environments use a minimal amount of channels and packages, in recommended ordering

Summary by CodeRabbit

  • New Features

    • Added support for generating and saving the FastQ-Screen configuration file as an output.
    • Enhanced flexibility to run FastQ-Screen with or without PNG output, and with inline configuration.
  • Bug Fixes

    • Improved temporary file handling and cleanup for more reliable execution.
  • Documentation

    • Updated metadata to include a new author and repository URL.
    • Clarified and expanded output file descriptions.
  • Chores

    • Updated environment dependencies and package versions for improved compatibility and performance.
    • Expanded test coverage to include new output scenarios.

Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough

"""

Walkthrough

The updates enhance the fastq_screen bioinformatics wrapper by adding new configuration and output options, updating environment dependencies, and expanding test coverage. Changes include new rule variants in the test workflow, improved temporary file handling in the wrapper, metadata updates, and the addition of new Perl and system package dependencies.

Changes

Files/Paths Change Summary
bio/fastq_screen/environment.linux-64.pin.txt Updated package versions, added new dependencies, removed some old packages, and changed some package sources.
bio/fastq_screen/environment.yaml Removed bowtie and bowtie2, added perl-gdgraph-histogram dependency.
bio/fastq_screen/meta.yaml Added new author and GitHub URL, marked outputs as optional, added optional conf output, updated notes.
bio/fastq_screen/test/Snakefile Enhanced existing rule with logging and threads, added two new rules for config file output and no-PNG output.
bio/fastq_screen/wrapper.py Refactored temp directory handling using context manager, improved config file logic, updated logging, conditional output moves.
test_wrappers.py Extended test_fastq_screen to test new output scenarios for config and no-PNG outputs.

Sequence Diagram(s)

sequenceDiagram
    participant Snakemake
    participant Wrapper (wrapper.py)
    participant fastq_screen
    participant TempDir

    Snakemake->>Wrapper (wrapper.py): Run with inputs, outputs, params (possibly config dict)
    Wrapper (wrapper.py)->>TempDir: Create temporary directory (context manager)
    alt Config is dict
        Wrapper (wrapper.py)->>TempDir: Write config file
    else Config is file path
        Wrapper (wrapper.py)->>TempDir: Use config file directly
    end
    Wrapper (wrapper.py)->>fastq_screen: Call fastq_screen with appropriate config and outputs
    fastq_screen-->>Wrapper (wrapper.py): Generate outputs (txt, png, optional conf)
    Wrapper (wrapper.py)->>TempDir: Move outputs to final locations (conditional on snakemake.output)
    TempDir-->>Wrapper (wrapper.py): Cleanup temporary directory (automatic)
Loading

Suggested labels

bio/bbtools

Suggested reviewers

  • fgvieira
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eca16d8 and 45f8357.

📒 Files selected for processing (1)
  • bio/fastq_screen/wrapper.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Do not try to improve formatting. Do not suggest type annotations for functions that are defined inside of functions or methods. Do not suggest type annotation of the `s...

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

  • bio/fastq_screen/wrapper.py
`**/wrapper.py`: Do not complain about use of undefined variable called `snakemake`.

**/wrapper.py: Do not complain about use of undefined variable called snakemake.

  • bio/fastq_screen/wrapper.py
🪛 Ruff (0.11.9)
bio/fastq_screen/wrapper.py

11-11: Undefined name snakemake

(F821)


13-13: Undefined name snakemake

(F821)


14-14: Undefined name snakemake

(F821)


15-15: Undefined name snakemake

(F821)


16-16: Undefined name snakemake

(F821)


20-20: Undefined name snakemake

(F821)


55-55: Undefined name snakemake

(F821)


59-59: Undefined name snakemake

(F821)


63-63: Undefined name snakemake

(F821)

🪛 Pylint (3.3.7)
bio/fastq_screen/wrapper.py

[error] 11-11: Undefined variable 'snakemake'

(E0602)


[error] 13-13: Undefined variable 'snakemake'

(E0602)


[error] 14-14: Undefined variable 'snakemake'

(E0602)


[error] 15-15: Undefined variable 'snakemake'

(E0602)


[error] 16-16: Undefined variable 'snakemake'

(E0602)


[error] 20-20: Undefined variable 'snakemake'

(E0602)


[error] 55-55: Undefined variable 'snakemake'

(E0602)


[error] 59-59: Undefined variable 'snakemake'

(E0602)


[error] 63-63: Undefined variable 'snakemake'

(E0602)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: docs
  • GitHub Check: testing
  • GitHub Check: Summary
🔇 Additional comments (5)
bio/fastq_screen/wrapper.py (5)

6-8: LGTM! Author metadata properly updated.

The addition of the second contributor with proper formatting is appropriate.


16-16: Good improvement: Enhanced logging configuration.

Adding append=True ensures log continuity, which is beneficial for debugging and maintaining complete execution logs.


23-39: Excellent refactor: Proper temporary directory management.

The switch to using tempfile.TemporaryDirectory() as a context manager is a best practice that ensures automatic cleanup and eliminates potential resource leaks. The conditional config file creation logic is well-structured.


41-52: Well-formatted shell command execution.

The command is clearly structured and readable. The execution within the temporary directory context ensures proper file handling.


54-65: Smart solution: Conditional output handling addresses PNG generation issues.

Making output file moves conditional based on their presence in snakemake.output directly addresses the PR objective of handling platforms where PNG generation fails. This approach allows the wrapper to succeed even when certain outputs cannot be generated, improving robustness across different environments.

The addition of config file output support (conf) is also a valuable enhancement.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4797c9 and 435836b.

📒 Files selected for processing (6)
  • bio/fastq_screen/environment.linux-64.pin.txt (1 hunks)
  • bio/fastq_screen/environment.yaml (1 hunks)
  • bio/fastq_screen/meta.yaml (2 hunks)
  • bio/fastq_screen/test/Snakefile (1 hunks)
  • bio/fastq_screen/wrapper.py (1 hunks)
  • test_wrappers.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Do not try to improve formatting. Do not suggest type annotations for functions that are defined inside of functions or methods. Do not suggest type annotation of the `s...

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

  • bio/fastq_screen/wrapper.py
  • test_wrappers.py
`**/wrapper.py`: Do not complain about use of undefined variable called `snakemake`.

**/wrapper.py: Do not complain about use of undefined variable called snakemake.

  • bio/fastq_screen/wrapper.py
🧠 Learnings (1)
bio/fastq_screen/meta.yaml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-wrappers#3123
File: utils/datavzrd/wrapper.py:31-32
Timestamp: 2024-08-21T08:30:42.757Z
Learning: In `wrapper.py` scripts, do not flag the use of an undefined variable called `snakemake`.
Learnt from: johanneskoester
PR: snakemake/snakemake-wrappers#3123
File: utils/datavzrd/wrapper.py:31-32
Timestamp: 2024-10-08T17:41:54.542Z
Learning: In `wrapper.py` scripts, do not flag the use of an undefined variable called `snakemake`.
🪛 Ruff (0.11.9)
bio/fastq_screen/wrapper.py

11-11: Undefined name snakemake

(F821)


13-13: Undefined name snakemake

(F821)


14-14: Undefined name snakemake

(F821)


15-15: Undefined name snakemake

(F821)


16-16: Undefined name snakemake

(F821)


20-20: Undefined name snakemake

(F821)


54-54: Undefined name snakemake

(F821)


58-58: Undefined name snakemake

(F821)


62-62: Undefined name snakemake

(F821)

🪛 Pylint (3.3.7)
bio/fastq_screen/wrapper.py

[error] 11-11: Undefined variable 'snakemake'

(E0602)


[error] 13-13: Undefined variable 'snakemake'

(E0602)


[error] 14-14: Undefined variable 'snakemake'

(E0602)


[error] 15-15: Undefined variable 'snakemake'

(E0602)


[error] 16-16: Undefined variable 'snakemake'

(E0602)


[error] 20-20: Undefined variable 'snakemake'

(E0602)


[error] 54-54: Undefined variable 'snakemake'

(E0602)


[error] 58-58: Undefined variable 'snakemake'

(E0602)


[error] 62-62: Undefined variable 'snakemake'

(E0602)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: testing
  • GitHub Check: docs
  • GitHub Check: Summary
🔇 Additional comments (12)
bio/fastq_screen/environment.yaml (1)

9-9: Verify availability and pin consistency of the new Perl package.
Ensure that perl-gdgraph-histogram=1.1 is published on both the conda-forge and bioconda channels to avoid resolution failures, and confirm that the corresponding Linux-64 pin file (environment.linux-64.pin.txt) has been updated.

#!/usr/bin/env bash
# Check availability on conda-forge and bioconda
conda search perl-gdgraph-histogram=1.1 -c conda-forge -c bioconda

# Verify the Linux-64 pin file includes this entry
grep -R "perl-gdgraph-histogram =1.1" bio/fastq_screen/environment.linux-64.pin.txt
bio/fastq_screen/meta.yaml (2)

4-5: Add new author and project URL.
Thibault Dayris is correctly added to the authors list, and the url field now points to the official FastQ-Screen GitHub repository.


46-48: ```shell
#!/usr/bin/env bash

Confirm whether the wrapper writes to snakemake.output.conf

rg -n "snakemake\.output\.conf" bio/fastq_screen/wrapper.py || echo "No direct reference to snakemake.output.conf"

Look for any handling of 'conf' or 'fastq_screen_config' in wrapper logic

rg -n "conf" bio/fastq_screen/wrapper.py
rg -n "fastq_screen_config" bio/fastq_screen/wrapper.py


</details>
<details>
<summary>test_wrappers.py (1)</summary>

`3218-3225`: **LGTM! Proper test coverage for new fastq_screen functionality.**

The additional test cases appropriately cover the new output options (config file and no-PNG mode) that were added to handle PNG generation issues on certain architectures. The implementation follows the existing test pattern and maintains consistency with the codebase.

</details>
<details>
<summary>bio/fastq_screen/wrapper.py (4)</summary>

`6-8`: **LGTM! Author metadata update is appropriate.**

The addition of the second contributor to the author and email fields is properly formatted.

---

`16-16`: **Good improvement to logging configuration.**

Adding `append=True` ensures log entries are preserved across multiple runs, which is helpful for debugging.

---

`23-51`: **Excellent refactoring using TemporaryDirectory context manager.**

The refactoring to use `TemporaryDirectory` is a significant improvement that ensures automatic cleanup of temporary files and directories, making the code more robust and maintainable.

---

`53-64`: **Excellent improvement with conditional output file moves.**

The conditional checks using `snakemake.output.get()` make the output operations optional, which aligns perfectly with the PR objectives to accommodate architectures that may have problems with PNG file creation. The verbose logging is also helpful for debugging.

</details>
<details>
<summary>bio/fastq_screen/test/Snakefile (3)</summary>

`3-15`: **Good formatting improvements to the existing rule.**

The trailing commas, quote consistency, and explicit log/threads specifications improve readability and maintainability.

---

`18-36`: **Excellent test rule for config file output.**

This rule properly tests the new functionality where the wrapper generates a config file from a dictionary and outputs it. The inline config dictionary structure matches the expected format used in the wrapper.

---

`39-55`: **Good test rule for the no-PNG scenario.**

This rule effectively tests the optional PNG output functionality, which is crucial for the PR objective of accommodating architectures that have problems with PNG file creation.

</details>
<details>
<summary>bio/fastq_screen/environment.linux-64.pin.txt (1)</summary>

`4-66`: **Appropriate package version updates and dependency additions.**

The environment file updates include:
- Core system library refreshes with newer versions
- Python 3.12 upgrade for better performance and features  
- Addition of `perl-gdgraph-histogram` and other Perl graphics packages to support PNG generation
- Updated bioinformatics tool versions (bowtie, bowtie2)

These changes align well with the PR objectives to improve PNG generation support and maintain current package versions.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@fgvieira
Copy link
Collaborator

fgvieira commented Jun 20, 2025

@tdayris Can you also address/check the issue raised by coderabbitai?

@fgvieira fgvieira merged commit d7e7503 into snakemake:master Jun 20, 2025
8 checks passed
fgvieira pushed a commit that referenced this pull request Jun 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[7.1.0](v7.0.0...v7.1.0)
(2025-06-20)


### Features

* Pyfaidx
([#4159](#4159))
([4bb2242](4bb2242))


### Bug Fixes

* Fastq screen missing PNG
([#4284](#4284))
([d7e7503](d7e7503))


### Performance Improvements

* autobump bio/bismark/bismark_methylation_extractor
([#4260](#4260))
([bfd4627](bfd4627))
* autobump bio/encode_fastq_downloader
([#4263](#4263))
([534231d](534231d))
* autobump bio/fastp
([#4275](#4275))
([a315cff](a315cff))
* autobump bio/gatk3/baserecalibrator
([#4268](#4268))
([3941eec](3941eec))
* autobump bio/gatk3/indelrealigner
([#4266](#4266))
([7142888](7142888))
* autobump bio/gatk3/printreads
([#4267](#4267))
([a70ac2a](a70ac2a))
* autobump bio/gatk3/realignertargetcreator
([#4265](#4265))
([7aac10d](7aac10d))
* autobump bio/gfatools
([#4264](#4264))
([6df1c85](6df1c85))
* autobump bio/igv-reports
([#4214](#4214))
([b93892b](b93892b))
* autobump bio/mapdamage2
([#4269](#4269))
([677d564](677d564))
* autobump bio/minimap2/aligner
([#4276](#4276))
([2944f38](2944f38))
* autobump bio/minimap2/index
([#4277](#4277))
([d92345b](d92345b))
* autobump bio/reference/ensembl-variation
([#4278](#4278))
([5b55c94](5b55c94))
* autobump bio/spades/metaspades
([#4270](#4270))
([2d1b106](2d1b106))
* autobump bio/tabix/index
([#4252](#4252))
([0152771](0152771))
* autobump bio/trf
([#4271](#4271))
([1e80067](1e80067))
* autobump bio/ucsc/faToTwoBit
([#4281](#4281))
([0037df1](0037df1))
* autobump bio/ucsc/twoBitInfo
([#4279](#4279))
([e0048ce](e0048ce))
* autobump bio/ucsc/twoBitToFa
([#4280](#4280))
([ff31ef7](ff31ef7))
* autobump bio/vembrane/filter
([#4282](#4282))
([870f1b0](870f1b0))
* autobump bio/vembrane/table
([#4283](#4283))
([d4797c9](d4797c9))
* autobump bio/vep/plugins
([#4272](#4272))
([7c47ce0](7c47ce0))
* autobump bio/whatshap/haplotag
([#4273](#4273))
([cd59f63](cd59f63))
* autobump utils/datavzrd
([#4262](#4262))
([aa0dc22](aa0dc22))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants