Skip to content

Commit

Permalink
#3445 - Atom properties "Substitution count" and "Ring bond count" co…
Browse files Browse the repository at this point in the history
…nvert 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
  • Loading branch information
AKZhuk authored Oct 16, 2023
1 parent f40f639 commit 5b53d66
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions packages/ketcher-core/src/application/render/restruct/reatom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`,
Expand Down

0 comments on commit 5b53d66

Please sign in to comment.