Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6026 - Bond length is different for monomers loaded from HELM and from the library #6152

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.
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.
6 changes: 3 additions & 3 deletions packages/ketcher-core/src/application/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
DrawingEntitiesManager,
MONOMER_START_X_POSITION,
MONOMER_START_Y_POSITION,
SNAKE_LAYOUT_CELL_WIDTH,
CELL_WIDTH,
} from 'domain/entities/DrawingEntitiesManager';
import { PolymerBond } from 'domain/entities/PolymerBond';
import { AttachmentPointName, MonomerItemType } from 'domain/types';
Expand Down Expand Up @@ -800,8 +800,8 @@ export class CoreEditor {
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,
MONOMER_START_X_POSITION - CELL_WIDTH / 4,
MONOMER_START_Y_POSITION - CELL_WIDTH / 4,
false,
);
}
Expand Down
10 changes: 3 additions & 7 deletions packages/ketcher-core/src/application/editor/tools/RnaPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { monomerFactory } from '../operations/monomer/monomerFactory';
import { RNABase } from 'domain/entities/RNABase';
import { Phosphate } from 'domain/entities/Phosphate';
import { Coordinates } from '../shared/coordinates';
import { CELL_WIDTH } from 'domain/entities/DrawingEntitiesManager';

export const RNA_MONOMER_DISTANCE = 22.5;
class RnaPresetTool implements Tool {
rnaBase: MonomerItemType | undefined;
sugar: MonomerItemType | undefined;
Expand Down Expand Up @@ -78,9 +78,7 @@ class RnaPresetTool implements Tool {
phosphatePosition: this.phosphatePreviewRenderer
? Coordinates.canvasToModel(
new Vec2(
this.editor.lastCursorPositionOfCanvas.x +
this.sugarPreviewRenderer?.width +
RNA_MONOMER_DISTANCE,
this.editor.lastCursorPositionOfCanvas.x + CELL_WIDTH,
this.editor.lastCursorPositionOfCanvas.y,
),
)
Expand All @@ -90,9 +88,7 @@ class RnaPresetTool implements Tool {
? Coordinates.canvasToModel(
new Vec2(
this.editor.lastCursorPositionOfCanvas.x,
this.editor.lastCursorPositionOfCanvas.y +
this.sugarPreviewRenderer.height +
RNA_MONOMER_DISTANCE,
this.editor.lastCursorPositionOfCanvas.y + CELL_WIDTH,
),
)
: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ConnectionDirectionInDegrees,
ConnectionDirectionOfLastCell,
} from 'domain/entities/canvas-matrix/Connection';
import { SNAKE_LAYOUT_CELL_WIDTH } from 'domain/entities/DrawingEntitiesManager';
import { CELL_WIDTH } from 'domain/entities/DrawingEntitiesManager';
import { DrawingEntity } from 'domain/entities/DrawingEntity';
import { PolymerBond } from 'domain/entities/PolymerBond';
import { getSugarFromRnaBase } from 'domain/helpers/monomers';
Expand Down Expand Up @@ -171,7 +171,7 @@ export class SnakeModePolymerBondRenderer extends BaseRenderer {
): string {
const sin = Math.sin((direction * Math.PI) / 180);
const cos = Math.cos((direction * Math.PI) / 180);
const xOffset = (SNAKE_LAYOUT_CELL_WIDTH / 2) * cos;
const xOffset = (CELL_WIDTH / 2) * cos;
const yOffset = (CELL_HEIGHT / 2) * sin;
const maxXOffset = cell.connections.reduce(
(max: number, connection: Connection): number => {
Expand Down
34 changes: 14 additions & 20 deletions packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ import { Chain } from 'domain/entities/monomer-chains/Chain';
const VERTICAL_DISTANCE_FROM_ROW_WITHOUT_RNA = 30;
const VERTICAL_OFFSET_FROM_ROW_WITH_RNA = 142;
const DISTANCE_FROM_RIGHT = 55;
export const SNAKE_LAYOUT_CELL_WIDTH = 60;
export const SNAKE_LAYOUT_Y_OFFSET_BETWEEN_CHAINS =
SNAKE_LAYOUT_CELL_WIDTH * 2 + 30;
export const MONOMER_START_X_POSITION = 20 + SNAKE_LAYOUT_CELL_WIDTH / 2;
export const MONOMER_START_Y_POSITION = 20 + SNAKE_LAYOUT_CELL_WIDTH / 2;
export const CELL_WIDTH = 60;
export const SNAKE_LAYOUT_Y_OFFSET_BETWEEN_CHAINS = CELL_WIDTH * 2 + 30;
export const MONOMER_START_X_POSITION = 20 + CELL_WIDTH / 2;
export const MONOMER_START_Y_POSITION = 20 + CELL_WIDTH / 2;

type RnaPresetAdditionParams = {
sugar: MonomerItemType;
Expand Down Expand Up @@ -1246,7 +1245,7 @@ export class DrawingEntitiesManager {
) {
const command = new Command();
const heightMonomerWithBond =
SNAKE_LAYOUT_CELL_WIDTH / 2 + VERTICAL_DISTANCE_FROM_ROW_WITHOUT_RNA;
CELL_WIDTH / 2 + VERTICAL_DISTANCE_FROM_ROW_WITHOUT_RNA;
const isNewRow = lastPosition.x === MONOMER_START_X_POSITION;

maxVerticalDistance =
Expand Down Expand Up @@ -1314,7 +1313,7 @@ export class DrawingEntitiesManager {
const oldSugarPosition = nucleotideOrNucleoside.sugar.position;
const rnaBasePosition = new Vec2(
lastPosition.x,
lastPosition.y + (isAntisense ? -1 : 1) * SNAKE_LAYOUT_CELL_WIDTH,
lastPosition.y + (isAntisense ? -1 : 1) * CELL_WIDTH,
);

if (needRepositionMonomers) {
Expand All @@ -1338,7 +1337,7 @@ export class DrawingEntitiesManager {
if (nucleotideOrNucleoside instanceof Nucleotide) {
nucleotideOrNucleoside.phosphate.isMonomerInRnaChainRow = true;
const phosphatePosition = new Vec2(
lastPosition.x + SNAKE_LAYOUT_CELL_WIDTH,
lastPosition.x + CELL_WIDTH,
lastPosition.y,
);

Expand All @@ -1363,8 +1362,8 @@ export class DrawingEntitiesManager {
maxVerticalDistance,
restOfRowsWithAntisense,
nucleotideOrNucleoside instanceof Nucleotide
? SNAKE_LAYOUT_CELL_WIDTH * 2
: SNAKE_LAYOUT_CELL_WIDTH,
? CELL_WIDTH * 2
: CELL_WIDTH,
);

const nextMonomer = getNextMonomerInChain(
Expand Down Expand Up @@ -1497,9 +1496,7 @@ export class DrawingEntitiesManager {
needRepositionMonomers = true,
) {
const command = new Command();
let lastPosition = startPosition.add(
new Vec2(0, SNAKE_LAYOUT_CELL_WIDTH * 3),
);
let lastPosition = startPosition.add(new Vec2(0, CELL_WIDTH * 3));
let rowsUsedByAntisense = 1;

antisenseChain.forEachNode(({ node }) => {
Expand Down Expand Up @@ -1856,15 +1853,12 @@ export class DrawingEntitiesManager {
lastPosition: Vec2,
height: number,
canvasWidth: number,
width = SNAKE_LAYOUT_CELL_WIDTH,
width = CELL_WIDTH,
restOfRowsWithAntisense: number,
) {
const isMonomerFitCanvas =
lastPosition.x +
width +
DISTANCE_FROM_RIGHT +
SNAKE_LAYOUT_CELL_WIDTH / 2 <
canvasWidth;
const monomerOccupiedWidth =
lastPosition.x + width + DISTANCE_FROM_RIGHT + CELL_WIDTH / 2;
const isMonomerFitCanvas = monomerOccupiedWidth < canvasWidth;

if (!isMonomerFitCanvas) {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/ketcher-core/src/domain/entities/Nucleoside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { Command } from 'domain/entities/Command';
import { getRnaPartLibraryItem } from 'domain/helpers/rna';
import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { AmbiguousMonomer } from 'domain/entities/AmbiguousMonomer';
import { RNA_MONOMER_DISTANCE } from 'application/editor/tools/RnaPreset';
import { SugarRenderer } from 'application/render';
import { RNA_DNA_NON_MODIFIED_PART } from 'domain/constants/monomers';
import { CELL_WIDTH } from './DrawingEntitiesManager';
import { KetMonomerClass } from 'application/formatters';

export class Nucleoside {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class Nucleoside {
const topLeftItemPosition = position;
const bottomItemPosition = position.add(
Coordinates.canvasToModel(
new Vec2(0, RNA_MONOMER_DISTANCE + SugarRenderer.monomerSize.height),
new Vec2(0, CELL_WIDTH + SugarRenderer.monomerSize.height),
),
);
const modelChanges = new Command();
Expand Down
7 changes: 3 additions & 4 deletions packages/ketcher-core/src/domain/entities/Nucleotide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { getRnaPartLibraryItem } from 'domain/helpers/rna';
import { RNA_DNA_NON_MODIFIED_PART } from 'domain/constants/monomers';
import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { AmbiguousMonomer } from 'domain/entities/AmbiguousMonomer';
import { RNA_MONOMER_DISTANCE } from 'application/editor/tools/RnaPreset';
import { SugarRenderer } from 'application/render';
import { SNAKE_LAYOUT_CELL_WIDTH } from 'domain/entities/DrawingEntitiesManager';
import { CELL_WIDTH } from 'domain/entities/DrawingEntitiesManager';
import { KetMonomerClass } from 'application/formatters';

export class Nucleotide {
Expand Down Expand Up @@ -76,7 +75,7 @@ export class Nucleotide {
const topLeftItemPosition = position;
const bottomItemPosition = position.add(
Coordinates.canvasToModel(
new Vec2(0, RNA_MONOMER_DISTANCE + SugarRenderer.monomerSize.height),
new Vec2(0, CELL_WIDTH + SugarRenderer.monomerSize.height),
),
);

Expand All @@ -88,7 +87,7 @@ export class Nucleotide {
rnaBasePosition: bottomItemPosition,
phosphate: phosphateLibraryItem,
phosphatePosition: topLeftItemPosition.add(
Coordinates.canvasToModel(new Vec2(SNAKE_LAYOUT_CELL_WIDTH, 0)),
Coordinates.canvasToModel(new Vec2(CELL_WIDTH, 0)),
),
});

Expand Down
Loading