Skip to content

Commit

Permalink
Merge branch 'master' into metrics-to-json
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrOertlin authored Jan 11, 2024
2 parents ebe8b7c + cfb771c commit 362cded
Show file tree
Hide file tree
Showing 21 changed files with 1,447 additions and 1,403 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 = 55.0.0
current_version = 55.2.1
commit = True
tag = True
tag_name = v{new_version}
Expand Down
2 changes: 1 addition & 1 deletion cg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "cg"
__version__ = "55.0.0"
__version__ = "55.2.1"
17 changes: 8 additions & 9 deletions cg/apps/crunchy/crunchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,24 @@ def is_compression_pending(compression_obj: CompressionData) -> bool:
def is_fastq_compression_possible(compression_obj: CompressionData) -> bool:
"""Check if FASTQ compression is possible.
There are three possible answers to this question:
- Compression is running -> Compression NOT possible
- SPRING archive exists -> Compression NOT possible
- Data is external -> Compression NOT possible
- Not compressed and not running -> Compression IS possible
- Compression is running -> Compression NOT possible
- SPRING file exists on Hasta -> Compression NOT possible
- Data is external -> Compression NOT possible
- Not compressed and
not running -> Compression IS possible
"""
if CrunchyAPI.is_compression_pending(compression_obj):
return False

if compression_obj.spring_exists():
LOG.info("SPRING file found")
LOG.debug("SPRING file found")
return False

if "external-data" in str(compression_obj.fastq_first):
LOG.info("File is external data and should not be compressed")
LOG.debug("File is external data and should not be compressed")
return False

LOG.info("FASTQ compression is possible")
LOG.debug("FASTQ compression is possible")

return True

Expand Down
14 changes: 0 additions & 14 deletions cg/apps/tb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,6 @@ def is_latest_analysis_completed(self, case_id: str) -> bool:
def is_latest_analysis_qc(self, case_id: str) -> bool:
return self.get_latest_analysis_status(case_id=case_id) == AnalysisStatus.QC

def mark_analyses_deleted(self, case_id: str) -> list | None:
"""Mark all analyses for case deleted without removing analysis files"""
request_body = {
"case_id": case_id,
}
response = self.query_trailblazer(
command="mark-analyses-deleted", request_body=request_body
)
if response:
if isinstance(response, list):
return [TrailblazerAnalysis.model_validate(analysis) for analysis in response]
if isinstance(response, dict):
return [TrailblazerAnalysis.model_validate(response)]

def add_pending_analysis(
self,
case_id: str,
Expand Down
9 changes: 1 addition & 8 deletions cg/constants/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,7 @@
{"salmon-quant"},
]

MICROSALT_ANALYSIS_CASE_TAGS: list[set[str]] = [
{"microsalt-qc"},
{"microsalt-type"},
{"assembly"},
{"trimmed-forward-reads"},
{"trimmed-reverse-reads"},
{"reference-alignment-deduplicated"},
]
MICROSALT_ANALYSIS_CASE_TAGS = [{"qc-report"}, {"typing-report"}]

MICROSALT_ANALYSIS_SAMPLE_TAGS: list[set[str]] = []

Expand Down
31 changes: 20 additions & 11 deletions cg/meta/compress/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from cg.constants import SequencingFileTag
from cg.meta.backup.backup import SpringBackupAPI
from cg.meta.compress import files
from cg.models import CompressionData, FileData
from cg.models import CompressionData
from cg.store.models import Sample

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -73,16 +73,11 @@ def compress_fastq(self, sample_id: str) -> bool:
for run_name in sample_fastq:
LOG.info(f"Check if compression possible for run {run_name}")
compression: CompressionData = sample_fastq[run_name]["compression_data"]
if FileData.is_empty(compression.fastq_first):
LOG.warning(f"Fastq files are empty for {sample_id}: {compression.fastq_first}")
self.delete_fastq_housekeeper(
hk_fastq_first=sample_fastq[run_name]["hk_first"],
hk_fastq_second=sample_fastq[run_name]["hk_second"],
)
all_ok = False
continue

if not self.crunchy_api.is_fastq_compression_possible(compression_obj=compression):
is_compression_possible: bool = self._is_fastq_compression_possible(
compression=compression,
sample_id=sample_id,
)
if not is_compression_possible:
LOG.warning(f"FASTQ to SPRING not possible for {sample_id}, run {run_name}")
all_ok = False
continue
Expand All @@ -93,6 +88,20 @@ def compress_fastq(self, sample_id: str) -> bool:
self.crunchy_api.fastq_to_spring(compression_obj=compression, sample_id=sample_id)
return all_ok

def _is_fastq_compression_possible(self, compression: CompressionData, sample_id: str) -> bool:
if self._is_spring_archived(compression):
LOG.debug(f"Found archived Spring file for {sample_id} - compression not possible")
return False
return self.crunchy_api.is_fastq_compression_possible(compression_obj=compression)

def _is_spring_archived(self, compression_data: CompressionData) -> bool:
spring_file: File | None = self.hk_api.get_file_insensitive_path(
path=compression_data.spring_path
)
if (not spring_file) or (not spring_file.archive):
return False
return bool(spring_file.archive.archived_at)

def decompress_spring(self, sample_id: str) -> bool:
"""Decompress SPRING archive for a sample.
Expand Down
1 change: 0 additions & 1 deletion cg/meta/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def get_analysis_finish_path(self, case_id: str) -> Path:

def add_pending_trailblazer_analysis(self, case_id: str) -> None:
self.check_analysis_ongoing(case_id)
self.trailblazer_api.mark_analyses_deleted(case_id)
self.trailblazer_api.add_pending_analysis(
case_id=case_id,
email=environ_email(),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "cg"
version = "55.0.0"
version = "55.2.1"
description = "Clinical Genomics command center"
authors = ["Clinical Genomics <[email protected]>"]
readme = "README.md"
Expand Down
Loading

0 comments on commit 362cded

Please sign in to comment.