Catalog pKa parsing edge cases with a comprehensive test suite #11

Open
opened 2026-04-12 16:39:35 -04:00 by aalexmmaldonado · 0 comments
aalexmmaldonado commented 2026-04-12 16:39:35 -04:00 (Migrated from github.com)

The pKa parser in dissociation_constant.py tries three regex patterns in priority order. The code notes several known false positives (e.g., density values, concentrations) and guards against them by requiring a label match. But there's no systematic accounting of which real-world formats succeed, which fail silently, and which produce wrong values.

A comprehensive test matrix does two things. It documents exactly what the parser handles today. And it provides a safety net so future changes don't quietly break formats that used to work.

Scope

Fetch 5–10 pages of real dissociation constant data from PubChem. Inspect the raw StringWithMarkup values by hand and sort them into four categories: parsed correctly, skipped correctly (not a pKa), skipped incorrectly (a valid pKa the regex misses), and parsed incorrectly (extracts the wrong number or label).

Write parametrized tests (@pytest.mark.parametrize) in tests/test_dissociation_constant.py using the actual raw strings from PubChem. Note the CID each string came from. For each false negative, file a sub-issue or add a # TODO describing the unhandled format.

Definition of done

At least 30 parametrized test cases drawn from real PubChem data. A summary table in the PR description listing format categories and counts. All currently-passing cases still pass. False negatives are documented, not necessarily fixed.

The pKa parser in `dissociation_constant.py` tries three regex patterns in priority order. The code notes several known false positives (e.g., density values, concentrations) and guards against them by requiring a label match. But there's no systematic accounting of which real-world formats succeed, which fail silently, and which produce wrong values. A comprehensive test matrix does two things. It documents exactly what the parser handles today. And it provides a safety net so future changes don't quietly break formats that used to work. ### Scope Fetch 5–10 pages of real dissociation constant data from PubChem. Inspect the raw `StringWithMarkup` values by hand and sort them into four categories: parsed correctly, skipped correctly (not a pKa), skipped incorrectly (a valid pKa the regex misses), and parsed incorrectly (extracts the wrong number or label). Write parametrized tests (`@pytest.mark.parametrize`) in `tests/test_dissociation_constant.py` using the actual raw strings from PubChem. Note the CID each string came from. For each false negative, file a sub-issue or add a `# TODO` describing the unhandled format. ### Definition of done At least 30 parametrized test cases drawn from real PubChem data. A summary table in the PR description listing format categories and counts. All currently-passing cases still pass. False negatives are documented, not necessarily fixed.
Sign in to join this conversation.