Combine_MGE_AMR.smk 1.83 KB
Newer Older
Laura Denies's avatar
Laura Denies committed
1
2
3
4
5
#AMR

import glob
import os

6
7
PROJECT = config["project"]
INPUT   = config["input_file"]
Laura Denies's avatar
Laura Denies committed
8
9
10
11
12
13

##########################
#     AMR Prediction     #
##########################

rule combine_AMR_plasmid:
14
15
16
17
18
19
20
21
22
23
24
    input:
        AMR="{OUTDIR}/{project}/AMR/deepARG_results/{input_file}.out.mapping.ARG",
        AMR_translation="{OUTDIR}/{project}/renamed/{input_file}_translation.tsv",
        Plasmid="{OUTDIR}/{project}/MGE/plasmid/{input_file}_plasflow_prediction_final.tsv",
        Contig_translation="{OUTDIR}/{project}/renamed/{input_file}_Contig_translation.tsv",
        Contig_gene_list="{OUTDIR}/{input_file}.contig",
        VirFinder="{OUTDIR}/{project}/MGE/phage/{input_file}_VirFinder_aggregated.csv",
        VirSorter="{OUTDIR}/{project}/MGE/phage/{input_file}_VIRSorter_aggregated.csv"
    output:    
        Report_1=temp("{OUTDIR}/{project}/AMR/{input_file}_MGE_AMR_prediction_detail_temp.csv"),
        Report_2=temp("{OUTDIR}/{project}/AMR/{input_file}_MGE_AMR_prediction_report_temp.csv")
25
26
    log:
        "{OUTDIR}/{project}/AMR/{input_file}_MGE_AMR_prediction_detail_temp.log"
27
28
29
30
31
32
    params:
        outdir="{OUTDIR}"
    conda:
        "../../envs/R.yaml"
    script:
        "../../scripts/AMR_MGE.R"
Laura Denies's avatar
Laura Denies committed
33
34

rule modify_details:
35
36
37
38
39
40
41
42
43
44
    input:
        "{OUTDIR}/{project}/AMR/{input_file}_MGE_AMR_prediction_detail_temp.csv"
    output:
        "{OUTDIR}/{project}/AMR/{input_file}_AMR_MGE_prediction_detailed.tsv"
    params:
        outdir="{OUTDIR}"
    shell:
        """
        sed 's/"//g' {input} | sed 's/,/\t/g' > {output}
        """
Laura Denies's avatar
Laura Denies committed
45

46
47
48
49
50
51
52
53
54
55
56
rule modify_report:
    input:
        "{OUTDIR}/{project}/AMR/{input_file}_MGE_AMR_prediction_report_temp.csv"
    output:
        "{OUTDIR}/{project}/AMR_MGE_prediction_{input_file}_report.tsv"
    params:
        outdir="{OUTDIR}"
    shell:
        """
        sed 's/"//g' {input} | sed 's/,/\t/g' > {output}
        """