Skip to content

Commit

Permalink
#6535 - Unable to add nucleoside to the end of sequence if hanging an…
Browse files Browse the repository at this point in the history
…tisense monomer present

- reworked sequence view model to work on same algorithm as snake view model
  • Loading branch information
rrodionov91 committed Feb 21, 2025
1 parent 7460cd4 commit 19f81bf
Show file tree
Hide file tree
Showing 7 changed files with 392 additions and 331 deletions.
21 changes: 13 additions & 8 deletions packages/ketcher-core/src/application/editor/modes/SequenceMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,6 @@ export class SequenceMode extends BaseMode {
const editor = CoreEditor.provideEditorInstance();
const history = new EditorHistory(editor);
const currentTwoStrandedNode = SequenceRenderer.currentEdittingNode;
const currentAntisenseNode = currentTwoStrandedNode?.antisenseNode;
const previousTwoStrandedNode =
(currentTwoStrandedNode &&
SequenceRenderer.getPreviousNode(currentTwoStrandedNode)) ||
Expand All @@ -1167,6 +1166,8 @@ export class SequenceMode extends BaseMode {
currentTwoStrandedNode,
)) ||
undefined;
const previousAntisenseNodeInSameChain =
previousTwoStrandedNodeInSameChain?.antisenseNode;

const insertNewSequenceItemResult = this.insertNewSequenceItem(
editor,
Expand All @@ -1190,12 +1191,13 @@ export class SequenceMode extends BaseMode {
DrawingEntitiesManager.createAntisenseNode(
addedNode,
(addedNode instanceof Nucleotide &&
(currentAntisenseNode instanceof Nucleotide ||
currentAntisenseNode instanceof Nucleoside ||
(currentAntisenseNode instanceof BackBoneSequenceNode &&
(currentAntisenseNode.secondConnectedNode instanceof
(previousAntisenseNodeInSameChain instanceof Nucleotide ||
previousAntisenseNodeInSameChain instanceof Nucleoside ||
(previousAntisenseNodeInSameChain instanceof
BackBoneSequenceNode &&
(previousAntisenseNodeInSameChain.secondConnectedNode instanceof
Nucleotide ||
currentAntisenseNode.secondConnectedNode instanceof
previousAntisenseNodeInSameChain.secondConnectedNode instanceof
Nucleoside)))) ||
(addedNode instanceof Nucleoside &&
!(
Expand Down Expand Up @@ -2228,7 +2230,10 @@ export class SequenceMode extends BaseMode {
currentSenseNode instanceof EmptySequenceNode &&
previousNodeInSameChain
) {
if (!this.isR2Free(previousNodeInSameChain)) {
if (
!previousTwoStrandedNodeInSameChain?.antisenseNode &&
!this.isR2Free(previousNodeInSameChain)
) {
this.showMergeWarningModal();
return;
}
Expand All @@ -2239,7 +2244,7 @@ export class SequenceMode extends BaseMode {
currentSenseNode &&
!(currentSenseNode instanceof EmptySequenceNode)
) {
if (!this.isR1Free(currentSenseNode)) {
if (!currentAntisenseNode && !this.isR1Free(currentSenseNode)) {
this.showMergeWarningModal();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export abstract class BaseSequenceItemRenderer extends BaseSequenceRenderer {
.attr('y', this.node.monomer.monomerItem.isAntisense ? '24' : '-24')
.text(
this.isAntisenseNode && isNumber(antisenseNodeIndex)
? this.currentChainNodesWithoutEmptyNodes.length - antisenseNodeIndex
? antisenseNodeIndex + 1
: senseNodeIndex + 1,
)
.attr('font-family', 'Courier New')
Expand All @@ -205,7 +205,7 @@ export abstract class BaseSequenceItemRenderer extends BaseSequenceRenderer {
!(this.node instanceof BackBoneSequenceNode) &&
(this.isAntisenseNode && isNumber(antisenseNodeIndex)
? (this.monomerIndexInChain + 1) % this.nthSeparationInRow === 1 ||
antisenseNodeIndex === 0
antisenseNodeIndex === this.chain.length - 1
: (this.monomerIndexInChain + 1) % this.nthSeparationInRow === 0 ||
this.isLastMonomerInChain)
);
Expand Down
Loading

0 comments on commit 19f81bf

Please sign in to comment.