Skip to content

Commit

Permalink
tox lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yaseminbridges committed Feb 14, 2024
1 parent f387f79 commit 2bc9889
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 45 deletions.
24 changes: 15 additions & 9 deletions src/pheval_exomiser/post_process/post_process_results_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,21 @@ def post_process_exomiser_results(
disease_analysis: bool,
):
"""Post-process Exomiser json results into PhEval gene and variant outputs."""
output_dir.joinpath("pheval_gene_results").mkdir(
parents=True, exist_ok=True
) if gene_analysis else None
output_dir.joinpath("pheval_variant_results").mkdir(
parents=True, exist_ok=True
) if variant_analysis else None
output_dir.joinpath("pheval_disease_results").mkdir(
parents=True, exist_ok=True
) if disease_analysis else None
(
output_dir.joinpath("pheval_gene_results").mkdir(parents=True, exist_ok=True)
if gene_analysis
else None
)
(
output_dir.joinpath("pheval_variant_results").mkdir(parents=True, exist_ok=True)
if variant_analysis
else None
)
(
output_dir.joinpath("pheval_disease_results").mkdir(parents=True, exist_ok=True)
if disease_analysis
else None
)
create_standardised_results(
results_dir,
output_dir,
Expand Down
66 changes: 39 additions & 27 deletions src/pheval_exomiser/prepare/create_batch_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ def add_phenotype_only_arguments(self) -> ExomiserCommandLineArguments:
return ExomiserCommandLineArguments(
sample=f"{PHENOPACKET_TARGET_DIRECTORY_DOCKER}{Path(self.phenopacket_path.name)}",
variant_analysis=self.variant_analysis,
output_options_file=f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
if output_options_file is not None
else None,
output_options_file=(
f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
if output_options_file is not None
else None
),
raw_results_dir=RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
)
elif self.environment == "local":
Expand Down Expand Up @@ -111,9 +113,11 @@ def add_variant_analysis_arguments(self, vcf_dir: Path) -> ExomiserCommandLineAr
sample=f"{PHENOPACKET_TARGET_DIRECTORY_DOCKER}{Path(self.phenopacket_path.name)}",
vcf_file=f"{VCF_TARGET_DIRECTORY_DOCKER}{Path(vcf_file_data.uri).name}",
vcf_assembly=vcf_file_data.file_attributes["genomeAssembly"],
output_options_file=f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
if output_options_file is not None
else None,
output_options_file=(
f"{OUTPUT_OPTIONS_TARGET_DIRECTORY_DOCKER}{Path(output_options_file).name}"
if output_options_file is not None
else None
),
variant_analysis=self.variant_analysis,
raw_results_dir=RAW_RESULTS_TARGET_DIRECTORY_DOCKER,
analysis_yaml=f"{EXOMISER_YAML_TARGET_DIRECTORY_DOCKER}{Path(self.analysis_yaml).name}",
Expand Down Expand Up @@ -185,18 +189,22 @@ def write_basic_analysis_command(self, command_arguments: ExomiserCommandLineArg
def write_results_dir(self, command_arguments: ExomiserCommandLineArguments) -> None:
"""Write results directory for exomiser ≥13.2.0 to run."""
try:
self.file.write(
" --output-directory " + str(command_arguments.raw_results_dir)
) if command_arguments.raw_results_dir is not None else None
(
self.file.write(" --output-directory " + str(command_arguments.raw_results_dir))
if command_arguments.raw_results_dir is not None
else None
)
except IOError:
print("Error writing ", self.file)

def write_output_options(self, command_arguments: ExomiserCommandLineArguments) -> None:
"""Write a command out for exomiser ≤13.1.0 to run - including output option file specified."""
try:
self.file.write(
" --output " + str(command_arguments.output_options_file)
) if command_arguments.output_options_file is not None else None
(
self.file.write(" --output " + str(command_arguments.output_options_file))
if command_arguments.output_options_file is not None
else None
)
except IOError:
print("Error writing ", self.file)

Expand Down Expand Up @@ -230,9 +238,11 @@ def write_phenotype_only_command(self, command_arguments: ExomiserCommandLineArg
self.file.write("\n")

def write_local_commands(self, command_arguments: ExomiserCommandLineArguments):
self.write_analysis_command(
command_arguments
) if self.variant_analysis else self.write_phenotype_only_command(command_arguments)
(
self.write_analysis_command(command_arguments)
if self.variant_analysis
else self.write_phenotype_only_command(command_arguments)
)

def close(self) -> None:
"""Close file."""
Expand Down Expand Up @@ -324,18 +334,20 @@ def create_batch_file(
output_options_file,
analysis,
)
BatchFileWriter(
command_arguments,
variant_analysis,
output_dir,
batch_prefix,
).write_all_commands() if max_jobs == 0 else BatchFileWriter(
command_arguments,
variant_analysis,
output_dir,
batch_prefix,
).create_split_batch_files(
max_jobs
(
BatchFileWriter(
command_arguments,
variant_analysis,
output_dir,
batch_prefix,
).write_all_commands()
if max_jobs == 0
else BatchFileWriter(
command_arguments,
variant_analysis,
output_dir,
batch_prefix,
).create_split_batch_files(max_jobs)
)


Expand Down
22 changes: 13 additions & 9 deletions src/pheval_exomiser/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@ def run_exomiser(
variant_analysis: bool,
):
"""Run Exomiser with specified environment."""
run_exomiser_local(
input_dir, testdata_dir, config, output_dir, tool_input_commands_dir, exomiser_version
) if config.environment == "local" else run_exomiser_docker(
input_dir,
testdata_dir,
tool_input_commands_dir,
raw_results_dir,
exomiser_version,
variant_analysis,
(
run_exomiser_local(
input_dir, testdata_dir, config, output_dir, tool_input_commands_dir, exomiser_version
)
if config.environment == "local"
else run_exomiser_docker(
input_dir,
testdata_dir,
tool_input_commands_dir,
raw_results_dir,
exomiser_version,
variant_analysis,
)
)
1 change: 1 addition & 0 deletions src/pheval_exomiser/runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exomiser Runner"""

from dataclasses import dataclass
from pathlib import Path

Expand Down

0 comments on commit 2bc9889

Please sign in to comment.