Skip to content

Commit

Permalink
Ensure populated CramPaths have both path and index_path (#542)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jmarshall authored Dec 11, 2023
1 parent de26ef5 commit 06aea81
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.18.12
current_version = 1.18.13
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
contents: read

env:
VERSION: 1.18.12
VERSION: 1.18.13

jobs:
docker:
Expand Down
14 changes: 9 additions & 5 deletions cpg_workflows/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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. '
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 06aea81

Please sign in to comment.