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

Structural distortion occurs during multi expand and multi collapse of macromolecule abbreviations in Micro mode #5670

Open
Zhirnoff opened this issue Oct 7, 2024 · 2 comments · Fixed by #6192
Assignees
Labels
bug Macro-Micro Bucket: Macro-Micro View related issues Priority: High

Comments

@Zhirnoff
Copy link
Collaborator

Zhirnoff commented Oct 7, 2024

Steps to Reproduce

  1. Open file in Macro mode (Flex mode) monomers-cycled.zip
  2. Switch to Micro mode
  3. Select all monomers and expand it

Actual behavior
During the multi expand of macromolecule abbreviations, the resulting structure is severely distorted, with overlapping bonds, misplaced functional groups, and general structural misalignment, as shown in the attached screenshot. This makes the expanded structure unusable and difficult to interpret.
2024-10-07_16h57_22
Same in not cycled chain:
2024-10-07_17h04_56

After multi-collapse, abbreviations do not return to their original places but are crowded together

2024-10-07_17h59_59

Expected behavior
The expanded macromolecules should retain their proper structure and alignment, with all components clearly displayed and positioned correctly.

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 128.0.6613.120 (Official Build) (64-bit)

Ketcher version
[Version 2.26.0-rc.1]
Indigo version
[Version 1.25.0-rc.1]
Bug found during testing: #5400

@Zhirnoff Zhirnoff added bug Priority: High Macro-Micro Bucket: Macro-Micro View related issues labels Oct 7, 2024
@Zhirnoff Zhirnoff added this to the Ketcher 2.26.0-rc.2 milestone Oct 7, 2024
@Zhirnoff Zhirnoff changed the title Structural distortion occurs during multi expand of macromolecule abbreviations in Micro mode Structural distortion occurs during multi expand and multi collapse of macromolecule abbreviations in Micro mode Oct 7, 2024
@rrodionov91 rrodionov91 self-assigned this Nov 12, 2024
@svvald svvald assigned svvald and unassigned rrodionov91 Dec 5, 2024
rrodionov91 added a commit that referenced this issue Dec 5, 2024
…llapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library
svvald pushed a commit that referenced this issue Dec 13, 2024
…llapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library
svvald added a commit that referenced this issue Dec 13, 2024
svvald added a commit that referenced this issue Dec 17, 2024
svvald added a commit that referenced this issue Dec 20, 2024
svvald pushed a commit that referenced this issue Dec 20, 2024
…llapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library
svvald added a commit that referenced this issue Dec 20, 2024
svvald added a commit that referenced this issue Dec 20, 2024
svvald pushed a commit that referenced this issue Dec 24, 2024
…llapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library
svvald added a commit that referenced this issue Dec 24, 2024
svvald added a commit that referenced this issue Dec 24, 2024
svvald added a commit that referenced this issue Dec 24, 2024
svvald pushed a commit that referenced this issue Dec 27, 2024
…llapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library
svvald added a commit that referenced this issue Dec 27, 2024
svvald added a commit that referenced this issue Dec 27, 2024
svvald added a commit that referenced this issue Dec 27, 2024
svvald added a commit that referenced this issue Dec 27, 2024
svvald added a commit that referenced this issue Dec 30, 2024
svvald added a commit that referenced this issue Dec 30, 2024
…lapse of macromolecule abbreviations in micro mode (#6192)

* #5670 - Structural distortion occurs during multi expand and multi collapse of macromolecule abbreviations in Micro mode

- implemented vertical shift for expanding monomers
- fixed U peptide structure in library

* #5670 – Fix vertical/horizontal movement for peptides

* #5670 – Fix collapse for multiple expanded monomers

* #5670 – Something working

* #5670 – Reimplement algorithm for expansion based on "lines" approach

* #5670 – Small fix on lines approach

* #5670 – Update UI tests

* #5670 – Update UI tests

* #5670 – Update UI tests

---------

Co-authored-by: Roman Rodionov <[email protected]>
@Zhirnoff
Copy link
Collaborator Author

Zhirnoff commented Jan 2, 2025

With multi-expand, the appearance has improved, but the structures are still disorganized, and bonds overlap with one another. The collapsing functionality, however, has been fixed—abbreviations now return to their original positions.

2025-01-02_12h27_25.mp4
2025-01-02_12h28_02.mp4

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 131.0.6778.205 (Official Build) (64-bit)

Ketcher version
[Version 3.0.0-rc.1]
Indigo version
[Version 1.28.0-rc.1]

@svvald
Copy link
Collaborator

svvald commented Jan 10, 2025

The refined algorithm for expanding monomers now utilizes the concept of "lines," which is the predominant method for representing monomers in micromolecular mode, particularly for RNA/DNA/Peptide sequences generated in macromolecular mode. The algorithm begins by traversing the monomer graph, starting from a designated monomer marked for expansion, and assesses whether each monomer aligns with the initial monomer. Monomers are considered aligned if their vertical coordinates are either equal to or within a specified delta (0.5 angstroms) of the initial monomer.

If a monomer is aligned with the initial monomer, it is shifted either to the left or right by half the width of the bounding box:
Screenshot 2025-01-10 at 2 06 40 PM
image

If a monomer is not aligned with the initial monomer, it is repositioned above or below it.
Screenshot 2025-01-10 at 2 11 02 PM

The following steps delineate the specifics of the vertical movement:
Identify the largest bounding box among already expanded monomers in the line.
Depending on its size relative to the bounding box of the monomer being expanded:

  • If larger or equal, no vertical movement occurs to prevent creating unnecessary gaps between lines.
image image - If smaller, adjust the vertical movement distance based on the absolute difference in height between the two bounding boxes to fit exactly the new expanded monomer between lines without creating unnecessary space. image image - If no expanded monomers exist in the line, set the vertical movement distance to half the height of the monomer's bounding box to fit the expanded monomer between lines. image image

This method also applies to cyclic chains. Despite their circular structure, monomers can still be categorized by "lines" and manipulated according to the same algorithm as linear structures:
Screenshot 2025-01-10 at 2 23 21 PM
image

For RNA/DNA sequences, this algorithm also accommodates "complementary lines," focusing on bases that are complementary to the sugars. A base is considered part of a "complementary line" if its vertical coordinate differs by a larger delta (2 angstroms) and it is connected only once to a monomer from the "main line":
Screenshot 2025-01-10 at 2 30 17 PM
Complementary line monomers are not moved vertically if its main line monomer is expanded except for the case when monomer is placed directly below the monomer being expanded to avoid overlapping sugar and the base connected to it.
Complementary line monomers are moved horizontally when main line monomers are expanded to ensure the vertical alignment of bases and sugars persists.
image

(Note: This method currently has limitations and may not consistently produce accurate results for RNA/DNA sequences, specifically when applying multiple monomers expansion. Further improvements are necessary to stabilize its performance.)

For multiple monomers expansion the algorithm is applied for each selected monomer one by one.

In addition to expanding monomers, the algorithm is responsible for collapsing them. It uses the inverse of the movement used during expansion, ensuring that monomers revert to their original positions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment