nf-core / website

Code and files for the main nf-core website.
https://nf-co.re
MIT License
69 stars 195 forks source link

A guide for developers of common implementation patterns #2242

Open mahesh-panchal opened 10 months ago

mahesh-panchal commented 10 months ago

Is your feature request related to a problem? Please describe.

It would be good to have a place to describe implementation patterns to common issues encountered by developers.

Describe the solution you'd like

A page with the implementation patterns that's easy to look up.

Additional context

Going through some code reviews, some common implementation issues pop up, that are sometimes addressed in strange ways. It would be nice to provide some best practice ways to deal with certain scenarios.

Examples:

mahesh-panchal commented 10 months ago

Throw an error on a empty channel:

params.something = 'test'
workflow {
    ch_in = Channel.empty()
        .ifEmpty{ error "Error" }
        .filter{ it != null }
    TASK( ch_in ).view()
}

process TASK{
    input:
    val message

    script:
    """
    echo $message
    """

    output:
    stdout
}

https://nextflow.slack.com/archives/C02T98A23U7/p1699950368556629?thread_ts=1699894501.983129&cid=C02T98A23U7

mahesh-panchal commented 10 months ago

How to use a function or closure to group channel operations