From 06aea81fec7383c43bccf57b2fd8fa05618521d9 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Mon, 11 Dec 2023 14:03:20 +1300 Subject: [PATCH] Ensure populated CramPaths have both path and index_path (#542) The resulting self.index_path will only be set if the CramPath() constructor also specifies an index_path. Use exists() to benefit from whole-directory existence caching. --- .bumpversion.cfg | 2 +- .github/workflows/docker.yaml | 2 +- cpg_workflows/inputs.py | 14 +++++++++----- setup.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 45d9918e1..d908532e1 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.18.12 +current_version = 1.18.13 commit = True tag = False diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 72d96ebca..2e0c4a6b4 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -15,7 +15,7 @@ permissions: contents: read env: - VERSION: 1.18.12 + VERSION: 1.18.13 jobs: docker: diff --git a/cpg_workflows/inputs.py b/cpg_workflows/inputs.py index 084a9252c..fa1e04ec9 100644 --- a/cpg_workflows/inputs.py +++ b/cpg_workflows/inputs.py @@ -10,6 +10,7 @@ from .metamist import AnalysisType, Assay, MetamistError, get_metamist, parse_reads from .targets import Cohort, PedigreeInfo, SequencingGroup, Sex +from .utils import exists _cohort: Cohort | None = None @@ -140,25 +141,28 @@ def _populate_analysis(cohort: Cohort) -> None: for sequencing_group in dataset.get_sequencing_groups(): if (analysis := gvcf_by_sgid.get(sequencing_group.id)) and analysis.output: # assert file exists - assert analysis.output.exists(), ( + assert exists(analysis.output), ( 'gvcf file does not exist', analysis.output, ) sequencing_group.gvcf = GvcfPath(path=analysis.output) - elif sequencing_group.make_gvcf_path().exists(): + elif exists(sequencing_group.make_gvcf_path()): logging.warning( f'We found a gvcf file in the expected location {sequencing_group.make_gvcf_path()},' 'but it is not logged in metamist. Skipping. You may want to update the metadata and try again. ' ) if (analysis := cram_by_sgid.get(sequencing_group.id)) and analysis.output: # assert file exists - assert analysis.output.exists(), ( + assert exists(analysis.output), ( 'cram file does not exist', analysis.output, ) - sequencing_group.cram = CramPath(path=analysis.output) + crai_path = analysis.output.with_suffix('.cram.crai') + if not exists(crai_path): + crai_path = None + sequencing_group.cram = CramPath(analysis.output, crai_path) - elif sequencing_group.make_cram_path().exists(): + elif exists(sequencing_group.make_cram_path()): logging.warning( f'We found a cram file in the expected location {sequencing_group.make_cram_path()},' 'but it is not logged in metamist. Skipping. You may want to update the metadata and try again. ' diff --git a/setup.py b/setup.py index 40e662c7a..acedbc1ee 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='cpg-workflows', # This tag is automatically updated by bumpversion - version='1.18.12', + version='1.18.13', description='CPG workflows for Hail Batch', long_description=open('README.md').read(), long_description_content_type='text/markdown',