Skip to content

Why can't we run conda and run together in a rule? #1619

@animesh-workplace

Description

@animesh-workplace
Conda environments are only allowed with shell, script, notebook, or wrapper directives (not with run or template_engine).

I'm receiving the above error when I'm trying to run a snakemake rule something like this

rule bcftools_consensus_1_15_1:

    input:
        file = rules.gatk_haplotype_caller_4_2_6_1.output.file,
        reference = "resources/reference/NC_045512.2.fna",
    output:
        file = "output/bcftools/A_consensus.fasta",
    threads: 1
    conda: "env.yaml"
    log: "output/bcftools/consensus_1_15_1.log"
    run:
        # few python statements run here
        # ...
        # ...
        shell(
            '''
                bcftools consensus -f {input.reference} {input.file} \
                -o {output.file} && sed -i "1s/.*/>A_fasta/" {output.file}
            '''
        )

Is there a way to achieve the use of conda and run together??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions