Skip to content

Commit

Permalink
#4608 - Bugfix (PolymerBond): Correct isSideChainConnection getter …
Browse files Browse the repository at this point in the history
…(the third requirement)
  • Loading branch information
DmitriiP-EPAM committed Jun 28, 2024
1 parent 555cc28 commit 9641c56
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/ketcher-core/src/domain/entities/PolymerBond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class PolymerBond extends DrawingEntity {
public get isBackboneChainConnection(): boolean {
// Variants:
// • Not RNA base [R2] — [R1] Not RNA base
// • Not RNA base [R1] — [R2] Not RNA base
// • Sugar [R3] — [R1] RNA base
// • [R1] RNA base — Sugar [R3]
if (!this.secondMonomer) {
return true;
}
Expand All @@ -95,21 +97,28 @@ export class PolymerBond extends DrawingEntity {
return true;
}

if (
firstMonomerAttachmentPoint === AttachmentPointName.R2 &&
secondMonomerAttachmentPoint === AttachmentPointName.R1 &&
!(firstMonomer instanceof RNABase) &&
!(secondMonomer instanceof RNABase)
) {
const thereAreR1AndR2 =
(firstMonomerAttachmentPoint === AttachmentPointName.R2 &&
secondMonomerAttachmentPoint === AttachmentPointName.R1) ||
(firstMonomerAttachmentPoint === AttachmentPointName.R1 &&
secondMonomerAttachmentPoint === AttachmentPointName.R2);
const thereAreNotRNABase =
!(firstMonomer instanceof RNABase) || !(secondMonomer instanceof RNABase);
if (thereAreR1AndR2 && thereAreNotRNABase) {
return true;
}

return (
let thereAreSugarWithR3AndRNABaseWithR1 =
firstMonomer instanceof Sugar &&
firstMonomerAttachmentPoint === AttachmentPointName.R3 &&
secondMonomer instanceof RNABase &&
secondMonomerAttachmentPoint === AttachmentPointName.R1
);
secondMonomerAttachmentPoint === AttachmentPointName.R1;
thereAreSugarWithR3AndRNABaseWithR1 ||=
secondMonomer instanceof Sugar &&
secondMonomerAttachmentPoint === AttachmentPointName.R3 &&
firstMonomer instanceof RNABase &&
firstMonomerAttachmentPoint === AttachmentPointName.R1;
return thereAreSugarWithR3AndRNABaseWithR1;
}

public get isSideChainConnection(): boolean {
Expand Down

0 comments on commit 9641c56

Please sign in to comment.