channels:
- bioconda
- r
dependencies:
- samtools ==1.3
Before the execution of any job, Snakemake creates the given environment in the working directory under .snakemake/conda/$ENVHASH with $ENVHASH being the md5 hash or the environment file. Rules and jobs can share environments. The hashing ensures that environments are only recreated if they are updated.
Environments are activated automatically for each shell command of a job or in case of using the script or wrapper directive.
Script support
For this to work, scripts have to be executed as separate processes. This allows to specify the Python and R version in the environment corresponding to a rule that uses the script directive.
Wrapper support
With wrappers, the environment is read from the directory of the wrapper (e.g. in the git repo), unless it is overwritten with the conda directive in the rule. The killer feature is that you can write
and Snakemake will take care of creating an environment with the needed software in the versions specified by the wrapper.
Combination with Docker
In the upcoming cluster support, conda environment handling will be used automatically to specialize a generic given docker container for executing a certain job.
Caveats
The prefix length issue in conda can still lead to problems, because not all packages have been rebuilt yet with conda-build 2.0. Therefore, conda-integration is optional and has to be activated with --use-conda.
This PR integrates the conda package manager into Snakemake. It is possible to define conda environments per rule, e.g.:
rule a: output: "test.out" conda: "envs/samtools.yaml" shell: "samtools view -h > {output}"
with
envs/samtools.yaml
being e.g.channels: - bioconda - r dependencies: - samtools ==1.3
Before the execution of any job, Snakemake creates the given environment in the working directory under
.snakemake/conda/$ENVHASH
with$ENVHASH
being the md5 hash or the environment file. Rules and jobs can share environments. The hashing ensures that environments are only recreated if they are updated.Environments are activated automatically for each shell command of a job or in case of using the script or wrapper directive.
Script support
For this to work, scripts have to be executed as separate processes. This allows to specify the Python and R version in the environment corresponding to a rule that uses the script directive.
Wrapper support
With wrappers, the environment is read from the directory of the wrapper (e.g. in the git repo), unless it is overwritten with the conda directive in the rule. The killer feature is that you can write
rule compress_vcf: input: "{prefix}.vcf" output: "{prefix}.vcf.gz" wrapper: "0.3.0/bio/vcf/compress"
and Snakemake will take care of creating an environment with the needed software in the versions specified by the wrapper.
Combination with Docker
In the upcoming cluster support, conda environment handling will be used automatically to specialize a generic given docker container for executing a certain job.
Caveats
The prefix length issue in conda can still lead to problems, because not all packages have been rebuilt yet with conda-build 2.0. Therefore, conda-integration is optional and has to be activated with
--use-conda
.