fix: complete PPI and KaKs reference handoff
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
from apps.web.vue3 import main
|
||||
|
||||
|
||||
def _write_config(input_dir: Path, pep: Path, cds: Path) -> None:
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
sheet.title = "config"
|
||||
sheet.append(
|
||||
[
|
||||
"Species_Code",
|
||||
"Species_Role",
|
||||
"File_Type",
|
||||
"Original_File_Name",
|
||||
"Ref",
|
||||
]
|
||||
)
|
||||
sheet.append(["At", "reference", "pep", pep.name, True])
|
||||
sheet.append(["At", "reference", "cds", cds.name, True])
|
||||
workbook.save(input_dir / "config.xlsx")
|
||||
|
||||
|
||||
def test_execute_validation_accepts_config_resolved_reference_pep_and_cds(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
input_root = tmp_path / "input"
|
||||
job_input = input_root / "job_at"
|
||||
external = tmp_path / "external"
|
||||
job_input.mkdir(parents=True)
|
||||
external.mkdir()
|
||||
pep = external / "Arabidopsis_thaliana.TAIR10.pep.all.fa"
|
||||
cds = external / "Arabidopsis_thaliana.TAIR10.cds.all.fa"
|
||||
pep.write_text(">AT1G01010\nMA\n", encoding="utf-8")
|
||||
cds.write_text(">AT1G01010\nATGGCT\n", encoding="utf-8")
|
||||
_write_config(job_input, pep, cds)
|
||||
monkeypatch.setattr(main, "INPUT_ROOT", input_root)
|
||||
monkeypatch.setenv("PLANTAI_REF_DATA_ROOT", str(external))
|
||||
|
||||
available, source = main._reference_bundle_species_available(
|
||||
"job_at",
|
||||
"At",
|
||||
require_cds=True,
|
||||
)
|
||||
|
||||
assert available is True
|
||||
assert source == str(job_input)
|
||||
|
||||
|
||||
def test_execute_validation_keeps_accepting_downloaded_reference_bundle(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
input_root = tmp_path / "input"
|
||||
species_dir = input_root / "job_spinach" / "string_taxon_3562"
|
||||
species_dir.mkdir(parents=True)
|
||||
(species_dir / "string_taxon_3562.pep.fasta").write_text(">S1\nMA\n", encoding="utf-8")
|
||||
(species_dir / "string_taxon_3562.cds.fasta").write_text(">S1\nATGGCT\n", encoding="utf-8")
|
||||
monkeypatch.setattr(main, "INPUT_ROOT", input_root)
|
||||
|
||||
available, source = main._reference_bundle_species_available(
|
||||
"job_spinach",
|
||||
"string_taxon_3562",
|
||||
require_cds=True,
|
||||
)
|
||||
|
||||
assert available is True
|
||||
assert source == str(species_dir)
|
||||
|
||||
|
||||
def test_execute_validation_still_rejects_a_truly_incomplete_reference(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
input_root = tmp_path / "input"
|
||||
species_dir = input_root / "job_incomplete" / "At"
|
||||
species_dir.mkdir(parents=True)
|
||||
(species_dir / "At.pep.fasta").write_text(">AT1G01010\nMA\n", encoding="utf-8")
|
||||
monkeypatch.setattr(main, "INPUT_ROOT", input_root)
|
||||
|
||||
available, reason = main._reference_bundle_species_available(
|
||||
"job_incomplete",
|
||||
"At",
|
||||
require_cds=True,
|
||||
)
|
||||
|
||||
assert available is False
|
||||
assert "missing CDS" in reason
|
||||
Reference in New Issue
Block a user