Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pre-qc-failed status filter #24

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion analyses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __str__(self):
return f"{self.name} {self.version}" if self.version is not None else self.name


class AssemblyManager(ENADerivedManager):
class AssemblyManager(SelectByStatusManagerMixin, ENADerivedManager):
def get_queryset(self):
return super().get_queryset().select_related("run")

Expand Down Expand Up @@ -267,6 +267,7 @@ class AssemblyStates(str, Enum):
def default_status(cls):
return {
cls.ASSEMBLY_STARTED: False,
cls.PRE_ASSEMBLY_QC_FAILED: False,
cls.ASSEMBLY_FAILED: False,
cls.ASSEMBLY_COMPLETED: False,
cls.ASSEMBLY_BLOCKED: False,
Expand Down Expand Up @@ -512,6 +513,7 @@ class AnalysisStates(str, Enum):
def default_status(cls):
return {
cls.ANALYSIS_STARTED: False,
cls.ANALYSIS_QC_FAILED: False,
cls.ANALYSIS_COMPLETED: False,
cls.ANALYSIS_BLOCKED: False,
cls.ANALYSIS_FAILED: False,
Expand Down
8 changes: 6 additions & 2 deletions workflows/flows/analysis_amplicon_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def get_analyses_to_attempt(
study.refresh_from_db()
analyses_worth_trying = (
study.analyses.exclude_by_statuses(
[AnalysisStates.ANALYSIS_COMPLETED, AnalysisStates.ANALYSIS_BLOCKED]
[
analyses.models.Analysis.AnalysisStates.ANALYSIS_QC_FAILED,
analyses.models.Analysis.AnalysisStates.ANALYSIS_COMPLETED,
analyses.models.Analysis.AnalysisStates.ANALYSIS_BLOCKED,
]
)
.filter(experiment_type=for_experiment_type.value)
.order_by("id")
Expand Down Expand Up @@ -545,7 +549,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=AnalysisStates.ANALYSIS_FAILED,
status=AnalysisStates.ANALYSIS_QC_FAILED,
reason=qc_failed_runs[analysis.run.first_accession],
)
elif analysis.run.first_accession in qc_completed_runs:
Expand Down
11 changes: 6 additions & 5 deletions workflows/flows/assemble_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ def get_assemblies_to_attempt(study: analyses.models.Study) -> List[Union[str, i
:return:
"""
study.refresh_from_db()
assemblies_worth_trying = study.assemblies_reads.filter(
**{
f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_COMPLETED}": False,
f"status__{analyses.models.Assembly.AssemblyStates.ASSEMBLY_BLOCKED}": False,
}
assemblies_worth_trying = study.assemblies_reads.exclude_by_statuses(
[
analyses.models.Assembly.AssemblyStates.PRE_ASSEMBLY_QC_FAILED,
analyses.models.Assembly.AssemblyStates.ASSEMBLY_COMPLETED,
analyses.models.Assembly.AssemblyStates.ASSEMBLY_BLOCKED,
]
).values_list("id", flat=True)
return assemblies_worth_trying

Expand Down
2 changes: 1 addition & 1 deletion workflows/tests/test_analysis_amplicon_study_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_qc_failed=True
).acount()
== 1
)
Expand Down
Loading