Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pbi file from post processing #3491

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class PacBioRunFileManager(RunFileManager):
def get_files_to_parse(self, run_data: PacBioRunData) -> list[Path]:
"""Get the file paths required by the PacBioMetricsParser."""
run_path: Path = run_data.full_path
files_to_parse: list[Path] = [self._find_ccs_report_file(run_path)]
files_to_parse.extend(self._get_report_files(run_path))
files_to_parse: list[Path] = self._get_report_files(run_path)
files_to_parse.append(self._get_ccs_report_file(run_path))
return files_to_parse

def get_files_to_store(self, run_data: PacBioRunData) -> list[Path]:
"""Get the files to store for the PostProcessingHKService."""
run_path: Path = run_data.full_path
files_to_store: list[Path] = self._find_hifi_files(run_path)
files_to_store.extend(self.get_files_to_parse(run_data))
files_to_store: list[Path] = self.get_files_to_parse(run_data)
files_to_store.append(self._get_hifi_read_file(run_path))
return files_to_store

@staticmethod
def _find_ccs_report_file(run_path: Path) -> Path:
def _get_ccs_report_file(run_path: Path) -> Path:
"""Return the path to the the CCS report file."""
statistics_dir: Path = Path(run_path, PacBioDirsAndFiles.STATISTICS_DIR)
files: list[Path] = get_files_matching_pattern(
Expand All @@ -52,15 +52,11 @@ def _get_report_files(run_path: Path) -> list[Path]:
return report_files

@staticmethod
def _find_hifi_files(run_path: Path) -> list[Path]:
"""Return the paths to the HiFi read files."""
def _get_hifi_read_file(run_path: Path) -> Path:
"""Return the path to the HiFi read file."""
hifi_dir = Path(run_path, PacBioDirsAndFiles.HIFI_READS)
bam_files: list[Path] = get_files_matching_pattern(
directory=hifi_dir, pattern=f"*{FileExtensions.BAM}*"
)
if len(bam_files) != 2:
raise PostProcessingFileNotFoundError(
f"Expected 2 HiFi read files in {hifi_dir}, found {len(bam_files)}"
)
validate_files_exist(bam_files)
return bam_files
bam_file: Path = get_files_matching_pattern(
directory=hifi_dir, pattern=f"*{FileExtensions.BAM}"
)[0]
validate_files_exist([bam_file])
return bam_file
13 changes: 4 additions & 9 deletions tests/fixture_plugins/pacbio_fixtures/path_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,15 @@ def pac_bio_report_files_to_parse(
) -> list[Path]:
"""Return the list of PacBio report files to parse."""
return [
pac_bio_ccs_report_file,
pac_bio_control_report_file,
pac_bio_loading_report_file,
pac_bio_raw_data_report_file,
pac_bio_smrtlink_datasets_report_file,
pac_bio_ccs_report_file,
]


@pytest.fixture
def pac_bio_hifi_files(
pac_bio_hifi_reads_dir: Path, pac_bio_1_a01_cell_full_name: str
) -> list[Path]:
"""Return the list of PacBio HiFi read files."""
return [
Path(pac_bio_hifi_reads_dir, f"{pac_bio_1_a01_cell_full_name}.hifi_reads.bam"),
Path(pac_bio_hifi_reads_dir, f"{pac_bio_1_a01_cell_full_name}.hifi_reads.bam.pbi"),
]
def pac_bio_hifi_read_file(pac_bio_hifi_reads_dir: Path, pac_bio_1_a01_cell_full_name: str) -> Path:
"""Return the PacBio HiFi read file."""
return Path(pac_bio_hifi_reads_dir, f"{pac_bio_1_a01_cell_full_name}.hifi_reads.bam")
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_get_files_to_parse(
def test_get_files_to_store(
expected_pac_bio_run_data: PacBioRunData,
pac_bio_report_files_to_parse: list[Path],
pac_bio_hifi_files: list[Path],
pac_bio_hifi_read_file: Path,
):
"""Test that the files to be stored are returned"""

Expand All @@ -39,5 +39,5 @@ def test_get_files_to_store(
files: list[Path] = file_manager.get_files_to_store(expected_pac_bio_run_data)

# THEN the correct files are returned
full_list: list[Path] = pac_bio_report_files_to_parse + pac_bio_hifi_files
full_list: list[Path] = pac_bio_report_files_to_parse + [pac_bio_hifi_read_file]
assert set(files) == set(full_list)
Loading