Skip to content

Return exact neutral roots during isoelectric bisection - #224

Merged
levitsky merged 1 commit into
levitsky:masterfrom
antonsoo:fix/exact-isoelectric-root
Oct 26, 2026
Merged

levitsky merged 1 commit into
levitsky:masterfrom
antonsoo:fix/exact-isoelectric-root

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor
from pyteomics.electrochem import pI

print(pI('AAA', pI_range=(2.34, 9.69)))

This returns about 7.8525 before the change, rather than 6.015. Only the terminal groups ionize for this peptide, so the neutral point is the mean of their pKa values.

An exactly zero charge at the midpoint falls into the branch that moves the left endpoint, which loses the root. Return an endpoint or midpoint immediately when its calculated charge is zero. The existing iteration remains the same for nonzero charges. Regression tests cover both endpoints, all three sequence representations, custom pKa values and a terminal override.

Independent analytic and Henderson-Hasselbalch/Brent references on peptides from four UniProt albumin/hemoglobin sequences agree with all 1,710 evaluations after the change, versus 990 before. All 990 previously correct records remain identical. These checks use default and custom pKa values, three pH brackets and all three input representations; the supplied example also fails with the default precision.

Validation uses Python 3.10/NumPy 1.26 and Python 3.12/NumPy 2.5, the project's per-file test commands, and an isolated wheel replay. The separate semi-specific digestion correction composes cleanly and preserves these results.

Each profile completes all 27 CI test files (491 tests, including one live-PostgreSQL service skip). On Python 3.10, ProForma and Unimod exceeded an initial 180-second bound and passed unchanged on targeted retries with a 600-second bound; both attempts are retained.

@levitsky
levitsky merged commit e0033c0 into levitsky:master Oct 26, 2026
15 checks passed
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.

2 participants