6  Prototyping

To build up an analysis project, workflow development aims to follow the GitFlow model of coding.

Make a new branch named <new_feature> in Git.

git checkout -b <new_feature>

Add a process into the workflow:

process <uppercase_name> {

  input:
  path <filename_var>

  // directives
  <directives>
  conda "<channel>::<software>=<version>"
  container "<software>:<version+build>"

  script:
  """
  command --opts $var
  """

  output:
  path "<filename>", emit: <file_type>
  path "*"  // Captures everything. Use when you don't know what the output is.

}

Pass the appropriate input channel(s) in the workflow block.

workflow {

  Channel.fromFilePairs( params.reads, checkIfExists: true )
    .set{ input_ch }

  FASTQC( input_ch )
  FASTP( input_ch )
  ASSEMBLE( FASTP.out.trimmed_reads )

}

Add the process resources to the configs.

process {
  withName: 'FASTQC' {
    cpus = 4
    time = '1h'
  }
  withName: 'FASTP' {
    cpus = 4
    time = '2h'
  }
}

Don’t forget to commit your changes to the feature branch as you develop:

git add <file>
git commit -m "What I did"

Mistakes to commits can be changed using:

git commit --amend

6.1 Running analyses

  • Have a folder under analyses for development (YYYY-MM-DD_workflow_dev)
    • params.yml points to test data.
    • Use YYYY-MM-DD to label folders and provide a natural ordering.
  • Have another folder under analyses to analyse the real data set (YYYY-MM-DD_fulldata_analysis)
  • Run stuff and break it.
    • Activate conda environment.
    • run_nextflow.sh
    • Nextflow prints the working directory when a process fails.

See Troubleshooting for tips on debugging issues.

6.2 Merging with git

Once it works, merge with the existing development branch or main branch. There are two forms of merging with git. merge tacks on the changes to the end of the branch. rebase undoes your changes, applies commits to bring the branch up to date, and then reapplies your changes.

# Update dev branch with changes from origin
git checkout dev
git pull --rebase

# merge updates from dev into new process branch
git checkout <new_feature>
git rebase dev
# IMPORTANT: It is your responsibility to resolve conflicts with stable code

# Switch to dev and merge new process
git checkout dev
git merge <new_feature>
git branch -d <new_feature> # delete new feature