Skip to content

Commit 9641c56

Browse files
committed
#4608 - Bugfix (PolymerBond): Correct isSideChainConnection getter (the third requirement)
1 parent 555cc28 commit 9641c56

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

packages/ketcher-core/src/domain/entities/PolymerBond.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export class PolymerBond extends DrawingEntity {
8080
public get isBackboneChainConnection(): boolean {
8181
// Variants:
8282
// • Not RNA base [R2] — [R1] Not RNA base
83+
// • Not RNA base [R1] — [R2] Not RNA base
8384
// • Sugar [R3] — [R1] RNA base
85+
// • [R1] RNA base — Sugar [R3]
8486
if (!this.secondMonomer) {
8587
return true;
8688
}
@@ -95,21 +97,28 @@ export class PolymerBond extends DrawingEntity {
9597
return true;
9698
}
9799

98-
if (
99-
firstMonomerAttachmentPoint === AttachmentPointName.R2 &&
100-
secondMonomerAttachmentPoint === AttachmentPointName.R1 &&
101-
!(firstMonomer instanceof RNABase) &&
102-
!(secondMonomer instanceof RNABase)
103-
) {
100+
const thereAreR1AndR2 =
101+
(firstMonomerAttachmentPoint === AttachmentPointName.R2 &&
102+
secondMonomerAttachmentPoint === AttachmentPointName.R1) ||
103+
(firstMonomerAttachmentPoint === AttachmentPointName.R1 &&
104+
secondMonomerAttachmentPoint === AttachmentPointName.R2);
105+
const thereAreNotRNABase =
106+
!(firstMonomer instanceof RNABase) || !(secondMonomer instanceof RNABase);
107+
if (thereAreR1AndR2 && thereAreNotRNABase) {
104108
return true;
105109
}
106110

107-
return (
111+
let thereAreSugarWithR3AndRNABaseWithR1 =
108112
firstMonomer instanceof Sugar &&
109113
firstMonomerAttachmentPoint === AttachmentPointName.R3 &&
110114
secondMonomer instanceof RNABase &&
111-
secondMonomerAttachmentPoint === AttachmentPointName.R1
112-
);
115+
secondMonomerAttachmentPoint === AttachmentPointName.R1;
116+
thereAreSugarWithR3AndRNABaseWithR1 ||=
117+
secondMonomer instanceof Sugar &&
118+
secondMonomerAttachmentPoint === AttachmentPointName.R3 &&
119+
firstMonomer instanceof RNABase &&
120+
firstMonomerAttachmentPoint === AttachmentPointName.R1;
121+
return thereAreSugarWithR3AndRNABaseWithR1;
113122
}
114123

115124
public get isSideChainConnection(): boolean {

0 commit comments

Comments
 (0)