Snakemake use the wrong environment

Viewed 154

I'm calling Snakemake workflow from a shell script.
But first I need to activate an environment that contains snakemake and other libraries installed.

source ${CONDA_HOME}/etc/profile.d/conda.sh
conda activate myenv
# then call the workflow.

Rules in the snakemake workflow use conda: to create their own environment. one of the rules uses python to run some script:

rule readsStat:
    """
    Input is the reads output is info about reads
    """
    input: expand(data_dir + "/{sample}", sample=sample_list)
    output:data_dir + "/statitics/raw_reads/reads_stat.txt",
    message: "Calculating read coverage statitics for: {input}",
    params:
        read_stat_script = rawcoverage_script,
    threads: config['read_raw_coverage_threads']
    benchmark: data_dir + "/benchmark/raw_reads/stat.benchmark.txt"
    conda: STAT_ENV
    shell:
        """
        python {params.read_stat_script} -i {input} -o {output} -t {threads}
        """

The issue is after the rule activates the proper environment instead of using it (e.x., .snakemake/conda/532a617ec7374b7bff46f066e73/bin/python), they still use myenv python envs/myenv/bin/python that I activated earlier in the calling script.

Any idea how can I fix that?

Thanks

Update:
versions
conda 4.10.1
Snakemake 6.2.1

1 Answers

The issue is in line:
source ${CONDA_HOME}/etc/profile.d/conda.sh
removing this line made Snakemake works as expected.
Thanks

Related