Skip to content

Simplify scoring, report and biophysics code without changing outputs - #31

Merged
DimaMolod merged 1 commit into
30-alphajudge-pae-handling-for-af3x-outputs-cross-linker-tokensfrom
30-simplify
Sep 28, 2026
Merged

DimaMolod merged 1 commit into
30-alphajudge-pae-handling-for-af3x-outputs-cross-linker-tokensfrom
30-simplify

Conversation

@DimaMolod

@DimaMolod DimaMolod commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

A simplification pass over the package: dead code, duplicated logic and needless indirection. No output changes. Net −1,257 lines (920 added, 2,177 removed). report.py goes from 2,031 to about 1,370 lines and connolly.py from 910 to 750.

This targets the #30 branch, so the diff shows only the cleanup.

Verification

  • Golden outputs. The CLI ran over every bundled run (AF2 pos/neg, AF3 pos/neg, AF3x 4G3Y crosslink fixture, Boltz-2 6OGE). The runs covered all models, per-run and aggregate PDFs, cached-CSV reuse, --skip_biophysical_scores, non-default thresholds, and the alphajudge-report entry point. Report timestamps were frozen for the comparison. All 63 CSV, PDF and PNG files are byte-identical to the base commit. The base itself was checked to be deterministic across two runs.
  • Biophysics. Raw Connolly dots, normals, burial flags and molecule labels, plus SC, H-bond, salt-bridge, disulfide, buried-area and solvation values, are bitwise equal on 16 interfaces.
  • Tests. pytest test/ passes 92/92 with ALPHAJUDGE_RUN_SLOW_SC_REFERENCE=1.

What changed

  • report.py. Removed:

    • the page-total and footer plumbing that nothing read;
    • the never-drawn logo, info icon and slider-marker branch;
    • an unused row grouper and three unused imports.

    Repeated axes setup and text boilerplate now go through _text_axes, _label_axes, _kv_rows and _save_page. The aggregate report no longer sorts lists that are already sorted, and counts backends with Counter.

  • runner.py.

    • One functools.partial worker serves both the serial and process-pool paths.
    • The cache-reuse and recompute branches share the report and aggregation tail.
    • Rows are built in _interface_row.
    • Removed the unused matplotlib/numpy imports and a lazy import of a module that was already imported.
  • Interface / Complex.

    • _pair_indices() replaces four copies of the residue-to-PAE lookup.
    • mpDockQ's global contact count is now the sum of the per-interface counts. Biopython's KD-tree applies the same d² <= r² test, so a second neighbour search is gone.
    • Removed a per-chain-pair atom cache that could never hit.
    • New Interface.label and Complex.chain_boundaries replace private-attribute access from the runner.
  • Parsers.

    • JSON and pickle loading share magic-byte decompression.
    • Path lookups share BaseParser._first_existing.
    • ParserManager keeps only register and pick.
  • Biophysics.

    • bonds: one KD-tree contact generator for H-bonds, salt bridges and disulfides.
    • prosurf: one coverage helper instead of two copied loops.
    • connolly: removed the unused trim(), _disptl and a neighbour list that was never read; shared probe-torus geometry between its two users.
    • sc, solvation: less bookkeeping.
  • scripts/. Smaller validate_ccp4_biophysics.py parsing, and the PISA session is now erased even if -analyse fails. STANDARD_AA is a single line.

Removed API, all with no callers (noted in CHANGELOG):

  • ParserManager.unregister, enable_only, set_precedence, list_parsers
  • confident_contacts.representative_atom_contact_pairs
  • biophysics.connolly.trim
  • the ignored residue_names argument of connolly.mds

alphajudge.core and alphajudge.biophysics.scoring still import as before.

Follow-up

The problems found during this review are fixed in the stacked draft PR #32. They change results, so they are kept out of this no-output-change PR:

  • solvation energy now matches PISA;
  • Boltz-2 PAE, pLDDT and pair ipTM are aligned to residues by token and chain;
  • report fixes for the PAE lookup, feature count, median and appendix numbering;
  • the ProSurf cache key covers every atom;
  • AF3 model ranking and structure lookup are hardened;
  • the af3.py and test-import leftovers are cleaned up.

🤖 Generated with Claude Code

A pass over the package for dead code, duplicated logic and needless
indirection. Scores, CSVs, report PDFs and PAE PNGs are byte-identical to
the previous commit on every bundled AF2, AF3, AF3x and Boltz-2 run (all
models, per-run and aggregate reports, cache reuse, non-default
thresholds), the raw Connolly dot surfaces are bitwise equal, and the
full test suite passes including the slow CCP4 SC reference checks.

report.py (2031 -> ~1370 lines): drop the page-total/footer plumbing that
nothing read, the never-drawn logo and info icon, an unused row grouper
and slider-marker branch. Repeated axes setup and text boilerplate go
through small _text_axes/_label_axes/_kv_rows helpers.

runner.py: one worker partial serves the serial and process-pool paths,
the cache/recompute branches share the report and aggregation tail, and
each CSV row is built by _interface_row. Unused matplotlib/numpy imports
and a deferred import of an already-imported module are gone.

Interface/Complex: one pair-index generator replaces four copies of the
residue-to-PAE lookup; mpDockQ's global contact count is the sum of the
per-interface counts (the same <= r^2 test Biopython's KD-tree applies)
instead of a second neighbour search; a per-pair atom cache that could
never hit is removed. Interface.label and Complex.chain_boundaries
replace private-attribute access from the runner.

Parsers: magic-byte decompression is shared by JSON and pickle loading,
path lookups share _first_existing, and ParserManager keeps only
register/pick.

Biophysics: bonds.py uses one KD-tree contact generator for H-bonds, salt
bridges and disulfides; prosurf.py computes each side's area through one
coverage helper; connolly.py loses an unused trim(), _disptl and a
never-read neighbour list, and shares the probe-torus geometry between
its two users; sc.py and solvation.py drop redundant bookkeeping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DimaMolod
DimaMolod marked this pull request as ready for review September 28, 2026 12:17
@DimaMolod
DimaMolod merged commit e206c1c into 30-alphajudge-pae-handling-for-af3x-outputs-cross-linker-tokens Sep 28, 2026
12 checks passed
@DimaMolod
DimaMolod deleted the 30-simplify branch September 28, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant