From 0191f6167aa2382c7b2f95cb9a3c478c5a74a92f Mon Sep 17 00:00:00 2001 From: Aliaksei Date: Fri, 29 Sep 2023 16:14:22 +0200 Subject: [PATCH] #3371 - Merge ring bond count, degree and atomic mass atom properties --- ketcher-autotests/tests/utils/canvas/types.ts | 3 - .../src/application/render/restruct/reatom.ts | 18 ----- .../ketcher-core/src/domain/entities/atom.ts | 6 -- .../ket/fromKet/moleculeToStruct.ts | 3 - .../src/domain/serializers/ket/schema.json | 15 ---- .../src/script/ui/data/convert/structconv.js | 15 ---- .../script/ui/data/schema/struct-schema.js | 69 ++++++++----------- .../src/script/ui/state/modal/form.js | 3 - .../ContextMenu/menuItems/AtomMenuItems.tsx | 2 - .../modal/components/toolbox/Atom/Atom.tsx | 3 - 10 files changed, 28 insertions(+), 109 deletions(-) diff --git a/ketcher-autotests/tests/utils/canvas/types.ts b/ketcher-autotests/tests/utils/canvas/types.ts index 76cbd7b758..9776594eaf 100644 --- a/ketcher-autotests/tests/utils/canvas/types.ts +++ b/ketcher-autotests/tests/utils/canvas/types.ts @@ -9,13 +9,10 @@ export type Chirality = 'clockwise' | 'anticlockwise'; export interface AtomQueryProperties { aromaticity?: Aromaticity | null; - degree?: number | null; ringMembership?: number | null; ringSize?: number | null; connectivity?: number | null; - ringConnectivity?: number | null; chirality?: Chirality | null; - atomicMass?: number | null; customQuery?: string | null; } diff --git a/packages/ketcher-core/src/application/render/restruct/reatom.ts b/packages/ketcher-core/src/application/render/restruct/reatom.ts index e0bd6a7c58..68945fc587 100644 --- a/packages/ketcher-core/src/application/render/restruct/reatom.ts +++ b/packages/ketcher-core/src/application/render/restruct/reatom.ts @@ -1134,13 +1134,10 @@ export function getAtomCustomQuery(atom) { hCount: (value) => Number(value) > 0 ? 'H' + (Number(value) - 1).toString() : '', implicitHCount: (value) => `h${value}`, - degree: (value) => `D${value}`, ringMembership: (value) => `R${value}`, ringSize: (value) => `r${value}`, connectivity: (value) => `X${value}`, - ringConnectivity: (value) => `x${value}`, chirality: (value) => (value === 'clockwise' ? '@@' : '@'), - atomicMass: (value) => value.toString(), }; for (const propertyName in atom) { @@ -1172,13 +1169,10 @@ function getQueryAttrsText(atom, isAromatized: boolean) { implicitHCount, queryProperties: { aromaticity, - degree, ringMembership, ringSize, connectivity, - ringConnectivity, chirality, - atomicMass, customQuery, }, } = atom.a; @@ -1209,10 +1203,6 @@ function getQueryAttrsText(atom, isAromatized: boolean) { addSemicolon(); queryAttrsText += aromaticity === 'aromatic' ? 'a' : 'A'; } - if (Number.isFinite(degree)) { - addSemicolon(); - queryAttrsText += `D${degree}`; - } if (Number.isFinite(ringMembership)) { addSemicolon(); queryAttrsText += `R${ringMembership}`; @@ -1225,18 +1215,10 @@ function getQueryAttrsText(atom, isAromatized: boolean) { addSemicolon(); queryAttrsText += `X${connectivity}`; } - if (Number.isFinite(ringConnectivity)) { - addSemicolon(); - queryAttrsText += `x${ringConnectivity}`; - } if (chirality !== null) { addSemicolon(); queryAttrsText += chirality === 'clockwise' ? '@@' : '@'; } - if (Number.isFinite(atomicMass)) { - addSemicolon(); - queryAttrsText += `${atomicMass}`; - } return queryAttrsText; } diff --git a/packages/ketcher-core/src/domain/entities/atom.ts b/packages/ketcher-core/src/domain/entities/atom.ts index f19a0794dc..28752c3544 100644 --- a/packages/ketcher-core/src/domain/entities/atom.ts +++ b/packages/ketcher-core/src/domain/entities/atom.ts @@ -61,13 +61,10 @@ export type Chirality = 'clockwise' | 'anticlockwise'; export interface AtomQueryProperties { aromaticity?: Aromaticity | null; - degree?: number | null; ringMembership?: number | null; ringSize?: number | null; connectivity?: number | null; - ringConnectivity?: number | null; chirality?: Chirality | null; - atomicMass?: number | null; customQuery?: string | null; } @@ -147,13 +144,10 @@ export class Atom { hCount: 0, queryProperties: { aromaticity: null, - degree: null, ringMembership: null, ringSize: null, connectivity: null, - ringConnectivity: null, chirality: null, - atomicMass: null, customQuery: null, }, atomList: null, diff --git a/packages/ketcher-core/src/domain/serializers/ket/fromKet/moleculeToStruct.ts b/packages/ketcher-core/src/domain/serializers/ket/fromKet/moleculeToStruct.ts index 87e8899821..17830a513f 100644 --- a/packages/ketcher-core/src/domain/serializers/ket/fromKet/moleculeToStruct.ts +++ b/packages/ketcher-core/src/domain/serializers/ket/fromKet/moleculeToStruct.ts @@ -86,13 +86,10 @@ export function atomToStruct(source) { const queryAttribute: Array = [ 'aromaticity', - 'degree', 'ringMembership', 'connectivity', 'ringSize', - 'ringConnectivity', 'chirality', - 'atomicMass', 'customQuery', ]; ifDef(params, 'label', source.label); diff --git a/packages/ketcher-core/src/domain/serializers/ket/schema.json b/packages/ketcher-core/src/domain/serializers/ket/schema.json index 1a58a16d52..96db524763 100644 --- a/packages/ketcher-core/src/domain/serializers/ket/schema.json +++ b/packages/ketcher-core/src/domain/serializers/ket/schema.json @@ -180,11 +180,6 @@ "type": "string", "enum": ["aromatic", "aliphatic"] }, - "degree": { - "type": "integer", - "minimum": 0, - "maximum": 6 - }, "ringMembership": { "type": "integer", "minimum": 0, @@ -200,16 +195,6 @@ "minimum": 0, "maximum": 5 }, - "ringConnectivity": { - "type": "integer", - "minimum": 0, - "maximum": 5 - }, - "atomicMass": { - "type": "integer", - "minimum": 0, - "maximum": 1000 - }, "chirality": { "type": "string", "enum": ["clockwise", "anticlockwise"] diff --git a/packages/ketcher-react/src/script/ui/data/convert/structconv.js b/packages/ketcher-react/src/script/ui/data/convert/structconv.js index b09e3fcce5..1c97555892 100644 --- a/packages/ketcher-react/src/script/ui/data/convert/structconv.js +++ b/packages/ketcher-react/src/script/ui/data/convert/structconv.js @@ -93,20 +93,14 @@ export function fromAtom(satom) { stereoParity: satom.stereoParity, implicitHCount: satom.implicitHCount, aromaticity: satom.queryProperties.aromaticity, - degree: satom.queryProperties.degree, ringMembership: satom.queryProperties.ringMembership, ringSize: satom.queryProperties.ringSize, connectivity: satom.queryProperties.connectivity, - ringConnectivity: satom.queryProperties.ringConnectivity, chirality: satom.queryProperties.chirality, customQuery: satom.queryProperties.customQuery === null ? '' : satom.queryProperties.customQuery.toString(), - atomicMass: - satom.queryProperties.atomicMass === null - ? '' - : satom.queryProperties.atomicMass.toString(), }; } @@ -115,13 +109,10 @@ export function toAtom(atom) { // see ratomtool const { aromaticity, - degree, ringMembership, ringSize, connectivity, - ringConnectivity, chirality, - atomicMass, customQuery, ...restAtom } = atom; @@ -140,14 +131,11 @@ export function toAtom(atom) { implicitHCount: null, queryProperties: { aromaticity: null, - degree: null, implicitHCount: null, ringMembership: null, ringSize: null, connectivity: null, - ringConnectivity: null, chirality: null, - atomicMass: null, customQuery, }, invRet: 0, @@ -165,14 +153,11 @@ export function toAtom(atom) { unsaturatedAtom: +(restAtom.unsaturatedAtom ?? false), queryProperties: { aromaticity, - degree, implicitHCount: restAtom.implicitHCount, ringMembership, ringSize, connectivity, - ringConnectivity, chirality, - atomicMass: atomicMass === '' ? null : Number(atomicMass), customQuery: customQuery === '' ? null : customQuery, }, }); diff --git a/packages/ketcher-react/src/script/ui/data/schema/struct-schema.js b/packages/ketcher-react/src/script/ui/data/schema/struct-schema.js index 944d5f8333..38d6066c53 100644 --- a/packages/ketcher-react/src/script/ui/data/schema/struct-schema.js +++ b/packages/ketcher-react/src/script/ui/data/schema/struct-schema.js @@ -49,7 +49,7 @@ export const atom = { default: -1, }, isotope: { - title: 'Isotope', + title: 'Isotope (atomic mass)', type: 'integer', minimum: 0, default: 0, @@ -73,20 +73,33 @@ export const atom = { }, ringBondCount: { title: 'Ring bond count', - enum: [0, -2, -1, 2, 3, 4], - enumNames: ['', 'As drawn', '0', '2', '3', '4'], + enum: [0, -2, -1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', 'As drawn', '0', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, hCount: { title: 'H count', - enum: [0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4'], + enum: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, substitutionCount: { title: 'Substitution count', - enum: [0, -2, -1, 1, 2, 3, 4, 5, 6], - enumNames: ['', 'As drawn', '0', '1', '2', '3', '4', '5', '6'], + enum: [0, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: [ + '', + 'As drawn', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + ], default: 0, }, unsaturatedAtom: { @@ -100,62 +113,36 @@ export const atom = { enumNames: ['', 'aromatic', 'aliphatic'], default: 0, }, - degree: { - title: 'Degree', - enum: [null, 0, 1, 2, 3, 4, 5, 6], - enumNames: ['', '0', '1', '2', '3', '4', '5', '6'], - default: 0, - }, implicitHCount: { title: 'Implicit H count', - enum: [null, 0, 1, 2, 3, 4], - enumNames: ['', '0', '1', '2', '3', '4'], + enum: [null, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, ringMembership: { title: 'Ring membership', - enum: [null, 0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4', '5'], + enum: [null, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, ringSize: { title: 'Ring size', - enum: [null, 0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4', '5'], + enum: [null, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, connectivity: { title: 'Connectivity', - enum: [null, 0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4', '5'], - default: 0, - }, - ringConnectivity1: { - title: 'Ring connectivity', - enum: [null, 0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4', '5'], + enum: [null, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + enumNames: ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], default: 0, }, - ringConnectivity: { - title: 'Ring connectivity', - enum: [null, 0, 1, 2, 3, 4, 5], - enumNames: ['', '0', '1', '2', '3', '4', '5'], - default: null, - }, chirality: { title: 'Chirality', enum: [null, 'clockwise', 'anticlockwise'], enumNames: ['', 'anticlockwise', 'clockwise'], default: 0, }, - atomicMass: { - title: 'Atomic mass', - type: 'string', - pattern: '^([+]?)([0-9]{1,3}|1000)([+-]?)$|(^$)', - default: '', - maxLength: 5, - invalidMessage: 'Invalid atomic mass', - }, customQuery: { title: 'Custom Query', pattern: '[^ ]', diff --git a/packages/ketcher-react/src/script/ui/state/modal/form.js b/packages/ketcher-react/src/script/ui/state/modal/form.js index cc0ee30ace..9e21542694 100644 --- a/packages/ketcher-react/src/script/ui/state/modal/form.js +++ b/packages/ketcher-react/src/script/ui/state/modal/form.js @@ -36,14 +36,11 @@ export const formsState = { ringBondCount: 0, substitutionCount: 0, aromaticity: null, - degree: null, implicitHCount: null, ringMembership: null, ringSize: null, connectivity: null, - ringConnectivity: null, chirality: null, - atomicMass: null, customQuery: null, }, }, diff --git a/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/AtomMenuItems.tsx b/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/AtomMenuItems.tsx index 0eea944681..88d1dc1927 100644 --- a/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/AtomMenuItems.tsx +++ b/packages/ketcher-react/src/script/ui/views/components/ContextMenu/menuItems/AtomMenuItems.tsx @@ -27,11 +27,9 @@ const { } = atom.properties; const properties: Array = [ 'aromaticity', - 'degree', 'ringMembership', 'ringSize', 'connectivity', - 'ringConnectivity', ]; const atomPropertiesForSubMenu: { diff --git a/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.tsx b/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.tsx index e89dcac81a..47454a93db 100644 --- a/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.tsx +++ b/packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.tsx @@ -70,14 +70,11 @@ const querySpecificFields: Array<{ { name: 'substitutionCount', component: 'dropdown' }, { name: 'unsaturatedAtom', labelPos: 'before', className: classes.checkbox }, { name: 'aromaticity', component: 'dropdown' }, - { name: 'degree', component: 'dropdown' }, { name: 'implicitHCount', component: 'dropdown' }, { name: 'ringMembership', component: 'dropdown' }, { name: 'ringSize', component: 'dropdown' }, { name: 'connectivity', component: 'dropdown' }, - { name: 'ringConnectivity', component: 'dropdown' }, { name: 'chirality', component: 'dropdown' }, - { name: 'atomicMass' }, ]; const Atom: FC = (props: Props) => { const {