refactor(clinical_report): clean id signatures - #75
ireneisdoomed wants to merge 6 commits into
Conversation
correspondence to primary source
|
This one would be nice to address for PPP, but it is not crucial |
d0choa
left a comment
There was a problem hiding this comment.
Looked at this closely since it changes public IDs. The hashing approach is right and the rule you've written down is a good one to keep.
The description doesn't match the diff. Fix #1 (adding ' to the regex) isn't here — sanitise_text is untouched — and wouldn't have worked anyway: it's an unescaper (\x → x), so it'd only catch \', not a bare apostrophe. The 27 IDs are still fixed, via SHA-256 on the TTD side. Worth correcting the description.
One ask — make the ChEMBL decision an allowlist (chembl/indications.py:99). The .otherwise keeps the raw ref_id for any ref_type outside ["INN","FDA","USAN"], so a new ChEMBL ref_type would silently pass its raw ID through — the exact failure class this PR closes. Flipping it makes the rule self-enforcing:
id=(
# Meaningful references are kept as-is: they can be looked up in the primary source
pl.when(pl.col("source").is_in(["ClinicalTrials", "DailyMed", "EMA", "ATC"]))
.then(pl.col("id"))
# Anything else is an artificial ID and gets hashed
.otherwise(pl.col("id").chash.sha2_256())
)One question: FDA is hashed, but it sits in APPROVAL_SOURCES alongside ATC/EMA/DailyMed, which you're deliberately not hashing. Is an FDA ref_id not lookup-able the way those are? Not blocking, just couldn't tell if it's intentional.
Last thing — this changes IDs for all TTD and ChEMBL INN/FDA/USAN rows, not just the 27. Worth a line in the PR body since they're API-facing (url is preserved, so provenance survives).
|
Thanks for the comments, @d0choa !
|
Issue
After @remo87 investigation, he observed that the root cause for opentargets/issues#4477 is the fact that some clinical report
ids present unescaped characters that make the API fail. For example,d00ijm/friedreich's ataxiahas the'character unscaped. That means that if you request any drug information where that clinical report is supporting the association, the whole query will fail. There are 27 of such IDsThe fix
clinical_report.sanitise_texthas code to clean unescaped characters from any string columns in the root level. Unfortunately,'wasn't part of the regex. A quick solution to this issue is to include'in the regexThe offending clinical report IDs come from TTD. TTD presents information at the drug level. How we convert this into clinical report evidence is by creating a row for each drug/indication. We literally create the ID by concatenating the drug and the indication. That is how this issue originated.
Because this is an artificial ID that doesn't directly reflect a reference in the primary source, I think this can be improved. We already have examples of hashed IDs.
In practice this has only changed the way we assign IDs for TTD and ChEMBL. But the above rule should be maintained keeping forward.
Let me know what you think