Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 42a2a6c
Author: Roman Rodionov <[email protected]>
Date:   Thu Dec 12 11:29:11 2024 +0100

    #6109 - Antisense of layout doesn't work on flex mode after load (#6114) (#6138)

    * #6109 - Antisense of layout doesn't work on flex mode after load
    - applied snake layout in flex mode if open/paste file with antisense chain
    - fixed open file implementation

    * #6083 - Creation of antisense chain causes monomer re-arrangement on the flex canvas
    - applied zoom to left top corner of the structures after antisense chains creation
    - updated ketcher version to 2.28.0-rc.2

commit 6c4a38b
Author: Roman Rodionov <[email protected]>
Date:   Thu Dec 12 11:28:28 2024 +0100

    #6107 - Create Antisense Strand doesn't work in some cases (#6116) (#6120)

    - changed implementation of searching first monomers in selection (in this case monomer can be in the middle of the chain and does not have free r1 attachment point)
    - changed antisense base for Adenine

commit c7d3f22
Author: Roman Rodionov <[email protected]>
Date:   Thu Dec 12 11:27:46 2024 +0100

    #5032 - Selection of monomers should disappear when the user moves the cursor (#6136)

commit 8862787
Author: Roman Rodionov <[email protected]>
Date:   Wed Dec 11 23:06:58 2024 +0100

    Backmerge: #5949 - Delete of micromolecules bonds works wrong (or doesn't work) (#6124)

    * #5949 - Delete of micromolecules bonds works wrong (or doesn't work)

    - added invertAfterAllOperations method to atom and bonds operations to allow renderers rely on final state of model before rendering
    - added deleting of atoms and bonds from molecules struct to synchronize molecules and macromolecules modes
    - reworked bonds/atoms deletion logic
    - moved post execution logic from renderer to command

commit dc4cfdc
Author: Igor Kostrubin <[email protected]>
Date:   Wed Dec 11 20:54:17 2024 +0100

    #5796 - Indigo functions doesn't work if monomer on micro canvas - system throws an error: Error: Cannot deserialize input JSON. (#6130)

commit 014472b
Author: Roman Rodionov <[email protected]>
Date:   Wed Dec 11 17:50:13 2024 +0100

    #5317 - Some side chain bonds are not shown in Sequence mode for bases, CHEMs, phosphates and sugars (#6054)

commit b236964
Author: Maksim Labovich <[email protected]>
Date:   Wed Dec 11 18:55:54 2024 +0300

    #5476 - Copy/Cut and Paste using Ctrl+C/X and Ctrl+V doesn't work for static elements in Mozilla Firefox (#6121)

    * #5476 - save to text/plain in KET format instead of RXN

    - Firefox doesn't support MIME types other than text/plain in ClipboardItem, and RXN format saved by default to text/plain supports only chemical elements

    * #5476 - added comment, added stringify for data object to avoid [object Object] in console

commit fa13b99
Author: Roman Rodionov <[email protected]>
Date:   Wed Dec 11 15:48:24 2024 +0100

    #6086 - Unable to create antisense chains for ambiguous monomers from the library (#6113) (#6118)

    - added antisense creation for chains with ambiguous bases

commit 668758d
Author: Roman Rodionov <[email protected]>
Date:   Wed Dec 11 15:34:37 2024 +0100

    #6096 - Antisense creation works wrong in case of partial selection (#6122) (#6123)

    - fixed creation of antisense for partial selection by several pieces in one chain

commit 89f5ce6
Author: Ruslan <[email protected]>
Date:   Wed Dec 11 13:14:21 2024 +0500

    #6127 - Hover mouse over ambiguous monomer on Micromolecules canvas causes app crash (#6128)

commit cca5f90
Author: Anrei Menshikov <[email protected]>
Date:   Wed Dec 11 12:05:35 2024 +0400

    #5978-entire-element-bounding-box-should-be-clickable-not-only-black-dots (#6059)

    * 5978-entire-element-bounding-box-should-be-clickable-not-only-black-dots

    * Refactoring

    * fix test

    * add new metod bondHoverablePath after review

    * createBondHoverablePath new logic

    * add type,const and refctoring createBondHoverablePath

    * commit TODO for mouseEvents

    * add ?? operand

    ---------

    Co-authored-by: Andrey Menshikov <[email protected]>

commit 932ed0f
Author: Roman Rodionov <[email protected]>
Date:   Tue Dec 10 12:49:17 2024 +0100

    Backmerge: #6068 - Same chain configuration imported by different HELM layouted differently (anyway - both are wrong) (#6111)

    * #6068 - Same chain configuration imported by different HELM layouted differently (anyway - both are wrong) (#6099)

    #6074 - System doesn't flip chain if connected to monomer but not to base (2)

    #6068 - Same chain configuration imported by different HELM layouted differently (anyway - both are wrong)

    #6074 - System doesn't flip chain if connected to monomer but not to base (2)

    #6080 - System doesn't flip chain if connected to monomer but not to base (3)

    #6081 - Smaller chain should be at the bottom

    #6087 - Antisense layout is wrong for any ambiguouse base from the library

    #6077 - H-bond is not alligned to Snake mode view in some cases

    #6076 - Two-to-one base H-bond connection layouted wrong

    #6075 - In case of multipal H-bonds system should arrange antisence chain to first base of bottom chain

    #6070 - System doesn't flip chain if connected to monomer but not to base

    #6067 - Two chains connected by H-bond arranged wrong if third bond present on the canvas

    #6061 - RNA chain remain flipped after hydrogen bond removal

    - reworked antisense chains calculation

    * - fixed flacky test
  • Loading branch information
knadonenkoepam committed Dec 12, 2024
1 parent dd20fad commit 7590a7f
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/ketcher-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ketcher-core",
"version": "2.28.0-rc.1",
"version": "2.28.0-rc.2",
"description": "Web-based molecule sketcher",
"license": "Apache-2.0",
"homepage": "http://lifescience.opensource.epam.com/ketcher",
Expand Down
21 changes: 20 additions & 1 deletion packages/ketcher-core/src/application/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ import assert from 'assert';
import { SequenceType, Struct, Vec2 } from 'domain/entities';
import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { Command } from 'domain/entities/Command';
import { DrawingEntitiesManager } from 'domain/entities/DrawingEntitiesManager';
import {
DrawingEntitiesManager,
MONOMER_START_X_POSITION,
MONOMER_START_Y_POSITION,
SNAKE_LAYOUT_CELL_WIDTH,
} from 'domain/entities/DrawingEntitiesManager';
import { PolymerBond } from 'domain/entities/PolymerBond';
import { AttachmentPointName, MonomerItemType } from 'domain/types';
import { DOMSubscription } from 'subscription';
Expand Down Expand Up @@ -416,6 +421,7 @@ export class CoreEditor {

this.renderersContainer.update(modelChanges);
history.update(modelChanges);
this.scrollToTopLeftCorner();
}

private onSelectMonomer(monomer: MonomerItemType) {
Expand Down Expand Up @@ -786,4 +792,17 @@ export class CoreEditor {

ZoomTool.instance.zoomStructureToFitHalfOfCanvas(structureBbox);
}

public scrollToTopLeftCorner() {
const drawnEntitiesBoundingBox =
RenderersManager.getRenderedStructuresBbox();

ZoomTool.instance.scrollTo(
new Vec2(drawnEntitiesBoundingBox.left, drawnEntitiesBoundingBox.top),
false,
MONOMER_START_X_POSITION - SNAKE_LAYOUT_CELL_WIDTH / 4,
MONOMER_START_Y_POSITION - SNAKE_LAYOUT_CELL_WIDTH / 4,
false,
);
}
}
20 changes: 19 additions & 1 deletion packages/ketcher-core/src/application/editor/modes/FlexMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,25 @@ export class FlexMode extends BaseMode {
}

applyAdditionalPasteOperations() {
return new Command();
const command = new Command();
const editor = CoreEditor.provideEditorInstance();

editor.drawingEntitiesManager.recalculateAntisenseChains();

if (!editor.drawingEntitiesManager.hasAntisenseChains) {
return command;
}

command.merge(
editor.drawingEntitiesManager.applySnakeLayout(
editor.canvas.width.baseVal.value,
true,
true,
true,
),
);

return command;
}

isPasteAllowedByMode(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,14 @@ export class SequenceMode extends BaseMode {
shortcut: ['ArrowUp'],
handler: () => {
SequenceRenderer.moveCaretUp();
this.unselectAllEntities();
},
},
'move-caret-down': {
shortcut: ['ArrowDown'],
handler: () => {
SequenceRenderer.moveCaretDown();
this.unselectAllEntities();
},
},
'move-caret-forward': {
Expand All @@ -818,8 +820,10 @@ export class SequenceMode extends BaseMode {
if (!this.isEditMode) {
return;
}

SequenceRenderer.moveCaretForward();
SequenceRenderer.resetLastUserDefinedCaretPosition();
this.unselectAllEntities();
},
},
'move-caret-back': {
Expand All @@ -828,8 +832,11 @@ export class SequenceMode extends BaseMode {
if (!this.isEditMode) {
return;
}

SequenceRenderer.moveCaretBack();
SequenceRenderer.resetLastUserDefinedCaretPosition();

this.unselectAllEntities();
},
},
'add-sequence-item': {
Expand Down
19 changes: 1 addition & 18 deletions packages/ketcher-core/src/application/editor/modes/SnakeMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import { Command } from 'domain/entities/Command';
import { ReinitializeModeOperation } from 'application/editor/operations/modes';
import { Vec2 } from 'domain/entities';
import { RenderersManager } from 'application/render/renderers/RenderersManager';
import {
MONOMER_START_X_POSITION,
MONOMER_START_Y_POSITION,
SNAKE_LAYOUT_CELL_WIDTH,
} from 'domain/entities/DrawingEntitiesManager';

export class SnakeMode extends BaseMode {
constructor(previousMode?: LayoutMode) {
Expand All @@ -33,22 +28,10 @@ export class SnakeMode extends BaseMode {
);

editor.drawingEntitiesManager.applyFlexLayoutMode();

command.merge(modelChanges);
editor.renderersContainer.update(modelChanges);
command.setUndoOperationReverse();

const drawnEntitiesBoundingBox =
RenderersManager.getRenderedStructuresBbox();
const zoom = ZoomTool.instance;

zoom.scrollTo(
new Vec2(drawnEntitiesBoundingBox.left, drawnEntitiesBoundingBox.top),
false,
MONOMER_START_X_POSITION - SNAKE_LAYOUT_CELL_WIDTH / 4,
MONOMER_START_Y_POSITION - SNAKE_LAYOUT_CELL_WIDTH / 4,
false,
);
editor.scrollToTopLeftCorner();

return command;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ export class DrawingEntitiesManager {

private get antisenseChainBasesMap() {
return {
[RnaDnaNaturalAnaloguesEnum.ADENINE]: RnaDnaNaturalAnaloguesEnum.THYMINE,
[RnaDnaNaturalAnaloguesEnum.ADENINE]: RnaDnaNaturalAnaloguesEnum.URACIL,
[RnaDnaNaturalAnaloguesEnum.CYTOSINE]: RnaDnaNaturalAnaloguesEnum.GUANINE,
[RnaDnaNaturalAnaloguesEnum.GUANINE]: RnaDnaNaturalAnaloguesEnum.CYTOSINE,
[RnaDnaNaturalAnaloguesEnum.THYMINE]: RnaDnaNaturalAnaloguesEnum.ADENINE,
Expand Down Expand Up @@ -2824,6 +2824,12 @@ export class DrawingEntitiesManager {
return command;
}

public get hasAntisenseChains() {
return [...this.monomers.values()].some(
(monomer) => monomer.monomerItem.isAntisense,
);
}

private getAntisenseBaseLabel(rnaBase: RNABase | AmbiguousMonomer) {
return this.antisenseChainBasesMap[
rnaBase instanceof AmbiguousMonomer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'domain/entities';
import {
getNextMonomerInChain,
getPreviousMonomerInChain,
getRnaBaseFromSugar,
isMonomerConnectedToR2RnaBase,
isRnaBaseOrAmbiguousRnaBase,
Expand Down Expand Up @@ -128,15 +129,15 @@ export class ChainsCollection {
chainsCollection.add(new Chain(monomer, !!IsChainCycled.CYCLED));
});

if (
firstMonomersInRegularChains.length === 0 &&
firstMonomersInCycledChains.length === 0
) {
const topLeftMonomer = this.getMonomerWithLowerCoordsFromMonomerList(
filteredMonomers.filter((monomer) => !(monomer instanceof RNABase)),
);
const firstMonomersInMiddleOfChains =
this.getFirstMonomersInMiddleOfChains(filteredMonomers);

chainsCollection.add(new Chain(topLeftMonomer));
if (firstMonomersInMiddleOfChains.length) {
firstMonomersInMiddleOfChains.forEach(
(firstMonomerInMiddleOfChain: BaseMonomer) => {
chainsCollection.add(new Chain(firstMonomerInMiddleOfChain));
},
);
}

return chainsCollection;
Expand Down Expand Up @@ -184,6 +185,42 @@ export class ChainsCollection {
return firstMonomersInChains;
}

private static getFirstMonomersInMiddleOfChains(monomers: BaseMonomer[]) {
const initialMonomersSet = new Set(monomers);
const handledMonomers = new Set<BaseMonomer>();
const firstMonomersInMiddleOfChains: BaseMonomer[] = [];

monomers.forEach((monomer) => {
if (handledMonomers.has(monomer)) {
return;
}

handledMonomers.add(monomer);

let previousMonomerInChain = getPreviousMonomerInChain(monomer);

while (
previousMonomerInChain &&
!handledMonomers.has(previousMonomerInChain) &&
!initialMonomersSet.has(previousMonomerInChain)
) {
const previousMonomer = getPreviousMonomerInChain(
previousMonomerInChain,
);

handledMonomers.add(previousMonomerInChain);

if (!previousMonomer) {
firstMonomersInMiddleOfChains.push(previousMonomerInChain);
} else {
previousMonomerInChain = previousMonomer;
}
}
});

return firstMonomersInMiddleOfChains;
}

public get firstNode() {
return this.chains[0]?.subChains[0]?.nodes[0];
}
Expand Down
18 changes: 18 additions & 0 deletions packages/ketcher-core/src/domain/helpers/monomers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ export function isMonomerConnectedToR2RnaBase(monomer?: BaseMonomer) {
);
}

export function getPreviousMonomerInChain(monomer: BaseMonomer) {
const r1PolymerBond = monomer.attachmentPointsToBonds.R1;
const previousMonomer =
r1PolymerBond instanceof PolymerBond
? r1PolymerBond?.getAnotherMonomer(monomer)
: undefined;

if (!previousMonomer || !(r1PolymerBond instanceof PolymerBond)) {
return undefined;
}

return previousMonomer &&
previousMonomer.getAttachmentPointByBond(r1PolymerBond) ===
AttachmentPointName.R2
? previousMonomer
: undefined;
}

export function getNextMonomerInChain(
monomer?: BaseMonomer,
firstMonomer?: BaseMonomer | null,
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-macromolecules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ketcher-macromolecules",
"version": "2.28.0-rc.1",
"version": "2.28.0-rc.2",
"description": "Web-based molecule sketcher",
"license": "Apache-2.0",
"homepage": "http://lifescience.opensource.epam.com/ketcher",
Expand Down
17 changes: 17 additions & 0 deletions packages/ketcher-macromolecules/src/components/modal/Open/Open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
macromoleculesFilesInputFormats,
ModeTypes,
SnakeMode,
FlexMode,
} from 'ketcher-core';
import { IndigoProvider } from 'ketcher-react';
import { RequiredModalProps } from '../modalContainer';
Expand Down Expand Up @@ -175,6 +176,22 @@ const addToCanvas = ({
const editorHistory = new EditorHistory(editor);
const isSequenceMode = editor.mode instanceof SequenceMode;
const isSnakeMode = editor.mode instanceof SnakeMode;
const isFlexMode = editor.mode instanceof FlexMode;

if (isFlexMode) {
editor.drawingEntitiesManager.recalculateAntisenseChains();

if (editor.drawingEntitiesManager.hasAntisenseChains) {
modelChanges.merge(
editor.drawingEntitiesManager.applySnakeLayout(
editor.canvas.width.baseVal.value,
true,
true,
true,
),
);
}
}

editor.renderersContainer.update(modelChanges);
editorHistory.update(modelChanges);
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ketcher-react",
"version": "2.28.0-rc.1",
"version": "2.28.0-rc.2",
"description": "Web-based molecule sketcher",
"license": "Apache-2.0",
"homepage": "http://lifescience.opensource.epam.com/ketcher",
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-standalone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ketcher-standalone",
"version": "2.28.0-rc.1",
"version": "2.28.0-rc.2",
"description": "Web-based molecule sketcher",
"license": "Apache-2.0",
"homepage": "http://lifescience.opensource.epam.com/ketcher",
Expand Down

0 comments on commit 7590a7f

Please sign in to comment.