GithubHelp home page GithubHelp logo

nextflow-template-bash's Introduction

Nextflow Template โ€“ BASH

Template repository for running a BASH script in Nextflow

Structure

The workflow in this repository will take in a single file as an input, run a BASH script, and publish any file saved by the script.

The BASH script itself is saved in templates/script.sh as native shell code, with one added nuance. The input file and parameters are referenced in the script with the syntax ${}. The path to the file specified with the input_csv parameter is referenced in the script at "${input_csv}" Any files or parameters specified with that syntax will be replaced by Nextflow with the appropriate value immediately prior to running the script. This allows you to run the script on any file, without having to hard-code the filename in the script.

Parameters

The parameters used to run the template workflow are:

  • input_csv: The path to the file which is read by the script
  • output: The folder in which all output files will be saved
  • string_to_append: A user-provided string which will be appended to every value in the input CSV

Modifying the workflow

Here is a simple guide to the most basic modifications which can be made to this workflow.

Dependencies

The dependencies used by script.sh are provided using a Docker container in which all needed libraries are installed. The template script uses the ubuntu:20.04 image, which provides the minimal dependencies needed to run this template script.

To use a different Docker image, simply modify the contents of params.container = "" in main.nf.

Parameters

To add any additional parameters to the workflow, simply reference those parameters in the script as ${params.param_name} where param_name is the name of the parameter which you have added. Those parameters do not need to be pre-defined in any other location, although it is probably a good idea to document them.

Files

To extend this template to use multiple input files, simply choose a parameter name to use for the second file and add code for it which follows the pattern used for the first input file.

To add a second input file with the parameter name second_input_csv, modify main.nf with:

// Raise an error if the second input CSV wasn't specified by the user
second_input_csv = file("${params.second_input_csv}", checkIfExists: true)

// Run the process on both files
run_script(input_csv, second_input_csv)

And then modify the run_script process to take two file inputs:

process run_script {
    container "${params.container}"
    publishDir "${params.output}", mode: "copy", overwrite: true

    input:
    path input_csv
    path second_input_csv

Contact Us

For any questions on the example shown in this workflow, please be in touch by email.

nextflow-template-bash's People

Contributors

sminot avatar

Watchers

James Cloos avatar Nathan Thorpe avatar Michael Zager avatar Dev Nambi avatar Ben McGough avatar John Dey avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.