From 4dea33699bf12f6f998307ad084bb4aaa0cb398c Mon Sep 17 00:00:00 2001 From: Ekaterina Sakharova Date: Tue, 17 Dec 2024 10:42:54 +0000 Subject: [PATCH 1/2] added pre-qc-failed status filter --- analyses/models.py | 3 ++- workflows/flows/analysis_amplicon_study.py | 3 ++- workflows/flows/assemble_study.py | 1 + workflows/tests/test_analysis_amplicon_study_flow.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/analyses/models.py b/analyses/models.py index 8834367..5b811ec 100644 --- a/analyses/models.py +++ b/analyses/models.py @@ -504,7 +504,7 @@ class AnalysisStates(str, Enum): ANALYSIS_COMPLETED = "analysis_completed" ANALYSIS_BLOCKED = "analysis_blocked" ANALYSIS_FAILED = "analysis_failed" - ANALYSIS_QC_FAILED = "analysis_qc_failed" + ANALYSIS_PRE_QC_FAILED = "analysis_pre_qc_failed" ANALYSIS_POST_SANITY_CHECK_FAILED = "analysis_post_sanity_check_failed" @classmethod @@ -514,6 +514,7 @@ def default_status(cls): cls.ANALYSIS_COMPLETED: False, cls.ANALYSIS_BLOCKED: False, cls.ANALYSIS_FAILED: False, + cls.ANALYSIS_PRE_QC_FAILED: False, } status = models.JSONField( diff --git a/workflows/flows/analysis_amplicon_study.py b/workflows/flows/analysis_amplicon_study.py index f7b9c80..efb00e1 100644 --- a/workflows/flows/analysis_amplicon_study.py +++ b/workflows/flows/analysis_amplicon_study.py @@ -64,6 +64,7 @@ def get_analyses_to_attempt( **{ f"status__{analyses.models.Analysis.AnalysisStates.ANALYSIS_COMPLETED}": False, f"status__{analyses.models.Analysis.AnalysisStates.ANALYSIS_BLOCKED}": False, + f"status__{analyses.models.Analysis.AnalysisStates.ANALYSIS_PRE_QC_FAILED}": False, } ) .filter(experiment_type=for_experiment_type) @@ -546,7 +547,7 @@ def set_post_analysis_states(amplicon_current_outdir: Path, amplicon_analyses: L if analysis.run.first_accession in qc_failed_runs: task_mark_analysis_status( analysis, - status=analyses.models.Analysis.AnalysisStates.ANALYSIS_FAILED, + status=analyses.models.Analysis.AnalysisStates.ANALYSIS_PRE_QC_FAILED, reason=qc_failed_runs[analysis.run.first_accession], ) elif analysis.run.first_accession in qc_completed_runs: diff --git a/workflows/flows/assemble_study.py b/workflows/flows/assemble_study.py index dad311a..8d145f8 100644 --- a/workflows/flows/assemble_study.py +++ b/workflows/flows/assemble_study.py @@ -126,6 +126,7 @@ def get_assemblies_to_attempt(study: analyses.models.Study) -> List[Union[str, i **{ f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_COMPLETED}": False, f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_BLOCKED}": False, + f"status__{analyses.models.Assembly.AssemblyStates.PRE_ASSEMBLY_QC_FAILED}": False, } ).values_list("id", flat=True) return assemblies_worth_trying diff --git a/workflows/tests/test_analysis_amplicon_study_flow.py b/workflows/tests/test_analysis_amplicon_study_flow.py index a0452a1..df3170c 100644 --- a/workflows/tests/test_analysis_amplicon_study_flow.py +++ b/workflows/tests/test_analysis_amplicon_study_flow.py @@ -505,7 +505,7 @@ async def test_prefect_analyse_amplicon_flow( # check failed runs assert ( await analyses.models.Analysis.objects.filter( - status__analysis_failed=True + status__analysis_pre_qc_failed=True ).acount() == 1 ) From 32ec2e88a4a6136bd207bac5aa9af193bd27306d Mon Sep 17 00:00:00 2001 From: Ekaterina Sakharova Date: Tue, 17 Dec 2024 14:44:03 +0000 Subject: [PATCH 2/2] added default for PRE_QC status --- analyses/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/analyses/models.py b/analyses/models.py index 5b811ec..b75c246 100644 --- a/analyses/models.py +++ b/analyses/models.py @@ -272,6 +272,7 @@ def default_status(cls): cls.ASSEMBLY_UPLOADED: False, cls.ASSEMBLY_UPLOAD_FAILED: False, cls.ASSEMBLY_UPLOAD_BLOCKED: False, + cls.PRE_ASSEMBLY_QC_FAILED: False, } status = models.JSONField(