shared.smk 3.6 KB
Newer Older
Philipp Spohr's avatar
Philipp Spohr committed
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
rule qualityControl:
	input:
		read1 = 'data/input/'+config['input_folder']+'/{id}'+config['input_read_1_ending'],
		read2 = 'data/input/'+ config['input_folder'] + '/{id}' + config['input_read_2_ending']
	output:
		read1 = 'data/auxiliary/'+config['input_folder']+'/{id}'+'.qc'+config['input_read_1_ending'],
		read2= 'data/auxiliary/' + config['input_folder'] + '/{id}' + '.qc' + config['input_read_2_ending'],
		jsonreport = 'data/auxiliary/' + config['input_folder'] + '/qc/{id}' + '.json',
		htmlreport = report('data/auxiliary/' + config['input_folder'] + '/qc/{id}' + '.html',category='Preprocessing',caption='../report/qualityControl.rst')
	params:
		# cluster execution
		cpus = '1',
		mem = '32G',
		gpus = '0',
		walltime = '00:15:00'
	log:
		'logs/' + config['input_folder'] + '/{id}/qualityControl.log'
	conda:
		'../envs/fastp.yaml'
	shell:
		'fastp -i {input.read1} -I {input.read2} -o {output.read1} -O {output.read2} -h {output.htmlreport} -j {output.jsonreport} > {log}'


if config['useSubset']:

	rule spaTypesToSequences:
		input:
			repeats = 'data/input/' + config['spa_repeats_file'],
			types = 'data/input/' + config['spa_types'],
			filterList = 'data/input/'+config['subsetFile']
		output:
			out = 'data/auxiliary/spaSequences.fa'
		params:
			# cluster execution
			cpus = '1',
			mem = '32G',
			gpus = '0',
			walltime = '00:15:00'
		conda:
			'../envs/biopythonworkbench.yaml'
		script:
			'../scripts/spaTypesToSequences.py'
else:

	rule spaTypesToSequences:
		input:
			repeats = 'data/input/' + config['spa_repeats_file'],
			types = 'data/input/' + config['spa_types']
		output:
			out = 'data/auxiliary/spaSequences.fa'
		params:
			# cluster execution
			cpus = '1',
			mem = '32G',
			gpus = '0',
			walltime = '00:15:00'
		conda:
			'../envs/biopythonworkbench.yaml'
		script:
			'../scripts/spaTypesToSequences.py'


rule index_bwa:
	input:
		'{any}.bam'
	output:
		'{any}.bam.bai'
	params:
		# cluster execution
		cpus = '1',
		mem = '32G',
		gpus = '0',
		walltime = '00:15:00'
	conda:
		'../envs/biopythonworkbench.yaml'
	shell:
		'samtools index {input}'



rule createBWAMemIndex:
	input:
		'{any}.fa'
	output:
		 '{any}.fa.bwt'
	params:
		# cluster execution
		cpus = '1',
		mem = '32G',
		gpus = '0',
		walltime = '00:15:00'
	singularity:
		'docker://biocontainers/bwa:v0.7.17-3-deb_cv1'
	shell:
		'bwa index {input}'

rule sort_bwa:
	input:
		'{any}.bam'
	output:
		'{any}.sorted.bam'
	params:
		# cluster execution
		cpus = '1',
		mem = '16G',
		gpus = '0',
		walltime = '00:15:00'
	conda:
		'../envs/biopythonworkbench.yaml'
	shell:
		'samtools sort {input} -o {output} -m 4G' #TODO 4 G limitation needed?



rule summarize:
	input:
		results = expand('data/auxiliary/'+config['input_folder']+'/kmers/{{kmer}}/{id}/scores.{{mode}}.tsv',id=inputIDs)
	output:
		summary = report('data/output/'+config['input_folder']+'/kmers/{kmer}/predictions.{mode}.tsv',category="Spa-Type Predictions",caption="../report/prediction.snk")
	params:
		# cluster execution
		cpus = '1',
		mem = '8G',
		gpus = '0',
		walltime = '00:05:00'
	conda:
		'../envs/biopythonworkbench.yaml'
	script:
		'../scripts/summarize.py'

rule metaSummarize:
	input:
		summary = expand('data/output/'+config['input_folder']+'/kmers/{kmer}/predictions.{{mode}}.tsv',kmer=kmer_lengths),
		groundTruth = 'data/input/' + config['ground_truth']
	output:
		meta = 'data/output/'+config['input_folder']+'/metaSummary.{mode}.tsv'
	params:
		# cluster execution
		cpus = '1',
		mem = '8G',
		gpus = '0',
		walltime = '00:05:00'
	conda:
		'../envs/biopythonworkbench.yaml'
	log:
		'logs/'+config['input_folder']+'/metaSummary.{mode}.log'
	script:
		'../scripts/metaSummarize.py'