ketcher-core
Version:
Web-based molecule sketcher
187 lines (186 loc) • 11.7 kB
TypeScript
import { AmbiguousMonomerType, AttachmentPointName, MonomerItemType, MonomerOrAmbiguousType } from "../types";
import { Vec2 } from "./vec2";
import { Command } from "./Command";
import { DrawingEntity } from "./DrawingEntity";
import { PolymerBond } from "./PolymerBond";
import { BaseMonomer, Chem, LinkerSequenceNode, Phosphate, RNABase, Struct, Sugar } from "./";
import { ChainsCollection } from "./monomer-chains/ChainsCollection";
import { Nucleoside } from './Nucleoside';
import { Nucleotide } from './Nucleotide';
import { MACROMOLECULES_BOND_TYPES } from "../../application/editor";
import { CanvasMatrix } from "./canvas-matrix/CanvasMatrix";
import { Matrix } from "./canvas-matrix/Matrix";
import { Cell } from "./canvas-matrix/Cell";
import { AmbiguousMonomer } from "./AmbiguousMonomer";
import { Atom, AtomProperties } from "./CoreAtom";
import { Bond } from "./CoreBond";
import { MonomerToAtomBond } from "./MonomerToAtomBond";
import { AtomLabel } from "../constants";
import { HydrogenBond } from "./HydrogenBond";
export declare const CELL_WIDTH = 60;
export declare const SNAKE_LAYOUT_Y_OFFSET_BETWEEN_CHAINS: number;
export declare const MONOMER_START_X_POSITION: number;
export declare const MONOMER_START_Y_POSITION: number;
declare type RnaPresetAdditionParams = {
sugar: MonomerItemType;
sugarPosition: Vec2;
rnaBase: MonomerItemType | undefined;
rnaBasePosition: Vec2 | undefined;
phosphate: MonomerItemType | undefined;
phosphatePosition: Vec2 | undefined;
existingNode?: Nucleotide | Nucleoside | LinkerSequenceNode;
};
export declare class DrawingEntitiesManager {
monomers: Map<number, BaseMonomer>;
polymerBonds: Map<number, PolymerBond | HydrogenBond>;
private bondsMonomersOverlaps;
atoms: Map<number, Atom>;
bonds: Map<number, Bond>;
monomerToAtomBonds: Map<number, MonomerToAtomBond>;
micromoleculesHiddenEntities: Struct;
canvasMatrix?: CanvasMatrix;
snakeLayoutMatrix?: Matrix<Cell>;
get bottomRightMonomerPosition(): Vec2;
get selectedEntitiesArr(): DrawingEntity[];
get selectedEntities(): [number, DrawingEntity][];
get allEntities(): [number, DrawingEntity][];
get hasDrawingEntities(): boolean;
get hasMonomers(): boolean;
get allBondsToMonomers(): ([number, PolymerBond] | [number, MonomerToAtomBond])[];
deleteSelectedEntities(): Command;
deleteAllEntities(): Command;
addMonomerChangeModel(monomerItem: MonomerItemType, position: Vec2, _monomer?: BaseMonomer): BaseMonomer | AmbiguousMonomer;
createMonomer(monomerItem: MonomerOrAmbiguousType, position: Vec2, generateId?: boolean): AmbiguousMonomer | Chem | Sugar | import("./").Peptide | RNABase | Phosphate;
updateMonomerItem(monomer: BaseMonomer, monomerItemNew: MonomerItemType): BaseMonomer;
addMonomer(monomerItem: MonomerItemType, position: Vec2, _monomer?: BaseMonomer): Command;
deleteDrawingEntity(drawingEntity: DrawingEntity, needToDeleteConnectedEntities?: boolean): Command;
selectDrawingEntity(drawingEntity: DrawingEntity): Command;
selectDrawingEntities(drawingEntities: DrawingEntity[]): Command;
createDrawingEntitySelectionCommand(drawingEntity: DrawingEntity): Command;
unselectAllDrawingEntities(): Command;
unselectDrawingEntity(drawingEntity: DrawingEntity): Command;
selectAllDrawingEntities(): Command;
addDrawingEntitiesToSelection(drawingEntities: DrawingEntity[]): Command;
moveDrawingEntityModelChange(drawingEntity: DrawingEntity, offset?: Vec2): DrawingEntity;
private moveChemAtomsPoint;
moveSelectedDrawingEntities(partOfMovementOffset: Vec2, fullMovementOffset?: Vec2): Command;
createDrawingEntityMovingCommand(drawingEntity: DrawingEntity, partOfMovementOffset: Vec2, fullMovementOffset?: Vec2): Command;
createDrawingEntityRedrawCommand(drawingEntityRedrawModelChange: () => DrawingEntity, invertDrawingEntityRedrawModelChange: () => DrawingEntity): Command;
private deleteMonomerChangeModel;
deleteMonomer(monomer: BaseMonomer, needToDeleteConnectedBonds?: boolean): Command;
modifyMonomerItem(monomer: BaseMonomer, monomerItemNew: MonomerItemType): Command;
selectIfLocatedInRectangle(rectangleTopLeftPoint: Vec2, rectangleBottomRightPoint: Vec2, previousSelectedEntities: [number, DrawingEntity][], shiftKey?: boolean): Command;
private checkBondSelectionForSequenceMode;
startPolymerBondCreationChangeModel(firstMonomer: any, startPosition: any, endPosition: any, bondType?: MACROMOLECULES_BOND_TYPES, _polymerBond?: PolymerBond | HydrogenBond): PolymerBond | HydrogenBond;
startPolymerBondCreation(firstMonomer: BaseMonomer, startPosition: Vec2, endPosition: Vec2, bondType: MACROMOLECULES_BOND_TYPES): {
command: Command;
polymerBond: any;
};
deletePolymerBondChangeModel(polymerBond: PolymerBond | HydrogenBond): void;
deletePolymerBond(polymerBond: PolymerBond | HydrogenBond): Command;
cancelPolymerBondCreation(polymerBond: PolymerBond, secondMonomer?: BaseMonomer): Command;
movePolymerBond(polymerBond: PolymerBond, position: Vec2): Command;
finishPolymerBondCreationModelChange(firstMonomer: BaseMonomer, secondMonomer: BaseMonomer, firstMonomerAttachmentPoint: AttachmentPointName, secondMonomerAttachmentPoint: AttachmentPointName, bondType?: MACROMOLECULES_BOND_TYPES, _polymerBond?: PolymerBond): PolymerBond | HydrogenBond;
finishPolymerBondCreation(polymerBond: PolymerBond, secondMonomer: BaseMonomer, firstMonomerAttachmentPoint: AttachmentPointName, secondMonomerAttachmentPoint: AttachmentPointName, bondType?: MACROMOLECULES_BOND_TYPES): Command;
createPolymerBond(firstMonomer: BaseMonomer, secondMonomer: BaseMonomer, firstMonomerAttachmentPoint: AttachmentPointName, secondMonomerAttachmentPoint: AttachmentPointName, bondType?: MACROMOLECULES_BOND_TYPES): Command;
intendToStartBondCreation(monomer: BaseMonomer): Command;
intendToStartAttachmenPointBondCreation(monomer: BaseMonomer, attachmentPointName: AttachmentPointName): Command;
intendToFinishBondCreation(monomer: BaseMonomer, bond: PolymerBond, shouldCalculateBonds: boolean): Command;
intendToFinishAttachmenPointBondCreation(monomer: BaseMonomer, bond: PolymerBond, attachmentPointName: AttachmentPointName, shouldCalculateBonds: boolean): Command;
cancelIntentionToFinishBondCreation(monomer: BaseMonomer, polymerBond?: PolymerBond): Command;
intendToSelectDrawingEntity(drawingEntity: DrawingEntity): Command;
cancelIntentionToSelectDrawingEntity(drawingEntity: DrawingEntity): Command;
showPolymerBondInformation(polymerBond: PolymerBond): Command;
hidePolymerBondInformation(polymerBond: PolymerBond): Command;
hideAllMonomersHoverAndAttachmentPoints(): Command;
addRnaPresetFromNode: (node: Nucleotide | Nucleoside | LinkerSequenceNode) => Command;
addRnaPreset({ sugar, sugarPosition, phosphate, phosphatePosition, rnaBase, rnaBasePosition, }: RnaPresetAdditionParams): {
command: Command;
monomers: BaseMonomer[];
};
rearrangeChainModelChange(monomer: BaseMonomer, newPosition: Vec2): BaseMonomer;
private reArrangeChain;
private reArrangeRnaChain;
private getNextMonomerPositionForSnakeLayout;
private addRnaOperations;
private recalculateCanvasMatrixModelChange;
recalculateCanvasMatrix(chainsCollection?: ChainsCollection, previousSnakeLayoutMatrix?: Matrix<Cell>): Command;
private rearrangeAntisenseChain;
private calculateSnakeLayoutMatrix;
applySnakeLayout(canvasWidth: number, isSnakeMode: boolean, needRedrawBonds?: boolean, needRepositionMonomers?: boolean): Command;
private redrawBondsModelChange;
redrawBonds(): Command;
getNextPositionAndDistance(lastPosition: Vec2, height: number, canvasWidth: number, width: number | undefined, restOfRowsWithAntisense: number): {
maxVerticalDistance: number;
lastPosition: Vec2;
};
isNucleosideAndPhosphateConnectedAsNucleotide(nucleoside: Nucleoside, phosphate: Phosphate): boolean;
setMicromoleculesHiddenEntities(struct: Struct): void;
clearMicromoleculesHiddenEntities(): void;
mergeInto(targetDrawingEntitiesManager: DrawingEntitiesManager): {
command: Command;
mergedDrawingEntities: DrawingEntitiesManager;
};
centerMacroStructure(): void;
getCurrentCenterPointOfCanvas(): Vec2;
getMacroStructureCenter(): Vec2;
applyMonomersSequenceLayout(): ChainsCollection;
clearCanvas(): void;
applyFlexLayoutMode(needRedrawBonds?: boolean): Command;
rerenderBondsOverlappedByMonomers(): void;
getAllSelectedEntitiesForEntities(drawingEntities: DrawingEntity[]): {
command: Command;
drawingEntities: DrawingEntity[];
};
getAllSelectedEntitiesForSingleEntity(drawingEntity: DrawingEntity, needToSelectConnectedBonds?: boolean, selectedDrawingEntities?: DrawingEntity[]): {
command: Command;
drawingEntities: DrawingEntity[];
};
validateIfApplicableForFasta(): boolean;
moveMonomer(monomer: BaseMonomer, position: Vec2): Command;
removeHoverForAllMonomers(): Command;
private reconnectPolymerBondModelChange;
reconnectPolymerBond(polymerBond: PolymerBond, newFirstMonomerAttachmentPoint: AttachmentPointName, newSecondMonomerAttachmentPoint: AttachmentPointName, initialFirstMonomerAttachmentPoint: AttachmentPointName, initialSecondMonomerAttachmentPoint: AttachmentPointName): Command;
private addAmbiguousMonomerChangeModel;
addAmbiguousMonomer(ambiguousMonomerItem: AmbiguousMonomerType, position: Vec2): Command;
private addAtomChangeModel;
addAtom(position: Vec2, monomer: BaseMonomer, atomIdInMicroMode: number, label: AtomLabel, properties?: AtomProperties): Command;
private deleteAtomChangeModel;
private deleteAtom;
private addBondChangeModel;
addBond(firstAtom: Atom, secondAtom: Atom, type: number, stereo: number, bondIdInMicroMode: number): Command;
private deleteBondChangeModel;
private deleteBond;
addMonomerToAtomBondChangeModel(monomer: BaseMonomer, atom: Atom, attachmentPoint: AttachmentPointName, _monomerToAtomBond?: MonomerToAtomBond): MonomerToAtomBond;
private deleteMonomerToAtomBondChangeModel;
deleteMonomerToAtomBond(monomerAtomBond: MonomerToAtomBond): Command;
addMonomerToAtomBond(monomer: BaseMonomer, atom: Atom, attachmentPoint: AttachmentPointName): Command;
static getStructureBbox(monomers: BaseMonomer[]): {
left: number;
right: number;
top: number;
bottom: number;
width: number;
height: number;
};
private static get antisenseChainBasesMap();
markMonomerAsAntisense(monomer: BaseMonomer): Command;
markMonomerAsSense(monomer: BaseMonomer): Command;
recalculateAntisenseChains(): Command;
get hasAntisenseChains(): boolean;
private static getAntisenseBaseLabel;
static createAntisenseNode(node: Nucleoside | Nucleotide, needAddPhosphate?: boolean): {
modelChanges: Command;
node: Nucleoside;
} | {
modelChanges: Command;
node: Nucleotide;
} | undefined;
createAntisenseChain(): Command;
get monomersArray(): BaseMonomer[];
get polymerBondsArray(): (PolymerBond | HydrogenBond)[];
get molecules(): BaseMonomer[];
private checkBondForOverlapsByMonomers;
detectBondsOverlappedByMonomers(polymerBonds?: Array<PolymerBond | HydrogenBond>): void;
}
export {};