Skip to content

Commit

Permalink
Backmerge: #5848 - Unable to establish connection between micro struc…
Browse files Browse the repository at this point in the history
…ture and sugar or phopshate (and partially - unresolved monomer) (#5871)

* #5679 - Unable to establish connection between micro structure and macro ones (#5847)
* #5848 - Unable to establish connection between micro structure and sugar or phopshate (and partially - unresolved monomer) (#5866)
  • Loading branch information
rrodionov91 authored Oct 25, 2024
1 parent 7953f3a commit d6ddc42
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class BondRenderer extends BaseRenderer {

private appendRootElement() {
return this.canvas
.append('g')
.insert('g', ':first-child')
.data([this])
.attr(
'transform',
Expand Down
8 changes: 8 additions & 0 deletions packages/ketcher-core/src/domain/entities/Phosphate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ export class Phosphate extends BaseMonomer {
}

public getValidSourcePoint(secondMonomer: BaseMonomer) {
if (!secondMonomer) {
return this.firstFreeAttachmentPoint;
}

return this.getValidPoint(
secondMonomer,
secondMonomer.potentialSecondAttachmentPointForBond,
);
}

public getValidTargetPoint(firstMonomer: BaseMonomer) {
if (!firstMonomer) {
return this.firstFreeAttachmentPoint;
}

// same implementation for both source and target attachment points
return this.getValidPoint(
firstMonomer,
Expand Down
10 changes: 9 additions & 1 deletion packages/ketcher-core/src/domain/entities/Sugar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ import { isRnaBaseOrAmbiguousRnaBase } from 'domain/helpers/monomers';
import { IVariantMonomer } from 'domain/entities/types';

export class Sugar extends BaseMonomer {
public getValidSourcePoint(secondMonomer: BaseMonomer & IVariantMonomer) {
public getValidSourcePoint(secondMonomer?: BaseMonomer & IVariantMonomer) {
if (!secondMonomer) {
return this.firstFreeAttachmentPoint;
}

return this.getValidPoint(
secondMonomer,
secondMonomer.potentialSecondAttachmentPointForBond,
);
}

public getValidTargetPoint(firstMonomer: BaseMonomer & IVariantMonomer) {
if (!firstMonomer) {
return this.firstFreeAttachmentPoint;
}

// same implementation for both source and target attachment points
return this.getValidPoint(
firstMonomer,
Expand Down
16 changes: 12 additions & 4 deletions packages/ketcher-core/src/domain/entities/UnresolvedMonomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import { SubChainNode } from 'domain/entities/monomer-chains/types';
import { Peptide } from 'domain/entities/Peptide';

export class UnresolvedMonomer extends BaseMonomer {
public getValidSourcePoint(monomer?: BaseMonomer) {
return Peptide.prototype.getValidSourcePoint.call(this, monomer);
public getValidSourcePoint(secondMonomer?: BaseMonomer) {
if (!secondMonomer) {
return this.firstFreeAttachmentPoint;
}

return Peptide.prototype.getValidSourcePoint.call(this, secondMonomer);
}

public getValidTargetPoint(monomer: BaseMonomer) {
return Peptide.prototype.getValidTargetPoint.call(this, monomer);
public getValidTargetPoint(firstMonomer: BaseMonomer) {
if (!firstMonomer) {
return this.firstFreeAttachmentPoint;
}

return Peptide.prototype.getValidTargetPoint.call(this, firstMonomer);
}

public get SubChainConstructor() {
Expand Down

0 comments on commit d6ddc42

Please sign in to comment.