Repository navigation
feat(dsstox): add ignore_case, fields and best_match options to dss_resolve() - #400
Merged
Merged
Conversation
- ignore_case = TRUE matches preferred names, IUPAC names and synonyms without regard to case. Synonyms use the stored ident_upper rows; the two name fields are folded at query time with DuckDB upper(). CAS numbers, formulas, InChIKeys, SMILES and DTXSIDs stay exact. - fields limits which fields may match, so a name lookup can leave out formulas and SMILES. - Defaults return the same rows and columns as before.
Contributor
📊 Test Coverage ReportCurrent Coverage: 90.97%
Note: Coverage is informational only and does not block merges. The 75% target is a guideline. View detailed coverage reportRun Coverage excludes: R/data.R (documentation-only file) |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
One row per input and DTXSID, keeping the first matching field in the build's sort order. Defaults unchanged. Also corrects the file-header comment on SQL interpolation.
Contributor
📊 Test Coverage ReportCurrent Coverage: 90.97%
Note: Coverage is informational only and does not block merges. The 75% target is a guideline. View detailed coverage reportRun Coverage excludes: R/data.R (documentation-only file) |
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.
What
dss_resolve()gains three options. The defaults return the same rows and columns as before.ignore_case = TRUEmatches preferred names, IUPAC names and synonyms without regard to case.ident_upperrows. Preferred and IUPAC names have no upper-cased copy, so those two fields (2.5M of 15.3M rows) are folded at query time with DuckDBupper(), the same function that builtident_upper. No rebuild is needed.matched_on = "IDENTIFIER"in this mode, never"ident_upper".c/C) and formulas (Co/CO).fieldslimits which fields may match (anymatched_onvalue). An input that matches only other fields comes back as the usualNArow. Withignore_case = TRUE,"ident_upper"means"IDENTIFIER".best_match = TRUEreturns one row per input and DTXSID when an input matches the same substance under several fields. It keeps the first field in the build's sort order: DTXSID, preferred name, CAS number, formula, InChIKey, IUPAC name, SMILES, upper-cased synonym, synonym.fieldsis applied first. An input that matches several substances still returns one row for each.The file-header comment on SQL interpolation is also corrected: field names are interpolated, after an allowlist check.
Not in this PR: synonym quality in the build
The build source has no synonym quality or type field, so nothing was added to
data-raw/dsstox.Rand no rebuild was run.DSSTox_CCD_dump_12092025_CSVs.zip(Clowder69529775e4b0731a616efc4b, the latest DSSTox zip on Clowder) has 13 columns:DTXSID, PREFERRED_NAME, CASRN, DTXCID, INCHIKEY, IUPAC_NAME, SMILES, MOLECULAR_FORMULA, AVERAGE_MASS, MONOISOTOPIC_MASS, QSAR_READY_SMILES, MS_READY_SMILES, IDENTIFIER.IDENTIFIERis one|-separated string of synonyms with no label per synonym.POST chemical/synonym/search/by-dtxsid/groups synonyms as valid / good / other / beilstein / alternate / pcCode / deleted. Per the probe in DSSTox: decide synonym source now that the export has no IDENTIFIER column #349 it returns records for about 32% of DTXSIDs.DSSTox_Synonyms.csv(April 2023,643d71e1e4b08a6b393ff1b7) has aSynonym Typecolumn parallel toSynonyms. It has two values only:Expert Validated Synonym(170,462 rows) andSynonym(415,962). 170,054 of its 1,210,230 substances have any synonyms. Joined to the installed build it would label 580,641 of 3,964,504IDENTIFIERrows (14.6%), on 169,627 of 1,246,396 substances.Checks
con =, no network) cover the unchanged default,ignore_case,fields,best_match, combinations and bad arguments.best_matchon the installed build, 4,997 names, in four modes (default,ignore_case,ignore_case+ name fields, default + name fields): one row per input and DTXSID, the same input/DTXSID pairs as without it, and the same field as a best-field pick computed separately in R. Rows drop from 9,398 to 5,034 (default) and from 9,081 to 5,043 (ignore_case).NOT_CRAN=trueagainst the installed build: 19 tests, 57 expectations, 0 fail, 0 skip.best_matchwas added; not re-run after): 11,514 pass, 0 fail, 3 skip, and 1 file-level error intest-generate_tests_pipeline.R. That file skips cleanly when run alone ("{specmill} is not installed" in this machine's default library) and does not touch this code.ignore_case = TRUEignore_case = TRUE+ name fieldsbest_matchignore_case+ name fields +best_matchThe table has no indexes, so every call is already a scan plus hash join.
ignore_caseadds two scans; its time is flat in the number of inputs (0.99 s for 50 names, 1.60 s for 50,000; default 0.45 s and 0.71 s).