user7249622
user7249622

Reputation: 115

error when pulling a docker container using singularity in nextflow

I am making a very short workflow in which I use a tool for my analysis called salmon. In the hpc that I am working in, I cannot install this tool so I decided to pull the container from biocontainers. In the hoc we do not have docker installed (I also do not have permission to do so) but we have singularity instead. So I have to pull docker container (from: quay.io/biocontainers/salmon:1.2.1--hf69c8f4_0) using singularity. The workflow management system that I am working with is nextflow. This is the short workflow I made (index.nf):

#!/usr/bin/env nextflow
nextflow.preview.dsl=2

container = 'quay.io/biocontainers/salmon:1.2.1--hf69c8f4_0'
shell = ['/bin/bash', '-euo', 'pipefail']


process INDEX {

  script:
  """
  salmon index \
  -t /hpc/genome/gencode.v39.transcripts.fa \
  -i index \
  """
}


workflow {
  INDEX()
}

I run it using this command:

nextflow run index.nf -resume

But got this error:

salmon: command not found

Do you know how I can fix the issue?

Upvotes: 1

Views: 758

Answers (1)

Steve
Steve

Reputation: 54512

You are so close! All you need to do is move these directives into your nextflow.config or declare them at the top of your process body:

container = 'quay.io/biocontainers/salmon:1.2.1--hf69c8f4_0'
shell = ['/bin/bash', '-euo', 'pipefail']

My preference is to use a process selector to assign the container directive. So for example, your nextflow.config might look like:

process {

    shell = ['/bin/bash', '-euo', 'pipefail']

    withName: INDEX {
        container = 'quay.io/biocontainers/salmon:1.2.1--hf69c8f4_0'
    }
}

singularity {

    enabled = true

    // not strictly necessary, but highly recommended
    cacheDir = '/path/to/singularity/cache'
}

And your index.nf might then look like:

nextflow.enable.dsl=2

params.transcripts = '/hpc/genome/gencode.v39.transcripts.fa'


process INDEX {

    input:
    path fasta

    output:
    path 'index'

    """
    salmon index \\
        -t "${fasta}" \\
        -i index \\
    """
}


workflow {

    transcripts = file( params.transcripts )

    INDEX( transcripts )
}

If run using:

nextflow run -ansi-log false index.nf

You should see the following results:

N E X T F L O W  ~  version 21.04.3
Launching `index.nf` [clever_bassi] - revision: d235de22c4
Pulling Singularity image docker://quay.io/biocontainers/salmon:1.2.1--hf69c8f4_0 [cache /path/to/singularity/cache/quay.io-biocontainers-salmon-1.2.1--hf69c8f4_0.img]
[8a/279df4] Submitted process > INDEX

Upvotes: 3

Related Questions