Phage.smk 2.77 KB
Newer Older
Laura Denies's avatar
Laura Denies committed
1
2
3
4
5
6
7
8
9
#Plasmid

import glob
import os

##########################
#     Phage Prediction   #
##########################

10
# VIRSORTER 
Laura Denies's avatar
Laura Denies committed
11
12

rule run_VirSorter:
13
    input:
14
        "{datadir}/{project}/renamed/{sample}_Contig_ID.fna"
15
    output:
16
        "{datadir}/{project}/MGE/phage/{sample}/virsorter/VIRSorter_global-phage-signal.csv"
17
    log:
18
        "{datadir}/{project}/MGE/phage/{sample}/virsorter/VIRSorter_global-phage-signal.log"
19
    params:
20
21
22
        outdir="{datadir}",
        runtime=config["pathofact"]["runtime"]["long"],
        mem=config["pathofact"]["mem"]["big_mem_per_core_gb"]
23
24
25
    conda:
        "../../envs/VirSorter.yaml"
    threads:
26
        config["pathofact"]["mem"]["big_mem_cores"]
27
28
    shell:
        """
29
        wrapper_phage_contigs_sorter_iPlant.pl -f {input} --ncpu {threads} --wdir {wildcards.datadir}/{wildcards.project}/MGE/phage/{wildcards.sample}/virsorter --data-dir {config[pathofact][scripts]}/virsorter-data &> {log}
30
31
        """

32
33
localrules: aggregate_VirSorter
rule aggregate_VirSorter:
34
    input:
35
        "{datadir}/{project}/MGE/phage/{sample}/virsorter/VIRSorter_global-phage-signal.csv"
36
    output:
37
        "{datadir}/{project}/MGE/phage/{sample}_VIRSorter_aggregated.csv"
38
    params:
39
        outdir="{datadir}"
40
41
    shell:
        "mv {input} {output}"
Laura Denies's avatar
Laura Denies committed
42
43

# VIRFINDER Prediction
44
rule run_VirFinder:
45
    input:
46
        "{datadir}/{project}/contig_splitted/{sample}/{file_i}.fasta"
47
    output:
48
        "{datadir}/{project}/MGE/phage/{sample}/virfinder/{file_i}.fasta_gt1bp_dvfpred.txt"
49
    log:
50
        "{datadir}/{project}/MGE/phage/{sample}/virfinder/{file_i}.fasta_gt1bp_dvfpred.log"
51
    params:
52
53
54
        outdir="{datadir}",
        runtime=config["pathofact"]["runtime"]["long"],
        mem=config["pathofact"]["mem"]["big_mem_per_core_gb"]
55
56
57
    conda:
        "../../envs/DeepVirFinder.yaml"
    threads:
58
        config["pathofact"]["mem"]["big_mem_cores"]
59
    shell:
60
        "python {config[pathofact][deepvirfinder]} -i {input} -o {wildcards.datadir}/{wildcards.project}/MGE/phage/{wildcards.sample}/virfinder -c {threads} &> {log}"
Laura Denies's avatar
Laura Denies committed
61

62
def aggregate_VirFinder(wildcards):
63
    checkpoint_output= checkpoints.splitcontig.get(**wildcards).output.split
64
    return expand(
65
        "{datadir}/{project}/MGE/phage/{sample}/virfinder/{file_i}.fasta_gt1bp_dvfpred.txt",
66
        datadir=wildcards.datadir,
67
        project=wildcards.project,
68
        sample=wildcards.sample,
69
        file_i=glob_wildcards(os.path.join(checkpoint_output, "{i}.fasta")).i
70
    )
Laura Denies's avatar
Laura Denies committed
71

72
rule aggregate_VirFinder:
73
    input:
74
        aggregate_VirFinder
75
    output:
76
        "{datadir}/{project}/MGE/phage/{sample}_VirFinder_aggregated.csv"
77
    params:
78
79
80
        outdir="{datadir}",
        runtime=config["pathofact"]["runtime"]["short"],
        mem=config["pathofact"]["mem"]["normal_mem_per_core_gb"]
81
82
    shell:
        "cat {input} >{output}"