Files
PlantAI-dev/docs/superpowers/plans/2026-07-07-ppi-string-image-fold2-links.md
2026-08-03 18:42:47 +08:00

4.0 KiB
Executable File

PPI STRING Image and Fold2 Links Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make PPI results reliably expose a current STRING network image and a clearly labeled AlphaFold DB/Fold2 single-protein link table.

Architecture: Keep the PPI execution model unchanged. Extend backend post-processing after STRING PPI completes: retry STRING static image downloads with PNG/SVG fallbacks, then derive an AlphaFold DB link TSV from existing STRING ID resolution output.

Tech Stack: Python 3.11, pytest, existing apps/web/pipeline_backend.py, existing PPI final artifacts.

Global Constraints

  • Do not add AlphaFold3 complex prediction.
  • Do not call external AlphaFold prediction services.
  • Label links as AlphaFold DB/Fold2 single-protein structure links, not interaction structures.
  • Preserve existing PPI network TSV, STRING URL, and species behavior.
  • Use TDD for backend behavior changes.

Task 1: STRING Static Image Fallbacks

Files:

  • Modify: apps/web/pipeline_backend.py
  • Test: tests/unit/test_pipeline_backend_execution_env.py

Interfaces:

  • Consumes: download_string_network_image(string_url: str, output_file: Path)

  • Produces: download_string_network_image(...) -> Optional[Path], returning either a .png or .svg path.

  • Step 1: Write failing tests

Add tests that monkeypatch requests.post so high-resolution PNG fails and normal PNG succeeds, and another test where PNG fails and SVG succeeds.

  • Step 2: Verify red

Run: pytest tests/unit/test_pipeline_backend_execution_env.py -k "string_network_image" -q Expected: tests fail because the current function only tries highres_image.

  • Step 3: Implement minimal fallback

Update download_string_network_image to try:

  1. https://string-db.org/api/highres_image/network to .png
  2. https://string-db.org/api/image/network to .png
  3. https://string-db.org/api/svg/network to .svg
  • Step 4: Verify green

Run: pytest tests/unit/test_pipeline_backend_execution_env.py -k "string_network_image" -q Expected: tests pass.

Files:

  • Modify: apps/web/pipeline_backend.py
  • Test: tests/unit/test_pipeline_backend_execution_env.py

Interfaces:

  • Consumes: final/{prefix}.ppi_id_resolution.tsv

  • Produces: final/{prefix}.ppi_alphafold2_links.tsv

  • Step 1: Write failing test

Add a test that creates a minimal PPI ID resolution TSV with a STRING identifier and verifies the generated AlphaFold DB link TSV exists, has explicit structure_type=AlphaFold DB/Fold2 single protein, and does not claim complex/interactor prediction.

  • Step 2: Verify red

Run: pytest tests/unit/test_pipeline_backend_execution_env.py -k "alphafold2_links" -q Expected: test fails because the helper does not exist.

  • Step 3: Implement minimal link generation

Add a helper that reads the ID resolution TSV and writes a link table. Use a conservative AlphaFold DB search URL when a direct UniProt accession is not available.

  • Step 4: Register artifact

When the link TSV exists, include it in the PPI manifest/status artifacts using a clear key such as alphafold2_links.

Task 3: Real Job Verification

Files:

  • No planned source edits beyond Tasks 1-2.

Verification:

  • Run Python syntax check for touched Python.
  • Run focused pytest tests.
  • Rerun PPI on workspace/job_1783408660053_d1349e or call the existing backend path using its current curated rice input.
  • Confirm:
    • final/Os.CRR.ppi_network.string.png or .svg exists and is non-empty.
    • final/Os.CRR.ppi_alphafold2_links.tsv exists and is non-empty.
    • Manifest/status artifacts include the image if downloaded and the Fold2 link TSV.
    • STRING URL remains species=39947 for rice and input genes remain the curated 20-member set.