UNPKG

@rcsb/rcsb-saguaro-app

Version:
144 lines 7.74 kB
import { __awaiter } from "tslib"; import { AnnotationCollector } from "../../RcsbCollectTools/AnnotationCollector/AnnotationCollector"; import { ComponentsManager } from "../RcsbFvComponents/ComponentsManager"; import { SingletonMap } from "../../RcsbUtils/Helpers/SingletonMap"; import { AlignmentCollector } from "../../RcsbCollectTools/AlignmentCollector/AlignmentCollector"; import { AlignmentTrackFactory } from "../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AlignmentTrackFactory"; import { SequenceTrackFactory } from "../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/SequenceTrackFactory"; import { AlignmentBlockFactory } from "../RcsbFvFactories/RcsbFvBlockFactory/AlignmentBlockFactory"; import { AnnotationsBlockFactory } from "../RcsbFvFactories/RcsbFvBlockFactory/AnnotationsBlockFactory"; import { AnnotationsTrackFactory } from "../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AnnotationsTrackFactory"; import * as acm from "../../RcsbAnnotationConfig/RcsbAnnotationConfig.ac.json"; import { AnnotationBlockManager } from "../RcsbFvFactories/RcsbFvBlockFactory/BlockManager/AnnotationBlockManager"; import { RcsbAnnotationConfig } from "../../RcsbAnnotationConfig/RcsbAnnotationConfig"; import { AnnotationTrackManagerFactory } from "../RcsbFvFactories/RcsbFvBlockFactory/BlockManager/AnnotationTrackManager"; export class RcsbFvAbstractModule { constructor(elementId, rcsbFv) { this.boardConfigData = { length: 0 }; this.rowConfigData = new Array(); this.alignmentCollector = new AlignmentCollector(); this.annotationCollector = new AnnotationCollector(); this.alignmentTracks = []; this.annotationTracks = []; this.activeDisplayFlag = false; this.rcsbFv = rcsbFv; this.elementId = elementId; ComponentsManager.buildLoaderSpinner(elementId); } setPolymerEntityInstanceTranslator(polymerEntityInstance) { this.polymerEntityInstance = polymerEntityInstance; } getPolymerEntityInstanceTranslator() { return this.polymerEntityInstance; } display() { return __awaiter(this, void 0, void 0, function* () { console.info(`Starting display ${this.elementId}`); yield this.rcsbFv.updateBoardConfig({ boardConfigData: yield this.getBoardConfig(), rowConfigData: [] }); ComponentsManager.unmountLoaderSpinner(this.elementId); console.info(`Rendering tracks ${this.elementId}`); this.rcsbFvRowUpdatePromise = this.rcsbFv.updateBoardConfig({ rowConfigData: yield this.getRowsConfig() }); this.activeDisplayFlag = true; return void 0; }); } activeDisplay() { return this.activeDisplayFlag; } getFv() { return this.rcsbFv; } getTargets() { return __awaiter(this, void 0, void 0, function* () { return yield this.alignmentCollector.getTargets(); }); } getAlignmentResponse() { return __awaiter(this, void 0, void 0, function* () { return yield this.alignmentCollector.getAlignment(); }); } getFeatures() { return __awaiter(this, void 0, void 0, function* () { //return (await this.annotationCollector.getAnnotationFeatures()).map(af=>af.features).flat(); return yield this.annotationCollector.getFeatures(); }); } getAnnotationConfigData() { return __awaiter(this, void 0, void 0, function* () { return this.annotationTracks; }); } build(buildConfig) { return __awaiter(this, void 0, void 0, function* () { SingletonMap.update(this.elementId, this); this.buildConfig = buildConfig; yield this.protectedBuild(); yield this.buildExternalTracks(); this.concatAlignmentAndAnnotationTracks(); yield this.display(); return void 0; }); } wait() { return this.rcsbFvRowUpdatePromise; } buildAlignmentTracks(alignmentRequestContext, alignmentResponse, trackFactories) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d; const sequenceTrackFactory = (_a = trackFactories === null || trackFactories === void 0 ? void 0 : trackFactories.sequenceTrackFactory) !== null && _a !== void 0 ? _a : new SequenceTrackFactory(this.getPolymerEntityInstanceTranslator()); if (alignmentResponse.query_sequence) this.referenceTrack = yield sequenceTrackFactory.getTrack(alignmentRequestContext, alignmentResponse.query_sequence); const alignmentBlockFactory = new AlignmentBlockFactory((_b = trackFactories === null || trackFactories === void 0 ? void 0 : trackFactories.alignmentTrackFactory) !== null && _b !== void 0 ? _b : new AlignmentTrackFactory(this.getPolymerEntityInstanceTranslator()), (_d = (_c = this.buildConfig.additionalConfig) === null || _c === void 0 ? void 0 : _c.trackConfigModifier) === null || _d === void 0 ? void 0 : _d.alignment); this.alignmentTracks = yield alignmentBlockFactory.getBlock(alignmentRequestContext, alignmentResponse); }); } buildAnnotationsTrack(annotationsRequestContext, annotationsFeatures, annotationConfigMap) { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const defaultAnnotationConfigMap = annotationConfigMap !== null && annotationConfigMap !== void 0 ? annotationConfigMap : acm; const annotationsBlockFactory = new AnnotationsBlockFactory(new AnnotationBlockManager(new AnnotationTrackManagerFactory(), new RcsbAnnotationConfig(defaultAnnotationConfigMap), this.getPolymerEntityInstanceTranslator()), new AnnotationsTrackFactory(), (_b = (_a = this.buildConfig.additionalConfig) === null || _a === void 0 ? void 0 : _a.trackConfigModifier) === null || _b === void 0 ? void 0 : _b.annotations); this.annotationTracks = yield annotationsBlockFactory.getBlock(annotationsRequestContext, annotationsFeatures); }); } getBoardConfig() { return __awaiter(this, void 0, void 0, function* () { return this.boardConfigData; }); } getRowsConfig() { return __awaiter(this, void 0, void 0, function* () { return this.rowConfigData; }); } buildExternalTracks() { return __awaiter(this, void 0, void 0, function* () { var _a, _b; const externalTrackBuilder = (_a = this.buildConfig.additionalConfig) === null || _a === void 0 ? void 0 : _a.externalTrackBuilder; const rcsbContext = (_b = this.buildConfig.additionalConfig) === null || _b === void 0 ? void 0 : _b.rcsbContext; if (!externalTrackBuilder) return; if (typeof externalTrackBuilder.processAlignmentAndFeatures === "function") yield externalTrackBuilder.processAlignmentAndFeatures({ annotations: yield this.annotationCollector.getAnnotationFeatures(), alignments: yield this.alignmentCollector.getAlignment(), rcsbContext: rcsbContext }); if (typeof externalTrackBuilder.addTo === "function") yield externalTrackBuilder.addTo({ alignmentTracks: this.alignmentTracks, annotationTracks: this.annotationTracks, rcsbContext: rcsbContext }); return void 0; }); } } //# sourceMappingURL=RcsbFvAbstractModule.js.map