epam / epam/ketcher

Support formation of circular structures in flex mode - Main logic

Open
#7,635 0 comments 0 reactions 0 assignees View on GitHub
Flex mode Usability
Dominant language
TypeScript
Stars
884
Forks
262
Avg merge
2d 16h
Merged PRs (30d)
138

Description

Related tickets: https://github.com/epam/ketcher/issues/8363, https://github.com/epam/Indigo/issues/3196

### Background

Currently, when a bond is established between the first and the n-th monomer in a structure of monomers, the structure stays as-is and there is no option for rearranging it into a circular structure. By implementing this feature, the user will be able to select an option for circle formation when selecting whole or partial structure of monomers.

### Requirements

1. When selecting monomers for circular structure formation, the user should be able to select either a whole or a part of a continuous monomer structure with only one closed structure inside of the selection.
1.1. The closed structure must have at least three monomers,
1.2. A closed structure is a collection of monomers where the first has a (ANY) bond with the second, second with the third, ... and the n-th with the first.
1.3. The closed structure must not include small molecules.

2. After selecting the structure, the user should be able to access the 'Create cyclic structure' option when in Flex mode only:
2.1. Via toolbar with a tooltip (see UX),
2.2. On the right click on the selected structure in the context menu or
2.3. By using hotkeys (Windows - `Shift+Alt+c` or Mac - `Shift+Option+c`).

3. One monomer should have its position fixed after layout:
- The top left monomer inside of the selection, if no monomers in the selection have bonds to non-selected monomers or
- The top left monomer inside the selection that has a bond to non-selected monomers.
- The rest of the monomers are arranged as such:
- 𝓷 is the number of monomers;
- 𝓵 is the standard bond length (distance between adjacent monomers), 𝓵=1,5Å;
- φ is the angle between monomers, φ=360°/𝓷;
- σ is the other angle in the monomer-monomer-center tringle, σ=(180°-φ)/2;
- 𝓻 is the radius of the "circle", 𝓻=𝓵*𝓼𝓲𝓷(σ)/𝓼𝓲𝓷(φ).
Image

3.1. The "center" of the n-agon should be positioned to the right of the fixed monomer with the distance of 𝓻.
3.2. All other monomers should be arranged clockwise, with the next being the first monomer in the KET file that is connected to the fixed one, with a distance to the previous monomer of 𝓵 and the distance to the "center" of 𝓻.

Examples - N-agon formation

Example 1:
Select the following group of monomers:
Image
𝓷=12
φ=360°/12=30°
σ=(180°-30°)/2=75°
𝓻=1,5Å*𝓼𝓲𝓷(75°)/𝓼𝓲𝓷(30°)=2,898Å
Image
Image
Image
...
Image
Image
After layout overlayed on before layout:
Image

Example 2:
Select the following group of monomers:
Image
𝓷=5
φ=360°/5=72°
σ=(180°-72°)/2=54°
𝓻=1,5Å*𝓼𝓲𝓷(54°)/𝓼𝓲𝓷(72°)=1,276Å
Image
Image
Image
Image
Image
After layout overlayed on before layout:
Image

4. If a newly formed circular structure is placed outside of the viewport, the canvas should scroll dynamically in appropriate directions, so that it becomes fully visible, there should be a buffer of one standard bond between the structure and the borders of the viewport.
> The dynamic scrolling from autochain an be reused.

5. After the formation of a circular structure, the monomers in the circle and the monomers connected to them that were shifted should all be selected.

### UX

Image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.