-
Notifications
You must be signed in to change notification settings - Fork 12
/
vibrant.smk
92 lines (75 loc) · 2.35 KB
/
vibrant.smk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
Vibrant
Manuscript: https://microbiomejournal.biomedcentral.com/articles/10.1186/s40168-020-00867-0
Software: https://github.com/AnantharamanLab/VIBRANT
"""
import os
# CONFIG
outDirName = 'vibrant'
vBuild = os.path.join(workflow.basedir, "../build/vibrant/")
# GENERIC CONFIG/RECIPES
include: os.path.join(workflow.basedir, "../rules/preflight.smk")
# TARGETS
rule all:
input:
expand(os.path.join(outputdir, f"{{genome}}_{outDirName}_tptn.tsv"), genome=GENOMES)
# RECIPES
rule vibrant_db_download:
output:
os.path.join(vBuild, 'setup.done')
conda:
"../conda_environments/vibrant.yaml"
shell:
"""
download-db.sh;
touch {output}
"""
rule run_vibrant:
input:
f = os.path.join(outputdir,"{genome}.fna"),
req = os.path.join(vBuild, 'setup.done')
output:
os.path.join(outputdir, '{genome}/VIBRANT_{genome}/VIBRANT_results_{genome}/VIBRANT_integrated_prophage_coordinates_{genome}.tsv')
conda:
"../conda_environments/vibrant.yaml"
benchmark:
os.path.join(outputdir, "benchmarks", "{genome}_vibrant.txt")
params:
os.path.join(outputdir, '{genome}')
resources:
mem_mb = 8000
shell:
"""
mkdir -p {params};
cd {params};
VIBRANT_run.py -i {input.f} -no_plot -t 1;
"""
rule vibrant_to_tbl:
input:
os.path.join(outputdir, '{genome}/VIBRANT_{genome}/VIBRANT_results_{genome}/VIBRANT_integrated_prophage_coordinates_{genome}.tsv')
output:
os.path.join(outputdir, "{genome}.out", "locs.tsv")
run:
outFH = open(output[0], 'w')
inFH = open(input[0], 'r')
for line in inFH:
l = line.split('\t')
if l[0] != 'scaffold':
outFH.write(f'{l[0]}\t{l[5]}\t{l[6]}\n')
outFH.close()
inFH.close()
rule count_tp_tn:
input:
gen = os.path.join(test_genomes, "{genome}.gb.gz"),
tbl = os.path.join(outputdir, "{genome}.out", "locs.tsv")
output:
tp = os.path.join(outputdir, "{genome}_vibrant_tptn.tsv")
params:
os.path.join(workflow.basedir,'../')
conda:
"../conda_environments/roblib.yaml"
shell:
"""
export PYTHONPATH={params};
python3 {scripts}/compare_predictions_to_phages.py -t {input.gen} -r {input.tbl} > {output.tp}
"""