Search code examples
snakemake

snakemake not finding executable in conda environment


I have the following conda environment

channels:
      - conda-forge
      - bioconda

dependencies:
      - perl=5.22.0.1
      - samtools=1.3
      - kallisto=0.43.1
      - cutadapt=1.9.1
      - trim-galore=0.4.3

which gets loaded when I run snakemake --use-conda

Activating conda environment: /fullpathto/.snakemake/conda/4ac435d8

But then I get the error:

/usr/bin/bash: trim_galore: command not found

even though I can manually run the trim_galore executable successfully with: .snakemake/conda/4ac435d8/bin/trim_galore

The rule calling trim_galore is:

rule trim_galore:
    input:
        unpack(in_funcs.get_trim_galore_input(config))
    output:
        r1 = join(config['outs']['trim_fq_out_path'], '{sample}1_val_1.fq.gz'),
        r2 = join(config['outs']['trim_fq_out_path'], '{sample}2_val_2.fq.gz'),
    params:
        out_path = config['outs']['trim_fq_out_path'],
    conda:
        join(config['protospork'], 'envs/biotools.yaml'),
    shell:
        'trim_galore --gzip -o {params.out_path} --paired {input.r1} {input.r2}'

Do I need to somehow specify that this trim_galore executable should be coming from the conda environment?


Solution

  • I figured it out, I was using a python installation from a virtualenv instead of making a conda environment. Hope this helps someone else

    Prior workaround which is unsatisfying in many ways:

    rule trim_galore:
        input:
            unpack(in_funcs.get_trim_galore_input(config))
        output:
            r1 = join(config['outs']['trim_fq_out_path'], '{sample}1_val_1.fq.gz'),
            r2 = join(config['outs']['trim_fq_out_path'], '{sample}2_val_2.fq.gz'),
        params:
            exec_path = glob.glob(join(config['protospork'],'.snakemake','conda','*','bin','trim_galore'))[0],
            out_path = config['outs']['trim_fq_out_path'],
        conda:
            join(config['protospork'], 'envs/biotools.yaml'),
        shell:
            '{params.exec_path} --gzip -o {params.out_path} --paired {input.r1} {input.r2}'