Skip to content

Commit

Permalink
#3371 - Merge ring bond count, degree and atomic mass atom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
AKZhuk committed Sep 29, 2023
1 parent f8c04df commit 0191f61
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 109 deletions.
3 changes: 0 additions & 3 deletions ketcher-autotests/tests/utils/canvas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 0 additions & 18 deletions packages/ketcher-core/src/application/render/restruct/reatom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1172,13 +1169,10 @@ function getQueryAttrsText(atom, isAromatized: boolean) {
implicitHCount,
queryProperties: {
aromaticity,
degree,
ringMembership,
ringSize,
connectivity,
ringConnectivity,
chirality,
atomicMass,
customQuery,
},
} = atom.a;
Expand Down Expand Up @@ -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}`;
Expand All @@ -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;
}

Expand Down
6 changes: 0 additions & 6 deletions packages/ketcher-core/src/domain/entities/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ export function atomToStruct(source) {

const queryAttribute: Array<keyof AtomQueryProperties> = [
'aromaticity',
'degree',
'ringMembership',
'connectivity',
'ringSize',
'ringConnectivity',
'chirality',
'atomicMass',
'customQuery',
];
ifDef(params, 'label', source.label);
Expand Down
15 changes: 0 additions & 15 deletions packages/ketcher-core/src/domain/serializers/ket/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@
"type": "string",
"enum": ["aromatic", "aliphatic"]
},
"degree": {
"type": "integer",
"minimum": 0,
"maximum": 6
},
"ringMembership": {
"type": "integer",
"minimum": 0,
Expand All @@ -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"]
Expand Down
15 changes: 0 additions & 15 deletions packages/ketcher-react/src/script/ui/data/convert/structconv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
}

Expand All @@ -115,13 +109,10 @@ export function toAtom(atom) {
// see ratomtool
const {
aromaticity,
degree,
ringMembership,
ringSize,
connectivity,
ringConnectivity,
chirality,
atomicMass,
customQuery,
...restAtom
} = atom;
Expand All @@ -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,
Expand All @@ -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,
},
});
Expand Down
69 changes: 28 additions & 41 deletions packages/ketcher-react/src/script/ui/data/schema/struct-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const atom = {
default: -1,
},
isotope: {
title: 'Isotope',
title: 'Isotope (atomic mass)',
type: 'integer',
minimum: 0,
default: 0,
Expand All @@ -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: {
Expand All @@ -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: '[^ ]',
Expand Down
3 changes: 0 additions & 3 deletions packages/ketcher-react/src/script/ui/state/modal/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ const {
} = atom.properties;
const properties: Array<AtomQueryPropertiesName> = [
'aromaticity',
'degree',
'ringMembership',
'ringSize',
'connectivity',
'ringConnectivity',
];

const atomPropertiesForSubMenu: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: Props) => {
const {
Expand Down

0 comments on commit 0191f61

Please sign in to comment.