Skip to content

Commit

Permalink
Remove constant DRAGEN and replace usages for BCLCONVERT (#2843)(patch)
Browse files Browse the repository at this point in the history
Fixes #2030. Remove all ambiguity between the constants `BclConverter.DRAGEN` and `BclConverter.BCLCONVERT`, removing de former and replacing all the usages with the latter.


### Changed

- Removes `BclConverter.DRAGEN` and changes it with `BclConverter.BCLCONVERT`
  • Loading branch information
diitaz93 authored Jan 16, 2024
1 parent b0d7c99 commit 274ed44
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cg/apps/demultiplex/demultiplex_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def start_demultiplexing(self, flow_cell: FlowCellDirectoryData):
number_tasks=18,
quality_of_service=self.slurm_quality_of_service,
)
if flow_cell.bcl_converter == BclConverter.DRAGEN:
if flow_cell.bcl_converter == BclConverter.BCLCONVERT:
sbatch_parameters: SbatchDragen = SbatchDragen(
account=self.slurm_account,
commands=commands,
Expand Down
6 changes: 4 additions & 2 deletions cg/apps/demultiplex/sbatch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# This one needs run_dir, out_dir, basemask and sample_sheet

from cg.constants.demultiplexing import BclConverter

DEMULTIPLEX_COMMAND = {
"bcl2fastq": """
BclConverter.BCL2FASTQ: """
log "singularity exec --bind \
/home/proj/{environment}/demultiplexed-runs,\
/home/proj/{environment}/flow_cells,\
Expand All @@ -25,7 +27,7 @@
touch {demux_completed_file}
log "bcl2fastq finished!"
""",
"dragen": """
BclConverter.BCLCONVERT: """
log "dragen --bcl-conversion-only true \
--bcl-input-directory {run_dir} \
--output-directory {demux_dir} \
Expand Down
2 changes: 1 addition & 1 deletion cg/apps/sequencing_metrics_parser/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_sample_lane_sequencing_metrics_for_flow_cell(
) -> list[SampleLaneSequencingMetrics]:
"""Parse the sequencing metrics data for the correct demultiplexing software
into the sequencing statistics model."""
if bcl_converter == BclConverter.BCLCONVERT or bcl_converter == BclConverter.DRAGEN:
if bcl_converter == BclConverter.BCLCONVERT:
return create_sample_lane_sequencing_metrics_from_bcl_convert_metrics_for_flow_cell(
flow_cell_directory
)
Expand Down
7 changes: 0 additions & 7 deletions cg/constants/bcl_convert_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ class BclConvertQualityMetricsColumnNames(StrEnum):
if column != "index2"
]
),
BclConverter.DRAGEN: ",".join(
[
column
for column in SampleSheetBCLConvertSections.Data.column_names()
if column != "index2"
]
),
}


Expand Down
7 changes: 3 additions & 4 deletions cg/constants/demultiplexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class BclConverter(StrEnum):
"""Define the BCL converter."""

DRAGEN: str = "dragen"
BCL2FASTQ: str = "bcl2fastq"
BCLCONVERT: str = "bcl_convert"

Expand Down Expand Up @@ -207,20 +206,20 @@ class IndexOverrideCycles(StrEnum):
OPTION_BCL_CONVERTER = click.option(
"-b",
"--bcl-converter",
type=click.Choice(["bcl2fastq", "dragen"]),
type=click.Choice([BclConverter.BCL2FASTQ, BclConverter.BCLCONVERT]),
default=None,
help="Specify bcl conversion software. Choose between bcl2fastq and dragen. "
"If not specified, the software will be determined automatically using the sequencer type.",
)


DEMUX_STATS_PATH: dict[str, dict[str, Path | None]] = {
"bcl2fastq": {
BclConverter.BCL2FASTQ: {
"demultiplexing_stats": Path("Stats", "DemultiplexingStats.xml"),
"conversion_stats": Path("Stats", "ConversionStats.xml"),
"runinfo": None,
},
"dragen": {
BclConverter.BCLCONVERT: {
"demultiplexing_stats": Path("Reports", "Demultiplex_Stats.csv"),
"conversion_stats": Path("Reports", "Demultiplex_Stats.csv"),
"adapter_metrics_stats": Path("Reports", "Adapter_Metrics.csv"),
Expand Down
4 changes: 2 additions & 2 deletions cg/models/flow_cell/flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Sequencers.NOVASEQX: RunParametersNovaSeqX,
}
SAMPLE_MODEL_TO_BCL_CONVERTER: dict[Type[FlowCellSample], str] = {
FlowCellSampleBCLConvert: BclConverter.DRAGEN,
FlowCellSampleBCLConvert: BclConverter.BCLCONVERT,
FlowCellSampleBcl2Fastq: BclConverter.BCL2FASTQ,
}

Expand All @@ -60,7 +60,7 @@ def __init__(self, flow_cell_path: Path, bcl_converter: str | None = None):
self.id: str = EMPTY_STRING
self.position: Literal["A", "B"] = "A"
self.parse_flow_cell_dir_name()
self.bcl_converter: str = bcl_converter or BclConverter.DRAGEN
self.bcl_converter: str = bcl_converter or BclConverter.BCLCONVERT
self._sample_sheet_path_hk: Path | None = None

def parse_flow_cell_dir_name(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/apps/demultiplex/test_sample_sheet_creator_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def test_sample_sheet_creator_factory_bcl_convert(
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 BCL Convert samples
assert novaseq_x_flow_cell.bcl_converter == BclConverter.DRAGEN
assert novaseq_x_flow_cell.bcl_converter == BclConverter.BCLCONVERT

# WHEN defining the sample sheet creator
sample_sheet_creator: SampleSheetCreator = get_sample_sheet_creator(
Expand Down
12 changes: 8 additions & 4 deletions tests/cli/demultiplex/test_create_sample_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_create_bcl2fastq_sample_sheet(
# WHEN creating a sample sheet
result = cli_runner.invoke(
create_sheet,
[str(tmp_flow_cells_directory_no_sample_sheet), "--bcl-converter", "bcl2fastq"],
[str(tmp_flow_cells_directory_no_sample_sheet), "--bcl-converter", BclConverter.BCL2FASTQ],
obj=sample_sheet_context,
)

Expand Down Expand Up @@ -144,7 +144,7 @@ def test_create_dragen_sample_sheet(
flow_cell_directory: Path = request.getfixturevalue(scenario.flow_cell_directory)
# GIVEN a flow cell directory with some run parameters
flow_cell: FlowCellDirectoryData = FlowCellDirectoryData(
flow_cell_directory, bcl_converter=BclConverter.DRAGEN
flow_cell_directory, bcl_converter=BclConverter.BCLCONVERT
)
assert flow_cell.run_parameters_path.exists()

Expand All @@ -166,7 +166,7 @@ def test_create_dragen_sample_sheet(
# WHEN creating a sample sheet
result = cli_runner.invoke(
create_sheet,
[str(flow_cell_directory), "-b", BclConverter.DRAGEN],
[str(flow_cell_directory), "-b", BclConverter.BCLCONVERT],
obj=sample_sheet_context,
)

Expand Down Expand Up @@ -213,7 +213,11 @@ def test_incorrect_bcl2fastq_headers_samplesheet(
# WHEN creating a sample sheet
cli_runner.invoke(
create_sheet,
[str(tmp_flow_cells_directory_malformed_sample_sheet), "--bcl-converter", "bcl2fastq"],
[
str(tmp_flow_cells_directory_malformed_sample_sheet),
"--bcl-converter",
BclConverter.BCL2FASTQ,
],
obj=sample_sheet_context,
)

Expand Down
13 changes: 8 additions & 5 deletions tests/cli/demultiplex/test_demultiplex_flowcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_demultiplex_bcl2fastq_flow_cell_dry_run(
str(tmp_flow_cells_directory_ready_for_demultiplexing_bcl2fastq),
"--dry-run",
"-b",
"bcl2fastq",
BclConverter.BCL2FASTQ,
],
obj=demultiplexing_context_for_demux,
)
Expand Down Expand Up @@ -90,7 +90,11 @@ def test_demultiplex_bcl2fastq_flow_cell(
# WHEN starting demultiplexing from the CLI with dry run flag
result: testing.Result = cli_runner.invoke(
demultiplex_flow_cell,
[str(tmp_flow_cells_directory_ready_for_demultiplexing_bcl2fastq), "-b", "bcl2fastq"],
[
str(tmp_flow_cells_directory_ready_for_demultiplexing_bcl2fastq),
"-b",
BclConverter.BCL2FASTQ,
],
obj=demultiplexing_context_for_demux,
)

Expand All @@ -110,7 +114,6 @@ def test_demultiplex_dragen_flowcell(
cli_runner: testing.CliRunner,
tmp_flow_cell_directory_bclconvert: Path,
demultiplexing_context_for_demux: CGConfig,
tmp_demultiplexed_runs_directory: Path,
caplog,
mocker,
):
Expand All @@ -119,7 +122,7 @@ def test_demultiplex_dragen_flowcell(
# GIVEN that all files are present for Dragen demultiplexing

flow_cell: FlowCellDirectoryData = FlowCellDirectoryData(
flow_cell_path=tmp_flow_cell_directory_bclconvert, bcl_converter="dragen"
flow_cell_path=tmp_flow_cell_directory_bclconvert, bcl_converter=BclConverter.BCLCONVERT
)
add_sample_sheet_path_to_housekeeper(
flow_cell_directory=tmp_flow_cell_directory_bclconvert,
Expand All @@ -142,7 +145,7 @@ def test_demultiplex_dragen_flowcell(
# WHEN starting demultiplexing from the CLI
result: testing.Result = cli_runner.invoke(
demultiplex_flow_cell,
[str(tmp_flow_cell_directory_bclconvert), "-b", "dragen"],
[str(tmp_flow_cell_directory_bclconvert), "-b", BclConverter.BCLCONVERT],
obj=demultiplexing_context_for_demux,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def novaseq_flow_cell_demultiplexed_with_bcl2fastq(
def bcl_convert_flow_cell(bcl_convert_flow_cell_dir: Path) -> FlowCellDirectoryData:
"""Create a bcl_convert flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=bcl_convert_flow_cell_dir, bcl_converter=BclConverter.DRAGEN
flow_cell_path=bcl_convert_flow_cell_dir, bcl_converter=BclConverter.BCLCONVERT
)


Expand All @@ -95,7 +95,7 @@ def novaseq_6000_flow_cell(bcl_convert_flow_cell: FlowCellDirectoryData) -> Flow
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_directory, bcl_converter=BclConverter.DRAGEN
flow_cell_path=novaseq_x_flow_cell_directory, bcl_converter=BclConverter.BCLCONVERT
)


Expand Down Expand Up @@ -142,7 +142,7 @@ def tmp_bcl_convert_flow_cell(
"""Create a flow cell object with flow cell that is demultiplexed."""
return FlowCellDirectoryData(
flow_cell_path=tmp_flow_cell_directory_bclconvert,
bcl_converter=BclConverter.DRAGEN,
bcl_converter=BclConverter.BCLCONVERT,
)


Expand Down
8 changes: 3 additions & 5 deletions tests/meta/demultiplex/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import pytest

from cg.apps.housekeeper.hk import HousekeeperAPI
from cg.constants.demultiplexing import DemultiplexingDirsAndFiles
from cg.constants.demultiplexing import BclConverter, DemultiplexingDirsAndFiles
from cg.meta.demultiplex.demux_post_processing import DemuxPostProcessingAPI
from cg.meta.demultiplex.housekeeper_storage_functions import (
add_sample_sheet_path_to_housekeeper,
)
from cg.meta.demultiplex.housekeeper_storage_functions import add_sample_sheet_path_to_housekeeper
from cg.models.cg_config import CGConfig
from cg.models.flow_cell.flow_cell import FlowCellDirectoryData
from cg.store.api import Store
Expand Down Expand Up @@ -242,7 +240,7 @@ def flow_cell_name_demultiplexed_with_bcl_convert_on_sequencer() -> str:
@pytest.fixture(scope="session")
def bcl2fastq_folder_structure(tmp_path_factory, cg_dir: Path) -> Path:
"""Return a folder structure that resembles a bcl2fastq run folder."""
base_dir: Path = tmp_path_factory.mktemp("".join((str(cg_dir), "bcl2fastq")))
base_dir: Path = tmp_path_factory.mktemp("".join((str(cg_dir), BclConverter.BCL2FASTQ)))
folders: list[str] = ["l1t21", "l1t11", "l2t11", "l2t21"]

for folder in folders:
Expand Down
5 changes: 3 additions & 2 deletions tests/meta/demultiplex/test_demux_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DemultiplexingScenario(BaseModel):
flow_cell_directory: str
flow_cell_name: str
samples_ids: str
bcl_converter: str = BclConverter.DRAGEN
bcl_converter: str = BclConverter.BCLCONVERT


@pytest.mark.parametrize(
Expand Down Expand Up @@ -209,7 +209,8 @@ def test_post_processing_tracks_undetermined_fastqs_for_bclconvert(

# WHEN post processing the flow cell
demux_post_processing_api.finish_flow_cell(
flow_cell_directory_name=bclconvert_flow_cell_dir_name, bcl_converter=BclConverter.DRAGEN
flow_cell_directory_name=bclconvert_flow_cell_dir_name,
bcl_converter=BclConverter.BCLCONVERT,
)

# THEN the undetermined fastqs were stored in housekeeper
Expand Down
2 changes: 1 addition & 1 deletion tests/models/flow_cell/test_flowcell_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_get_bcl_converter_default(
flow_cell = FlowCellDirectoryData(Path(flow_cell_directory_name_demultiplexed_with_bcl_convert))

# THEN it sets the converter to BCLConverter
assert flow_cell.bcl_converter == BclConverter.DRAGEN
assert flow_cell.bcl_converter == BclConverter.BCLCONVERT


def test_get_bcl_converter_bcl2fastq_flow_cell(
Expand Down

0 comments on commit 274ed44

Please sign in to comment.