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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from pheval_exomiser.constants import EXOMISER_DATA_DIRECTORY_TARGET_DOCKER
|
|
5
|
+
from pheval_exomiser.prepare.tool_specific_configuration_options import ExomiserConfigurations
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ExomiserConfigurationFileWriter:
|
|
9
|
+
def __init__(self, input_dir: Path, configurations: ExomiserConfigurations):
|
|
10
|
+
self.input_dir = input_dir
|
|
11
|
+
self.configurations = configurations
|
|
12
|
+
self.application_properties = open(input_dir.joinpath("application.properties"), "w")
|
|
13
|
+
|
|
14
|
+
def write_remm_version(self) -> None:
|
|
15
|
+
"""Write the remm version to application.properties file."""
|
|
16
|
+
if self.configurations.application_properties.remm_version is not None:
|
|
17
|
+
self.application_properties.write(
|
|
18
|
+
f"remm.version={self.configurations.application_properties.remm_version}\n"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def write_cadd_version(self) -> None:
|
|
22
|
+
"""Write the cadd version to application.properties file."""
|
|
23
|
+
if self.configurations.application_properties.cadd_version is not None:
|
|
24
|
+
self.application_properties.write(
|
|
25
|
+
f"cadd.version={self.configurations.application_properties.cadd_version}\n"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def write_exomiser_data_directory(self) -> None:
|
|
29
|
+
"""Write the exomiser data directory to application.properties file."""
|
|
30
|
+
if self.configurations.environment.lower() == "docker":
|
|
31
|
+
self.application_properties.write(
|
|
32
|
+
f"exomiser.data-directory={EXOMISER_DATA_DIRECTORY_TARGET_DOCKER}\n"
|
|
33
|
+
)
|
|
34
|
+
if self.configurations.environment.lower() == "local":
|
|
35
|
+
self.application_properties.write(f"exomiser.data-directory={self.input_dir}\n")
|
|
36
|
+
|
|
37
|
+
def write_exomiser_hg19_data_version(self) -> None:
|
|
38
|
+
"""Write the hg19 data version to application.properties file."""
|
|
39
|
+
if self.configurations.application_properties.hg19_data_version is not None:
|
|
40
|
+
self.application_properties.write(
|
|
41
|
+
f"exomiser.hg19.data-version={self.configurations.application_properties.hg19_data_version}\n"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def write_exomiser_hg19_cadd_snv_path(self) -> None:
|
|
45
|
+
"""Write the hg19 cadd snv path to application.properties file."""
|
|
46
|
+
if (
|
|
47
|
+
self.configurations.application_properties.cadd_version is not None
|
|
48
|
+
and self.configurations.application_properties.hg19_data_version is not None
|
|
49
|
+
):
|
|
50
|
+
self.application_properties.write(
|
|
51
|
+
"exomiser.hg19.cadd-snv-path="
|
|
52
|
+
"${exomiser.data-directory}/cadd/${cadd.version}/hg19/"
|
|
53
|
+
"whole_genome_SNVs.tsv.gz\n"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def write_exomiser_hg19_cadd_indel_path(self) -> None:
|
|
57
|
+
"""Write the hg19 cadd indel path to application.properties file."""
|
|
58
|
+
if (
|
|
59
|
+
self.configurations.application_properties.cadd_version is not None
|
|
60
|
+
and self.configurations.application_properties.hg19_data_version is not None
|
|
61
|
+
):
|
|
62
|
+
self.application_properties.write(
|
|
63
|
+
"exomiser.hg19.cadd-in-del-path="
|
|
64
|
+
"${exomiser.data-directory}/cadd/${cadd.version}/hg19/"
|
|
65
|
+
"InDels.tsv.gz\n"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def write_exomiser_hg19_remm_path(self) -> None:
|
|
69
|
+
"""Write the hg19 remm path to application.properties file."""
|
|
70
|
+
if (
|
|
71
|
+
self.configurations.application_properties.remm_version is not None
|
|
72
|
+
and self.configurations.application_properties.hg19_data_version is not None
|
|
73
|
+
):
|
|
74
|
+
self.application_properties.write(
|
|
75
|
+
"exomiser.hg19.remm-path="
|
|
76
|
+
"${exomiser.data-directory}/remm/ReMM.v${remm.version}.hg19.tsv.gz\n"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def write_exomiser_hg19_local_frequency_path(self) -> None:
|
|
80
|
+
"""Write the hg19 local frequency path to application.properties file."""
|
|
81
|
+
if self.configurations.application_properties.hg19_local_frequency_path is not None:
|
|
82
|
+
self.application_properties.write(
|
|
83
|
+
f"exomiser.hg19.local-frequency-path="
|
|
84
|
+
f"${{exomiser.data-directory}}/local/"
|
|
85
|
+
f"{self.configurations.application_properties.hg19_local_frequency_path}\n"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def write_exomiser_hg38_data_version(self) -> None:
|
|
89
|
+
"""Write the hg38 data version to application.properties file."""
|
|
90
|
+
if self.configurations.application_properties.hg38_data_version is not None:
|
|
91
|
+
self.application_properties.write(
|
|
92
|
+
f"exomiser.hg38.data-version={self.configurations.application_properties.hg38_data_version}\n"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def write_exomiser_hg38_cadd_snv_path(self) -> None:
|
|
96
|
+
"""Write the hg38 cadd snv path to application.properties file."""
|
|
97
|
+
if (
|
|
98
|
+
self.configurations.application_properties.cadd_version is not None
|
|
99
|
+
and self.configurations.application_properties.hg38_data_version is not None
|
|
100
|
+
):
|
|
101
|
+
self.application_properties.write(
|
|
102
|
+
"exomiser.hg38.cadd-snv-path="
|
|
103
|
+
"${exomiser.data-directory}/cadd/${cadd.version}/hg38/"
|
|
104
|
+
"whole_genome_SNVs.tsv.gz\n"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
def write_exomiser_hg38_cadd_indel_path(self) -> None:
|
|
108
|
+
"""Write the hg38 cadd indel path to application.properties file."""
|
|
109
|
+
if (
|
|
110
|
+
self.configurations.application_properties.cadd_version is not None
|
|
111
|
+
and self.configurations.application_properties.hg38_data_version is not None
|
|
112
|
+
):
|
|
113
|
+
self.application_properties.write(
|
|
114
|
+
"exomiser.hg38.cadd-in-del-path="
|
|
115
|
+
"${exomiser.data-directory}/cadd/${cadd.version}/hg38/"
|
|
116
|
+
"InDels.tsv.gz\n"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def write_exomiser_hg38_remm_path(self) -> None:
|
|
120
|
+
"""Write the hg38 remm path to application.properties file."""
|
|
121
|
+
if (
|
|
122
|
+
self.configurations.application_properties.remm_version is not None
|
|
123
|
+
and self.configurations.application_properties.hg38_data_version is not None
|
|
124
|
+
):
|
|
125
|
+
self.application_properties.write(
|
|
126
|
+
"exomiser.hg38.remm-path="
|
|
127
|
+
"${exomiser.data-directory}/remm/ReMM.v${remm.version}.hg38.tsv.gz\n"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def write_exomiser_hg38_local_frequency_path(self) -> None:
|
|
131
|
+
"""Write the hg38 local frequency path to application.properties file."""
|
|
132
|
+
if self.configurations.application_properties.hg38_local_frequency_path is not None:
|
|
133
|
+
self.application_properties.write(
|
|
134
|
+
f"exomiser.hg38.local-frequency-path="
|
|
135
|
+
f"${{exomiser.data-directory}}/local/"
|
|
136
|
+
f"{self.configurations.application_properties.hg38_local_frequency_path}\n"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
def write_exomiser_phenotype_data_version(self) -> None:
|
|
140
|
+
"""Write the phenotype data version to application.properties file."""
|
|
141
|
+
self.application_properties.write(
|
|
142
|
+
f"exomiser.phenotype.data-version={self.configurations.application_properties.phenotype_data_version}\n"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
def write_hg19_white_list_path(self) -> None:
|
|
146
|
+
"""Write the hg19 whitelist path to application.properties file."""
|
|
147
|
+
if self.configurations.application_properties.hg19_whitelist_path is not None:
|
|
148
|
+
self.application_properties.write(
|
|
149
|
+
f"exomiser.hg19.variant-white-list-path="
|
|
150
|
+
f"{self.configurations.application_properties.hg19_whitelist_path}\n"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def write_hg38_white_list_path(self) -> None:
|
|
154
|
+
"""Write the hg38 whitelist path to application.properties file."""
|
|
155
|
+
if self.configurations.application_properties.hg38_whitelist_path is not None:
|
|
156
|
+
self.application_properties.write(
|
|
157
|
+
f"exomiser.hg38.variant-white-list-path="
|
|
158
|
+
f"{self.configurations.application_properties.hg38_whitelist_path}\n"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
def write_cache_type(self):
|
|
162
|
+
"""Write the cache type to application.properties file."""
|
|
163
|
+
if self.configurations.application_properties.cache_type is not None:
|
|
164
|
+
self.application_properties.write(
|
|
165
|
+
f"spring.cache.type=" f"{self.configurations.application_properties.cache_type}\n"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def write_cache_spec(self):
|
|
169
|
+
"""Write the cache spec to application.properties file."""
|
|
170
|
+
if self.configurations.application_properties.cache_caffeine_spec is not None:
|
|
171
|
+
self.application_properties.write(
|
|
172
|
+
f"spring.cache.caffeine.spec=maximumSize="
|
|
173
|
+
f"{self.configurations.application_properties.cache_caffeine_spec}\n"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
def write_application_properties(self) -> None:
|
|
177
|
+
"""Write the application.properties file."""
|
|
178
|
+
methods = inspect.getmembers(self, predicate=inspect.ismethod)
|
|
179
|
+
for name, method in methods:
|
|
180
|
+
if name != "write_application_properties" and name != "__init__":
|
|
181
|
+
method()
|
|
182
|
+
self.application_properties.close()
|
pheval_exomiser/run/run.py
CHANGED
|
@@ -2,55 +2,47 @@ import os
|
|
|
2
2
|
import subprocess
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
6
|
import docker
|
|
7
|
+
from packaging import version
|
|
8
8
|
from pheval.utils.file_utils import all_files
|
|
9
9
|
|
|
10
|
-
from pheval_exomiser.
|
|
10
|
+
from pheval_exomiser.constants import (
|
|
11
|
+
EXOMISER_CONFIG_TARGET_DIRECTORY_DOCKER,
|
|
12
|
+
EXOMISER_DATA_DIRECTORY_TARGET_DOCKER,
|
|
13
|
+
EXOMISER_YAML_TARGET_DIRECTORY_DOCKER,
|
|
14
|
+
INPUT_COMMANDS_TARGET_DIRECTORY_DOCKER,
|
|
15
|
+
PHENOPACKET_TARGET_DIRECTORY_DOCKER,
|
|
16
|
+
RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
|
|
17
|
+
VCF_TARGET_DIRECTORY_DOCKER,
|
|
18
|
+
)
|
|
11
19
|
from pheval_exomiser.prepare.create_batch_commands import create_batch_file
|
|
12
|
-
|
|
13
|
-
# def write_output_options(input_dir: Path, output_dir: Path, run: ExomiserConfigSingleRun):
|
|
14
|
-
# try:
|
|
15
|
-
# Path(input_dir.joinpath("output_options")).mkdir()
|
|
16
|
-
# except FileExistsError:
|
|
17
|
-
# pass
|
|
18
|
-
# with open(Path(input_dir).joinpath("output_options/output_options.yaml"), "w") as output_options:
|
|
19
|
-
# yaml.dump({'outputPrefix': f'{output_dir.absolute().joinpath(run.run_identifier)}_results/'}, output_options)
|
|
20
|
-
# output_options.close()
|
|
21
|
-
# return Path(input_dir).joinpath("output_options/output_options.yaml")
|
|
20
|
+
from pheval_exomiser.prepare.tool_specific_configuration_options import ExomiserConfigurations
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
def prepare_batch_files(
|
|
25
|
-
input_dir: Path,
|
|
24
|
+
input_dir: Path,
|
|
25
|
+
testdata_dir: Path,
|
|
26
|
+
config: ExomiserConfigurations,
|
|
27
|
+
tool_input_commands_dir: Path,
|
|
28
|
+
raw_results_dir: Path,
|
|
29
|
+
variant_analysis: bool,
|
|
26
30
|
) -> None:
|
|
27
31
|
"""Prepare the exomiser batch files"""
|
|
28
|
-
results_sub_output_dir = Path(output_dir).joinpath(
|
|
29
|
-
f"exomiser_{config.run.exomiser_configurations.exomiser_version.replace('.', '_')}_"
|
|
30
|
-
f"{os.path.basename(input_dir)}"
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
results_sub_output_dir.mkdir(parents=True, exist_ok=True)
|
|
34
|
-
print("...created sub results output directory...")
|
|
35
32
|
print("...preparing batch files...")
|
|
33
|
+
vcf_dir_name = Path(testdata_dir).joinpath("vcf")
|
|
36
34
|
create_batch_file(
|
|
37
|
-
environment=config.
|
|
38
|
-
analysis=config.
|
|
39
|
-
phenopacket_dir=Path(testdata_dir).joinpath(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
][0]
|
|
45
|
-
),
|
|
46
|
-
vcf_dir=Path(testdata_dir).joinpath(
|
|
47
|
-
[directory for directory in os.listdir(str(testdata_dir)) if "vcf" in str(directory)][0]
|
|
48
|
-
),
|
|
49
|
-
output_dir=results_sub_output_dir,
|
|
50
|
-
batch_prefix=os.path.basename(testdata_dir),
|
|
51
|
-
max_jobs=config.run.max_jobs,
|
|
35
|
+
environment=config.environment,
|
|
36
|
+
analysis=input_dir.joinpath(config.analysis_configuration_file),
|
|
37
|
+
phenopacket_dir=Path(testdata_dir).joinpath("phenopackets"),
|
|
38
|
+
vcf_dir=vcf_dir_name if variant_analysis else None,
|
|
39
|
+
output_dir=tool_input_commands_dir,
|
|
40
|
+
batch_prefix=Path(testdata_dir).name,
|
|
41
|
+
max_jobs=config.max_jobs,
|
|
52
42
|
output_options_file=None,
|
|
53
43
|
output_options_dir=None,
|
|
44
|
+
results_dir=raw_results_dir,
|
|
45
|
+
variant_analysis=variant_analysis,
|
|
54
46
|
)
|
|
55
47
|
|
|
56
48
|
|
|
@@ -61,257 +53,128 @@ class BasicDockerMountsForExomiser:
|
|
|
61
53
|
phenopacket_test_data: str
|
|
62
54
|
vcf_test_data: str
|
|
63
55
|
exomiser_yaml: str
|
|
64
|
-
|
|
56
|
+
tool_input_commands_path: str
|
|
65
57
|
exomiser_data_dir: str
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
@dataclass
|
|
70
|
-
class ExomiserConfigParameters:
|
|
71
|
-
"""Exomiser configuration arguments."""
|
|
72
|
-
|
|
73
|
-
application_properties_path: Path = None
|
|
74
|
-
exomiser_phenotype_version: str = None
|
|
75
|
-
exomiser_hg19_version: str = None
|
|
76
|
-
exomiser_hg38_version: str = None
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def read_application_properties(config: ExomiserConfig) -> [str]:
|
|
80
|
-
"""Return contents of Exomiser application.properties."""
|
|
81
|
-
with open(
|
|
82
|
-
config.run.exomiser_configurations.path_to_application_properties_config
|
|
83
|
-
) as exomiser_config:
|
|
84
|
-
exomiser_config_lines = exomiser_config.readlines()
|
|
85
|
-
exomiser_config.close()
|
|
86
|
-
return exomiser_config_lines
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
class EditExomiserApplicationProperties:
|
|
90
|
-
def __init__(self, config: ExomiserConfig, input_dir: Path, exomiser_config_contents: [str]):
|
|
91
|
-
self.config = config
|
|
92
|
-
self.input_dir = input_dir
|
|
93
|
-
self.exomiser_config_contents = exomiser_config_contents
|
|
94
|
-
|
|
95
|
-
def edit_data_path_for_local_run(self):
|
|
96
|
-
"""Edit input data path for running locally."""
|
|
97
|
-
return [
|
|
98
|
-
line.replace(line, f"exomiser.data-directory={self.input_dir}\n")
|
|
99
|
-
if line.startswith("exomiser.data-directory=")
|
|
100
|
-
else line
|
|
101
|
-
for line in self.exomiser_config_contents
|
|
102
|
-
]
|
|
103
|
-
|
|
104
|
-
def edit_data_path_for_docker_run(self):
|
|
105
|
-
"""Edit input data path for running with docker."""
|
|
106
|
-
return [
|
|
107
|
-
line.replace(line, "exomiser.data-directory=/exomiser-data\n")
|
|
108
|
-
if line.startswith("exomiser.data-directory=")
|
|
109
|
-
else line
|
|
110
|
-
for line in self.exomiser_config_contents
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
def edit_data_path(self) -> [str]:
|
|
114
|
-
"""Return edited contents of application.properties."""
|
|
115
|
-
return (
|
|
116
|
-
self.edit_data_path_for_local_run()
|
|
117
|
-
if self.config.run.environment == "local"
|
|
118
|
-
else self.edit_data_path_for_docker_run()
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def write_edited_application_properties(
|
|
123
|
-
config: ExomiserConfig, input_dir: Path, exomiser_config_contents: [str]
|
|
124
|
-
) -> None:
|
|
125
|
-
"""Write application.properties with edited contents."""
|
|
126
|
-
with open(
|
|
127
|
-
config.run.exomiser_configurations.path_to_application_properties_config, "w"
|
|
128
|
-
) as exomiser_config:
|
|
129
|
-
exomiser_config.writelines(
|
|
130
|
-
EditExomiserApplicationProperties(
|
|
131
|
-
config, input_dir, exomiser_config_contents
|
|
132
|
-
).edit_data_path()
|
|
133
|
-
)
|
|
134
|
-
exomiser_config.close()
|
|
58
|
+
raw_results_dir: Path
|
|
59
|
+
exomiser_application_properties: Path
|
|
135
60
|
|
|
136
61
|
|
|
137
62
|
def mount_docker(
|
|
138
|
-
input_dir: Path,
|
|
63
|
+
input_dir: Path,
|
|
64
|
+
testdata_dir: Path,
|
|
65
|
+
tool_input_commands_dir: Path,
|
|
66
|
+
raw_results_dir: Path,
|
|
67
|
+
variant_analysis: bool,
|
|
139
68
|
) -> BasicDockerMountsForExomiser:
|
|
140
69
|
"""Create docker mounts for paths required for running Exomiser."""
|
|
141
|
-
test_data = os.listdir(str(testdata_dir))
|
|
142
70
|
phenopacket_test_data = (
|
|
143
|
-
f"{Path(testdata_dir).joinpath(
|
|
144
|
-
f"{os.sep}
|
|
71
|
+
f"{Path(testdata_dir).joinpath('phenopackets')}"
|
|
72
|
+
f"{os.sep}:{PHENOPACKET_TARGET_DIRECTORY_DOCKER}"
|
|
145
73
|
)
|
|
146
74
|
vcf_test_data = (
|
|
147
|
-
f"{Path(testdata_dir).joinpath(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
exomiser_yaml = f"{config.run.path_to_analysis_yaml.parents[0]}{os.sep}:/exomiser-yaml-template"
|
|
151
|
-
batch_file_path = str(
|
|
152
|
-
Path(output_dir).joinpath(
|
|
153
|
-
f"exomiser_{config.run.exomiser_configurations.exomiser_version.replace('.', '_')}"
|
|
154
|
-
f"_{os.path.basename(input_dir)}{os.sep}exomiser_batch_files{os.sep}:/exomiser-batch-file"
|
|
155
|
-
)
|
|
156
|
-
)
|
|
157
|
-
exomiser_data_dir = f"{input_dir}{os.sep}:/exomiser-data"
|
|
158
|
-
if config.run.exomiser_configurations.path_to_application_properties_config is None:
|
|
159
|
-
# TODO add mount for results directory to be specified in the output-options
|
|
160
|
-
return BasicDockerMountsForExomiser(
|
|
161
|
-
phenopacket_test_data=phenopacket_test_data,
|
|
162
|
-
vcf_test_data=vcf_test_data,
|
|
163
|
-
exomiser_yaml=exomiser_yaml,
|
|
164
|
-
batch_file_path=batch_file_path,
|
|
165
|
-
exomiser_data_dir=exomiser_data_dir,
|
|
166
|
-
)
|
|
167
|
-
else:
|
|
168
|
-
exomiser_config = (
|
|
169
|
-
f"{config.run.exomiser_configurations.path_to_application_properties_config.parents[0]}{os.sep}"
|
|
170
|
-
f":/exomiser-config"
|
|
171
|
-
)
|
|
172
|
-
return BasicDockerMountsForExomiser(
|
|
173
|
-
phenopacket_test_data=phenopacket_test_data,
|
|
174
|
-
vcf_test_data=vcf_test_data,
|
|
175
|
-
exomiser_yaml=exomiser_yaml,
|
|
176
|
-
batch_file_path=batch_file_path,
|
|
177
|
-
exomiser_data_dir=exomiser_data_dir,
|
|
178
|
-
exomiser_application_properties=exomiser_config,
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
def add_exomiser_config_file_for_docker(config: ExomiserConfig) -> ExomiserConfigParameters:
|
|
183
|
-
"""Add application.properties path to config parameters."""
|
|
184
|
-
return ExomiserConfigParameters(
|
|
185
|
-
application_properties_path=config.run.exomiser_configurations.path_to_application_properties_config.parents[
|
|
186
|
-
0
|
|
187
|
-
]
|
|
75
|
+
(f"{Path(testdata_dir).joinpath('vcf')}" f"{os.sep}:{VCF_TARGET_DIRECTORY_DOCKER}")
|
|
76
|
+
if variant_analysis
|
|
77
|
+
else None
|
|
188
78
|
)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
def exomiser_config_parameters(config: ExomiserConfig) -> ExomiserConfigParameters:
|
|
204
|
-
"""Add application.properties path to config arguments if specified, otherwise add manual configurations."""
|
|
205
|
-
return (
|
|
206
|
-
add_exomiser_config_file_for_docker(config)
|
|
207
|
-
if config.run.exomiser_configurations.path_to_application_properties_config is not None
|
|
208
|
-
else add_exomiser_config_parameters_for_docker(config)
|
|
79
|
+
exomiser_yaml = f"{input_dir}:{EXOMISER_YAML_TARGET_DIRECTORY_DOCKER}"
|
|
80
|
+
batch_file_path = f"{tool_input_commands_dir}/:{INPUT_COMMANDS_TARGET_DIRECTORY_DOCKER}"
|
|
81
|
+
exomiser_data_dir = f"{input_dir}{os.sep}:{EXOMISER_DATA_DIRECTORY_TARGET_DOCKER}"
|
|
82
|
+
results_dir = f"{raw_results_dir}/:{RAW_RESULTS_TARGET_DIRECTORY_DOCKER}"
|
|
83
|
+
exomiser_config = f"{input_dir}{os.sep}" f":{EXOMISER_CONFIG_TARGET_DIRECTORY_DOCKER}"
|
|
84
|
+
return BasicDockerMountsForExomiser(
|
|
85
|
+
phenopacket_test_data=phenopacket_test_data,
|
|
86
|
+
vcf_test_data=vcf_test_data,
|
|
87
|
+
exomiser_yaml=exomiser_yaml,
|
|
88
|
+
tool_input_commands_path=batch_file_path,
|
|
89
|
+
exomiser_data_dir=exomiser_data_dir,
|
|
90
|
+
exomiser_application_properties=exomiser_config,
|
|
91
|
+
raw_results_dir=results_dir,
|
|
209
92
|
)
|
|
210
93
|
|
|
211
94
|
|
|
212
95
|
def run_exomiser_local(
|
|
213
|
-
input_dir: Path,
|
|
96
|
+
input_dir: Path,
|
|
97
|
+
testdata_dir: Path,
|
|
98
|
+
config: ExomiserConfigurations,
|
|
99
|
+
output_dir: Path,
|
|
100
|
+
tool_input_commands_dir: Path,
|
|
101
|
+
exomiser_version: str,
|
|
214
102
|
) -> None:
|
|
215
103
|
"""Run Exomiser locally."""
|
|
216
104
|
print("...running exomiser...")
|
|
217
|
-
|
|
218
|
-
f"exomiser_{config.run.exomiser_configurations.exomiser_version.replace('.', '_')}"
|
|
219
|
-
f"_{os.path.basename(input_dir)}"
|
|
220
|
-
)
|
|
221
|
-
results_sub_output_dir.joinpath(f"{os.path.basename(testdata_dir)}_results").mkdir(
|
|
222
|
-
exist_ok=True, parents=True
|
|
223
|
-
)
|
|
224
|
-
write_edited_application_properties(config, input_dir, read_application_properties(config))
|
|
225
|
-
os.chdir(results_sub_output_dir.joinpath(f"{os.path.basename(testdata_dir)}_results"))
|
|
105
|
+
os.chdir(output_dir)
|
|
226
106
|
batch_files = [
|
|
227
107
|
file
|
|
228
|
-
for file in all_files(
|
|
229
|
-
if file.name.startswith(
|
|
108
|
+
for file in all_files(tool_input_commands_dir)
|
|
109
|
+
if file.name.startswith(Path(testdata_dir).name)
|
|
230
110
|
]
|
|
231
111
|
exomiser_jar_file = [
|
|
232
112
|
filename
|
|
233
|
-
for filename in all_files(config.
|
|
113
|
+
for filename in all_files(input_dir.joinpath(config.exomiser_software_directory))
|
|
234
114
|
if filename.name.endswith(".jar")
|
|
235
115
|
][0]
|
|
236
|
-
exomiser_jar_file_path = config.
|
|
237
|
-
exomiser_jar_file
|
|
238
|
-
)
|
|
116
|
+
exomiser_jar_file_path = config.exomiser_software_directory.joinpath(exomiser_jar_file)
|
|
239
117
|
for file in batch_files:
|
|
240
118
|
subprocess.run(
|
|
241
119
|
[
|
|
242
|
-
"
|
|
120
|
+
"java",
|
|
243
121
|
"-Xmx4g",
|
|
244
122
|
"-jar",
|
|
245
123
|
exomiser_jar_file_path,
|
|
246
124
|
"--batch",
|
|
247
125
|
file,
|
|
248
|
-
f"--spring.config.location={
|
|
126
|
+
f"--spring.config.location={Path(input_dir).joinpath('application.properties')}",
|
|
249
127
|
],
|
|
250
128
|
shell=False,
|
|
251
129
|
)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
f"{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
f"{os.path.basename(testdata_dir)}_results{os.sep}exomiser_results"
|
|
258
|
-
),
|
|
259
|
-
)
|
|
130
|
+
if version.parse(exomiser_version) < version.parse("13.1.0"):
|
|
131
|
+
os.rename(
|
|
132
|
+
f"{output_dir}/results",
|
|
133
|
+
output_dir.joinpath("raw_results"),
|
|
134
|
+
)
|
|
260
135
|
|
|
261
136
|
|
|
262
|
-
def create_docker_run_command(
|
|
137
|
+
def create_docker_run_command(batch_file: Path) -> [str]:
|
|
263
138
|
"""Creates docker run command."""
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
f"--exomiser.data-directory=/exomiser-data"
|
|
270
|
-
f"--exomiser.hg19.data-version={exomiser_config_params.exomiser_hg19_version}",
|
|
271
|
-
f"--exomiser.hg38.data-version={exomiser_config_params.exomiser_hg38_version}",
|
|
272
|
-
f"--exomiser.phenotype.data-version={exomiser_config_params.exomiser_phenotype_version}",
|
|
273
|
-
]
|
|
274
|
-
else:
|
|
275
|
-
return [
|
|
276
|
-
"--batch",
|
|
277
|
-
"/exomiser-batch-file/" + batch_file.name,
|
|
278
|
-
"--spring.config.location=/exomiser-config/application.properties",
|
|
279
|
-
]
|
|
139
|
+
return [
|
|
140
|
+
"--batch",
|
|
141
|
+
f"{INPUT_COMMANDS_TARGET_DIRECTORY_DOCKER}" + batch_file.name,
|
|
142
|
+
f"--spring.config.location={EXOMISER_CONFIG_TARGET_DIRECTORY_DOCKER}application.properties",
|
|
143
|
+
]
|
|
280
144
|
|
|
281
145
|
|
|
282
146
|
def run_exomiser_docker(
|
|
283
|
-
input_dir: Path,
|
|
147
|
+
input_dir: Path,
|
|
148
|
+
testdata_dir: Path,
|
|
149
|
+
tool_input_commands_dir: Path,
|
|
150
|
+
raw_results_dir: Path,
|
|
151
|
+
exomiser_version: str,
|
|
152
|
+
variant_analysis: bool,
|
|
284
153
|
):
|
|
285
154
|
"""Run Exomiser with docker."""
|
|
286
155
|
print("...running exomiser...")
|
|
287
156
|
client = docker.from_env()
|
|
288
|
-
results_sub_output_dir = Path(output_dir).joinpath(
|
|
289
|
-
f"exomiser_{config.run.exomiser_configurations.exomiser_version.replace('.', '_')}"
|
|
290
|
-
f"_{os.path.basename(input_dir)}"
|
|
291
|
-
)
|
|
292
|
-
results_sub_output_dir.joinpath(f"{os.path.basename(testdata_dir)}_results").mkdir(
|
|
293
|
-
exist_ok=True, parents=True
|
|
294
|
-
)
|
|
295
|
-
write_edited_application_properties(config, input_dir, read_application_properties(config))
|
|
296
|
-
os.chdir(results_sub_output_dir.joinpath(f"{os.path.basename(testdata_dir)}_results"))
|
|
297
157
|
batch_files = [
|
|
298
158
|
file
|
|
299
|
-
for file in all_files(
|
|
300
|
-
if file.name.startswith(
|
|
159
|
+
for file in all_files(tool_input_commands_dir)
|
|
160
|
+
if file.name.startswith(Path(testdata_dir).name)
|
|
301
161
|
]
|
|
302
162
|
for file in batch_files:
|
|
303
|
-
docker_command = create_docker_run_command(
|
|
304
|
-
docker_mounts = mount_docker(
|
|
163
|
+
docker_command = create_docker_run_command(file)
|
|
164
|
+
docker_mounts = mount_docker(
|
|
165
|
+
input_dir, testdata_dir, tool_input_commands_dir, raw_results_dir, variant_analysis
|
|
166
|
+
)
|
|
305
167
|
vol = [
|
|
306
168
|
docker_mounts.vcf_test_data,
|
|
307
169
|
docker_mounts.phenopacket_test_data,
|
|
308
170
|
docker_mounts.exomiser_data_dir,
|
|
309
171
|
docker_mounts.exomiser_yaml,
|
|
310
|
-
docker_mounts.
|
|
172
|
+
docker_mounts.tool_input_commands_path,
|
|
311
173
|
docker_mounts.exomiser_application_properties,
|
|
174
|
+
docker_mounts.raw_results_dir,
|
|
312
175
|
]
|
|
313
176
|
container = client.containers.run(
|
|
314
|
-
f"exomiser/exomiser-cli:{
|
|
177
|
+
f"exomiser/exomiser-cli:{exomiser_version}",
|
|
315
178
|
" ".join(docker_command),
|
|
316
179
|
volumes=[x for x in vol if x is not None],
|
|
317
180
|
detach=True,
|
|
@@ -321,10 +184,28 @@ def run_exomiser_docker(
|
|
|
321
184
|
break
|
|
322
185
|
|
|
323
186
|
|
|
324
|
-
def run_exomiser(
|
|
187
|
+
def run_exomiser(
|
|
188
|
+
input_dir: Path,
|
|
189
|
+
testdata_dir,
|
|
190
|
+
config: ExomiserConfigurations,
|
|
191
|
+
output_dir: Path,
|
|
192
|
+
tool_input_commands_dir: Path,
|
|
193
|
+
raw_results_dir: Path,
|
|
194
|
+
exomiser_version: str,
|
|
195
|
+
variant_analysis: bool,
|
|
196
|
+
):
|
|
325
197
|
"""Run Exomiser with specified environment."""
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
198
|
+
(
|
|
199
|
+
run_exomiser_local(
|
|
200
|
+
input_dir, testdata_dir, config, output_dir, tool_input_commands_dir, exomiser_version
|
|
201
|
+
)
|
|
202
|
+
if config.environment == "local"
|
|
203
|
+
else run_exomiser_docker(
|
|
204
|
+
input_dir,
|
|
205
|
+
testdata_dir,
|
|
206
|
+
tool_input_commands_dir,
|
|
207
|
+
raw_results_dir,
|
|
208
|
+
exomiser_version,
|
|
209
|
+
variant_analysis,
|
|
210
|
+
)
|
|
330
211
|
)
|