Skip to content

Fixed Foldseek similarities, 2D split ratios, and cluster stratification - #36

Open
weitse-hsu wants to merge 6 commits into
kalininalab:mainfrom
weitse-hsu:bugfixes
Open

weitse-hsu wants to merge 6 commits into
kalininalab:mainfrom
weitse-hsu:bugfixes

Conversation

@weitse-hsu

Copy link
Copy Markdown

This PR corrects Foldseek similarity calculations, repeated ratio conversion in C2/I2, and incorrect class counts passed to the solver after clustering or overflow splitting. It includes regression tests for each fix.

Foldseek similarities

Foldseek labels such as protein.pdb_A were not mapped consistently to entity names, so matrix construction could miss the aggregated chain scores. The matrix loop also counted columns from zero when iterating over a sliced name list, placing scores in the wrong cells and sometimes overwriting the diagonal.

The fixes make identifier handling consistent and start the column index at i + 1, while preserving the existing chain-selection and scoring rules. In the multichain regression fixture, the expected similarity is 0.51; upstream returns 0.10, and the patched version returns 0.51.

See 5dc67a5, d7b6405, and 37ca771.

C2/I2 split ratios

Overflow preprocessing already converts requested ratios into per-axis targets, but the solvers converted them again. For an 8:1:1 request, this changed the weight targets from approximately 58.6/20.7/20.7% to 45.7/27.2/27.2%.

The solvers now use the targets returned by preprocessing for both weight and stratification constraints. Public arguments are unchanged, but direct callers of the internal C2/I2 solvers must pass already-converted, overflow-adjusted targets. These are per-axis targets, not a guarantee of exact proportions among retained interactions.

See 9d16024.

Cluster stratification

C2 passed entity-level interaction counts to the solver instead of cluster totals. For example, a cluster with counts [3,1] could receive its representative entity’s [1,1].

Overflow splitting also left class counts attached to old cluster memberships. This could preserve the overall totals while assigning counts to the wrong clusters. The patch passes cluster totals to C2 and rebuilds both entity- and interaction-class counts after splitting.

See 870abd3 and 37ca771.

Tests

All 70 focused regression cases pass; the same tests on upstream produce 59 failures and 11 passes. Validation includes native SCIP cases and real Foldseek runs checked against independently calculated similarities. Broader comparisons found no new failures in existing tests.

I could not complete full-suite collection because of missing pytest_cases and a pre-existing syntax error in test_stratification.py. Separate overflow defects and memory/scalability work are outside this PR.

@Old-Shatterhand Old-Shatterhand self-assigned this Nov 18, 2026
@Old-Shatterhand Old-Shatterhand added the bug Something isn't working label Nov 18, 2026
@weitse-hsu

Copy link
Copy Markdown
Author

Hi @Old-Shatterhand, thanks for approving the CI runs. I’ve pushed 65ce26a to fix the pre-existing test collection issues. Running the suite also exposed a Foldseek identifier-handling regression introduced by this PR, which I’ve corrected in the same commit. Both CI commands now pass locally.

Please let me know if there’s anything you’d like clarified or adjusted. Thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants