Skip to content

Commit

Permalink
- backmerge #4399 - Different chains shown by the same sequence in se…
Browse files Browse the repository at this point in the history
…quence mode (system ignores sugar presence)
  • Loading branch information
baranovdv authored and rrodionov91 committed May 29, 2024
1 parent 1e7c398 commit 4263cd4
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 35 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Nucleoside, Phosphate } from 'domain/entities';
import { getNextMonomerInChain } from 'domain/helpers/monomers';
import { RNASequenceItemRenderer } from './RNASequenceItemRenderer';
import { D3SvgElementSelection } from 'application/render/types';

export class NucleosideSequenceItemRenderer extends RNASequenceItemRenderer {
private nucleosideCircleElement?: D3SvgElementSelection<
SVGCircleElement,
void
>;

protected drawModification() {
const node = this.node as Nucleoside;
const nextNode = getNextMonomerInChain(node.sugar);

this.drawCommonModification(node);

if (this.nucleosideCircleElement) {
this.nucleosideCircleElement.remove();
}

// show modification for not last Nucleoside
if (nextNode && !(nextNode instanceof Phosphate)) {
this.nucleosideCircleElement = this.rootElement
?.append('circle')
.attr('r', '3px')
.attr(
'stroke',
this.isSequenceEditInRnaBuilderModeTurnedOn ? '#24545A' : '#585858',
)
.attr('stroke-width', '1px')
.attr('fill', 'none')
.attr('cx', '10')
.attr('cy', '-16');
}
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,23 @@
import { BaseSequenceItemRenderer } from 'application/render/renderers/sequence/BaseSequenceItemRenderer';
import { Nucleotide } from 'domain/entities';
import { D3SvgElementSelection } from 'application/render/types';

export class NucleotideSequenceItemRenderer extends BaseSequenceItemRenderer {
import { RNASequenceItemRenderer } from './RNASequenceItemRenderer';

export class NucleotideSequenceItemRenderer extends RNASequenceItemRenderer {
private phosphateModificationCircleElement?: D3SvgElementSelection<
SVGCircleElement,
void
>;

get symbolToDisplay(): string {
return (
this.node.monomer.attachmentPointsToBonds.R3?.getAnotherMonomer(
this.node.monomer,
)?.monomerItem?.props.MonomerNaturalAnalogCode || '@'
);
}

protected drawModification() {
drawModification() {
const node = this.node as Nucleotide;

this.drawCommonModification(node);

if (this.phosphateModificationCircleElement) {
this.phosphateModificationCircleElement.remove();
}

if (node.rnaBase.isModification) {
this.backgroundElement?.attr(
'fill',
this.node.monomer.selected
? this.isSequenceEditInRnaBuilderModeTurnedOn
? '#41A8B2'
: '#3ACA6A'
: this.isSequenceEditModeTurnedOn
? '#ff7a004f'
: '#CAD3DD',
);
}

if (node.sugar.isModification) {
this.backgroundElement
?.attr(
'stroke',
this.isSequenceEditInRnaBuilderModeTurnedOn ? '#24545A' : '#585858',
)
.attr('stroke-width', '1px');
}

if (node.phosphate?.isModification) {
this.phosphateModificationCircleElement = this.rootElement
?.append('circle')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { BaseSequenceItemRenderer } from 'application/render/renderers/sequence/BaseSequenceItemRenderer';
import { Nucleoside, Nucleotide } from 'domain/entities';

export abstract class RNASequenceItemRenderer extends BaseSequenceItemRenderer {
get symbolToDisplay(): string {
return (
this.node.monomer.attachmentPointsToBonds.R3?.getAnotherMonomer(
this.node.monomer,
)?.monomerItem?.props.MonomerNaturalAnalogCode || '@'
);
}

protected drawCommonModification(node: Nucleoside | Nucleotide) {
if (node.rnaBase.isModification) {
this.backgroundElement?.attr(
'fill',
this.node.monomer.selected
? this.isSequenceEditInRnaBuilderModeTurnedOn
? '#41A8B2'
: '#3ACA6A'
: this.isSequenceEditModeTurnedOn
? '#ff7a004f'
: '#CAD3DD',
);
}

if (node.sugar.isModification) {
this.backgroundElement
?.attr(
'stroke',
this.isSequenceEditInRnaBuilderModeTurnedOn ? '#24545A' : '#585858',
)
.attr('stroke-width', '1px');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EmptySequenceItemRenderer } from 'application/render/renderers/sequence
import { BaseMonomerRenderer } from 'application/render';
import { BaseSequenceItemRenderer } from 'application/render/renderers/sequence/BaseSequenceItemRenderer';
import { LinkerSequenceNode } from 'domain/entities/LinkerSequenceNode';
import { NucleosideSequenceItemRenderer } from './NucleosideSequenceItemRenderer';

export class SequenceNodeRendererFactory {
static fromNode(
Expand All @@ -30,7 +31,7 @@ export class SequenceNodeRendererFactory {
RendererClass = NucleotideSequenceItemRenderer;
break;
case Nucleoside:
RendererClass = NucleotideSequenceItemRenderer;
RendererClass = NucleosideSequenceItemRenderer;
break;
case EmptySequenceNode:
RendererClass = EmptySequenceItemRenderer;
Expand Down
9 changes: 8 additions & 1 deletion packages/ketcher-core/src/domain/entities/Nucleoside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RNABase } from 'domain/entities/RNABase';
import { Sugar } from 'domain/entities/Sugar';
import assert from 'assert';
import {
getNextMonomerInChain,
getRnaBaseFromSugar,
isValidNucleoside,
isValidNucleotide,
Expand Down Expand Up @@ -97,6 +98,12 @@ export class Nucleoside {
}

public get modified() {
return this.rnaBase.isModification || this.sugar.isModification;
// TODO move isNotLastNode to separate getter because it is not modification
// It was added here because it needs to show similar icon as for phosphates modifications
const isNotLastNode = !!getNextMonomerInChain(this.sugar);

return (
this.rnaBase.isModification || this.sugar.isModification || isNotLastNode
);
}
}

0 comments on commit 4263cd4

Please sign in to comment.