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

#4880 – Adjust previews – add APs, show IDT aliases for previews in sequence mode, increase debounce time #5160

Merged
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
Expand Up @@ -39,6 +39,7 @@ import {
toggleNucleotidesAccordion,
togglePhosphatesAccordion,
} from '@utils/macromolecules/rnaBuilder';
import { clickOnSequenceSymbol } from '@utils/macromolecules/sequence';

async function pasteFromClipboardAndAddToMacromoleculesCanvas(
page: Page,
Expand Down Expand Up @@ -392,7 +393,7 @@ test.describe('Import-Saving .idt Files', () => {
`A*C*G*C*G*C*G*A*C*T*A*T*A*C*G*C*G*C*C*T`,
);
await selectSequenceLayoutModeTool(page);
await page.getByText('G').locator('..').first().click({ button: 'right' });
await clickOnSequenceSymbol(page, 'G', { button: 'right' });
await page.getByTestId('edit_sequence').click();
await enterSequence(page, 'ttt');
await page.keyboard.press('Escape');
Expand Down
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.
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
Expand Up @@ -6,6 +6,7 @@ import {
selectSingleBondTool,
waitForPageInit,
takeEditorScreenshot,
moveMouseAway,
} from '@utils';
import { turnOnMacromoleculesEditor } from '@utils/macromolecules';
import { bondTwoMonomers } from '@utils/macromolecules/polymerBond';
Expand Down Expand Up @@ -71,6 +72,7 @@ test.describe('Check attachment point rotation', () => {
await bondTwoMonomers(page, peptide3, peptide4);

// Hover 1th peptide
await moveMouseAway(page);
await peptide1.hover();

// Get rid of flakiness because of preview
Expand All @@ -79,6 +81,7 @@ test.describe('Check attachment point rotation', () => {
await takeEditorScreenshot(page);

// Hover 2nd peptide
await moveMouseAway(page);
await peptide2.hover();

// Get rid of flakiness because of preview
Expand Down Expand Up @@ -123,6 +126,7 @@ test.describe('Check attachment point rotation', () => {
await bondTwoMonomers(page, peptide1, peptide2);

// Hover 1th peptide
await moveMouseAway(page);
await peptide1.hover();

await takeEditorScreenshot(page);
Expand All @@ -131,6 +135,7 @@ test.describe('Check attachment point rotation', () => {
await selectRectangleSelectionTool(page);
await page.mouse.move(400, 400);
await dragMouseTo(200, 400, page);
await moveMouseAway(page);

await selectSingleBondTool(page);
// Hover 1th peptide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,13 @@ test.describe('Snake Bond Tool', () => {
`KET/peptides-flex-chain.ket`,
page,
);
scrollUp(page, 200);
await scrollUp(page, 200);
await moveMouseAway(page);
await takeEditorScreenshot(page);
await page.getByText('meS').locator('..').first().hover();
await dragMouseTo(x, y, page);
await page.mouse.click(x2, y2);
await moveMouseAway(page);
await takeEditorScreenshot(page);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,4 @@
}
]
}
}
}
1 change: 1 addition & 0 deletions ketcher-autotests/tests/utils/macromolecules/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export async function clickOnSequenceSymbol(
symbolText,
clickOptions?.nthNumber,
);
await symbolLocator.hover();
await symbolLocator.click(clickOptions);
}

Expand Down
17 changes: 16 additions & 1 deletion packages/ketcher-core/src/application/editor/data/monomers.ket
Original file line number Diff line number Diff line change
Expand Up @@ -168890,6 +168890,9 @@
"id": "A",
"name": "A",
"class": "RNA",
"idtAliases": {
"base": "rA"
},
"templates": [
{
"$ref": "monomerTemplate-R___Ribose"
Expand All @@ -168907,6 +168910,9 @@
"id": "C",
"name": "C",
"class": "RNA",
"idtAliases": {
"base": "rC"
},
"templates": [
{
"$ref": "monomerTemplate-R___Ribose"
Expand All @@ -168924,6 +168930,9 @@
"id": "G",
"name": "G",
"class": "RNA",
"idtAliases": {
"base": "rG"
},
"templates": [
{
"$ref": "monomerTemplate-R___Ribose"
Expand All @@ -168941,6 +168950,9 @@
"id": "T",
"name": "T",
"class": "RNA",
"idtAliases": {
"base": "rT"
},
"templates": [
{
"$ref": "monomerTemplate-R___Ribose"
Expand All @@ -168958,6 +168970,9 @@
"id": "U",
"name": "U",
"class": "RNA",
"idtAliases": {
"base": "rU"
},
"templates": [
{
"$ref": "monomerTemplate-R___Ribose"
Expand Down Expand Up @@ -169056,7 +169071,7 @@
"name": "dR(U)P",
"class": "RNA",
"idtAliases": {
"base": "deoxyU"
"base": "U"
},
"templates": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type RenderOptions = {
connectedMonomerAttachmentPoints?: string[];
currentlySelectedMonomerAttachmentPoint?: string;
labelInMonomerConnectionsModal?: boolean;
labelInPreview?: boolean;
};

export interface RelativeBox {
Expand Down
34 changes: 25 additions & 9 deletions packages/ketcher-core/src/application/render/restruct/reatom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,15 @@ function buildLabel(
leftMargin: number;
label: ElemAttr;
} {
const {
atomColoring,
font,
fontsz,
currentlySelectedMonomerAttachmentPoint,
connectedMonomerAttachmentPoints,
labelInMonomerConnectionsModal,
labelInPreview,
} = options;
// eslint-disable-line max-statements
const label: any = {
text: getLabelText(atom.a, atomId, sgroup),
Expand All @@ -801,18 +810,19 @@ function buildLabel(

if (label.text === atom.a.label) {
const element = Elements.get(label.text);
if (options.atomColoring && element) {
if (atomColoring && element) {
atom.color = ElementColor[label.text] || '#000';
}
}

const shouldStyleLabel = labelInMonomerConnectionsModal || labelInPreview;
const isMonomerAttachmentPoint = attachmentPointNames.includes(label.text);
const isMonomerAttachmentPointSelected =
options.currentlySelectedMonomerAttachmentPoint === label.text;
currentlySelectedMonomerAttachmentPoint === label.text;
const isMonomerAttachmentPointUsed =
options.connectedMonomerAttachmentPoints?.includes(label.text);
connectedMonomerAttachmentPoints?.includes(label.text);

if (isMonomerAttachmentPoint && options.labelInMonomerConnectionsModal) {
if (isMonomerAttachmentPoint && shouldStyleLabel) {
atom.color = isMonomerAttachmentPointSelected
? '#FFF'
: isMonomerAttachmentPointUsed
Expand All @@ -828,20 +838,20 @@ function buildLabel(
const { previewOpacity } = options;

label.path = paper.text(ps.x, ps.y, label.text).attr({
font: options.font,
'font-size': options.fontsz,
font,
'font-size': fontsz,
fill: atom.color,
'font-style': atom.a.pseudo ? 'italic' : '',
'fill-opacity': atom.a.isPreview ? previewOpacity : 1,
});

if (isMonomerAttachmentPoint && options.labelInMonomerConnectionsModal) {
if (isMonomerAttachmentPoint && shouldStyleLabel) {
const fill = isMonomerAttachmentPointSelected
? '#167782'
: isMonomerAttachmentPointUsed
? '#E1E5EA'
: '#FFF';
const backgroundSize = options.fontsz * 2;
const backgroundSize = fontsz * 2;

label.background = paper
.rect(
Expand All @@ -852,7 +862,13 @@ function buildLabel(
10,
)
.attr({ fill })
.attr({ stroke: isMonomerAttachmentPointUsed ? '#B4B9D6' : '#7C7C7F' });
.attr({
stroke: labelInPreview
? 'none'
: isMonomerAttachmentPointUsed
? '#B4B9D6'
: '#7C7C7F',
});
}
if (tooltip) {
addTooltip(label.path.node, tooltip);
Expand Down
6 changes: 3 additions & 3 deletions packages/ketcher-core/src/domain/entities/BaseMonomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export abstract class BaseMonomer extends DrawingEntity {
public potentialSecondAttachmentPointForBond: AttachmentPointName | null;
public chosenSecondAttachmentPointForBond: AttachmentPointName | null;

public potentialAttachmentPointsToBonds: Partial<
Record<AttachmentPointName, PolymerBond | null>
> = {};
public potentialAttachmentPointsToBonds: {
[key: string]: PolymerBond | null | undefined;
} = {};

public attachmentPointsVisible = false;
public monomerItem: MonomerItemType;
Expand Down
1 change: 1 addition & 0 deletions packages/ketcher-core/src/domain/entities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ export * from './EmptySequenceNode';
export * from './LinkerSequenceNode';
export * from './UnresolvedMonomer';
export * from './UnsplitNucleotide';
export * from './PolymerBond';
8 changes: 4 additions & 4 deletions packages/ketcher-macromolecules/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { NodeSelection, PolymerBondRenderer } from 'ketcher-core';
import { store } from 'state';
import {
defaultTheme,
muiOverrides,
EditorTheme,
MergedThemeType,
muiOverrides,
} from 'theming/defaultTheme';
import { getGlobalStyles } from 'theming/globalStyles';
import { Layout } from 'components/Layout';
Expand All @@ -49,19 +49,19 @@ import {
StyledToastContent,
} from 'components/shared/StyledToast/styles';
import {
PeptideAvatar,
ChemAvatar,
SugarAvatar,
PeptideAvatar,
PhosphateAvatar,
RNABaseAvatar,
SugarAvatar,
UnresolvedMonomerAvatar,
NucleotideAvatar,
} from 'components/shared/monomerOnCanvas';
import { ErrorModal } from 'components/modal/Error';
import {
TopMenuRightWrapper,
EditorWrapper,
TogglerComponentWrapper,
TopMenuRightWrapper,
} from './styledComponents';
import { useLoading } from './hooks/useLoading';
import useSetRnaPresets from './hooks/useSetRnaPresets';
Expand Down
Loading
Loading