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

A guide for developers of common implementation patterns #2242

Open
mahesh-panchal opened this issue Jan 26, 2024 · 2 comments
Open

A guide for developers of common implementation patterns #2242

mahesh-panchal opened this issue Jan 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mahesh-panchal
Copy link
Member

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:

  • How to implement collectFile with meta information.
        Channel.of( [ id: 'test', taxid: 1234 ] )
            .tap { ch_data }
            .collectFile( newLine: true ) { meta -> [ "${meta.id}.tsv", "$meta.taxid" ] }
            .map{ file -> [ file.baseName , file ] }
            .join( ch_data.map { meta -> [ meta.id, meta ] }, by: 0 )
            .map{ id, idfile, meta -> [ meta, idfile ] }
  • How should database's be handled for future use.
    Separate the database download and use storeDir instead of publishDir.
  • How should one map to multiple databases/references.
    Use combine to make a Cartesian product of inputs vs indexes, and map and + to merge metadata appropriately.
@mahesh-panchal mahesh-panchal added the enhancement New feature or request label Jan 26, 2024
@mahesh-panchal
Copy link
Member Author

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
Copy link
Member Author

mahesh-panchal commented Jan 27, 2024

How to use a function or closure to group channel operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant