Skip to content

Prevent invalid modificationTypes from loading monomers#9071

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-monomer-loading-issue
Draft

Prevent invalid modificationTypes from loading monomers#9071
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-monomer-loading-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

How the feature works? / How did you fix the issue?

Invalid modificationTypes values (empty/formatting/overlong) previously allowed monomers to load into the library, contradicting the expected validation behavior. This change blocks those invalid definitions and logs a clear error, keeping the library clean.

  • Monomer library validation
    • Rejects invalid modificationTypes during updateMonomersLibrary and logs a targeted error message before the monomer is inserted.
  • Unit coverage
    • Adds tests for empty/formatting invalid values and a valid path to ensure acceptance remains correct.

Example validation guard:

const invalidReason = getInvalidModificationTypesReason(
  newMonomer.props?.modificationTypes,
);
if (invalidReason) {
  KetcherLogger.error(
    `Load of "${newMonomer.props.MonomerName}" monomer has failed, ` +
      `monomer definition contains invalid modificationTypes value. ${invalidReason}`,
  );
  return;
}

Screenshot: https://github.com/user-attachments/assets/7c84219d-20b0-46de-9f76-f75aea20bebe

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request
Original prompt

This section details on the original issue you should resolve

<issue_title>System should not load monomer to the library if modificationTypes value contain inproper symbols</issue_title>
<issue_description>Steps to Reproduce

  1. Open Macromolecules - Flex mode (clean canvas)
  2. Go to console and execute following commands:
_Peptide1 with tab in modificationTypes value

await ketcher.updateMonomersLibrary('\n  -INDIGO-10122515372D\n\n  0  0  0  0  0  0  0  0  0  0  0 V3000\nM  V30 BEGIN CTAB\nM  V30 COUNTS 1 0 0 0 0\nM  V30 BEGIN ATOM\nM  V30 1 _Peptide1 11.975 -7.85 0.0 0 CLASS=AA SEQID=1\nM  V30 END ATOM\nM  V30 BEGIN BOND\nM  V30 END BOND\nM  V30 END CTAB\nM  V30 BEGIN TEMPLATE\nM  V30 TEMPLATE 1 AA/_Peptide1/_Peptide1/ NATREPLACE=AA/A\nM  V30 BEGIN CTAB\nM  V30 COUNTS 4 3 3 0 0\nM  V30 BEGIN ATOM\nM  V30 1 C -0.75 0.0 0.0 0\nM  V30 2 C 0.25 0.0 0.0 0\nM  V30 3 H 0.75 0.866 0.0 0\nM  V30 4 H 0.75 -0.866 0.0 0\nM  V30 END ATOM\nM  V30 BEGIN BOND\nM  V30 1 2 1 2\nM  V30 2 1 2 3\nM  V30 3 1 2 4\nM  V30 END BOND\nM  V30 BEGIN SGROUP\nM  V30 1 SUP 1 ATOMS=(1 3) XBONDS=(1 2) BRKXYZ=(9 -0.250000 -0.433000 0.00000-\nM  V30 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLASS-\nM  V30 =LGRP\nM  V30 2 SUP 2 ATOMS=(1 4) XBONDS=(1 3) BRKXYZ=(9 -0.250000 0.433000 0.000000-\nM  V30  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000) LABEL=H CLASS=-\nM  V30 LGRP\nM  V30 3 SUP 3 ATOMS=(2 1 2) XBONDS=(2 2 3) BRKXYZ=(9 0.250000 0.433000 0.000-\nM  V30 000 0.250000 -0.433000 0.000000 0.000000 0.000000 0.000000) LABEL=_Pep-\nM  V30 tide1 CLASS=AA SAP=(3 2 3 Al) SAP=(3 2 4 Br) NATREPLACE=AA/A\nM  V30 END SGROUP\nM  V30 END CTAB\nM  V30 END TEMPLATE\nM  END\n>  <type>\nmonomerTemplate\n\n>  <modificationTypes>\n \t ;\n\n$$$$\n', { format: 'sdf' })

Actual behavior
_Peptide1 amino acid appears in the library
Image

Expected behavior
Monomer doesn't appear at the Library
System throws an error in console: Load of "_Peptide1" monomer has failed, monomer definition contains invalid modificationTypes value. The modificationTypes couldn't be empty

As per requirement:

  • modificationTypes - string, optional. Used for aminoacids modification through the context menu.
    Format: Any symbol except formatting ones, max length 200, spaces allowed
    If value doesn't fit format - throw an error

Environment details:

  • Ketcher Version 3.9.0-rc.1 Build at 2025-10-02; 16:35:40
  • Indigo Version 1.37.0-rc.1.0-gca09660df-wasm32-wasm-clang-19.0.0
  • Chrome Version 141.0.7390.55 (Official Build) (64-bit)
  • Win10

Related issue: epam/Indigo#3161</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with loading monomer in library due to improper symbols Prevent invalid modificationTypes from loading monomers Feb 1, 2026
Copilot AI requested a review from AlexeyGirin February 1, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System should not load monomer to the library if modificationTypes value contain inproper symbols

2 participants