From 5b53d66288d37f75598972943431e0e09ff3fda9 Mon Sep 17 00:00:00 2001 From: Aliaksei Date: Mon, 16 Oct 2023 11:52:52 +0200 Subject: [PATCH] #3445 - Atom properties "Substitution count" and "Ring bond count" convert incorrectly to custom query (#3446) * #3445 - Atom properties "Substitution count" and "Ring bond count" convert incorrectly to custom query * #3445 - Atom properties "Substitution count" and "Ring bond count" convert incorrectly to custom query - Remove property "unsaturated" from custom query --- .../src/application/render/restruct/reatom.ts | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/ketcher-core/src/application/render/restruct/reatom.ts b/packages/ketcher-core/src/application/render/restruct/reatom.ts index 82ba094962..87730cfe22 100644 --- a/packages/ketcher-core/src/application/render/restruct/reatom.ts +++ b/packages/ketcher-core/src/application/render/restruct/reatom.ts @@ -1091,6 +1091,26 @@ function getRingBondCountAttrText(value: number) { return attrText; } +function getRingConnectivity(value: number) { + if (value > 0) { + return 'x' + value.toString(); + } else if (value === -1 || value === -2) { + return 'x0'; + } else { + return ''; + } +} + +function getDegree(value: number) { + if (value > 0) { + return 'D' + value.toString(); + } else if (value === -1 || value === -2) { + return 'D0'; + } else { + return ''; + } +} + function getSubstitutionCountAttrText(value: number) { let attrText: string; if (value > 0) { @@ -1152,11 +1172,8 @@ export function getAtomCustomQuery(atom) { return charge[0] !== '-' ? `+${charge}` : charge; }, explicitValence: (value) => (Number(value) !== -1 ? `v${value}` : ''), - ringBondCount: (value) => - Number(value) !== 0 ? getRingBondCountAttrText(Number(value)) : '', - substitutionCount: (value) => - Number(value) !== 0 ? getSubstitutionCountAttrText(Number(value)) : '', - unsaturatedAtom: (value) => (value ? 'u' : ''), + ringBondCount: (value) => getRingConnectivity(Number(value)), + substitutionCount: (value) => getDegree(Number(value)), hCount: (value) => Number(value) > 0 ? 'H' + (Number(value) - 1).toString() : '', implicitHCount: (value) => `h${value}`,