Skip to content

Commit

Permalink
add nallo to more config-case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpru committed Jan 23, 2025
1 parent f940b1d commit 5fb2a36
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 27 deletions.
6 changes: 3 additions & 3 deletions tests/cli/workflow/nf_analysis/test_cli_config_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_config_case_without_options(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_config_with_missing_case(
cli_runner: CliRunner,
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_config_with_missing_case(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_config_case_without_samples(
cli_runner: CliRunner,
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_config_case_default_parameters(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_config_case_dry_run(
cli_runner: CliRunner,
Expand Down
24 changes: 21 additions & 3 deletions tests/cli/workflow/nf_analysis/test_cli_metrics_deliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@

@pytest.mark.parametrize(
"workflow",
[Workflow.RAREDISEASE, Workflow.RNAFUSION, Workflow.TAXPROFILER, Workflow.TOMTE, Workflow.NALLO],
[
Workflow.RAREDISEASE,
Workflow.RNAFUSION,
Workflow.TAXPROFILER,
Workflow.TOMTE,
Workflow.NALLO,
],
)
def test_metrics_deliver_without_options(
cli_runner: CliRunner, workflow: Workflow, request: FixtureRequest
Expand All @@ -38,7 +44,13 @@ def test_metrics_deliver_without_options(

@pytest.mark.parametrize(
"workflow",
[Workflow.RAREDISEASE, Workflow.RNAFUSION, Workflow.TAXPROFILER, Workflow.TOMTE, Workflow.NALLO],
[
Workflow.RAREDISEASE,
Workflow.RNAFUSION,
Workflow.TAXPROFILER,
Workflow.TOMTE,
Workflow.NALLO,
],
)
def test_metrics_deliver_with_missing_case(
cli_runner: CliRunner,
Expand Down Expand Up @@ -69,7 +81,13 @@ def test_metrics_deliver_with_missing_case(

@pytest.mark.parametrize(
"workflow",
[Workflow.RAREDISEASE, Workflow.RNAFUSION, Workflow.TAXPROFILER, Workflow.TOMTE, Workflow.NALLO],
[
Workflow.RAREDISEASE,
Workflow.RNAFUSION,
Workflow.TAXPROFILER,
Workflow.TOMTE,
Workflow.NALLO,
],
)
def test_metrics_deliver_case(
cli_runner: CliRunner,
Expand Down
1 change: 1 addition & 0 deletions tests/cli/workflow/test_cli_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_no_options(cli_runner: CliRunner, base_context: CGConfig):
assert "microsalt" in result.output
assert "mip-dna" in result.output
assert "mip-rna" in result.output
assert "nallo" in result.output
assert "raredisease" in result.output
assert "rnafusion" in result.output
assert "taxprofiler" in result.output
67 changes: 46 additions & 21 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ def context_config(
"workflow_bin_path": Path("workflow", "path").as_posix(),
"profile": "myprofile",
"references": Path("path", "to", "references").as_posix(),
"revision": "dev",
"revision": "2.2.0",
"root": str(nallo_dir),
"slurm": {
"account": "development",
Expand Down Expand Up @@ -2516,7 +2516,7 @@ def bam_unmapped_read_paths(housekeeper_dir: Path) -> Path:
"""Path to existing bam read file."""
bam_unmapped_read_path = Path(
housekeeper_dir, "m00000_000000_000000_s4.hifi_reads.bc2021"
).with_suffix(f"{AlignmentFileTag.BAM}")
).with_suffix(f".{AlignmentFileTag.BAM}")
with open(bam_unmapped_read_path, "wb") as wh:
wh.write(
b"1f 8b 08 04 00 00 00 00 00 ff 06 00 42 43 02 00 1b 00 03 00 00 00 00 00 00 00 00 00"
Expand All @@ -2543,62 +2543,89 @@ def nallo_context(
helpers: StoreHelpers,
nf_analysis_housekeeper: HousekeeperAPI,
trailblazer_api: MockTB,
hermes_api: HermesApi,
cg_dir: Path,
nallo_case_id: str,
sample_id: str,
father_sample_id: str,
sample_name: str,
another_sample_name: str,
father_sample_id: str,
no_sample_case_id: str,
total_sequenced_reads_pass: int,
wgs_long_read_application_tag: str,
case_id_not_enough_reads: str,
sample_id_not_enough_reads: str,
total_sequenced_reads_not_pass: int,
mocker: MockFixture,
) -> CGConfig:
"""Context to use in CLI."""
"""context to use in cli"""
cg_context.housekeeper_api_ = nf_analysis_housekeeper
cg_context.trailblazer_api_ = trailblazer_api
cg_context.meta_apis["analysis_api"] = NalloAnalysisAPI(config=cg_context)
status_db: Store = cg_context.status_db

# NB: the order in which the cases are added matters for the tests of store_available

# Create ERROR case with NO SAMPLES
helpers.add_case(status_db, internal_id=no_sample_case_id, name=no_sample_case_id)

# Create textbook case with two samples
nallo_case_enough_reads: Case = helpers.add_case(
# Create textbook case with enough reads
case_enough_reads: Case = helpers.add_case(
store=status_db,
internal_id=nallo_case_id,
name=nallo_case_id,
data_analysis=Workflow.NALLO,
)

nallo_sample_one: Sample = helpers.add_sample(
sample_enough_reads: Sample = helpers.add_sample(
status_db,
internal_id=sample_id,
name=sample_name,
last_sequenced_at=datetime.now(),
reads=total_sequenced_reads_pass,
application_tag=wgs_long_read_application_tag,
reference_genome=GenomeVersion.HG38,
)

another_nallo_sample: Sample = helpers.add_sample(
another_sample_enough_reads: Sample = helpers.add_sample(
status_db,
internal_id=father_sample_id,
name=another_sample_name,
last_sequenced_at=datetime.now(),
reads=total_sequenced_reads_pass,
application_tag=wgs_long_read_application_tag,
reference_genome=GenomeVersion.HG38,
)

helpers.add_relationship(
status_db,
case=nallo_case_enough_reads,
sample=nallo_sample_one,
case=case_enough_reads,
sample=sample_enough_reads,
)

helpers.add_relationship(
status_db,
case=nallo_case_enough_reads,
sample=another_nallo_sample,
case=case_enough_reads,
sample=another_sample_enough_reads,
)

# Create case without enough reads
case_not_enough_reads: Case = helpers.add_case(
store=status_db,
internal_id=case_id_not_enough_reads,
name=case_id_not_enough_reads,
data_analysis=Workflow.NALLO,
)

sample_not_enough_reads: Sample = helpers.add_sample(
status_db,
internal_id=sample_id_not_enough_reads,
last_sequenced_at=datetime.now(),
reads=total_sequenced_reads_not_pass,
application_tag=wgs_long_read_application_tag,
reference_genome=GenomeVersion.HG38,
)

helpers.add_relationship(status_db, case=case_not_enough_reads, sample=sample_not_enough_reads)

return cg_context


Expand All @@ -2619,9 +2646,7 @@ def nallo_config(nallo_dir: Path, nallo_case_id: str) -> None:


@pytest.fixture(scope="function")
def nallo_deliverable_data(
nallo_dir: Path, nallo_case_id: str, sample_id: str
) -> dict:
def nallo_deliverable_data(nallo_dir: Path, nallo_case_id: str, sample_id: str) -> dict:
return {
"files": [
{
Expand Down Expand Up @@ -2693,7 +2718,7 @@ def nallo_mock_analysis_finish(
def nallo_mock_deliverable_dir(
nallo_dir: Path, nallo_deliverable_data: dict, nallo_case_id: str
) -> Path:
"""Create raredisease deliverable file with dummy data and files to deliver."""
"""Create nallo deliverable file with dummy data and files to deliver."""
Path.mkdir(
Path(nallo_dir, nallo_case_id),
parents=True,
Expand All @@ -2720,10 +2745,10 @@ def nallo_multiqc_json_metrics_path(nallo_analysis_dir: Path) -> Path:
return Path(nallo_analysis_dir, multiqc_json_file)


@pytest.fixture
def nallo_multiqc_json_metrics(nallo_multiqc_json_metrics_path: Path) -> list[dict]:
@pytest.fixture(scope="function")
def nallo_multiqc_json_metrics(nallo_analysis_dir) -> dict:
"""Returns the content of a mock Multiqc JSON file."""
return read_json(file_path=nallo_multiqc_json_metrics_path)
return read_json(file_path=Path(nallo_analysis_dir, multiqc_json_file))


@pytest.fixture(scope="function")
Expand Down

0 comments on commit 5fb2a36

Please sign in to comment.