Skip to content

Added an option to select models based on a reverse ranking#1623

Merged
amjjbonvin merged 9 commits into
mainfrom
reverse-selection
Jul 16, 2026
Merged

Added an option to select models based on a reverse ranking#1623
amjjbonvin merged 9 commits into
mainfrom
reverse-selection

Conversation

@amjjbonvin

@amjjbonvin amjjbonvin commented Jul 15, 2026

Copy link
Copy Markdown
Member

What does this PR do and why?

Until now the assumptions as that the best models would have the lowest scores, with a default ascending sorting when ranking them. Some scoring function might have a different behaviour (e.g. higher is better).
This PR implements the option to rank/select models in reverse order.
An option was added to both seletop and seletopclust to rank models/clusters in reverse (descending) order meaning in from high to low scores. The default behavior remain unchanged (ascending order, from low to high scores).

Single structure selection

  • Added the sort_ascending parameter: true (default) selects best-scoring clusters first; false reverses the order (highest average score first).

Score-based cluster selection

  • Added the sort_ascending parameter: true (default) selects best-scoring clusters first; false reverses the order (highest average score first). The reverse option applies only to the score-based ranking, not to size-based ordering.
  • rank_clust_order now ranks clusters by their average score (computed over each cluster's best-scoring models via the shared libclust.rank_clusters helper), instead of just sorting the original cluster-rank keys coming from the clustering module.
  • Added cluster_score_threshold (default 4): number of best-scoring models per cluster used to compute the cluster's average score. Replaces a previously hard-coded value.
  • Exported cluster PDB files are now named following the average-score ranking: cluster_1_model_1.pdb corresponds to the best-scoring cluster (in ascending or descending order). The export loop renumbers clt_rank by its position in the computed ranking.

How was this tested?

Tested by running a test workflow from the docking-protein-protein example, adding sort_ascending=false to the seletop, seletopclust and caprieval stages and manually control that the ranking is indeed reverted.

Integration test for seletopclust adapted for the new option and new test added for seletop.
All tests passing.

AI assistance

AI was used to sort out some error in the seletopclust implementation and in updating the tests.

Checklist

  • Tests cover the new and/or changed code
  • Documentation updated if needed (also in the haddock3 user-manual
  • CHANGELOG.md updated for user-facing changes

Related issues

#1620

…nd clusters in reverse order,

meaning in descending order (from high to low scores). The default behavir remain unchanged (ascending order, from low to high scores).

Score-based cluster ranking
- Added the `sort_ascending` parameter: `true` (default) selects best-scoring clusters
  first; `false` reverses the order (highest average score first). The reverse option
  applies **only** to the score-based ranking, not to size-based ordering.
- `rank_clust_order` now ranks clusters by their **average score** (computed over each
  cluster's best-scoring models via the shared `libclust.rank_clusters` helper), instead
  of just sorting the original cluster-rank keys coming from the clustering module.
- Added `cluster_score_threshold` (default 4): number of best-scoring models per cluster
  used to compute the cluster's average score. Replaces a previously hard-coded value.

Output naming
- Exported cluster PDB files are now named following the **average-score ranking**:
  `cluster_1_model_1.pdb` corresponds to the best-scoring cluster (in ascending or descending
  order).  The export loop renumbers `clt_rank` by its position in the computed ranking.

Tests
- Updated `tests/test_module_seletopclusts.py` for the new behavior
@amjjbonvin amjjbonvin self-assigned this Jul 15, 2026
@amjjbonvin amjjbonvin added enhancement Improving something in the codebase m|seletop Select top module m|seletopclusts labels Jul 15, 2026
@amjjbonvin
amjjbonvin requested review from AnnaKravchenko, Comp-era and VGPReys and removed request for VGPReys July 15, 2026 08:20
Comment thread src/haddock/modules/analysis/seletop/defaults.yaml Outdated
Comment thread src/haddock/modules/analysis/seletopclusts/defaults.yaml Outdated
amjjbonvin and others added 2 commits July 15, 2026 11:53
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Comment thread src/haddock/modules/analysis/seletop/__init__.py
Comment thread src/haddock/modules/analysis/seletopclusts/__init__.py Outdated
Comment thread src/haddock/modules/analysis/seletop/defaults.yaml Outdated
Comment thread src/haddock/modules/analysis/seletopclusts/defaults.yaml Outdated
amjjbonvin and others added 4 commits July 15, 2026 15:26
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
Comment thread src/haddock/modules/analysis/seletopclusts/__init__.py
@AnnaKravchenko

Copy link
Copy Markdown
Contributor

If you could add a separate log for when sortby = ‘size’ (I added suggestinos for that) - it would be extremely perfect !

Co-authored-by: Arha <kravchenko.anna.d@gmail.com>
@amjjbonvin
amjjbonvin merged commit 6261eff into main Jul 16, 2026
9 checks passed
@amjjbonvin
amjjbonvin deleted the reverse-selection branch July 16, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving something in the codebase m|seletop Select top module m|seletopclusts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants