Running a program directly from a container in nextflow process

Hi,

I am trying to run this process in my nextflow workflow that runs deepvariant directly from a container:

process deepvariant {
    container 'quay.io/nf-core/deepvariant:1.5.0'
    publishDir "${params.output_dir}/deepvariant", mode: 'copy'

    input:
    tuple path(bam), path(bam_index)
    path reference
    path reference_index

    output:
    path "${bam.baseName}.vcf.gz", emit: vcf
    path "${bam.baseName}.vcf.gz.tbi", emit: vcf_tbi
    path "${bam.baseName}.g.vcf.gz", emit: gvcf
    path "${bam.baseName}.g.vcf.gz.tbi", emit: gvcf_tbi
    path "versions.yml", emit: versions

    script:
    """
    

    # Verify the contents of the container
    ls -l /opt/deepvariant/bin/

    # Run DeepVariant
    /opt/deepvariant/bin/run_deepvariant \\
        --model_type=WGS \\
        --ref=${reference} \\
        --reads=${bam} \\
        --output_vcf=${bam.baseName}.vcf.gz \\
        --output_gvcf=${bam.baseName}.g.vcf.gz \\
        --num_shards=${task.cpus} \\
        --intermediate_results_dir=.

    # Create versions.yml file
    cat <<-END_VERSIONS > versions.yml
    "${task.process}":
        deepvariant: \$(echo \$(/opt/deepvariant/bin/run_deepvariant --version 2>&1) | sed 's/^.*version //; s/ .*\$//' )
    END_VERSIONS
    """
}

However when I run this on my EC2 instance, I get an error

ls: cannot access '/opt/deepvariant/bin/': No such file or directory

Buy when I run the container interactively, it confirms I have the right path:

docker run -it  quay.io/nf-core/deepvariant:1.5.0 ls -l /opt/deepvariant/bin/run_deepvariant

-rwxr-xr-x. 1 root root 68 Feb 26  2023 /opt/deepvariant/bin/run_deepvariant

Is there something I’m fundamentally missing? I would eventually want to run my workflow on AWS batch, but I’m testing out this process locally on EC2 to make sure it works there first.

I should have RTFM, when I added the following to my nextflow.config

docker.enabled = true

The error went away and the process is running.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.