Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace selected monomer on canvas with monomer from library in sequence mode #4878

Closed
olganaz opened this issue Jun 24, 2024 · 1 comment · Fixed by #5194
Closed

Replace selected monomer on canvas with monomer from library in sequence mode #4878

olganaz opened this issue Jun 24, 2024 · 1 comment · Fixed by #5194
Assignees
Labels
feature request Monomer Library Test Cases Written Test cases has been written for that issue

Comments

@olganaz
Copy link
Collaborator

olganaz commented Jun 24, 2024

Background
Currently library is blocked in sequence mode and it is impossible to add monomers on canvas from library.
Implementing this feature will unlock the library in sequence mode, adding the option for the user to add/replace monomers on the canvas by choosing them from the library.
When in "text-editing" mode the behavior will be similar to text-editors.
While the selection of monomers in "view only" mode gives the user the ability to replace every selected monomer with monomers from the library.

Solution

  • Enable library in sequence mode
  • Allow user to add monomers to the chain directly from the library
  • Allow user to change selected items by click on library item
    In scope of this task monomers are considered to be peptide monomers, sugars, bases, phosphates, chems as well as RNA presets (nucleotides and nucleosides).
    AP - attachment points
    Nucleotide = sugar+base+phosphate (sugar and base are connected through R3-R1 bond, sugar and phosphate are connected through R2-R1 bond). Base is optional monomer.
    Nucleoside = sugar+base connected through R3-R1 bond.
    Attachment points of nucleotide: R1 - sugar's R1, R2 - phosphate's R2.
    Attachment points of nucleoside: R1, R2 - sugar's R1, R2.

Requirements

  1. User should be able to add monomers on canvas from library in sequence mode.
    .
    .
  2. In text-editing mode (cursor is blinking) after user clicks on monomer in library the monomer should be added to the chain where the cursor is located and merged with existed sequence.
    .....2.1 Peptides, nucleotides (RNA presets) and chems should be merged with existed sequence by R2-R1 rule (as for paste) #3916
    .....2.2 If monomer being added lacks AP necessary for establishing connections then error message should be displayed and no monomer is added.
Position where monomer is added AP checks Error message text
Monomer is added to the beginning of the chain Monomer has R2 AP The monomer lacks R2 attachment point and cannot be inserted at current position
Monomer is added in the middle of the chain Monomer has R1 AND R2 The monomer lacks (Ri, i – the number of absent AP) connection point and cannot be inserted at current position
Monomer is added to the end of the chain Monomer has R1 The monomer lacks R1 connection point and cannot be inserted at current position

.....2.3. If the sequence is empty, and the user clicks on the monomer in the library, no checks are performed, and the monomer is added as the only monomer in the sequence (and canvas remains in edit mode).
image
.
.
3. If the user selects any number of monomers in text-editing mode, and clicks on the monomer card in the library, one chosen monomer form the library should replace all the selected monomer(s) on the canvas. (user selects 5 monomers -> user selects A in the library -> 5 monomers get replaced by 1 A) Related issues: #5032 and #5031
.....3.1 R2-R1 bonds should be established automatically if possible (rule 2.2 also applies).
..........3.1.1. If the monomer(s) are unable to be replaced the selected monomer(s) stay selected after the user closes the error message.
.....3.2. If any of the selected symbols is @ (and it represents more that one monomer), modal window with a warning message should appear. Warning message: "Symbol @ can represent multiple monomers, all of them are going to be deleted. Do you want to proceed?".
..........3.2.1. "Yes" option -> selected monomer(s) on canvas are replaced.
..........3.2.2. "Cancel" option -> modal window is closed, monomer(s) on canvas remain selected.
..........3.2.3. "Cancel" option should be default.
.....3.3. If any of the selected monomers have side connections, a modal window with a warning message should appear. Warning message: "Side chain connections will be deleted during replacement. Do you want to proceed?"
..........3.3.1."Yes" option -> selected monomer(s) on canvas are replaced, side chain connections are deleted.
..........3.3.2. "Cancel" option -> modal window is closed, monomer(s) on canvas remain selected.
..........3.3.3. "Cancel" option should be default.
.....3.4. If both 3.2. and 3.3. are true, the first warning message should be the one from 3.2.
.
.
4. If the user selects any number of monomers in view mode, and clicks on the monomer card in the library, all selected monomer on the canvas are replaced by chosen monomer from the library each (user selects 5 monomers -> user selects A in the library -> 5 monomers get replaced by 5 As).
.....4.1. R2-R1 bonds should be established automatically if possible.
..........4.1.1. Checks from requirement 2.2. are performed for every selected position.
...............4.1.1.1. If the checks fail at any position an error message should appear. Error message: "The monomer lacks appropriate attachment points, and cannot be inserted at selected positions."
...............4.1.1.2. If the monomer(s) are unable to be replaced the selected monomer(s) stay selected after the user closes the error message.
.....4.2. If any of the selected symbols is @ (and it represents more that one monomer), modal window with a warning message should appear. Warning message: "Symbol @ can represent multiple monomers, all of them are going to be replaced. Do you want to proceed?".
..........4.2.1. "Yes" option -> all selected monomer(s) on canvas are replaced.
(Images for better understanding)
image
Go to sequence mode, select A and @:
image
Click on C in the library, "Yes" in the modal window:
image
..........4.2.2. "Cancel" option -> modal window is closed, monomer(s) on canvas remain selected.
..........4.2.3. "Cancel" option should be default.
.....4.3. If any of the selected monomers have side connections, and the monomer chosen from the library is not of the same type (types: peptides, chems, sugars, bases, phosphates, presets, nucleotides) as at least one selected monomer with a side connection
or
If the monomer chosen form the library is of the same type, but doesn't have all needed attachment points to establish all side connections (see 4.5. and 4.6.),
a modal window with a warning message should appear. Warning message: "Side chain connections will be deleted during replacement. Do you want to proceed?"
..........4.3.1. "Yes" option -> selected monomer(s) on canvas are replaced, appropriate side chain connections are deleted.
..........4.3.2. "Cancel" option -> modal window is closed, monomer(s) on canvas remain selected.
..........4.3.3. "Cancel" option should be default.
.....4.5. If a peptide, chem, sugar, base, phosphate or a nucleotide is being replaced by a monomer of the same type, a side connection at the attachment point Rn (n>2) is preserved is the monomer chosen from the library also has Rn.
(example: user selected, among others, a Cysteine (peptide) with an R3 side connection to Rm of some other monomer-> user chooses dGlutamine (peptide) from the library -> because dGlutamine has R3, Cysteine is replaced with dGlutamine and a side chain connection is established between R3 of dGlutamine and Rm of that other monomer)
.....4.6. If a preset is being replaced with another preset, side connection is preserved if the new preset has the same Rn at the same element within the preset.
(example 1: selected preset has a side connection form R3 of the phosphate -> user chooses a preset that also has R3 in the phosphate -> old preset is replaced by the new, side chain connection from R3 of phosphate is preserved)
(example 2: selected preset has a side connection from R3 of the phosphate -> user chooses a preset from the library that doesn't have R3 in the phosphate, but does have R3 on the base -> replacement leads to breaking of side chain connection (requirement 4.3.)
.....4.7. If both 4.2. and 4.3. are true, the first warning message should be the one from 4.2.
.
.
5. If the canvas is empty, and the "view only" mode is active, clicking on a monomer is the library adds a monomer as the first (and only) monomer in a first sequence and turns on "text edit mode" placing the caret after the new monomer (similar to requirement 2.3.)
.....5.1. No checks need to be preformed.

@olganaz olganaz added this to the Ketcher 2.24.0-rc.1 milestone Jun 24, 2024
@olganaz olganaz self-assigned this Jun 24, 2024
@olganaz olganaz changed the title Replace selected monomer on canvas with monomer from library (sequence/flex/snake) Replace selected monomer on canvas with monomer from library in sequence mode Jun 27, 2024
@Zhirnoff Zhirnoff added the Test Cases Written Test cases has been written for that issue label Jul 8, 2024
@svvald svvald self-assigned this Jul 16, 2024
@svvald svvald linked a pull request Jul 31, 2024 that will close this issue
9 tasks
svvald added a commit that referenced this issue Aug 2, 2024
rrodionov91 added a commit that referenced this issue Aug 3, 2024
…in sequence mode

- added ketcher-standalone builds for indigo without render module
- added structService reinitialization
rrodionov91 added a commit that referenced this issue Aug 3, 2024
…in sequence mode

- added ketcher-standalone builds for indigo without render module
- added structService reinitialization
svvald added a commit that referenced this issue Aug 5, 2024
rrodionov91 pushed a commit that referenced this issue Aug 5, 2024
rrodionov91 pushed a commit that referenced this issue Aug 5, 2024
svvald added a commit that referenced this issue Aug 5, 2024
rrodionov91 added a commit that referenced this issue Aug 6, 2024
- unlocked monomers library for sequence mode
- implemented monomer/rna replacing by selecting in sequence mode and clicking by item in library

---------

Co-authored-by: Roman Rodionov <roman_rodionov@epam.com>
@AlexeyGirin
Copy link
Collaborator

AlexeyGirin commented Aug 9, 2024

Verified.

  • Ketcher Version 2.24.0-rc.1 Build at 2024-08-06; 19:17:47
  • Indigo Toolkit Version 1.23.0-rc.1.0-g85f89b8f5-wasm32-wasm-clang-19.0.0
  • Windows 10 Pro
  • Chrome Version 127.0.6533.100 (Official Build) (64-bit)

@github-project-automation github-project-automation bot moved this to Done in Ketcher Aug 27, 2024
Guch1g0v pushed a commit that referenced this issue Oct 17, 2024
- unlocked monomers library for sequence mode
- implemented monomer/rna replacing by selecting in sequence mode and clicking by item in library

---------

Co-authored-by: Roman Rodionov <roman_rodionov@epam.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Monomer Library Test Cases Written Test cases has been written for that issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants