-
Notifications
You must be signed in to change notification settings - Fork 4
/
Metabat.snake
68 lines (60 loc) · 2.72 KB
/
Metabat.snake
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
if COVERAGE_UNIQUE_SAMPLE:
rule generate_depth :
input: lambda w : [w.group+"/map/"+sample.split('/')[-1]+"_mapped_sorted.bam" for sample in GROUPS[w.group]]
output: "{group}/map/depth.txt"
log : "{group}/map/depth.log"
conda : CONDA_ENV + "/metabat2.yaml"
resources:
slurm_partition = get_resource("partition"),
mem_mb = get_resource("mem")
singularity : "docker://quay.io/annacprice/metabat2:2.15"
shell: "jgi_summarize_bam_contig_depths --outputDepth {output} {input} &>{log}"
else:
rule generate_depth :
input: lambda w : ["%s/map/%s_mapped_sorted.bam"%(w.group,basename(sample)) for sample in SAMPLES]
output: "{group}/map/depth.txt"
log : "{group}/map/depth.log"
conda : CONDA_ENV + "/metabat2.yaml"
resources:
slurm_partition = get_resource("partition"),
mem_mb = get_resource("mem")
singularity : "docker://quay.io/annacprice/metabat2:2.15"
shell: "jgi_summarize_bam_contig_depths --outputDepth {output} {input} &>{log}"
rule metabat2 :
input: contig="{group}/contigs/contigs.fa",
depth="{group}/map/depth.txt"
output: "{group}/binning/metabat2/bins/done"
params: out="{group}/binning/metabat2/bins/bin",
min_contig_size=max(1500,MIN_CONTIG_SIZE_METABAT2) # metabat2 does not bin anything smaller than 1500
conda : CONDA_ENV + "/metabat2.yaml"
threads : 20
resources:
slurm_partition = get_resource("partition", min_size=30000),
mem_mb = get_resource("mem", min_size=30000)
singularity : "docker://quay.io/annacprice/metabat2:2.15"
shell: """metabat2 -i {input.contig} -a {input.depth} -t {threads} -o {params.out} -m {params.min_contig_size}
touch {output}
"""
rule renames_metabat2_bins :
input: "{group}/binning/metabat2/bins/done"
output:"{group}/binning/metabat2/bins/name_done"
resources:
slurm_partition = get_resource("partition"),
mem_mb = get_resource("mem")
run:
List_bins=glob.glob(wildcards.group+"/binning/metabat2/bins/bin*.fa")
for bin_ in List_bins:
new_name=bin_.replace("bin.","Bin_")
os.system("mv %s %s"%(bin_,new_name))
os.system("touch %s"%output)
rule post_processing :
input: "{group}/binning/metabat2/bins/name_done"
output:"{group}/binning/metabat2/clustering_metabat2.csv"
conda : CONDA_ENV + "/pythonenv.yaml"
resources:
slurm_partition = get_resource("partition"),
mem_mb = get_resource("mem")
singularity : "docker://quay.io/annacprice/pythonenv:3.9"
shell: """
{SCRIPTS}/post_processing.py -o {output} -w {wildcards.group}
"""