I'm trying to add amrfinder running within conda to a snakemake workflow, working on a slurm HPC.
The first time you run amrfinder
, you have to run amrfinder -u
to update/download the database of genes/proteins which it searches for. Since I'm using the --use-conda
flag of snakemake
, the first time I run the workflow, it creates a new env for the conda
package, so this command has to be run before that copy of amrfinder
will work.
My question is: how do I run amrfinder -u
within snakemake
? If I do it as part of the standard amrfinder
command, it runs as many times as there are samples, and as all the jobs are looking at the same database, when it updates for one job, it breaks the other jobs.
I can't figure out how to run this command in a 'snakemake-y' way, as it has no input, it's just literally amrfinder -u
.
Of course, I can make it work with a hack/workaround, but I'm interested in a snakemake way of doing it.
This is the main snakemake rule for running amr_finder_plus, the new rule, to run amrfinder -u
needs to run before this
rule amr_finder_plus:
input:
assembly = 'my_assembly.fasta'
output:
amr_finder_plus_results = 'my_amr_finder_plus_results.tsv'
conda:
'../../envs/amrfinderplus.yaml'
shell:
'amrfinder -n {input.assembly} -O Salmonella --output {output.amr_finder_plus_results} --threads 4'