Skip to content

Commit

Permalink
#3475 - fixed style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chgayane authored and chgayane committed Nov 8, 2023
1 parent d5f23bf commit 6d4a986
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
7 changes: 5 additions & 2 deletions packages/ketcher-core/src/domain/entities/BaseMonomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ export abstract class BaseMonomer extends DrawingEntity {
return Boolean(this.firstFreeAttachmentPoint);
}

public isAttachmentPointExistAndFree(attachmentPoint: AttachmentPointName){
return this.hasAttachmentPoint(attachmentPoint) && !this.isAttachmentPointUsed(attachmentPoint)
public isAttachmentPointExistAndFree(attachmentPoint: AttachmentPointName) {
return (
this.hasAttachmentPoint(attachmentPoint) &&
!this.isAttachmentPointUsed(attachmentPoint)
);
}

public setRenderer(renderer: BaseMonomerRenderer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,11 @@ export class DrawingEntitiesManager {
monomer.turnOnAttachmentPointsVisibility();
bond.firstMonomer.removePotentialBonds();
monomer.removePotentialBonds();
const firstMonomerValidSourcePoint = bond.firstMonomer.getValidSourcePoint(monomer);
const secondMonomerValidTargetPoint = monomer.getValidTargetPoint(bond.firstMonomer);
const firstMonomerValidSourcePoint =
bond.firstMonomer.getValidSourcePoint(monomer);
const secondMonomerValidTargetPoint = monomer.getValidTargetPoint(
bond.firstMonomer,
);
bond.firstMonomer.setPotentialBond(firstMonomerValidSourcePoint, bond);
monomer.setPotentialBond(secondMonomerValidTargetPoint, bond);
const connectFirstMonomerOperation = new MonomerHoverOperation(
Expand Down
41 changes: 24 additions & 17 deletions packages/ketcher-core/src/domain/entities/Peptide.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
import { BaseMonomer } from './BaseMonomer';

export class Peptide extends BaseMonomer {

public getValidSourcePoint(monomer: BaseMonomer) {

if (monomer.isAttachmentPointExistAndFree('R1') && this.isAttachmentPointExistAndFree('R2')) {

return 'R2';
if (
monomer.isAttachmentPointExistAndFree('R1') &&
this.isAttachmentPointExistAndFree('R2')
) {
return 'R2';
}
if (
this.isAttachmentPointExistAndFree('R1') &&
monomer.isAttachmentPointExistAndFree('R2')
) {
return 'R1';
}

}
if (this.isAttachmentPointExistAndFree('R1') && monomer.isAttachmentPointExistAndFree('R2') ) {
return 'R1';
}

return this.firstFreeAttachmentPoint;
}

public getValidTargetPoint(monomer: BaseMonomer) {

if (this.isAttachmentPointExistAndFree('R1') && monomer.isAttachmentPointExistAndFree('R2') ) {
return 'R1';
}
if (monomer.isAttachmentPointExistAndFree('R1') && this.isAttachmentPointExistAndFree('R2')) {
return 'R2';
}
if (
this.isAttachmentPointExistAndFree('R1') &&
monomer.isAttachmentPointExistAndFree('R2')
) {
return 'R1';
}
if (
monomer.isAttachmentPointExistAndFree('R1') &&
this.isAttachmentPointExistAndFree('R2')
) {
return 'R2';
}

return this.firstFreeAttachmentPoint;
}
Expand Down

0 comments on commit 6d4a986

Please sign in to comment.