Source-aware parsing for annotation processors #12

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

Different depositors write the same property differently. ChEBI might format pKa as "pKa = 4.76 at 25 °C" while DrugBank writes "4.76 (Predicted)". The AnnotationEntry carries a SourceName field, but the current parser ignores it and runs every string through the same generic patterns.

Knowing the source means we can apply tighter regex patterns per depositor: more successful parses, fewer false positives.

Scope

Fetch several pages of dissociation constant data, group by SourceName, and document each source's typical string format for the top 5–10 depositors.

Then pick a design. Two options:

Per-source pattern lists. The processor holds a dict[str, list[Pattern]] mapping source names to specialized patterns. Known sources get their patterns tried first; unknown sources fall through to the generic set.

Per-source subclasses. Each major source gets a small subclass overriding parse_value. A factory selects the right one by source name.

Implement the chosen approach to calculate dissociation constants using at least two sources. Add source_name to the output DataFrame. Document the design decision in the PR description.

Definition of done

The source_name column is present in the output. Two source-specific parsing paths implemented and tested. Generic fallback still works for unknown sources.

Different depositors write the same property differently. ChEBI might format pKa as `"pKa = 4.76 at 25 °C"` while DrugBank writes `"4.76 (Predicted)"`. The `AnnotationEntry` carries a `SourceName` field, but the current parser ignores it and runs every string through the same generic patterns. Knowing the source means we can apply tighter regex patterns per depositor: more successful parses, fewer false positives. ### Scope Fetch several pages of dissociation constant data, group by `SourceName`, and document each source's typical string format for the top 5–10 depositors. Then pick a design. Two options: *Per-source pattern lists.* The processor holds a `dict[str, list[Pattern]]` mapping source names to specialized patterns. Known sources get their patterns tried first; unknown sources fall through to the generic set. *Per-source subclasses.* Each major source gets a small subclass overriding `parse_value`. A factory selects the right one by source name. Implement the chosen approach to calculate dissociation constants using at least two sources. Add `source_name` to the output DataFrame. Document the design decision in the PR description. ### Definition of done The `source_name` column is present in the output. Two source-specific parsing paths implemented and tested. Generic fallback still works for unknown sources.
Sign in to join this conversation.