Hi everyone,
I'm working on a snakefile involving several conda environements. As it's more simple (and avoid package troubles) to split each tools in a specific conda environment, I've separated my tools and calling them in my rules just like this:
#trimming
rule trimming:
message:
"Filtering fastq using NanoFilt."
input:
merged_fastq = rules.merge.output.merged_fastq
output:
trimmed_fastq = resultpath+"TRIMMED/{barcode}_trimmed.fastq"
conda:
"env/nanofilt.yaml"
shell:
"NanoFilt --quality 10 --length 100 --maxlength 1500 {input} > {output} "
On my computer, snakemake is already installed and I basicaly typing the command below:
snakemake -s viralION.py --use-conda
The full pipeline is executing perfectly.
However, my trouble appear when I'm trying to launch the same command, but from an environment containing snakemake (and snakemake only) created with this command:
conda create -c conda-forge -c bioconda -n snakemake snakemake
conda activate snakemake
snakemake -s viralION.py --use-conda
snakemake return an error telling me that NanoFilt command was not found. As this rule is the first one involving an environment, i can guess this problem will extend for others tools (samtools,bcftools etc...)
Here is the full message of the failed job:
[Wed Jul 1 12:10:17 2020]
Job 5: Filtering fastq using NanoFilt.
/bin/bash: activate: No such file or folder
/bin/bash: NanoFilt : command not found
Activating conda environment: /home/chu-lyon.fr/regueex/git/MinION_HBV/.snakemake/conda/8c13cc8c
RuleException:
CalledProcessError in line 72 of /home/chu-lyon.fr/regueex/git/MinION_HBV/viralION.py:
Command 'source activate /home/chu-lyon.fr/regueex/git/MinION_HBV/.snakemake/conda/8c13cc8c; set -euo pipefail; NanoFilt --quality 10 --length 100 --maxlength 1500 /srv/nfs/ngs-stockage/NGS_Virologie/HadrienR/CARO_PIPELINE/RESULT_HDV/MERGED/barcode03_merged.fastq > /srv/nfs/ngs-stockage/NGS_Virologie/HadrienR/CARO_PIPELINE/RESULT_HDV/TRIMMED/barcode03_trimmed.fastq ' returned non-zero exit status 127.
File "/home/chu-lyon.fr/regueex/git/MinION_HBV/viralION.py", line 72, in __rule_trimming
File "/home/chu-lyon.fr/regueex/anaconda3/envs/snakemake/lib/python3.6/concurrent/futures/thread.py", line 56, in run
I dont realy get what the problem is. Do you have some clues?
EDIT: I've also tried to execute my snakefile from a empty conda environment but it's not working too(NanoFilt cant be found):
conda create -n testLaunchSnakefile
conda activate testLaunchSnakefile
snakemake -s viralION.py --use-conda
Thanks, and have a nice day.
Hadrien
AFAIK, you'd need to ensure that all tools included in the Snakemake pipeline are installed in the specific environment you're running the Snakemake pipeline from. You'd need to install NanoFilt and other tools either in the new conda environment.
as mentionned on the snakemake documentation and biostar tutorial its possible to call tools from separate environments using snakemake. For exemple, NanoFilt is not installed on this computed, but the snakefile is working fine. However I dont know why my pipeline dont work when executed from a conda environment.
Sorry, you're right, I misunderstood the question.
Can you clarify what you mean by 'On my computer, snakemake is already installed' ? Do you mean you have snakemake installed in your base env?
To be more precise, I'm working on a server, where snakemake is already installed. I haven't root access, so I've installed anaconda personnaly to use other bioinformatic tools. So yeah , snakemake is present in my base environment, but was installed before conda.
Hope I was clear:)
Thanks for clarifying that, just to check, could you try putting
nanofilt.yaml
at the same directory level as the snakemake file and modify the file path in the script? Re-run the script and see if still get the same error? I am just wondering if snakemake is able to find the env file specified in the script.can you show us what
env/nanofilt.yaml
looks like?Sure, here is the full file: