Skip to content

Commit

Permalink
RAREDISEASE: add store, store available and store housekeeper commands (
Browse files Browse the repository at this point in the history
#3128)

### Added

- store, store-available and store-housekeeper commands for raredisease with template file bundle for deliverables

### Changed

- 

### Fixed

-
  • Loading branch information
rannick authored Jun 19, 2024
1 parent c943ec9 commit ffda3c1
Show file tree
Hide file tree
Showing 15 changed files with 1,261 additions and 130 deletions.
6 changes: 1 addition & 5 deletions cg/cli/workflow/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,10 @@ def store_available(context: click.Context, dry_run: bool) -> None:

analysis_api: NfAnalysisAPI = context.obj.meta_apis[MetaApis.ANALYSIS_API]

exit_code: int = EXIT_SUCCESS

for case in analysis_api.get_cases_to_store():
LOG.info(f"Storing deliverables for {case.internal_id}")
try:
analysis_api.store(case_id=case.internal_id, dry_run=dry_run)
except Exception as error:
LOG.error(f"Error storing {case.internal_id}: {repr(error)}")
exit_code: int = EXIT_FAIL
if exit_code:
raise click.Abort
raise click.Abort
8 changes: 8 additions & 0 deletions cg/cli/workflow/raredisease/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
from cg.cli.workflow.nf_analysis import (
config_case,
metrics_deliver,
report_deliver,
run,
start,
start_available,
store,
store_available,
store_housekeeper,
)
from cg.constants.cli_options import DRY_RUN
from cg.constants.constants import MetaApis
Expand All @@ -33,9 +37,13 @@ def raredisease(context: click.Context) -> None:
raredisease.add_command(metrics_deliver)
raredisease.add_command(resolve_compression)
raredisease.add_command(config_case)
raredisease.add_command(report_deliver)
raredisease.add_command(run)
raredisease.add_command(start)
raredisease.add_command(start_available)
raredisease.add_command(store)
raredisease.add_command(store_available)
raredisease.add_command(store_housekeeper)


@raredisease.command("panel")
Expand Down
7 changes: 7 additions & 0 deletions cg/constants/nextflow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Nextflow related constants."""

from enum import IntEnum
from cg.constants import Workflow

NFX_WORK_DIR = "work"
NFX_SAMPLE_HEADER = "sample"
Expand All @@ -12,6 +13,12 @@
NXF_PID_FILE_ENV = "NXF_PID_FILE"
NXF_JVM_ARGS_ENV = "NXF_JVM_ARGS"
JAVA_MEMORY_HEADJOB = "-Xmx5g"
NEXTFLOW_WORKFLOWS: list = [
Workflow.RAREDISEASE,
Workflow.RNAFUSION,
Workflow.TAXPROFILER,
Workflow.TOMTE,
]


class SlurmHeadJobDefaults(IntEnum):
Expand Down
10 changes: 5 additions & 5 deletions cg/meta/workflow/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,16 @@ def run_analysis(

def get_deliverables_template_content(self) -> list[dict[str, str]]:
"""Return deliverables file template content."""
LOG.debug("Getting deliverables file template content")
return ReadFile.get_content_from_file(
file_format=FileFormat.YAML,
file_path=self.get_bundle_filenames_path(),
)

@staticmethod
def get_bundle_filenames_path() -> Path | None:
def get_bundle_filenames_path() -> Path:
"""Return bundle filenames path."""
return None
raise NotImplementedError

@staticmethod
def get_formatted_file_deliverable(
Expand Down Expand Up @@ -607,7 +608,6 @@ def get_deliverables_for_case(self, case_id: str) -> WorkflowDeliverables:
sample=sample, case_id=case_id, template=deliverable_template
)
files.extend(bundle for bundle in bundles_per_sample if bundle not in files)

return WorkflowDeliverables(files=files)

def get_multiqc_json_path(self, case_id: str) -> Path:
Expand Down Expand Up @@ -766,10 +766,10 @@ def report_deliver(self, case_id: str, dry_run: bool = False, force: bool = Fals
if dry_run:
LOG.info(f"Dry-run: Would have created delivery files for case {case_id}")
return
workflow_content: WorkflowDeliverables = self.get_deliverables_for_case(case_id)
workflow_content: WorkflowDeliverables = self.get_deliverables_for_case(case_id=case_id)
self.write_deliverables_file(
deliverables_content=workflow_content.dict(),
file_path=self.get_deliverables_file_path(case_id),
file_path=self.get_deliverables_file_path(case_id=case_id),
)
LOG.info(
f"Writing deliverables file in {self.get_deliverables_file_path(case_id=case_id).as_posix()}"
Expand Down
6 changes: 6 additions & 0 deletions cg/meta/workflow/raredisease.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
RarediseaseSampleSheetEntry,
RarediseaseSampleSheetHeaders,
)
from cg.resources import RAREDISEASE_BUNDLE_FILENAMES_PATH
from cg.store.models import CaseSample, Sample

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -116,6 +117,11 @@ def get_sex_code(sex: str) -> int:
raise ValueError(f"{sex} is not a valid sex")
return code

@staticmethod
def get_bundle_filenames_path() -> Path:
"""Return Raredisease bundle filenames path."""
return RAREDISEASE_BUNDLE_FILENAMES_PATH

@property
def root(self) -> str:
return self.config.raredisease.root
Expand Down
8 changes: 8 additions & 0 deletions cg/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

from cg.constants import FileExtensions

RAREDISEASE_BUNDLE_FILENAMES: str = (
Path("resources", "raredisease_bundle_filenames").with_suffix(FileExtensions.YAML).as_posix()
)

RNAFUSION_BUNDLE_FILENAMES: str = (
Path("resources", "rnafusion_bundle_filenames").with_suffix(FileExtensions.YAML).as_posix()
)
Expand All @@ -16,6 +20,10 @@
Path("resources", "tomte_bundle_filenames").with_suffix(FileExtensions.YAML).as_posix()
)

RAREDISEASE_BUNDLE_FILENAMES_PATH = Path(
pkg_resources.resource_filename("cg", RAREDISEASE_BUNDLE_FILENAMES)
)

RNAFUSION_BUNDLE_FILENAMES_PATH: Path = Path(
pkg_resources.resource_filename("cg", RNAFUSION_BUNDLE_FILENAMES)
)
Expand Down
Loading

0 comments on commit ffda3c1

Please sign in to comment.