diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts-snapshots/Import-Saving-ket-Files-Check-that-macro-ket-file-can-be-imported-in-micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts-snapshots/Import-Saving-ket-Files-Check-that-macro-ket-file-can-be-imported-in-micro-mode-1-chromium-linux.png index 5c935e18ce..a939ab6a6a 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts-snapshots/Import-Saving-ket-Files-Check-that-macro-ket-file-can-be-imported-in-micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-ket.spec.ts-snapshots/Import-Saving-ket-Files-Check-that-macro-ket-file-can-be-imported-in-micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-Saving-mol-Files-Check-that-macro-mol-file-can-be-imported-in-micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-Saving-mol-Files-Check-that-macro-mol-file-can-be-imported-in-micro-mode-1-chromium-linux.png index 1f429c7f8f..7ce29825bd 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-Saving-mol-Files-Check-that-macro-mol-file-can-be-imported-in-micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-Saving-mol-Files-Check-that-macro-mol-file-can-be-imported-in-micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-6bd73--check-that-structure-is-in-center-of-canvas-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-6bd73--check-that-structure-is-in-center-of-canvas-2-chromium-linux.png index 260a12d82f..98338b007d 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-6bd73--check-that-structure-is-in-center-of-canvas-2-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-6bd73--check-that-structure-is-in-center-of-canvas-2-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-d8e83--check-that-structure-is-in-center-of-canvas-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-d8e83--check-that-structure-is-in-center-of-canvas-1-chromium-linux.png index 777fd1c7ce..f1fef1273e 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-d8e83--check-that-structure-is-in-center-of-canvas-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Open-a-macro-file-and-put-d8e83--check-that-structure-is-in-center-of-canvas-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--00142--with-connection-between-monomer-and-molecule-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--00142--with-connection-between-monomer-and-molecule-1-chromium-linux.png index 0b257a3972..daf3fdd402 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--00142--with-connection-between-monomer-and-molecule-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--00142--with-connection-between-monomer-and-molecule-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--1b10a--with-connection-between-monomer-and-molecule-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--1b10a--with-connection-between-monomer-and-molecule-2-chromium-linux.png index 9ee2d0b947..eadc7406ca 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--1b10a--with-connection-between-monomer-and-molecule-2-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--1b10a--with-connection-between-monomer-and-molecule-2-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--61a89--with-connection-between-monomer-and-molecule-3-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--61a89--with-connection-between-monomer-and-molecule-3-chromium-linux.png index 9de3fa47ea..5862c1b73e 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--61a89--with-connection-between-monomer-and-molecule-3-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers--61a89--with-connection-between-monomer-and-molecule-3-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-1-chromium-linux.png index cede976b1e..1350354071 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-2-chromium-linux.png index a0f9aa7aa3..0aeb9bd8d7 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-2-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-2-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-3-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-3-chromium-linux.png index 83542b4e65..08f6f3704d 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-3-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Polymer-Bond-Tool/connection-rules-for-molecules-with-monomers.spec.ts-snapshots/Connection-rules-for-molecules-with-monomers-Delete-connection-between-monomer-and-molecule-3-chromium-linux.png differ diff --git a/packages/ketcher-core/src/application/editor/MacromoleculesConverter.ts b/packages/ketcher-core/src/application/editor/MacromoleculesConverter.ts index 10bf3fc40b..12a898b028 100644 --- a/packages/ketcher-core/src/application/editor/MacromoleculesConverter.ts +++ b/packages/ketcher-core/src/application/editor/MacromoleculesConverter.ts @@ -90,9 +90,12 @@ export class MacromoleculesConverter { const atomIdMap = monomerToAtomIdMap.get(monomer); return { - attachmentAtomId: + globalAttachmentAtomId: isNumber(attachmentPoint?.attachmentAtom) && atomIdMap?.get(attachmentPoint?.attachmentAtom as number), + attachmentAtomId: + isNumber(attachmentPoint?.attachmentAtom) && + attachmentPoint?.attachmentAtom, attachmentPointNumber, }; } @@ -178,7 +181,7 @@ export class MacromoleculesConverter { drawingEntitiesManager.polymerBonds.forEach((polymerBond) => { assert(polymerBond.secondMonomer); const { - attachmentAtomId: beginAtom, + globalAttachmentAtomId: beginAtom, attachmentPointNumber: beginSuperatomAttachmentPointNumber, } = this.findAttachmentPointAtom( polymerBond, @@ -186,7 +189,7 @@ export class MacromoleculesConverter { monomerToAtomIdMap, ); const { - attachmentAtomId: endAtom, + globalAttachmentAtomId: endAtom, attachmentPointNumber: endSuperatomAttachmentPointNumber, } = this.findAttachmentPointAtom( polymerBond, diff --git a/packages/ketcher-core/src/domain/serializers/ket/ketSerializer.ts b/packages/ketcher-core/src/domain/serializers/ket/ketSerializer.ts index f5d1585dcb..941076ac1d 100644 --- a/packages/ketcher-core/src/domain/serializers/ket/ketSerializer.ts +++ b/packages/ketcher-core/src/domain/serializers/ket/ketSerializer.ts @@ -494,7 +494,7 @@ export class KetSerializer implements Serializer { monomerToAtomIdMap: Map>, struct: Struct, ): IKetConnectionMoleculeEndPoint { - const { attachmentAtomId } = + const { attachmentAtomId, globalAttachmentAtomId } = MacromoleculesConverter.findAttachmentPointAtom( polymerBond, monomer, @@ -503,7 +503,7 @@ export class KetSerializer implements Serializer { return { moleculeId: `mol${ - struct.atoms.get(attachmentAtomId as number)?.fragment + struct.atoms.get(globalAttachmentAtomId as number)?.fragment }`, atomId: `${attachmentAtomId as number}`, }; diff --git a/packages/ketcher-react/src/script/ui/state/shared.ts b/packages/ketcher-react/src/script/ui/state/shared.ts index b52ac9c589..3f6b47623c 100644 --- a/packages/ketcher-react/src/script/ui/state/shared.ts +++ b/packages/ketcher-react/src/script/ui/state/shared.ts @@ -31,6 +31,7 @@ import { import { supportedSGroupTypes } from './constants'; import { setAnalyzingFile } from './request'; import tools from '../action/tools'; +import { isNumber } from 'lodash'; export function onAction(action) { if (action && action.dialog) { @@ -149,6 +150,14 @@ export function load(struct: Struct, options?) { const hasUnsupportedGroups = parsedStruct.sgroups.some( (sGroup) => !supportedSGroupTypes[sGroup.type], ); + const hasMoleculeToMonomerConnections = parsedStruct.bonds.find( + (_, bond) => { + return ( + isNumber(bond.beginSuperatomAttachmentPointNumber) || + isNumber(bond.endSuperatomAttachmentPointNumber) + ); + }, + ); if (hasUnsupportedGroups) { await editor.event.confirm.dispatch(); @@ -157,7 +166,10 @@ export function load(struct: Struct, options?) { ); } - parsedStruct.rescale(); // TODO: move out parsing? + // scaling works bad with molecule-to-monomer connections + if (!hasMoleculeToMonomerConnections) { + parsedStruct.rescale(); // TODO: move out parsing? + } if (editor.struct().atoms.size) { // NB: reset id