Skip to content

Add sort_reactants option to ReactionEnumerator - #7

Open
mattball30 wants to merge 3 commits into
MolecularAI:mainfrom
mattball30:sort-reactants-option
Open

mattball30 wants to merge 3 commits into
MolecularAI:mainfrom
mattball30:sort-reactants-option

Conversation

@mattball30

Copy link
Copy Markdown

Summary

Adds a sort_reactants argument (default True) to ReactionEnumerator. Currently reactant_a and reactant_b of each ReactionResult are always the two input SMILES in sorted order. With sort_reactants=False, they keep the order of the input pair, so a caller can supply reactants in a deterministic order.

Changes

  • sort_reactants is accepted by enumerate_pair, products_for_pair, enumerate_pairs and enumerate_pairs_lazy.
  • The option is passed through _enumerate_pair_from_mols, _enumerate_pair_from_keys, _process_chunk and the parallel worker functions (_worker_run_pair, _worker_run_pairs_batch), so serial and parallel runs behave the same.
  • Tests for both argument orders across enumerate_pair, enumerate_pairs (serial and parallel) and enumerate_pairs_lazy. The submit spy in an existing test now forwards the extra argument.
  • README example, CHANGELOG entry under [Unreleased], and an AUTHORS.md update.

Compatibility

The default is True, so existing behaviour is unchanged. Products and template order are not affected by this option.

Testing

The full test suite passes (155 tests).

mattball30 and others added 3 commits October 15, 2026 11:01
Lets callers keep the input order of reactants in results instead of
sorting them, so a deterministic reactant order can be passed through.
Defaults to True, so existing behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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