Model
Pydantic models for PubChem assay and compound-property payloads.
DEFAULT_PROPERTIES = ['SMILES', 'XLogP', 'ExactMass', 'MolecularWeight', 'Charge', 'Complexity', 'TPSA', 'InChIKey']
¶
AffinityStrategy
¶
AssayInfo
¶
Bases: BaseModel
A parsed PubChem concise assay record.
active_cids
¶
CIDs marked Active in the assay.
aid
¶
The PubChem Assay ID.
inactive_cids
¶
CIDs marked Inactive in the assay.
model_config = ConfigDict(populate_by_name=True)
¶
pubmed_id
¶
Return the PMID shared by all records, or None if they disagree or none is set. Per-row PMIDs live on record.pubmed_id.
records = Field(default_factory=list)
¶
One record per row of the concise table.
unique_cids
¶
All distinct, non-blank CIDs in the assay (any outcome).
binding_affinity(cids=None, strategy=AffinityStrategy.ALL, outcome=None)
¶
Map CID to a list of (activity_value, activity_name, outcome) entries.
| PARAMETER | DESCRIPTION |
|---|---|
cids
|
Optional iterable of CIDs to keep. If None, all are kept.
TYPE:
|
strategy
|
"all" keeps every value; "min"/"average" collapse to one entry per activity_name using non-None values.
TYPE:
|
outcome
|
Optional filter for activity outcome (e.g. "active"). If None, all outcomes excluding unspecified are kept.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[int, list[tuple[float | None, str, str]]]
|
dict mapping CID to a list of affinity value_or_None, activity_name and outcome tuples |
cids(outcome)
¶
CIDs for an arbitrary outcome (e.g. 'inconclusive', 'probe').
from_concise(aid, data)
¶
Parse a concise assay payload into an AssayInfo.
| PARAMETER | DESCRIPTION |
|---|---|
aid
|
The PubChem Assay ID the payload belongs to.
TYPE:
|
data
|
The raw concise JSON response (already confirmed to be a dict without a Fault by the client).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AssayInfo
|
An AssayInfo. Records/pubmed_id are empty/None if the table is absent. |
to_dataframe(outcome=None)
¶
Return the flattened rows as a pandas DataFrame, optionally filtered.
to_rows(outcome=None)
¶
Flatten to one dict per record. Optionally filter by outcome.
CompoundProperties
¶
Bases: BaseModel
Compound properties for a single CID from the property endpoint.
charge = Field(default=None, alias='Charge')
¶
Net formal charge of the molecule.
complexity = Field(default=None, alias='Complexity')
¶
Bertz/Hendrickson/Ihlenfeldt molecular complexity rating. Smaller values indicate simpler molecules.
exact_mass = Field(default=None, alias='ExactMass')
¶
Mass of the most likely isotopic composition (mass-spec oriented).
inchikey = Field(default='', alias='InChIKey')
¶
Hashed InChI; canonical 27-character compound identifier.
model_config = ConfigDict(populate_by_name=True, extra='allow')
¶
molecular_weight = Field(default=None, alias='MolecularWeight')
¶
A sum of all atomic weights of the atoms in the compound, measured in g/mol.
smiles = Field(default='', alias='SMILES')
¶
SMILES string including stereochemistry and isotopes.
tpsa = Field(default=None, alias='TPSA')
¶
Topological polar surface area.
xlogp = Field(default=None, alias='XLogP')
¶
Computed octanol-water partition coefficient (hydrophobicity).