pheval-exomiser 0.1.3__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pheval_exomiser/constants.py +8 -0
- pheval_exomiser/post_process/post_process.py +14 -10
- pheval_exomiser/post_process/post_process_results_format.py +277 -172
- pheval_exomiser/prepare/create_batch_commands.py +177 -160
- pheval_exomiser/prepare/tool_specific_configuration_options.py +65 -0
- pheval_exomiser/prepare/write_application_properties.py +182 -0
- pheval_exomiser/run/run.py +115 -234
- pheval_exomiser/runner.py +29 -24
- pheval_exomiser-0.2.1.dist-info/METADATA +183 -0
- pheval_exomiser-0.2.1.dist-info/RECORD +18 -0
- {pheval_exomiser-0.1.3.dist-info → pheval_exomiser-0.2.1.dist-info}/WHEEL +1 -1
- pheval_exomiser/config_parser.py +0 -160
- pheval_exomiser/prepare/prepare.py +0 -56
- pheval_exomiser/utils/__init__.py +0 -0
- pheval_exomiser/utils/exomiser_config_parser.py +0 -0
- pheval_exomiser-0.1.3.dist-info/METADATA +0 -36
- pheval_exomiser-0.1.3.dist-info/RECORD +0 -19
- {pheval_exomiser-0.1.3.dist-info → pheval_exomiser-0.2.1.dist-info}/entry_points.txt +0 -0
|
@@ -10,14 +10,25 @@ from pheval.prepare.custom_exceptions import MutuallyExclusiveOptionError
|
|
|
10
10
|
from pheval.utils.file_utils import all_files, files_with_suffix, obtain_closest_file_name
|
|
11
11
|
from pheval.utils.phenopacket_utils import PhenopacketUtil, phenopacket_reader
|
|
12
12
|
|
|
13
|
+
from pheval_exomiser.constants import (
|
|
14
|
+
EXOMISER_YAML_TARGET_DIRECTORY_DOCKER,
|
|
15
|
+
OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER,
|
|
16
|
+
PHENOPACKET_TARGET_DIRECTORY_DOCKER,
|
|
17
|
+
RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
|
|
18
|
+
VCF_TARGET_DIRECTORY_DOCKER,
|
|
19
|
+
)
|
|
20
|
+
|
|
13
21
|
|
|
14
22
|
@dataclass
|
|
15
23
|
class ExomiserCommandLineArguments:
|
|
16
24
|
"""Store command line arguments for each phenopacket to be run with Exomiser."""
|
|
17
25
|
|
|
18
26
|
sample: Path
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
analysis_yaml: Path or None = None
|
|
28
|
+
vcf_file: Path or None = None
|
|
29
|
+
vcf_assembly: str or None = None
|
|
30
|
+
raw_results_dir: Path or None = None
|
|
31
|
+
variant_analysis: bool or None = None
|
|
21
32
|
output_options_file: Optional[Path] = None
|
|
22
33
|
|
|
23
34
|
|
|
@@ -26,34 +37,28 @@ def get_all_files_from_output_opt_directory(output_options_dir: Path) -> list[Pa
|
|
|
26
37
|
return None if output_options_dir is None else all_files(output_options_dir)
|
|
27
38
|
|
|
28
39
|
|
|
29
|
-
# def edit_output_options_file_output_prefix(output_options_file: Path, phenopacket_path: Path) -> Path:
|
|
30
|
-
# with open(output_options_file) as output_options:
|
|
31
|
-
# output_opt = yaml.safe_load(output_options)
|
|
32
|
-
# output_options.close()
|
|
33
|
-
# output_opt['outputPrefix'] = output_options_file.absolute().parents[0].joinpath(phenopacket_path.stem)
|
|
34
|
-
# with open
|
|
35
|
-
# (output_options_file.absolute().parents[0].joinpath(phenopacket_path.stem + "-" + str(output_options_file.name)),
|
|
36
|
-
# 'w') as correct_prefixed:
|
|
37
|
-
# yaml.dump(output_opt, correct_prefixed)
|
|
38
|
-
# correct_prefixed.close()
|
|
39
|
-
# return
|
|
40
|
-
# output_options_file.absolute().parents[0].joinpath(phenopacket_path.stem + "-" + str(output_options_file.name))
|
|
41
|
-
|
|
42
|
-
|
|
43
40
|
class CommandCreator:
|
|
44
41
|
"""Create a command for a phenopacket."""
|
|
45
42
|
|
|
46
43
|
def __init__(
|
|
47
44
|
self,
|
|
45
|
+
environment: str,
|
|
48
46
|
phenopacket_path: Path,
|
|
49
47
|
phenopacket: Phenopacket or Family,
|
|
48
|
+
variant_analysis: bool,
|
|
50
49
|
output_options_dir_files: list[Path] or None,
|
|
51
50
|
output_options_file: Path or None,
|
|
51
|
+
raw_results_dir: Path or None,
|
|
52
|
+
analysis_yaml: Path or None,
|
|
52
53
|
):
|
|
54
|
+
self.environment = environment
|
|
53
55
|
self.phenopacket_path = phenopacket_path
|
|
54
56
|
self.phenopacket = phenopacket
|
|
57
|
+
self.variant_analysis = variant_analysis
|
|
55
58
|
self.output_options_dir_files = output_options_dir_files
|
|
56
59
|
self.output_options_file = output_options_file
|
|
60
|
+
self.results_dir = raw_results_dir
|
|
61
|
+
self.analysis_yaml = analysis_yaml
|
|
57
62
|
|
|
58
63
|
def assign_output_options_file(self) -> Path or None:
|
|
59
64
|
"""Return the path of a single output option yaml if specified,
|
|
@@ -67,32 +72,75 @@ class CommandCreator:
|
|
|
67
72
|
else obtain_closest_file_name(self.phenopacket_path, self.output_options_dir_files)
|
|
68
73
|
)
|
|
69
74
|
|
|
70
|
-
def
|
|
71
|
-
|
|
75
|
+
def add_phenotype_only_arguments(self) -> ExomiserCommandLineArguments:
|
|
76
|
+
output_options_file = self.assign_output_options_file()
|
|
77
|
+
if self.environment == "docker":
|
|
78
|
+
return ExomiserCommandLineArguments(
|
|
79
|
+
sample=f"{PHENOPACKET_TARGET_DIRECTORY_DOCKER}{Path(self.phenopacket_path.name)}",
|
|
80
|
+
variant_analysis=self.variant_analysis,
|
|
81
|
+
output_options_file=(
|
|
82
|
+
f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
|
|
83
|
+
if output_options_file is not None
|
|
84
|
+
else None
|
|
85
|
+
),
|
|
86
|
+
raw_results_dir=RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
|
|
87
|
+
)
|
|
88
|
+
elif self.environment == "local":
|
|
89
|
+
return ExomiserCommandLineArguments(
|
|
90
|
+
sample=Path(self.phenopacket_path),
|
|
91
|
+
variant_analysis=self.variant_analysis,
|
|
92
|
+
output_options_file=output_options_file,
|
|
93
|
+
raw_results_dir=self.results_dir,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def add_variant_analysis_arguments(self, vcf_dir: Path) -> ExomiserCommandLineArguments:
|
|
72
97
|
vcf_file_data = PhenopacketUtil(self.phenopacket).vcf_file_data(
|
|
73
98
|
self.phenopacket_path, vcf_dir
|
|
74
99
|
)
|
|
75
100
|
output_options_file = self.assign_output_options_file()
|
|
76
|
-
if
|
|
101
|
+
if self.environment == "local":
|
|
77
102
|
return ExomiserCommandLineArguments(
|
|
78
103
|
sample=Path(self.phenopacket_path),
|
|
79
104
|
vcf_file=Path(vcf_file_data.uri),
|
|
80
105
|
vcf_assembly=vcf_file_data.file_attributes["genomeAssembly"],
|
|
106
|
+
output_options_file=output_options_file,
|
|
107
|
+
variant_analysis=self.variant_analysis,
|
|
108
|
+
raw_results_dir=self.results_dir,
|
|
109
|
+
analysis_yaml=self.analysis_yaml,
|
|
81
110
|
)
|
|
82
|
-
|
|
111
|
+
elif self.environment == "docker":
|
|
83
112
|
return ExomiserCommandLineArguments(
|
|
84
|
-
sample=Path(self.phenopacket_path),
|
|
85
|
-
vcf_file=Path(vcf_file_data.uri),
|
|
113
|
+
sample=f"{PHENOPACKET_TARGET_DIRECTORY_DOCKER}{Path(self.phenopacket_path.name)}",
|
|
114
|
+
vcf_file=f"{VCF_TARGET_DIRECTORY_DOCKER}{Path(vcf_file_data.uri).name}",
|
|
86
115
|
vcf_assembly=vcf_file_data.file_attributes["genomeAssembly"],
|
|
87
|
-
output_options_file=
|
|
116
|
+
output_options_file=(
|
|
117
|
+
f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
|
|
118
|
+
if output_options_file is not None
|
|
119
|
+
else None
|
|
120
|
+
),
|
|
121
|
+
variant_analysis=self.variant_analysis,
|
|
122
|
+
raw_results_dir=RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
|
|
123
|
+
analysis_yaml=f"{EXOMISER_YAML_TARGET_DIRECTORY_DOCKER}{Path(self.analysis_yaml).name}",
|
|
88
124
|
)
|
|
89
125
|
|
|
126
|
+
def add_command_line_arguments(self, vcf_dir: Path or None) -> ExomiserCommandLineArguments:
|
|
127
|
+
"""Return a dataclass of all the command line arguments corresponding to phenopacket sample."""
|
|
128
|
+
return (
|
|
129
|
+
self.add_variant_analysis_arguments(vcf_dir)
|
|
130
|
+
if self.variant_analysis
|
|
131
|
+
else self.add_phenotype_only_arguments()
|
|
132
|
+
)
|
|
133
|
+
|
|
90
134
|
|
|
91
135
|
def create_command_arguments(
|
|
136
|
+
environment: str,
|
|
92
137
|
phenopacket_dir: Path,
|
|
138
|
+
phenotype_only: bool,
|
|
93
139
|
vcf_dir: Path,
|
|
140
|
+
results_dir: Path or None,
|
|
94
141
|
output_options_dir: Path or None = None,
|
|
95
142
|
output_options_file: Path or None = None,
|
|
143
|
+
analysis_yaml: Path or None = None,
|
|
96
144
|
) -> list[ExomiserCommandLineArguments]:
|
|
97
145
|
"""Return a list of Exomiser command line arguments for a directory of phenopackets."""
|
|
98
146
|
phenopacket_paths = files_with_suffix(phenopacket_dir, ".json")
|
|
@@ -100,12 +148,16 @@ def create_command_arguments(
|
|
|
100
148
|
output_option_dir_files = get_all_files_from_output_opt_directory(output_options_dir)
|
|
101
149
|
for phenopacket_path in phenopacket_paths:
|
|
102
150
|
phenopacket = phenopacket_reader(phenopacket_path)
|
|
103
|
-
# output_options_file = edit_output_options_file_output_prefix(output_options_file,
|
|
104
|
-
# phenopacket_path) if output_options_file \
|
|
105
|
-
# is not None else None
|
|
106
151
|
commands.append(
|
|
107
152
|
CommandCreator(
|
|
108
|
-
|
|
153
|
+
environment,
|
|
154
|
+
phenopacket_path,
|
|
155
|
+
phenopacket,
|
|
156
|
+
phenotype_only,
|
|
157
|
+
output_option_dir_files,
|
|
158
|
+
output_options_file,
|
|
159
|
+
results_dir,
|
|
160
|
+
analysis_yaml,
|
|
109
161
|
).add_command_line_arguments(vcf_dir)
|
|
110
162
|
)
|
|
111
163
|
return commands
|
|
@@ -114,92 +166,86 @@ def create_command_arguments(
|
|
|
114
166
|
class CommandsWriter:
|
|
115
167
|
"""Write a command to file."""
|
|
116
168
|
|
|
117
|
-
def __init__(self, file: Path):
|
|
169
|
+
def __init__(self, file: Path, variant_analysis: bool):
|
|
118
170
|
self.file = open(file, "w")
|
|
171
|
+
self.variant_analysis = variant_analysis
|
|
119
172
|
|
|
120
|
-
def
|
|
121
|
-
|
|
122
|
-
) -> None:
|
|
123
|
-
"""Write a command out for exomiser to run."""
|
|
173
|
+
def write_basic_analysis_command(self, command_arguments: ExomiserCommandLineArguments):
|
|
174
|
+
"""Write basic analysis command for Exomiser"""
|
|
124
175
|
try:
|
|
125
176
|
self.file.write(
|
|
126
177
|
"--analysis "
|
|
127
|
-
+ str(analysis_yaml)
|
|
178
|
+
+ str(command_arguments.analysis_yaml)
|
|
128
179
|
+ " --sample "
|
|
129
180
|
+ str(command_arguments.sample)
|
|
130
181
|
+ " --vcf "
|
|
131
182
|
+ str(command_arguments.vcf_file)
|
|
132
183
|
+ " --assembly "
|
|
133
184
|
+ command_arguments.vcf_assembly
|
|
134
|
-
+ "
|
|
185
|
+
+ " --output-filename "
|
|
186
|
+
+ f"{command_arguments.sample.stem}-exomiser"
|
|
135
187
|
)
|
|
136
188
|
except IOError:
|
|
137
189
|
print("Error writing ", self.file)
|
|
138
190
|
|
|
139
|
-
def
|
|
140
|
-
|
|
141
|
-
) -> None:
|
|
142
|
-
"""Write a docker command out for exomiser to run."""
|
|
191
|
+
def write_results_dir(self, command_arguments: ExomiserCommandLineArguments) -> None:
|
|
192
|
+
"""Write results directory for exomiser ≥13.2.0 to run."""
|
|
143
193
|
try:
|
|
144
|
-
|
|
145
|
-
"--
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
+ str("/exomiser-testdata-phenopacket/" + command_arguments.sample.name)
|
|
149
|
-
+ " --vcf "
|
|
150
|
-
+ str("/exomiser-testdata-vcf/" + command_arguments.vcf_file.name)
|
|
151
|
-
+ " --assembly "
|
|
152
|
-
+ command_arguments.vcf_assembly
|
|
153
|
-
+ "\n"
|
|
194
|
+
(
|
|
195
|
+
self.file.write(" --output-directory " + str(command_arguments.raw_results_dir))
|
|
196
|
+
if command_arguments.raw_results_dir is not None
|
|
197
|
+
else None
|
|
154
198
|
)
|
|
155
199
|
except IOError:
|
|
156
200
|
print("Error writing ", self.file)
|
|
157
201
|
|
|
158
|
-
def
|
|
159
|
-
|
|
160
|
-
) -> None:
|
|
161
|
-
"""Write a command out for exomiser to run - including output option file specified."""
|
|
202
|
+
def write_output_options(self, command_arguments: ExomiserCommandLineArguments) -> None:
|
|
203
|
+
"""Write a command out for exomiser ≤13.1.0 to run - including output option file specified."""
|
|
162
204
|
try:
|
|
163
|
-
|
|
164
|
-
"--
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
+ str(command_arguments.sample)
|
|
168
|
-
+ " --vcf "
|
|
169
|
-
+ str(command_arguments.vcf_file)
|
|
170
|
-
+ " --assembly "
|
|
171
|
-
+ command_arguments.vcf_assembly
|
|
172
|
-
+ " --output "
|
|
173
|
-
+ str(command_arguments.output_options_file)
|
|
174
|
-
+ "\n"
|
|
205
|
+
(
|
|
206
|
+
self.file.write(" --output " + str(command_arguments.output_options_file))
|
|
207
|
+
if command_arguments.output_options_file is not None
|
|
208
|
+
else None
|
|
175
209
|
)
|
|
176
210
|
except IOError:
|
|
177
211
|
print("Error writing ", self.file)
|
|
178
212
|
|
|
179
|
-
def
|
|
180
|
-
self
|
|
213
|
+
def write_analysis_command(self, command_arguments: ExomiserCommandLineArguments):
|
|
214
|
+
self.write_basic_analysis_command(command_arguments)
|
|
215
|
+
self.write_results_dir(command_arguments)
|
|
216
|
+
self.write_output_options(command_arguments)
|
|
217
|
+
self.file.write("\n")
|
|
218
|
+
|
|
219
|
+
def write_basic_phenotype_only_command(
|
|
220
|
+
self, command_arguments: ExomiserCommandLineArguments
|
|
181
221
|
) -> None:
|
|
182
|
-
"""Write a
|
|
222
|
+
"""Write a phenotype-only command out for exomiser ≥13.2.0 to run."""
|
|
183
223
|
try:
|
|
184
224
|
self.file.write(
|
|
185
|
-
"--
|
|
186
|
-
+ str(
|
|
187
|
-
+ " --
|
|
188
|
-
+ str(
|
|
189
|
-
+ " --
|
|
190
|
-
+
|
|
191
|
-
+ " --
|
|
192
|
-
+
|
|
193
|
-
+ " --output "
|
|
194
|
-
+ str(
|
|
195
|
-
"/exomiser-testdata-output-options/"
|
|
196
|
-
+ command_arguments.output_options_file.name
|
|
197
|
-
)
|
|
198
|
-
+ "\n"
|
|
225
|
+
"--sample "
|
|
226
|
+
+ str(command_arguments.sample)
|
|
227
|
+
+ " --output-directory "
|
|
228
|
+
+ str(command_arguments.raw_results_dir)
|
|
229
|
+
+ " --output-filename "
|
|
230
|
+
+ f"{Path(command_arguments.sample).stem}-exomiser"
|
|
231
|
+
+ " --preset "
|
|
232
|
+
+ "phenotype-only"
|
|
199
233
|
)
|
|
200
234
|
except IOError:
|
|
201
235
|
print("Error writing ", self.file)
|
|
202
236
|
|
|
237
|
+
def write_phenotype_only_command(self, command_arguments: ExomiserCommandLineArguments):
|
|
238
|
+
self.write_basic_phenotype_only_command(command_arguments)
|
|
239
|
+
self.write_output_options(command_arguments)
|
|
240
|
+
self.file.write("\n")
|
|
241
|
+
|
|
242
|
+
def write_local_commands(self, command_arguments: ExomiserCommandLineArguments):
|
|
243
|
+
(
|
|
244
|
+
self.write_analysis_command(command_arguments)
|
|
245
|
+
if self.variant_analysis
|
|
246
|
+
else self.write_phenotype_only_command(command_arguments)
|
|
247
|
+
)
|
|
248
|
+
|
|
203
249
|
def close(self) -> None:
|
|
204
250
|
"""Close file."""
|
|
205
251
|
try:
|
|
@@ -213,64 +259,37 @@ class BatchFileWriter:
|
|
|
213
259
|
|
|
214
260
|
def __init__(
|
|
215
261
|
self,
|
|
216
|
-
analysis_yaml: Path,
|
|
217
262
|
command_arguments_list: list[ExomiserCommandLineArguments],
|
|
263
|
+
variant_analysis: bool,
|
|
218
264
|
output_dir: Path,
|
|
219
265
|
batch_prefix: str,
|
|
220
266
|
):
|
|
221
|
-
self.analysis_yaml = analysis_yaml
|
|
222
267
|
self.command_arguments_list = command_arguments_list
|
|
268
|
+
self.variant_analysis = variant_analysis
|
|
223
269
|
self.output_dir = output_dir
|
|
224
270
|
self.batch_prefix = batch_prefix
|
|
225
271
|
|
|
226
272
|
def write_commands(self, commands_writer: CommandsWriter) -> None:
|
|
227
273
|
"""Write command arguments to a file."""
|
|
228
274
|
for command_arguments in self.command_arguments_list:
|
|
229
|
-
commands_writer.
|
|
230
|
-
self.analysis_yaml, command_arguments
|
|
231
|
-
) if command_arguments.output_options_file is None else commands_writer.write_command_output_options(
|
|
232
|
-
self.analysis_yaml, command_arguments
|
|
233
|
-
)
|
|
234
|
-
commands_writer.close()
|
|
235
|
-
|
|
236
|
-
def write_docker_commands(self, commands_writer: CommandsWriter) -> None:
|
|
237
|
-
"""Write docker command arguments to a file."""
|
|
238
|
-
for command_arguments in self.command_arguments_list:
|
|
239
|
-
commands_writer.write_docker_command(
|
|
240
|
-
self.analysis_yaml, command_arguments
|
|
241
|
-
) if command_arguments.output_options_file is None else commands_writer.write_docker_command_output_options(
|
|
242
|
-
self.analysis_yaml, command_arguments
|
|
243
|
-
)
|
|
275
|
+
commands_writer.write_local_commands(command_arguments)
|
|
244
276
|
commands_writer.close()
|
|
245
277
|
|
|
246
278
|
def write_temp_file(self) -> str:
|
|
247
279
|
"""Write commands out to a temporary file."""
|
|
248
280
|
temp = tempfile.NamedTemporaryFile(delete=False)
|
|
249
|
-
commands_writer = CommandsWriter(Path(temp.name))
|
|
281
|
+
commands_writer = CommandsWriter(Path(temp.name), self.variant_analysis)
|
|
250
282
|
self.write_commands(commands_writer)
|
|
251
283
|
return temp.name
|
|
252
284
|
|
|
253
|
-
def write_docker_temp_file(self) -> str:
|
|
254
|
-
"""Write docker commands out to a temporary file."""
|
|
255
|
-
temp = tempfile.NamedTemporaryFile(delete=False)
|
|
256
|
-
commands_writer = CommandsWriter(Path(temp.name))
|
|
257
|
-
self.write_docker_commands(commands_writer)
|
|
258
|
-
return temp.name
|
|
259
|
-
|
|
260
285
|
def write_all_commands(self) -> None:
|
|
261
286
|
"""Write all commands out to a single file."""
|
|
262
287
|
commands_writer = CommandsWriter(
|
|
263
|
-
Path(self.output_dir).joinpath(self.batch_prefix + "-exomiser-batch.txt")
|
|
288
|
+
Path(self.output_dir).joinpath(self.batch_prefix + "-exomiser-batch.txt"),
|
|
289
|
+
self.variant_analysis,
|
|
264
290
|
)
|
|
265
291
|
self.write_commands(commands_writer)
|
|
266
292
|
|
|
267
|
-
def write_all_docker_commands(self) -> None:
|
|
268
|
-
"""Write all docker commands out to a single file."""
|
|
269
|
-
commands_writer = CommandsWriter(
|
|
270
|
-
Path(self.output_dir).joinpath(self.batch_prefix + "-exomiser-batch.txt")
|
|
271
|
-
)
|
|
272
|
-
self.write_docker_commands(commands_writer)
|
|
273
|
-
|
|
274
293
|
def create_split_batch_files(self, max_jobs: int) -> None:
|
|
275
294
|
"""Split temp file into separate batch files, dependent on the number of max jobs allocated to each file."""
|
|
276
295
|
temp_file_name = self.write_temp_file()
|
|
@@ -292,27 +311,6 @@ class BatchFileWriter:
|
|
|
292
311
|
tmp_file.close()
|
|
293
312
|
Path(temp_file_name).unlink()
|
|
294
313
|
|
|
295
|
-
def create_docker_split_batch_files(self, max_jobs: int) -> None:
|
|
296
|
-
"""Split temp file into separate batch files, dependent on the number of max jobs allocated to each file."""
|
|
297
|
-
temp_file_name = self.write_docker_temp_file()
|
|
298
|
-
lines_per_file, f_name = max_jobs, 0
|
|
299
|
-
splitfile = None
|
|
300
|
-
with open(temp_file_name) as tmp_file:
|
|
301
|
-
for lineno, line in enumerate(tmp_file):
|
|
302
|
-
if lineno % lines_per_file == 0:
|
|
303
|
-
f_name += 1
|
|
304
|
-
if splitfile:
|
|
305
|
-
splitfile.close()
|
|
306
|
-
split_filename = Path(self.output_dir).joinpath(
|
|
307
|
-
self.batch_prefix + "-exomiser-batch-{}.txt".format(f_name)
|
|
308
|
-
)
|
|
309
|
-
splitfile = open(split_filename, "w")
|
|
310
|
-
splitfile.write(line)
|
|
311
|
-
if splitfile:
|
|
312
|
-
splitfile.close()
|
|
313
|
-
tmp_file.close()
|
|
314
|
-
Path(temp_file_name).unlink()
|
|
315
|
-
|
|
316
314
|
|
|
317
315
|
def create_batch_file(
|
|
318
316
|
environment: str,
|
|
@@ -322,35 +320,37 @@ def create_batch_file(
|
|
|
322
320
|
output_dir: Path,
|
|
323
321
|
batch_prefix: str,
|
|
324
322
|
max_jobs: int,
|
|
323
|
+
variant_analysis: bool,
|
|
324
|
+
results_dir: Path,
|
|
325
325
|
output_options_dir: Path = None,
|
|
326
326
|
output_options_file: Path = None,
|
|
327
327
|
) -> None:
|
|
328
328
|
"""Create Exomiser batch files."""
|
|
329
|
-
try:
|
|
330
|
-
Path(output_dir).joinpath("exomiser_batch_files").mkdir()
|
|
331
|
-
except FileExistsError:
|
|
332
|
-
pass
|
|
333
329
|
command_arguments = create_command_arguments(
|
|
334
|
-
|
|
330
|
+
environment,
|
|
331
|
+
phenopacket_dir,
|
|
332
|
+
variant_analysis,
|
|
333
|
+
vcf_dir,
|
|
334
|
+
results_dir,
|
|
335
|
+
output_options_dir,
|
|
336
|
+
output_options_file,
|
|
337
|
+
analysis,
|
|
335
338
|
)
|
|
336
|
-
|
|
339
|
+
(
|
|
337
340
|
BatchFileWriter(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
).
|
|
350
|
-
|
|
351
|
-
)
|
|
352
|
-
else:
|
|
353
|
-
raise EnvironmentError
|
|
341
|
+
command_arguments,
|
|
342
|
+
variant_analysis,
|
|
343
|
+
output_dir,
|
|
344
|
+
batch_prefix,
|
|
345
|
+
).write_all_commands()
|
|
346
|
+
if max_jobs == 0
|
|
347
|
+
else BatchFileWriter(
|
|
348
|
+
command_arguments,
|
|
349
|
+
variant_analysis,
|
|
350
|
+
output_dir,
|
|
351
|
+
batch_prefix,
|
|
352
|
+
).create_split_batch_files(max_jobs)
|
|
353
|
+
)
|
|
354
354
|
|
|
355
355
|
|
|
356
356
|
@click.command()
|
|
@@ -366,7 +366,7 @@ def create_batch_file(
|
|
|
366
366
|
@click.option(
|
|
367
367
|
"--analysis-yaml",
|
|
368
368
|
"-a",
|
|
369
|
-
required=
|
|
369
|
+
required=False,
|
|
370
370
|
metavar="FILE",
|
|
371
371
|
type=Path,
|
|
372
372
|
help="Path to the analysis .yml file.",
|
|
@@ -406,6 +406,20 @@ def create_batch_file(
|
|
|
406
406
|
show_default=True,
|
|
407
407
|
help="Number of jobs in each file.",
|
|
408
408
|
)
|
|
409
|
+
@click.option(
|
|
410
|
+
"--phenotype-only",
|
|
411
|
+
type=bool,
|
|
412
|
+
default=False,
|
|
413
|
+
cls=MutuallyExclusiveOptionError,
|
|
414
|
+
mutually_exclusive=["vcf_dir", "analysis_yaml"],
|
|
415
|
+
help="Run Exomiser with phenotype only preset - strongly recommended to run with versions 13.2.0 onwards.",
|
|
416
|
+
)
|
|
417
|
+
@click.option(
|
|
418
|
+
"--results-dir",
|
|
419
|
+
type=Path,
|
|
420
|
+
required=False,
|
|
421
|
+
help="Results directory for Exomiser results - compatible with versions 13.2.0 onwards.",
|
|
422
|
+
)
|
|
409
423
|
@click.option(
|
|
410
424
|
"--output-options-dir",
|
|
411
425
|
"-O",
|
|
@@ -432,12 +446,14 @@ def prepare_exomiser_batch(
|
|
|
432
446
|
phenopacket_dir: Path,
|
|
433
447
|
vcf_dir: Path,
|
|
434
448
|
output_dir: Path,
|
|
435
|
-
batch_prefix,
|
|
436
|
-
max_jobs,
|
|
449
|
+
batch_prefix: str,
|
|
450
|
+
max_jobs: int,
|
|
451
|
+
phenotype_only: bool,
|
|
437
452
|
output_options_dir: Path = None,
|
|
438
453
|
output_options_file: Path = None,
|
|
439
454
|
):
|
|
440
455
|
"""Generate Exomiser batch files."""
|
|
456
|
+
Path(output_dir).joinpath("tool_input_commands").mkdir(exist_ok=True)
|
|
441
457
|
create_batch_file(
|
|
442
458
|
environment,
|
|
443
459
|
analysis_yaml,
|
|
@@ -446,6 +462,7 @@ def prepare_exomiser_batch(
|
|
|
446
462
|
output_dir,
|
|
447
463
|
batch_prefix,
|
|
448
464
|
max_jobs,
|
|
465
|
+
phenotype_only,
|
|
449
466
|
output_options_dir,
|
|
450
467
|
output_options_file,
|
|
451
468
|
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ApplicationProperties(BaseModel):
|
|
7
|
+
"""
|
|
8
|
+
Class for defining the application.properties configurations.
|
|
9
|
+
Args:
|
|
10
|
+
remm_version (str): Version of the REMM database
|
|
11
|
+
cadd_version (str): Version of the CADD database
|
|
12
|
+
hg19_data_version (str): Data version of the hg19 Exomiser data
|
|
13
|
+
hg19_local_frequency_path (Path): The file name of the hg19 local frequency file
|
|
14
|
+
hg19_whitelist_path (Path): The file name of the hg19 whitelist.
|
|
15
|
+
hg38_data_version (str): Data version of the hg38 Exomiser data
|
|
16
|
+
hg38_local_frequency_path (Path): The file name of the hg38 local frequency file
|
|
17
|
+
hg38_whitelist_path (Path): The file name of the hg38 whitelist.
|
|
18
|
+
phenotype_data_version (str): Data version of the Exomiser phenotype data
|
|
19
|
+
cache_caffeine_spec (int): Cache limit
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
remm_version: str = Field(None)
|
|
23
|
+
cadd_version: str = Field(None)
|
|
24
|
+
hg19_data_version: str = Field(None)
|
|
25
|
+
hg19_local_frequency_path: Path = Field(None)
|
|
26
|
+
hg19_whitelist_path: Path = Field(None)
|
|
27
|
+
hg38_data_version: str = Field(None)
|
|
28
|
+
hg38_local_frequency_path: Path = Field(None)
|
|
29
|
+
hg38_whitelist_path: Path = Field(None)
|
|
30
|
+
phenotype_data_version: str = Field(None)
|
|
31
|
+
cache_type: str = Field(None)
|
|
32
|
+
cache_caffeine_spec: int = Field(None)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class PostProcessing(BaseModel):
|
|
36
|
+
"""
|
|
37
|
+
Class for defining the post-processing configurations.
|
|
38
|
+
Args:
|
|
39
|
+
score_name (str): Name of score to extract from results.
|
|
40
|
+
sort_order (str): Order to sort results
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
score_name: str = Field(...)
|
|
44
|
+
sort_order: str = Field(...)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ExomiserConfigurations(BaseModel):
|
|
48
|
+
"""
|
|
49
|
+
Class for defining the Exomiser configurations in tool_specific_configurations field,
|
|
50
|
+
within the input_dir config.yaml
|
|
51
|
+
Args:
|
|
52
|
+
environment (str): Environment to run Exomiser, i.e., local/docker
|
|
53
|
+
exomiser_software_directory (Path): Directory name for Exomiser software directory
|
|
54
|
+
analysis_configuration_file (Path): The file name of the analysis configuration file located in the input_dir
|
|
55
|
+
max_jobs (int): Maximum number of jobs to run in a batch
|
|
56
|
+
application_properties (ApplicationProperties): application.properties configurations
|
|
57
|
+
post_process (PostProcessing): Post-processing configurations
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
environment: str = Field(...)
|
|
61
|
+
exomiser_software_directory: Path = Field(...)
|
|
62
|
+
analysis_configuration_file: Path = Field(...)
|
|
63
|
+
max_jobs: int = Field(...)
|
|
64
|
+
application_properties: ApplicationProperties = Field(...)
|
|
65
|
+
post_process: PostProcessing = Field(...)
|