Skip to content

Commit

Permalink
Fix quality result model
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard committed Dec 12, 2023
1 parent 48e247b commit ec60b96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cg/meta/workflow/microsalt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ class QualityMetrics(BaseModel):


class QualityResult(BaseModel):
sample: Sample
sample_id: str
is_negative_control: bool
passes_qc: bool
7 changes: 5 additions & 2 deletions cg/meta/workflow/microsalt/quality_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def quality_control(self, run_dir_path: Path, lims_project: str):
self.quality_control_case(sample_results)

def quality_control_sample(self, sample_id: str, metrics: SampleMetrics) -> QualityResult:
sample = self.status_db.get_sample_by_internal_id(sample_id)
valid_reads: bool = self.is_valid_total_reads(sample_id)
valid_mapping: bool = self.is_valid_mapped_rate(metrics)
valid_duplication: bool = self.is_valid_duplication_rate(metrics)
Expand All @@ -57,8 +56,12 @@ def quality_control_sample(self, sample_id: str, metrics: SampleMetrics) -> Qual
and valid_10x_coverage
)

sample = self.status_db.get_sample_by_internal_id(sample_id)
is_negative_control: bool = sample.control == ControlEnum.negative

return QualityResult(
sample=sample,
sample_id=sample_id,
is_negative_control=is_negative_control,
passed=sample_passes_qc,
)

Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/microsalt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ def parse_quality_metrics(file_path: Path) -> QualityMetrics:

def get_negative_control_result(results: list[QualityResult]) -> QualityResult:
for result in results:
if result.sample.control == ControlEnum.negative:
if result.is_negative_control:
return result

0 comments on commit ec60b96

Please sign in to comment.