fix(data): recover 524 silently-unnamed molecules; prefer flavorist names - #255
Merged
Merged
Conversation
β¦ames
Three naming defects, found by auditing what the grid and cards actually render.
1. NaN IS TRUTHY. `pr.get("common_name") or pr.get("iupac_name")` returns NaN whenever
the common name is missing, so it never fell through to the IUPAC name β leaving
~500 molecules with no name at all even though a perfectly good one sat in the
table. They rendered as raw SMILES. Replaced with an explicit _pick_name() that
type-checks each candidate, with a comment explaining why the idiomatic `or` is
wrong here so nobody "simplifies" it back.
2. CURATED NAMES LOST TO SYSTEMATIC ONES. PubChem's "common_name" is frequently
systematic β spilanthol's is "N-(2-Methylpropyl)-2,6,8-decatrienamide" β so our
hand-picked flavorist names were being overridden by worse ones. Curated names
(flavors + aroma/mouthfeel supplements, 836 of them) now take precedence: those
were chosen deliberately as what a flavorist calls the molecule. spilanthol now
reads "spilanthol".
3. CAS-INVERTED NAMES READ BACKWARDS. "Carvone, (+-)-", "Cyclohexanol, 5-methyl-2-
(1-methylethenyl)-" β an ordering that exists for alphabetised print indexes.
_uninvert_cas() handles the three cases separately (stereo descriptor -> prefix
keeping the parent's case; derivative word -> suffix; substituent -> prefix with
the parent lowercased) and returns anything it doesn't recognise untouched, since
a wrong "fix" is worse than none. 124 -> 16.
Net: 7,559 -> 8,083 named of 8,853. The remaining 770 genuinely have no name in any
source we hold and need the PubChem crawl (#209).
Part of #217.
Signed-off-by: Austin L. <86896075+rvnminers-A-and-N@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #217. Three naming defects, found by auditing what the grid and cards actually render rather than by reading the code.
1.
NaNis truthy.pr.get("common_name") or pr.get("iupac_name")returns NaN whenever the common name is missing, so it never fell through to the IUPAC name β leaving ~500 molecules unnamed even though a perfectly good name sat in the table. They rendered as raw SMILES in the grid and on cards. Replaced with an explicit_pick_name()that type-checks each candidate, carrying a comment on why the idiomaticoris wrong here so nobody "simplifies" it back.2. Curated names were losing to systematic ones. PubChem's
common_nameis frequently systematic β spilanthol's isN-(2-Methylpropyl)-2,6,8-decatrienamideβ so our hand-picked flavorist names were being overridden by worse ones. The 836 curated names (flavors + aroma/mouthfeel supplements) now take precedence: they were chosen deliberately as what a flavorist calls the molecule. spilanthol now reads "spilanthol".3. CAS-inverted names read backwards.
Carvone, (+-)-Β·Cyclohexanol, 5-methyl-2-(1-methylethenyl)-β an ordering that exists for alphabetised print indexes and reads backwards to everyone else._uninvert_cas()handles the three cases separately, because they resolve differently:Carvone, (+-)-(+-)-Carvone(stereo prefix, parent keeps its case)Linalool, oxideLinalool oxide(derivative suffix)2-Hexen-1-ol, 1-acetate2-Hexen-1-ol 1-acetate(ester suffix, not a locant prefix)Cyclohexanol, 5-methyl-β¦5-methyl-β¦-cyclohexanol(substituent prefix)Anything it doesn't recognise is returned untouched β a wrong "fix" is worse than none. 124 β 16. Verified
Vanillin,Methyl Methacrylateand1,6-Dihydrocarvonepass through unchanged.Net: 7,559 β 8,083 named of 8,853. The remaining 770 genuinely have no name in any source we hold and need the PubChem crawl (#209), so #217 stays open.
ruff check .clean and 30 unit tests pass.