Skip to content

Commit

Permalink
epam#6096 - Antisense creation works wrong in case of partial selecti…
Browse files Browse the repository at this point in the history
…on (epam#6122) (epam#6123)

- fixed creation of antisense for partial selection by several pieces in one chain
  • Loading branch information
rrodionov91 authored Dec 11, 2024
1 parent 89f5ce6 commit 668758d
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
RNABase,
SGroupForest,
Struct,
SubChainNode,
Sugar,
} from 'domain/entities';
import {
Expand Down Expand Up @@ -2800,12 +2801,45 @@ export class DrawingEntitiesManager {
);
},
);
const selectedPiecesInChains: SubChainNode[][] = [];

chainsForAntisenseCreation.forEach((chain) => {
let selectedPiece: SubChainNode[] = [];
let hasRnaInPiece = false;

chain.nodes.forEach((node) => {
const hasSelectedMonomerInNode = node.monomers.some(
(monomer) => monomer.selected,
);

if (!hasSelectedMonomerInNode) {
if (hasRnaInPiece) {
selectedPiecesInChains.push(selectedPiece);
}
selectedPiece = [];
hasRnaInPiece = false;
} else {
selectedPiece.push(node);
}

if (node instanceof Nucleoside || node instanceof Nucleotide) {
hasRnaInPiece = true;
}
});

if (hasRnaInPiece) {
selectedPiecesInChains.push(selectedPiece);
}

selectedPiece = [];
hasRnaInPiece = false;
});

let lastAddedNode;
let lastAddedMonomer;

chainsForAntisenseCreation.forEach((chain) => {
chain.forEachNode(({ node }) => {
selectedPiecesInChains.forEach((selectedPiece) => {
selectedPiece.forEach((node) => {
if (!node.monomer.selected) {
lastAddedMonomer = undefined;
lastAddedNode = undefined;
Expand Down

0 comments on commit 668758d

Please sign in to comment.