Skip to content
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
79ba771
feat: add delete operation
KristinaKasyanovskaya May 28, 2025
e75e325
Merge remote-tracking branch 'origin' into 7083-delete-operation-on-s…
KristinaKasyanovskaya May 28, 2025
c36d888
fix: fix code
KristinaKasyanovskaya May 28, 2025
aabf11b
fix: prevent bond creation when only one adjacent node exists
KristinaKasyanovskaya May 29, 2025
40b8d41
fix(sequence): properly remove ribose when deleting backbone
KristinaKasyanovskaya May 29, 2025
dfeeaf6
fix: move logic in separate method
KristinaKasyanovskaya May 29, 2025
43c7d96
fix: fix backspace method
KristinaKasyanovskaya May 30, 2025
0ec0a75
fix: fix delete method in keyboard events
KristinaKasyanovskaya May 30, 2025
9b3e4ae
fix: fix orphanPhosphate method
KristinaKasyanovskaya May 30, 2025
5ea21b2
fix: fix orphanPhosphate method
KristinaKasyanovskaya May 30, 2025
9a32746
Revert "fix: fix orphanPhosphate method"
KristinaKasyanovskaya May 30, 2025
b44d20d
fix: fix logic to handle delete method
KristinaKasyanovskaya Jun 1, 2025
021eac4
fix: fix logic to handle delete method
KristinaKasyanovskaya Jun 1, 2025
f4bc0fa
Merge remote-tracking branch 'origin' into 7083-delete-operation-on-s…
KristinaKasyanovskaya Jun 1, 2025
874f87b
fix: fix sequence mode
KristinaKasyanovskaya Jun 1, 2025
54edf5b
feat: add delete operation
KristinaKasyanovskaya Jun 3, 2025
3870ea9
fix(sequence): handle edge-case deletions for antisense monomers
KristinaKasyanovskaya Jun 3, 2025
50678b4
removed an extra check in the code
KristinaKasyanovskaya Jun 3, 2025
a392a62
#7083 Delete operation on Sequence mode causes hanging bonds and unde…
KukushkinDmi1riy Jul 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions packages/ketcher-core/src/application/editor/modes/SequenceMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ export class SequenceMode extends BaseMode {
? potentialNodeAfterSelection.secondConnectedNode
: potentialNodeAfterSelection.firstConnectedNode
: potentialNodeAfterSelection;

const nodeInSameChainBeforeSelection =
(twoStrandedNodeInSameChainBeforeSelection &&
getNodeFromTwoStrandedNode(
Expand All @@ -915,11 +916,6 @@ export class SequenceMode extends BaseMode {
potentialNodeInSameChainAfterSelection instanceof BackBoneSequenceNode
? potentialNodeInSameChainAfterSelection.secondConnectedNode
: potentialNodeInSameChainAfterSelection;
const previouseNodeInBackbone =
strandType === STRAND_TYPE.SENSE
? nodeBeforeSelection
: nodeAfterSelection;

// Сase delete A (for sense) and empty node (for antisense) in sync mode:
// G | A | G
// C | | C
Expand All @@ -941,7 +937,6 @@ export class SequenceMode extends BaseMode {
) {
return;
}

// Сase delete "-":
// G | - | G
// C | | C
Expand All @@ -954,26 +949,35 @@ export class SequenceMode extends BaseMode {
selectionStartNode instanceof BackBoneSequenceNode
? selectionStartNode
: (selectionEndNode as BackBoneSequenceNode);
const polymerBondToDelete =
backBoneSequenceNode.firstConnectedNode.lastMonomerInNode
.attachmentPointsToBonds.R2;

if (!(polymerBondToDelete instanceof PolymerBond)) {
return;
}
const firstConnected = backBoneSequenceNode.firstConnectedNode;
const secondConnected = backBoneSequenceNode.secondConnectedNode;

modelChanges.merge(
editor.drawingEntitiesManager.deletePolymerBond(polymerBondToDelete),
);
let polymerBondToDelete: PolymerBond | undefined;

if (previouseNodeInBackbone instanceof Nucleotide) {
if (
firstConnected instanceof Nucleotide &&
firstConnected.lastMonomerInNode?.attachmentPointsToBonds
?.R2 instanceof PolymerBond
) {
polymerBondToDelete =
firstConnected.lastMonomerInNode.attachmentPointsToBonds.R2;
} else if (
secondConnected instanceof Nucleotide &&
secondConnected.firstMonomerInNode?.attachmentPointsToBonds
?.R1 instanceof PolymerBond
) {
polymerBondToDelete =
secondConnected.firstMonomerInNode.attachmentPointsToBonds.R1;
}

if (polymerBondToDelete) {
modelChanges.merge(
editor.drawingEntitiesManager.deleteMonomer(
previouseNodeInBackbone.lastMonomerInNode,
editor.drawingEntitiesManager.deletePolymerBond(
polymerBondToDelete,
),
);
}

return;
}

Expand Down Expand Up @@ -1048,7 +1052,7 @@ export class SequenceMode extends BaseMode {
),
);
}
} else {
} else if (nodeBeforeSelection && nodeAfterSelection) {
if (
!nodeAfterSelection ||
nodeAfterSelection instanceof EmptySequenceNode
Expand Down Expand Up @@ -1095,7 +1099,7 @@ export class SequenceMode extends BaseMode {
nodeBeforeSelection.firstMonomerInNode,
),
);
} else if (nodeBeforeSelection && nodeAfterSelection) {
} else {
modelChanges.merge(
this.tryToCreatePolymerBond(
isPhosphateAdditionalyDeleted
Expand Down Expand Up @@ -1233,20 +1237,23 @@ export class SequenceMode extends BaseMode {
}
};

const deleteHandler = (direction: Direction) => {
if (this.isEditInRNABuilderMode) return;
if (SequenceRenderer.selections.length > 0) {
this.deleteSelection();
} else {
deleteNode(direction);
}
};

return {
delete: {
shortcut: ['Delete'],
handler: () => {
if (this.isEditInRNABuilderMode) return;
deleteNode(Direction.Right);
},
handler: () => deleteHandler(Direction.Right),
},
backspace: {
shortcut: ['Backspace'],
handler: () => {
if (this.isEditInRNABuilderMode) return;
deleteNode(Direction.Left);
},
handler: () => deleteHandler(Direction.Left),
},
'turn-off-edit-mode': {
shortcut: ['Escape'],
Expand Down
Loading