Repository navigation
#3666, #3671, #3672, #3695 – Reject an SDF monomer library item with an invalid property - #4030
Open
MysterionRise wants to merge 1 commit into
Open
MysterionRise wants to merge 1 commit into
MysterionRise wants to merge 1 commit into
Conversation
…n invalid property The SDF reader of the monomer library accepted items that #3161 says must be rejected: - an unknown or empty `type` sent the item down the preset path, which loaded its templates as plain monomers (#3695); - a preset without `groupName` or `groupClass` skipped the preset and kept its templates (#3666); - an empty `modificationTypes` was taken as no modification types (#3671); - an `idtAliases` entry without a value was dropped, because the split on '=' drops empty tokens and `base=` comes back as one token (#3672). All four are now checked before anything is added to the library, and the error names the item, in the wording the issues ask for. The whole load fails, as the existing check for a disconnected preset does; Ketcher shows the message as "Monomer item could not be loaded because of an error". tests/formats/molecules/monomer_library/*.sdf new the four issue inputs, the edges of each check, and a valid counterpart of each tests/formats/ref/monomer_library/*.ket new what the valid counterparts load to ref/formats/monomer_library_properties.py.out new the error of each invalid input .memory-bank/features/monomer-library-sdf.md new the properties and their failure contract verified: macOS arm64 (full integration harness, core/api/cpp GTest, python wrapper tests), Jython compile, clang-format 11 / isort / black / pflake8 in the CI tester image. Not run: Windows, Linux, IronPython. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
Generic request
#1234 – issue nameOptional
.memory-bank/features/monomer-library-sdf.mdCloses #3666
Closes #3671
Closes #3672
Closes #3695
What changed
Four issues from the #3161 checklist, all in the SDF reader of the monomer library (
MonomerTemplateLibrary::addMonomersFromMolecule), which accepted items the requirement says must be rejected:typeunknown or emptyType: "wrongTypeHere" is unknown. "_Base1" monomer hasn't been added to the library.groupName(orgroupClass), or with an empty onecontains("groupClass") && contains("groupName")skipped the preset silently and kept its templatesLoad of preset has failed, preset definition contains invalid groupName value. The groupName couldn't be empty(and the same forgroupClass, naming the preset)modificationTypesLoad of "_Peptide1" monomer has failed, monomer definition contains invalid modificationTypes value. The modificationTypes couldn't be emptyidtAliasesentry without a value (base=, orep3with no=)split()drops empty tokens, sobase=comes back as the single tokenbaseand failed thesize() == 2testLoad of "_Nucleotide1" monomer has failed, monomer definition contains invalid idtAliases value. The value of "base" couldn't be emptyThe messages for #3695 and #3671 are the ones the issues give; the other two follow their wording. All checks run before anything is added to the library and outside the
try/catchthat deliberately swallows duplicate templates. As with the existing "has disconnected templates" check, a failed check fails the whole load; Ketcher sends the whole SDF in oneconvertcall and shows the message asMonomer item could not be loaded because of an error: <message>.The four issues are in one PR because they edit the same function and the same test; separate PRs would conflict with each other.
Not in this PR
aliasHELMon nucleotides, CHEMs and presets should be ignored with a warning) — the library load has no way to return a warning.groupClassis not checked againstRNA, and anidtAliaseskey other thanbase/ep5/ep3/internalis still ignored.Compatibility. Every SDF in the repository (234 files) was scanned for a record the new checks reject: none. Ketcher's default library (
api/wasm/indigo-ketcher/test/monomer_library.ket, 855 records, 21 presets) saved as SDF loads back with the checks: the saver writes only the two known types, always writes both group fields, and writesidtAliasesandmodificationTypesonly when they have a value.Tests
New
api/tests/integration/tests/formats/monomer_library_properties.py, with inputs intests/formats/molecules/monomer_library/and references intests/formats/ref/monomer_library/:monomer_library_properties.py.out): the four issue inputs as reported, plus an emptygroupName, a missinggroupClass, an emptytype, one empty entry among valid ones (ep5=5Nuc1;ep3=;internal=iNuc1), and an entry with no=.compare_diffagainst KET): a valid counterpart of each — the No error if preset loaded to the library without <groupName> defined #3666 preset with agroupName,modificationTypesMod Type 1;Mod Type 2;,idtAliasesep5=…,ep3=…,internal=…, and an explicittypemonomerTemplate.The error texts are new, so a Ketcher autotest asserting on them will need them.
🤖 Generated with Claude Code