Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jun 4, 2024
1 parent c8b2a0e commit 0e0e8d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/depiction_targeted_preproc/app/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
import polars as pl
import typer
import yaml
from depiction_targeted_preproc.example.run import snakemake_invoke, get_result_files, export_results, \
RESULT_FILE_MAPPING
from depiction_targeted_preproc.example.run import (
snakemake_invoke,
get_result_files,
export_results,
RESULT_FILE_MAPPING,
)

from depiction.misc.find_file_util import find_one_by_extension
from depiction_targeted_preproc.pipeline_config.model import PipelineParameters, \
PipelineArtifact, PipelineParametersPreset
from depiction_targeted_preproc.pipeline_config.model import (
PipelineParameters,
PipelineArtifact,
PipelineParametersPreset,
)


def entrypoint(
Expand Down Expand Up @@ -40,17 +47,26 @@ def entrypoint(

# Set up the workdir for the Snakemake workflow
work_dir = output_dir / "work"
setup_workdir(params=params, input_imzml_file=Path(input_imzml_file), input_panel_file=Path(input_panel_file),
work_dir=work_dir)
setup_workdir(
params=params,
input_imzml_file=Path(input_imzml_file),
input_panel_file=Path(input_panel_file),
work_dir=work_dir,
)

# Execute the snakemake workflow
sample_name = Path(input_imzml_file).stem
result_files = get_result_files(params=params, work_dir=work_dir, sample_name=sample_name)
snakemake_invoke(work_dir=work_dir, result_files=result_files)

# Export the results
export_results(work_dir=work_dir, output_dir=output_dir, sample_name=sample_name,
requested_artifacts=params.requested_artifacts, result_file_mapping=RESULT_FILE_MAPPING)
export_results(
work_dir=work_dir,
output_dir=output_dir,
sample_name=sample_name,
requested_artifacts=params.requested_artifacts,
result_file_mapping=RESULT_FILE_MAPPING,
)

# Zip the results
zip_results(output_dir=output_dir, sample_name=sample_name)
Expand Down Expand Up @@ -126,9 +142,7 @@ def parse_parameters(yaml_file: Path) -> PipelineParameters:
requested_artifacts.append(PipelineArtifact.CALIB_QC)
# requested_artifacts.append("CALIB_QC")
return PipelineParameters.from_preset_and_settings(
preset=preset,
requested_artifacts=requested_artifacts,
n_jobs=32
preset=preset, requested_artifacts=requested_artifacts, n_jobs=32
)


Expand Down
2 changes: 2 additions & 0 deletions src/depiction_targeted_preproc/pipeline_config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class PipelineArtifact(str, Enum):

# class PipelineParametersPreset(BaseModel, use_enum_values=True):


class PipelineParametersPreset(BaseModel):
baseline_adjustment: BaselineAdjustment
peak_picker: PeakPicker
Expand All @@ -78,6 +79,7 @@ class PipelineParametersPreset(BaseModel):

# class PipelineParameters(PipelineParametersPreset, use_enum_values=True):


class PipelineParameters(PipelineParametersPreset):
requested_artifacts: list[PipelineArtifact]
n_jobs: int
Expand Down

0 comments on commit 0e0e8d8

Please sign in to comment.