Skip to content

Commit

Permalink
refactor - Organise lims samples fixtures (#2841)(patch)
Browse files Browse the repository at this point in the history
This is the first step of #2842. Refactor the fixtures returning lists of `FlowCellSample` to only use elements from the 7 canonical flow cells in demultiplexing


### Added

- Raw sample file `tests/fixtures/apps/demultiplexing/flow_cells/190927_A00689_0069_BHLYWYDSXX/HLYWYDSXX_bcl2fastq_raw.json`  with anonymised names and projects

### Changed

- Renamed `novaseq_6000_pre_1_5_kits_lims_samples` and `novaseq_6000_post_1_5_kits_lims_samples` to explicitly include the bcl converter in their name

### Fixed

- Removed fixture `lims_novaseq_6000_bcl2fastq_samples`, replaced usages with `novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples`.
- Removed fixture `lims_novaseq_bcl_convert_samples`, replaced usages with `novaseq_x_lims_samples`
- Removed paths to lims sample files that were used only once. Instantiated Path in the fixture where they were used instead.
  • Loading branch information
diitaz93 authored Jan 16, 2024
1 parent 21568e6 commit 6fc47e8
Show file tree
Hide file tree
Showing 13 changed files with 6,493 additions and 140 deletions.
4 changes: 2 additions & 2 deletions tests/apps/demultiplex/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def bcl_convert_samples_similar_index2() -> list[FlowCellSampleBCLConvert]:
@pytest.fixture
def bcl2fastq_sample_sheet_creator(
novaseq_flow_cell_demultiplexed_with_bcl2fastq: FlowCellDirectoryData,
lims_novaseq_6000_bcl2fastq_samples: list[FlowCellSampleBcl2Fastq],
novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples: list[FlowCellSampleBcl2Fastq],
) -> SampleSheetCreatorBcl2Fastq:
"""Returns a sample sheet creator for version 1 sample sheets with bcl2fastq format."""
return SampleSheetCreatorBcl2Fastq(
flow_cell=novaseq_flow_cell_demultiplexed_with_bcl2fastq,
lims_samples=lims_novaseq_6000_bcl2fastq_samples,
lims_samples=novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples,
)


Expand Down
10 changes: 8 additions & 2 deletions tests/apps/demultiplex/test_sample_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,14 @@ def test_update_barcode_mismatches_2(
"run_parameters_fixture, raw_lims_samples_fixture",
[
("novaseq_x_run_parameters", "novaseq_x_lims_samples"),
("novaseq_6000_run_parameters_pre_1_5_kits", "novaseq_6000_pre_1_5_kits_lims_samples"),
("novaseq_6000_run_parameters_post_1_5_kits", "novaseq_6000_post_1_5_kits_lims_samples"),
(
"novaseq_6000_run_parameters_pre_1_5_kits",
"novaseq_6000_pre_1_5_kits_bcl_convert_lims_samples",
),
(
"novaseq_6000_run_parameters_post_1_5_kits",
"novaseq_6000_post_1_5_kits_bcl_convert_lims_samples",
),
("hiseq_x_single_index_run_parameters", "hiseq_x_single_index_bcl_convert_lims_samples"),
("hiseq_x_dual_index_run_parameters", "hiseq_x_dual_index_bcl_convert_lims_samples"),
("hiseq_2500_dual_index_run_parameters", "hiseq_2500_dual_index_bcl_convert_lims_samples"),
Expand Down
4 changes: 2 additions & 2 deletions tests/apps/demultiplex/test_sample_sheet_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

def test_bcl_convert_sample_sheet_fails_with_bcl2fastq(
novaseq_x_flow_cell: FlowCellDirectoryData,
lims_novaseq_bcl_convert_samples: list[FlowCellSampleBCLConvert],
novaseq_x_lims_samples: list[FlowCellSampleBCLConvert],
):
"""Test that creating a BCL Convert sample sheet fails if the bcl converter is Bcl2fastq."""
# GIVEN a NovaSeqX flow cell and samples and the bcl converter is Bcl2fastq
Expand All @@ -31,7 +31,7 @@ def test_bcl_convert_sample_sheet_fails_with_bcl2fastq(
with pytest.raises(SampleSheetError) as exc_info:
SampleSheetCreatorBCLConvert(
flow_cell=novaseq_x_flow_cell,
lims_samples=lims_novaseq_bcl_convert_samples,
lims_samples=novaseq_x_lims_samples,
)
# THEN an error is raised
assert (
Expand Down
12 changes: 6 additions & 6 deletions tests/apps/demultiplex/test_sample_sheet_creator_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def test_sample_sheet_creator_factory_novaseq_6000(
novaseq_flow_cell_demultiplexed_with_bcl2fastq: FlowCellDirectoryData,
lims_novaseq_bcl2fastq_samples: list[FlowCellSampleBcl2Fastq],
novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples: list[FlowCellSampleBcl2Fastq],
):
"""Test that a sample sheet creator defined with NovaSeq6000 data is V1."""
# GIVEN a NovaSeq6000 flow cell and a list of NovaSeq6000 samples
Expand All @@ -28,26 +28,26 @@ def test_sample_sheet_creator_factory_novaseq_6000(
# WHEN defining the sample sheet creator
sample_sheet_creator: SampleSheetCreator = get_sample_sheet_creator(
flow_cell=novaseq_flow_cell_demultiplexed_with_bcl2fastq,
lims_samples=lims_novaseq_bcl2fastq_samples,
lims_samples=novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples,
force=False,
)

# THEN no error is raised and the sample sheet creator is a Bcl2Fastq sample sheet creator
assert isinstance(sample_sheet_creator, SampleSheetCreatorBcl2Fastq)


def test_sample_sheet_creator_factory_BCL_convert(
def test_sample_sheet_creator_factory_bcl_convert(
novaseq_x_flow_cell: FlowCellDirectoryData,
lims_novaseq_bcl_convert_samples: list[FlowCellSampleBCLConvert],
novaseq_x_lims_samples: list[FlowCellSampleBCLConvert],
):
"""Test that a sample sheet creator defined with BCL convert data is BCL Convert."""
# GIVEN a NovaSeqX flow cell and a list of NovaSeqX samples that is demultiplexed wit BCL Convert
# GIVEN a NovaSeqX flow cell and a list of NovaSeqX BCL Convert samples
assert novaseq_x_flow_cell.bcl_converter == BclConverter.DRAGEN

# WHEN defining the sample sheet creator
sample_sheet_creator: SampleSheetCreator = get_sample_sheet_creator(
flow_cell=novaseq_x_flow_cell,
lims_samples=lims_novaseq_bcl_convert_samples,
lims_samples=novaseq_x_lims_samples,
force=False,
)

Expand Down
25 changes: 12 additions & 13 deletions tests/cli/demultiplex/test_create_sample_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_create_sample_sheet_no_run_parameters_fails(
cli_runner: testing.CliRunner,
tmp_flow_cells_directory_no_run_parameters: Path,
sample_sheet_context: CGConfig,
lims_novaseq_bcl2fastq_samples: list[FlowCellSampleBcl2Fastq],
novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples: list[FlowCellSampleBcl2Fastq],
caplog,
mocker,
):
Expand All @@ -36,7 +36,7 @@ def test_create_sample_sheet_no_run_parameters_fails(
# GIVEN flow cell samples
mocker.patch(
FLOW_CELL_FUNCTION_NAME,
return_value=lims_novaseq_bcl2fastq_samples,
return_value=novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples,
)

# GIVEN that the context's flow cell directory holds the given flow cell
Expand All @@ -60,7 +60,7 @@ def test_create_bcl2fastq_sample_sheet(
cli_runner: testing.CliRunner,
tmp_flow_cells_directory_no_sample_sheet: Path,
sample_sheet_context: CGConfig,
lims_novaseq_bcl2fastq_samples: list[FlowCellSampleBcl2Fastq],
novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples: list[FlowCellSampleBcl2Fastq],
mocker,
):
"""Test that creating a Bcl2fastq sample sheet works."""
Expand All @@ -82,7 +82,7 @@ def test_create_bcl2fastq_sample_sheet(
# GIVEN flow cell samples
mocker.patch(
FLOW_CELL_FUNCTION_NAME,
return_value=lims_novaseq_bcl2fastq_samples,
return_value=novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples,
)
# GIVEN a lims api that returns some samples

Expand Down Expand Up @@ -116,14 +116,14 @@ class SampleSheetScenario(BaseModel):
"scenario",
[
SampleSheetScenario(
flow_cell_directory="novaseq_6000_pre_1_5_kits_flow_cell",
lims_samples="novaseq_6000_pre_1_5_kits_lims_samples",
correct_sample_sheet="novaseq_6000_pre_1_5_kits_correct_sample_sheet",
flow_cell_directory="novaseq_6000_pre_1_5_kits_flow_cell_path",
lims_samples="novaseq_6000_pre_1_5_kits_bcl_convert_lims_samples",
correct_sample_sheet="novaseq_6000_pre_1_5_kits_correct_sample_sheet_path",
),
SampleSheetScenario(
flow_cell_directory="novaseq_6000_post_1_5_kits_flow_cell",
lims_samples="novaseq_6000_post_1_5_kits_lims_samples",
correct_sample_sheet="novaseq_6000_post_1_5_kits_correct_sample_sheet",
flow_cell_directory="novaseq_6000_post_1_5_kits_flow_cell_path",
lims_samples="novaseq_6000_post_1_5_kits_bcl_convert_lims_samples",
correct_sample_sheet="novaseq_6000_post_1_5_kits_correct_sample_sheet_path",
),
SampleSheetScenario(
flow_cell_directory="novaseq_x_flow_cell_directory",
Expand All @@ -137,7 +137,6 @@ def test_create_dragen_sample_sheet(
cli_runner: testing.CliRunner,
scenario: SampleSheetScenario,
sample_sheet_context: CGConfig,
lims_novaseq_bcl_convert_samples: list[FlowCellSampleBCLConvert],
mocker,
request: FixtureRequest,
):
Expand Down Expand Up @@ -193,7 +192,7 @@ def test_incorrect_bcl2fastq_headers_samplesheet(
cli_runner: testing.CliRunner,
tmp_flow_cells_directory_malformed_sample_sheet: Path,
sample_sheet_context: CGConfig,
lims_novaseq_bcl2fastq_samples: list[FlowCellSampleBcl2Fastq],
novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples: list[FlowCellSampleBcl2Fastq],
mocker,
caplog,
):
Expand All @@ -207,7 +206,7 @@ def test_incorrect_bcl2fastq_headers_samplesheet(
# GIVEN flow cell samples
mocker.patch(
FLOW_CELL_FUNCTION_NAME,
return_value=lims_novaseq_bcl2fastq_samples,
return_value=novaseq_6000_pre_1_5_kits_bcl2fastq_lims_samples,
)
# GIVEN a lims api that returns some samples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def novaseq_6000_flow_cell(bcl_convert_flow_cell: FlowCellDirectoryData) -> Flow


@pytest.fixture(scope="function")
def novaseq_x_flow_cell(novaseq_x_flow_cell_dir: Path) -> FlowCellDirectoryData:
def novaseq_x_flow_cell(novaseq_x_flow_cell_directory: Path) -> FlowCellDirectoryData:
"""Create a NovaSeqX flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=novaseq_x_flow_cell_dir, bcl_converter=BclConverter.DRAGEN
flow_cell_path=novaseq_x_flow_cell_directory, bcl_converter=BclConverter.DRAGEN
)


Expand Down
41 changes: 12 additions & 29 deletions tests/fixture_plugins/demultiplex_fixtures/path_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,39 +202,27 @@ def demux_results_not_finished_dir(demultiplex_fixtures: Path) -> Path:


@pytest.fixture
def novaseq_6000_post_1_5_kits_flow_cell(tmp_flow_cells_directory: Path) -> Path:
def novaseq_6000_post_1_5_kits_flow_cell_path(tmp_flow_cells_directory: Path) -> Path:
return Path(tmp_flow_cells_directory, "230912_A00187_1009_AHK33MDRX3")


@pytest.fixture
def novaseq_6000_post_1_5_kits_correct_sample_sheet(
novaseq_6000_post_1_5_kits_flow_cell: Path,
def novaseq_6000_post_1_5_kits_correct_sample_sheet_path(
novaseq_6000_post_1_5_kits_flow_cell_path: Path,
) -> Path:
return Path(novaseq_6000_post_1_5_kits_flow_cell, CORRECT_SAMPLE_SHEET)
return Path(novaseq_6000_post_1_5_kits_flow_cell_path, CORRECT_SAMPLE_SHEET)


@pytest.fixture
def novaseq_6000_post_1_5_kits_raw_lims_samples(
novaseq_6000_post_1_5_kits_flow_cell: Path,
) -> Path:
return Path(novaseq_6000_post_1_5_kits_flow_cell, "HK33MDRX3_raw.json")


@pytest.fixture
def novaseq_6000_pre_1_5_kits_flow_cell(tmp_flow_cells_directory: Path) -> Path:
def novaseq_6000_pre_1_5_kits_flow_cell_path(tmp_flow_cells_directory: Path) -> Path:
return Path(tmp_flow_cells_directory, "190927_A00689_0069_BHLYWYDSXX")


@pytest.fixture
def novaseq_6000_pre_1_5_kits_correct_sample_sheet(
novaseq_6000_pre_1_5_kits_flow_cell: Path,
def novaseq_6000_pre_1_5_kits_correct_sample_sheet_path(
novaseq_6000_pre_1_5_kits_flow_cell_path: Path,
) -> Path:
return Path(novaseq_6000_pre_1_5_kits_flow_cell, CORRECT_SAMPLE_SHEET)


@pytest.fixture
def novaseq_6000_pre_1_5_kits_raw_lims_samples(novaseq_6000_pre_1_5_kits_flow_cell: Path) -> Path:
return Path(novaseq_6000_pre_1_5_kits_flow_cell, "HLYWYDSXX_raw.json")
return Path(novaseq_6000_pre_1_5_kits_flow_cell_path, CORRECT_SAMPLE_SHEET)


@pytest.fixture
Expand All @@ -247,11 +235,6 @@ def novaseq_x_correct_sample_sheet(novaseq_x_flow_cell_directory: Path) -> Path:
return Path(novaseq_x_flow_cell_directory, CORRECT_SAMPLE_SHEET)


@pytest.fixture
def novaseq_x_raw_lims_samples(novaseq_x_flow_cell_directory: Path) -> Path:
return Path(novaseq_x_flow_cell_directory, "22F52TLT3_raw.json")


@pytest.fixture(scope="session")
def novaseq_x_manifest_file(novaseq_x_flow_cell_dir: Path) -> Path:
"""Return the path to a NovaSeqX manifest file."""
Expand Down Expand Up @@ -374,22 +357,22 @@ def novaseq_6000_run_parameters_path(bcl2fastq_flow_cell_dir: Path) -> Path:

@pytest.fixture
def novaseq_6000_run_parameters_pre_1_5_kits_path(
novaseq_6000_pre_1_5_kits_flow_cell: Path,
novaseq_6000_pre_1_5_kits_flow_cell_path: Path,
) -> Path:
"""Return the path to a NovaSeq6000 pre 1.5 kit run parameters file."""
return Path(
novaseq_6000_pre_1_5_kits_flow_cell,
novaseq_6000_pre_1_5_kits_flow_cell_path,
DemultiplexingDirsAndFiles.RUN_PARAMETERS_PASCAL_CASE,
)


@pytest.fixture
def novaseq_6000_run_parameters_post_1_5_kits_path(
novaseq_6000_post_1_5_kits_flow_cell: Path,
novaseq_6000_post_1_5_kits_flow_cell_path: Path,
) -> Path:
"""Return the path to a NovaSeq6000 post 1.5 kit run parameters file."""
return Path(
novaseq_6000_post_1_5_kits_flow_cell,
novaseq_6000_post_1_5_kits_flow_cell_path,
DemultiplexingDirsAndFiles.RUN_PARAMETERS_PASCAL_CASE,
)

Expand Down
Loading

0 comments on commit 6fc47e8

Please sign in to comment.