Support LogP (experimental only) #3
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right now, pcdigitizer parses exactly one annotation heading: Dissociation Constants. The architecture is ready for more. You add a member to the
Annotationenum, write a processor class that satisfiesAnnotationProcessor, and register it. That's the pattern.LogP, the octanol–water partition coefficient, is a natural second heading to support. It's one of the most used molecular descriptors in drug design and environmental chemistry, and PubChem stores it under the
"LogP"heading via PUG-View.But there's a catch. PubChem has experimental LogP values for roughly 26,000 compounds and computed LogP values (XLogP3, ALOGPS, CLogP, and others) for over 90 million compounds. These cannot be mixed. Computed values are predictions from earlier models; training on them is circular. This processor must output only experimentally measured values.
Each
AnnotationEntryincludes aSourceNamefield that indicates who deposited the data. That's the most reliable filter. Experimental sources (e.g., HSDB, DrugBank, ILO-ICSC, HMDB, ChEBI) deposit measured partition coefficients, usually with a literature citation. HSDB entries look like"log Kow = 1.19"and cite Hansch/Leo. DrugBank and ILO-ICSC deposit bare floats like"1.19". Computed sources deposit predicted values and often name the method:"XLogP3 = 1.2","ALOGPS logP = 2.34". Filter onSourceName, not on the free-text string.Scope
Add
LOGP = "LogP"to theAnnotationenum. Createpcdigitizer/data/logp.pywith aLogPDataclass whosefrom_pagereturns a DataFrame with these columns:cid,sid,pclid,source_name(String),logp_value(Float64),temperature_C(Float64, nullable),reference(String, nullable),comment(String, nullable).Maintain an explicit set of known experimental source names and skip everything else with a
logger.debugmessage. Err on the side of exclusion; sources can be added later after manual review. As a secondary guard, skip entries whose string contains"XLogP","ALOGPS","Estimated","Predicted", or"calc"— some experimental sources occasionally include computed values too.Common experimental formats to parse:
Register
LogPDatainregistry.py. Export it frompcdigitizer/data/__init__.py. Write tests intests/test_logp.pycovering bare numerics,log Kow =format, values with temperature, computed-source filtering, junk strings, and the empty-input case.The
referencecolumn matters for downstream confidence scoring. An experimental value citing Hansch & Leo is more trustworthy than a bare float with no citation.Definition of done
GetAnnotationPage().do(item=1, annotation=Annotation.LOGP)returns a DataFrame containing only experimental values. The PR description includes a table of discoveredSourceNamevalues classified as experimental, computed, or ambiguous, with example strings from each. Tests pass. Docstrings follow the style indissociation_constant.py.Getting started
Read
dissociation_constant.pyend to end; it's the template for every new processor. Then look at howAnnotationandANNOTATION_REGISTRYconnect inannotations.pyandregistry.py.Your first task is not to write a parser. Write a scratch script that fetches two or three pages of LogP data, groups entries by
SourceName, and prints each source's name, entry count, and three exampleStringWithMarkupvalues. That table tells you which sources are experimental and what formats to expect.