Refactor: Unified pipeline execution, simplified UI, and fixed Docker config
- Backend: Refactored tasks.py to directly invoke run_single_fna_pipeline.py for consistency. - Backend: Changed output format to ZIP and added auto-cleanup of intermediate files. - Backend: Fixed language parameter passing in API and tasks. - Frontend: Removed CRISPR Fusion UI elements from Submit and Monitor views. - Frontend: Implemented simulated progress bar for better UX. - Frontend: Restored One-click load button and added result file structure documentation. - Docker: Fixed critical Restarting loop by removing incorrect image directive in docker-compose.yml. - Docker: Optimized Dockerfile to correct .pixi environment path issues and prevent accidental deletion of frontend assets.
This commit is contained in:
@@ -18,8 +18,9 @@ Dependencies:
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Dict, Any
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -29,6 +30,8 @@ try:
|
||||
except Exception:
|
||||
_HAS_SNS = False
|
||||
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
@@ -265,6 +268,65 @@ def _labels(lang: str):
|
||||
return zh if lang == "zh" else en
|
||||
|
||||
|
||||
def _format_crispr_section(crispr_data: Dict[str, Any], lang: str) -> List[str]:
|
||||
"""Format CRISPR analysis results as a Markdown section."""
|
||||
L = {
|
||||
"zh": {
|
||||
"title": "## CRISPR-Cas 融合分析",
|
||||
"summary": "CRISPR-Cas 系统检测摘要",
|
||||
"associations": "CRISPR-毒素关联",
|
||||
"arrays": "检测到的 CRISPR Arrays",
|
||||
"proximal": "邻近关联 (Proximity)",
|
||||
"spacer": "Spacer 匹配",
|
||||
"none": "未检测到显著关联。",
|
||||
"table_header": "类型 | 毒素 | 距离 (bp) | Array ID",
|
||||
"table_sep": "--- | --- | --- | ---"
|
||||
},
|
||||
"en": {
|
||||
"title": "## CRISPR-Cas Fusion Analysis",
|
||||
"summary": "CRISPR-Cas System Detection Summary",
|
||||
"associations": "CRISPR-Toxin Associations",
|
||||
"arrays": "Detected CRISPR Arrays",
|
||||
"proximal": "Proximity",
|
||||
"spacer": "Spacer Match",
|
||||
"none": "No significant associations detected.",
|
||||
"table_header": "Type | Toxin | Distance (bp) | Array ID",
|
||||
"table_sep": "--- | --- | --- | ---"
|
||||
}
|
||||
}
|
||||
txt = L.get(lang, L["en"])
|
||||
lines = []
|
||||
lines.append(txt["title"])
|
||||
lines.append("")
|
||||
|
||||
# Summary
|
||||
if "summary" in crispr_data:
|
||||
s = crispr_data["summary"]
|
||||
lines.append(f"- **{txt['proximal']}**: {s.get('proximal_pairs', 0)}")
|
||||
lines.append(f"- **{txt['spacer']}**: {s.get('spacer_matches', 0)}")
|
||||
lines.append("")
|
||||
|
||||
# Associations Table
|
||||
assocs = crispr_data.get("associations", [])
|
||||
if assocs:
|
||||
lines.append(f"### {txt['associations']}")
|
||||
lines.append("")
|
||||
lines.append(txt["table_header"])
|
||||
lines.append(txt["table_sep"])
|
||||
for a in assocs:
|
||||
atype = a.get("type", "unknown")
|
||||
toxin = a.get("toxin", "")
|
||||
dist = a.get("distance", "-")
|
||||
aid = a.get("array_id", "")
|
||||
lines.append(f"{atype} | {toxin} | {dist} | {aid}")
|
||||
lines.append("")
|
||||
else:
|
||||
lines.append(txt["none"])
|
||||
lines.append("")
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def write_summary_md(
|
||||
out_path: Path,
|
||||
strain_scores_path: Path,
|
||||
@@ -275,11 +337,18 @@ def write_summary_md(
|
||||
species_heatmap_path: Optional[Path],
|
||||
merge_unresolved: bool,
|
||||
args_namespace,
|
||||
crispr_data: Optional[Dict] = None,
|
||||
):
|
||||
labels = _labels(getattr(args_namespace, "lang", "zh"))
|
||||
lines: List[str] = []
|
||||
lines.append(labels["summary"])
|
||||
lines.append(labels["summary"])
|
||||
lines.append("")
|
||||
|
||||
# CRISPR Section (Top)
|
||||
if crispr_data:
|
||||
lines.extend(_format_crispr_section(crispr_data, getattr(args_namespace, "lang", "zh")))
|
||||
lines.append("")
|
||||
|
||||
# Parameters
|
||||
lines.append(labels["params"])
|
||||
lines.append(f"- allow_unknown_families: {getattr(args_namespace, 'allow_unknown_families', 'NA')}")
|
||||
@@ -359,6 +428,7 @@ def write_report_md(
|
||||
species_heatmap_path: Optional[Path],
|
||||
merge_unresolved: bool,
|
||||
args_namespace,
|
||||
crispr_data: Optional[Dict] = None,
|
||||
):
|
||||
if mode == "summary":
|
||||
return write_summary_md(
|
||||
@@ -371,6 +441,7 @@ def write_report_md(
|
||||
species_heatmap_path,
|
||||
merge_unresolved,
|
||||
args_namespace,
|
||||
crispr_data,
|
||||
)
|
||||
|
||||
L = _labels(lang)
|
||||
@@ -551,6 +622,7 @@ def main():
|
||||
species_heatmap_path=species_png,
|
||||
merge_unresolved=args.merge_unresolved,
|
||||
args_namespace=args,
|
||||
crispr_data=crispr_data,
|
||||
)
|
||||
print(f"Saved: {summary_md}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user