|
1 | 1 | rule run_srax:
|
2 | 2 | input:
|
3 |
| - genome_dir = lambda w: os.path.dirname(get_assembly(w)) |
| 3 | + contigs = get_assembly |
4 | 4 | output:
|
5 |
| - report = "results/{sample}/srax/Summary_files/sraX_detected_ARGs.tsv", |
| 5 | + report = "results/{sample}/srax/sraX_detected_ARGs.tsv", |
6 | 6 | metadata = "results/{sample}/srax/metadata.txt"
|
7 | 7 | message: "Running rule run_srax on {wildcards.sample} with contigs"
|
8 | 8 | log:
|
9 |
| - "logs/srax_{sample}.log" |
| 9 | + "logs/srax_{sample}.log" |
10 | 10 | conda:
|
11 |
| - "../envs/srax.yaml" |
| 11 | + "../envs/srax.yaml" |
12 | 12 | threads:
|
13 |
| - config["params"]["threads"] |
| 13 | + config["params"]["threads"] |
14 | 14 | params:
|
15 |
| - dbtype = config["params"]["srax"]["dbtype"], |
16 |
| - outdir = "results/{sample}/srax", |
17 |
| - tmp_output_dir = "results/{sample}/srax/tmp", |
18 |
| - log_output_dir = "results/{sample}/srax/Log", |
19 |
| - ARG_DB_output_dir = "results/{sample}/srax/ARG_DB", |
20 |
| - analysis_output_dir = "results/{sample}/srax/Analysis", |
21 |
| - result_output_dir = "results/{sample}/srax/Results", |
22 |
| - dateformat = config["params"]["dateformat"] |
| 15 | + dbtype = config["params"]["srax"]["dbtype"], |
| 16 | + dateformat = config["params"]["dateformat"] |
23 | 17 | shell:
|
| 18 | + """{{ |
| 19 | + mkdir -p $(dirname {output.report}) |
| 20 | + # copy input to a temp directory because sraX processes every fasta file in its input directory |
| 21 | + TMPDIR=$(mktemp -d) |
| 22 | + cp {input.contigs} $TMPDIR/ |
| 23 | + sraX -i $TMPDIR -t 4 -db {params.dbtype} -o $TMPDIR/output |
| 24 | + mv $TMPDIR/output/Results/Summary_files/sraX_detected_ARGs.tsv {output.report} |
| 25 | + rm -rf $TMPDIR |
| 26 | + }} >{log} 2>&1 |
| 27 | + printf -- '--analysis_software_version %s --reference_database_version %s --reference_database_name srax_{params.dbtype}_amr_db' \ |
| 28 | + $(sraX --version | fgrep version | cut -d: -f2) $(date '+{params.dateformat}') >{output.metadata} |
24 | 29 | """
|
25 |
| - sraX -i {input.genome_dir} -t 4 -db {params.dbtype} -o {params.outdir} > {log} 2>&1 |
26 |
| - mv {params.result_output_dir}/* {params.outdir} |
27 |
| - sraX --version | grep version | perl -p -e 's/.+version: (.+)/--analysis_software_version $1/' > {output.metadata} |
28 |
| - date +"{params.dateformat}" | perl -p -e 's/(.+)/--reference_database_version $1/' >> {output.metadata} |
29 |
| - """ |
30 |
| -# rm -rf {params.tmp_output_dir} {params.log_output_dir} {params.ARG_DB_output_dir} {params.analysis_output_dir} {params.result_output_dir} |
31 | 30 |
|
32 | 31 | rule hamronize srax:
|
33 | 32 | input:
|
34 | 33 | contigs = get_assembly,
|
35 |
| - report = "results/{sample}/srax/Summary_files/sraX_detected_ARGs.tsv", |
| 34 | + report = "results/{sample}/srax/sraX_detected_ARGs.tsv", |
36 | 35 | metadata = "results/{sample}/srax/metadata.txt"
|
37 | 36 | output:
|
38 | 37 | "results/{sample}/srax/hamronized_report.tsv"
|
39 |
| - params: |
40 |
| - dbtype = config["params"]["srax"]["dbtype"] |
41 | 38 | conda:
|
42 | 39 | "../envs/hamronization.yaml"
|
43 | 40 | shell:
|
44 | 41 | """
|
45 |
| - hamronize srax --input_file_name {input.contigs} $(paste - - < {input.metadata}) --reference_database_name srax_{params.dbtype}_amr_db {input.report} > {output} |
| 42 | + hamronize srax --input_file_name {input.contigs} $(cat {input.metadata}) {input.report} > {output} |
46 | 43 | """
|
0 commit comments