-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalign_all_HLA.smk
206 lines (187 loc) · 6.64 KB
/
align_all_HLA.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import os
genes = []
with open("genes_HLA_full.txt", "r") as f:
genes = [gene.strip() for gene in f.readlines()]
error_levels = ["0", "3", "5"]
recs= ["0", "1", "2"]
split_read_files = []
for gene in genes:
for rec in recs:
for err in error_levels:
output_dir = f"output/HLA/genes/{gene}/{rec}/reads_{err}_split"
if os.path.exists(output_dir):
for read_file in os.listdir(output_dir):
if read_file.startswith("read_") and read_file.endswith(".fa"):
path = os.path.join(f"{gene}/{rec}/reads_{err}_split", read_file.split(".")[0])
split_read_files.append(path)
genes_short = []
with open("genes_HLA_short.txt", "r") as f:
genes_short = [gene.strip() for gene in f.readlines()]
split_read_files_short = []
for gene in genes_short:
for rec in recs:
for err in error_levels:
output_dir = f"output/HLA/genes/{gene}/{rec}/reads_{err}_split"
if os.path.exists(output_dir):
for read_file in os.listdir(output_dir):
if read_file.startswith("read_") and read_file.endswith(".fa"):
path = os.path.join(f"{gene}/{rec}/reads_{err}_split", read_file.split(".")[0])
split_read_files_short.append(path)
rule all:
input:
"bin/recgraph_a_star",
"bin/minichain",
"bin/recgraph",
"bin/minigraph",
expand("output/HLA/{mode}/{read_path}.gaf",
mode=["ga", "ra_c", "ra_s","ra_f","mc", "mg"],
read_path=split_read_files
),
expand("output/HLA/rg/{read_path}.gaf",
read_path=split_read_files_short
)
rule build_minichain:
output:
"bin/minichain"
shadow: "shallow"
conda: "envs/rust.yaml"
threads: 4
shell:
"""
mkdir minichain
cd minichain
git clone https://github.com/at-cg/minichain
cd minichain && make
cd ../..
cp minichain/minichain/minichain {output}
"""
rule build_recgraph_a_star:
output:
"bin/recgraph_a_star"
shadow: "shallow"
conda: "envs/rust.yaml"
threads: 4
shell:
"""
mkdir a_star
cd a_star
git clone https://github.com/AlgoLab/RecGraph.git
cd RecGraph/
git checkout a_star
cargo build --release --jobs {threads}
cd ../..
cp a_star/RecGraph/target/release/recalign {output}
"""
rule build_recgraph:
output:
"bin/recgraph"
shadow: "shallow"
conda: "envs/rust.yaml"
threads: 4
shell:
"""
git clone https://github.com/AlgoLab/RecGraph.git
cd RecGraph/
git checkout main
cargo build --release --jobs {threads}
cd ..
cp RecGraph/target/release/recgraph {output}
"""
rule build_minigraph:
output:
"bin/minigraph"
shadow: "shallow"
conda: "envs/rust.yaml"
threads: 4
shell:
"""
mkdir minigraph
cd minigraph
git clone https://github.com/lh3/minigraph
cd minigraph && make
cd ../..
cp minigraph/minigraph/minigraph {output}
"""
rule generate_mc_graphs:
input:
gfa="output/HLA/genes/{gene}/graph.gfa",
output:
w_gfa="output/HLA/genes/{gene}/w_graph.gfa"
shell:
"python scripts/mc_fix.py {input.gfa} > {output.w_gfa} "
rule run_recgraph_a_star_chaining:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
rg = "bin/recgraph_a_star"
log:
"output/HLA/ra_c/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/ra_c/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.rg} -q {input.fa} -g {input.gfa} -s 14 -r 4 -k 2 -e chaining> {output} 2> {log}"
rule run_recgraph_a_star_seeding:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
rg = "bin/recgraph_a_star"
log:
"output/HLA/ra_s/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/ra_s/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.rg} -q {input.fa} -g {input.gfa} -s 14 -r 4 -k 2 -e seeding> {output} 2> {log}"
rule run_recgraph_a_star_fast:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
rg = "bin/recgraph_a_star"
log:
"output/HLA/ra_f/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/ra_f/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.rg} -q {input.fa} -g {input.gfa} -s 14 -r 4 -k 2 -e fast> {output} 2> {log}"
rule run_minichain:
input:
minichain="bin/minichain",
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/w_graph.gfa",
log:
"output/HLA/mc/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/mc/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.minichain} -cx lr {input.gfa} {input.fa} -R 4 -k 12 -w 8 > {output} 2> {log}"
rule run_graphaligner:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
log:
"output/HLA/ga/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/ga/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v GraphAligner -f {input.fa} -g {input.gfa} -a {output} -x vg 2> {log}"
rule run_minigraph:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
mg = "bin/minigraph"
log:
"output/HLA/mg/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/mg/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.mg} -cxsr {input.gfa} {input.fa} > {output} 2> {log}"
rule run_recgraph:
input:
fa="output/HLA/genes/{gene}/{rec}/reads_{err}_split/{read_file}.fa",
gfa="output/HLA/genes/{gene}/graph.gfa",
rg = "bin/recgraph"
log:
"output/HLA/rg/{gene}/{rec}/reads_{err}_split/{read_file}.log"
output:
"output/HLA/rg/{gene}/{rec}/reads_{err}_split/{read_file}.gaf"
shell:
"/usr/bin/time -v {input.rg} {input.fa} {input.gfa} -m 8 > {output} 2> {log}"