-
Notifications
You must be signed in to change notification settings - Fork 1
/
pangeblocks_docker
executable file
·147 lines (143 loc) · 3.92 KB
/
pangeblocks_docker
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
#!/usr/bin/env python3
"""
Compute a Variation Graph from an MSA.
This programs only parses some command line options and produces the snakemake call to compute a single graph.
"""
import argparse
import pathlib
import subprocess
import os
# Command line options
parser = argparse.ArgumentParser()
parser.add_argument(
"--path-msa",
help="path to MSA in .fa format",
dest="path_msa",
type=pathlib.Path,
default="/data/sars-cov-2.fa",
)
parser.add_argument(
"--path-gfa",
help="path to save the output in GFA format",
dest="path_gfa",
type=pathlib.Path,
default="/results/sars-cov-2.gfa",
)
parser.add_argument(
"--dir-subsolutions",
help="directory where suboptimal coverage are saved",
dest="dir_subsolutions",
type=pathlib.Path,
default="/results/submsa",
)
parser.add_argument(
"--path-vert-blocks",
help="json file with vertical blocks",
dest="path_vert_blocks",
type=pathlib.Path,
)
parser.add_argument(
"--log-level",
default="ERROR",
dest="log_level",
help="set log level (ERROR/WARNING/INFO/DEBUG)",
)
parser.add_argument(
"--obj-function",
help="the objective function to optimize",
dest="obj_function",
choices=["nodes", "strings", "weighted", "depth", "depth_and_len"],
default="weighted",
)
parser.add_argument(
"--penalization",
help="used only with the weighted obj function",
dest="penalization",
default=1000,
type=int,
)
parser.add_argument(
"--min-len",
help="used only with the weighted obj function",
dest="min_len",
default=2,
type=int,
)
parser.add_argument(
"--time-limit", help="Timeout (in minutes)", dest="time_limit", default=10, type=int
)
parser.add_argument(
"--threshold-vertical-blocks",
help="minimum width of a vertical block",
dest="alpha",
default=50,
type=int,
)
parser.add_argument(
"--min-coverage", help="", dest="min_coverage", default=0.2, type=float
)
parser.add_argument(
"--larger-decomposition",
help="",
dest="standard_decomposition",
action="store_true",
)
parser.add_argument(
"--consistent",
help="use an alpha-consistent strategy",
dest="consistent",
action="store_true",
)
parser.add_argument(
"--cores", help="Number of cores to be used", dest="threads", default="2", type=int
)
parser.add_argument(
"--submsa_threads", help="", dest="submsa_threads", default=2, type=int
)
parser.add_argument("--ilp-threads", help="", dest="ilp_threads", default=2, type=int)
parser.add_argument(
"--max-memory",
help="Maximum RAM used (in MBytes)",
dest="max_memory",
default=5120,
type=int,
)
parser.add_argument(
"--min-rows-block", help="", dest="min_rows_block", default=0, type=int
)
parser.add_argument(
"--max-rows-block", help="", dest="max_rows_block", default=0, type=int
)
parser.add_argument(
"--max-msa-size", help="", dest="max_msa_size", default=80000, type=int
)
args = parser.parse_args()
cmds = [
f"snakemake",
f"-c{args.threads}",
f"--printshellcmds",
f"-s",
"pangeblocks_docker.smk",
f"--directory={pathlib.Path(os.path.realpath(args.path_gfa)).parent}",
f"--config",
f"root_dir={pathlib.Path(os.path.realpath(__file__)).parents[0]}",
f"PATH_MSA={args.path_msa}",
f"PATH_OUTPUT={args.path_gfa}",
f"OBJECTIVE_FUNCTION={args.obj_function}",
f"PENALIZATION={args.penalization}",
f"MIN_LEN={args.min_len}",
f"TIME_LIMIT={args.time_limit}",
f"THRESHOLD_VERTICAL_BLOCKS={args.alpha}",
f"MIN_COVERAGE={args.min_coverage}",
f"STANDARD={args.standard_decomposition}",
f"ALPHA_CONSISTENT={args.consistent}",
f"SUBMSAS={args.submsa_threads}",
f"ILP={args.ilp_threads}",
f"MEM_MB={args.max_memory}",
f"MIN_ROWS_FIX_BLOCK={args.min_rows_block}",
f"MIN_COLS_FIX_BLOCK={args.max_rows_block}",
f"MAX_POSITIONS_SUBMSAS={args.max_msa_size}",
f"LOG_LEVEL={args.log_level}",
]
print(" ".join(cmds))
subprocess.run(cmds)