Skip to content

Commit 555cc28

Browse files
committed
#4608 - Bugfix (PolymerBond): Correct isSideChainConnection getter (another requirement)
1 parent 1410b4a commit 555cc28

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

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

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BackBoneBondSequenceRenderer } from 'application/render/renderers/seque
44
import { PolymerBondSequenceRenderer } from 'application/render/renderers/sequence/PolymerBondSequenceRenderer';
55
import { BaseMonomer } from 'domain/entities/BaseMonomer';
66
import { DrawingEntity } from 'domain/entities/DrawingEntity';
7-
import { Phosphate } from 'domain/entities/Phosphate';
87
import { RNABase } from 'domain/entities/RNABase';
98
import { Sugar } from 'domain/entities/Sugar';
109
import { Vec2 } from 'domain/entities/vec2';
@@ -80,50 +79,36 @@ export class PolymerBond extends DrawingEntity {
8079

8180
public get isBackboneChainConnection(): boolean {
8281
// Variants:
83-
// • Sugar [R2] — [R1] Phosphate
84-
// • Sugar [R1] — [R2] Phosphate
85-
// • Phosphate [R2] — [R1] Sugar
86-
// • Phosphate [R1] — [R2] Sugar
82+
// • Not RNA base [R2] — [R1] Not RNA base
8783
// • Sugar [R3] — [R1] RNA base
88-
// • RNA base [R1] — [R3] Sugar
8984
if (!this.secondMonomer) {
9085
return true;
9186
}
9287

93-
let sugarMonomer: Sugar;
94-
let anotherMonomer: BaseMonomer;
95-
if (this.firstMonomer instanceof Sugar) {
96-
sugarMonomer = this.firstMonomer;
97-
anotherMonomer = this.secondMonomer;
98-
} else if (this.secondMonomer instanceof Sugar) {
99-
sugarMonomer = this.secondMonomer;
100-
anotherMonomer = this.firstMonomer;
101-
} else {
102-
return false;
103-
}
104-
105-
const sugarMonomerAttachmentPoint =
106-
sugarMonomer.getAttachmentPointByBond(this);
107-
const anotherMonomerAttachmentPoint =
108-
anotherMonomer.getAttachmentPointByBond(this);
109-
if (!sugarMonomerAttachmentPoint || !anotherMonomerAttachmentPoint) {
88+
const firstMonomer = this.firstMonomer;
89+
const secondMonomer = this.secondMonomer;
90+
const firstMonomerAttachmentPoint =
91+
firstMonomer.getAttachmentPointByBond(this);
92+
const secondMonomerAttachmentPoint =
93+
secondMonomer.getAttachmentPointByBond(this);
94+
if (!firstMonomerAttachmentPoint || !secondMonomerAttachmentPoint) {
11095
return true;
11196
}
11297

113-
const thereArePhosphateAndSugar = anotherMonomer instanceof Phosphate;
114-
const thereAreR1AndR2 =
115-
(sugarMonomerAttachmentPoint === AttachmentPointName.R2 &&
116-
anotherMonomerAttachmentPoint === AttachmentPointName.R1) ||
117-
(sugarMonomerAttachmentPoint === AttachmentPointName.R1 &&
118-
anotherMonomerAttachmentPoint === AttachmentPointName.R2);
119-
if (thereArePhosphateAndSugar && thereAreR1AndR2) {
98+
if (
99+
firstMonomerAttachmentPoint === AttachmentPointName.R2 &&
100+
secondMonomerAttachmentPoint === AttachmentPointName.R1 &&
101+
!(firstMonomer instanceof RNABase) &&
102+
!(secondMonomer instanceof RNABase)
103+
) {
120104
return true;
121105
}
122106

123107
return (
124-
sugarMonomerAttachmentPoint === AttachmentPointName.R3 &&
125-
anotherMonomer instanceof RNABase &&
126-
anotherMonomerAttachmentPoint === AttachmentPointName.R1
108+
firstMonomer instanceof Sugar &&
109+
firstMonomerAttachmentPoint === AttachmentPointName.R3 &&
110+
secondMonomer instanceof RNABase &&
111+
secondMonomerAttachmentPoint === AttachmentPointName.R1
127112
);
128113
}
129114

0 commit comments

Comments
 (0)