Skip to content
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

add find/unpigz module #7383

Merged
merged 11 commits into from
Jan 29, 2025
Merged

add find/unpigz module #7383

merged 11 commits into from
Jan 29, 2025

Conversation

BioWilko
Copy link
Contributor

Add a module for decompressing a large number of gzipped files, theoretically without hitting the terminal argument limit

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added a new tool - have you followed the module conventions in the contribution docs
  • If necessary, include test data in your PR.
  • Remove all TODO statements.
  • Emit the versions.yml file.
  • Follow the naming conventions.
  • Follow the parameters requirements.
  • Follow the input/output options guidelines.
  • Add a resource label
  • Use BioConda and BioContainers if possible to fulfil software requirements.
  • Ensure that the test works with either Docker / Singularity. Conda CI tests can be quite flaky:
    • For modules:
      • nf-core modules test <MODULE> --profile docker
      • nf-core modules test <MODULE> --profile singularity
      • nf-core modules test <MODULE> --profile conda
    • For subworkflows:
      • nf-core subworkflows test <SUBWORKFLOW> --profile docker
      • nf-core subworkflows test <SUBWORKFLOW> --profile singularity
      • nf-core subworkflows test <SUBWORKFLOW> --profile conda

@BioWilko
Copy link
Contributor Author

Resubmitted due to making an embarrassing git mess on the previous PR (#7379), previous review by @jfy133 taken into account

Copy link
Member

@jfy133 jfy133 left a comment

Choose a reason for hiding this comment

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

LGTM, would be good to get a second 👀 again, maybe from @maxulysse as he looked atthe other?

modules/nf-core/find/unpigz/tests/main.nf.test Outdated Show resolved Hide resolved
@mahesh-panchal
Copy link
Member

We might be able to trim this. Let me have a think.

Copy link
Member

@mahesh-panchal mahesh-panchal left a comment

Choose a reason for hiding this comment

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

I think this is over-complicating things a lot.

Can files be staged in a directory or is this breaking things?

See if this works for your use case:

process TASK {
    input:
    path files_in, stageAs: 'gzipped/*'

    script:
    prefix = task.ext.prefix?: 'meta'
    def args = task.ext.args ?: ''
    if( files_in.any{ file -> !file.name.endsWith('.gz') } ){
        error("All files provided to this module must be gzipped (and have the .gz extension).")
    }
    if( files_in.any{ file -> file.baseName.startsWith(prefix) } ) {
        error("No input files can start with the same name as the output prefix in the module FIND_UNPIGZ (currently '${prefix}'). Please choose a different one.")
    }
    """
    while IFS= read -r -d \$'\\0' file; do
        unpigz \\
            ${args} \\
            -cd \\
            --processes ${task.cpus} \\
            \$file \\
            > ${prefix}.\$( basename \$file .gz )
    done < <( find gzipped/ -name '*.gz' -print0 )
    """

    output:
    path "$prefix.*"
}

Edit, I just noticed there's a problem with file.name in this context. It's not stripping the directory name like it should to check the prefix. Use baseName instead.

modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
modules/nf-core/find/unpigz/main.nf Outdated Show resolved Hide resolved
@BioWilko
Copy link
Contributor Author

Thanks for the suggestions @mahesh-panchal , that's far more elegant!

@BioWilko BioWilko added this pull request to the merge queue Jan 28, 2025
@BioWilko BioWilko removed this pull request from the merge queue due to a manual request Jan 28, 2025
Co-authored-by: Mahesh Binzer-Panchal <mahesh.binzer-panchal@nbis.se>
Co-authored-by: Mahesh Binzer-Panchal <mahesh.binzer-panchal@nbis.se>
@mahesh-panchal mahesh-panchal requested a review from jfy133 January 28, 2025 15:06
modules/nf-core/find/unpigz/main.nf Show resolved Hide resolved
@BioWilko BioWilko added this pull request to the merge queue Jan 29, 2025
Merged via the queue into nf-core:master with commit f53dd9e Jan 29, 2025
24 checks passed
@BioWilko BioWilko deleted the find_unpigz branch January 29, 2025 10:04
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.

4 participants