UNPKG

@rcsb/rcsb-saguaro-app

Version:
148 lines (147 loc) 8.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbFvAbstractModule = void 0; const tslib_1 = require("tslib"); const AnnotationCollector_1 = require("../../RcsbCollectTools/AnnotationCollector/AnnotationCollector"); const ComponentsManager_1 = require("../RcsbFvComponents/ComponentsManager"); const SingletonMap_1 = require("../../RcsbUtils/Helpers/SingletonMap"); const AlignmentCollector_1 = require("../../RcsbCollectTools/AlignmentCollector/AlignmentCollector"); const AlignmentTrackFactory_1 = require("../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AlignmentTrackFactory"); const SequenceTrackFactory_1 = require("../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/SequenceTrackFactory"); const AlignmentBlockFactory_1 = require("../RcsbFvFactories/RcsbFvBlockFactory/AlignmentBlockFactory"); const AnnotationsBlockFactory_1 = require("../RcsbFvFactories/RcsbFvBlockFactory/AnnotationsBlockFactory"); const AnnotationsTrackFactory_1 = require("../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/AnnotationsTrackFactory"); const acm = tslib_1.__importStar(require("../../RcsbAnnotationConfig/RcsbAnnotationConfig.ac.json")); const AnnotationBlockManager_1 = require("../RcsbFvFactories/RcsbFvBlockFactory/BlockManager/AnnotationBlockManager"); const RcsbAnnotationConfig_1 = require("../../RcsbAnnotationConfig/RcsbAnnotationConfig"); const AnnotationTrackManager_1 = require("../RcsbFvFactories/RcsbFvBlockFactory/BlockManager/AnnotationTrackManager"); class RcsbFvAbstractModule { constructor(elementId, rcsbFv) { this.boardConfigData = { length: 0 }; this.rowConfigData = new Array(); this.alignmentCollector = new AlignmentCollector_1.AlignmentCollector(); this.annotationCollector = new AnnotationCollector_1.AnnotationCollector(); this.alignmentTracks = []; this.annotationTracks = []; this.activeDisplayFlag = false; this.rcsbFv = rcsbFv; this.elementId = elementId; ComponentsManager_1.ComponentsManager.buildLoaderSpinner(elementId); } setPolymerEntityInstanceTranslator(polymerEntityInstance) { this.polymerEntityInstance = polymerEntityInstance; } getPolymerEntityInstanceTranslator() { return this.polymerEntityInstance; } display() { return tslib_1.__awaiter(this, void 0, void 0, function* () { console.info(`Starting display ${this.elementId}`); yield this.rcsbFv.updateBoardConfig({ boardConfigData: yield this.getBoardConfig(), rowConfigData: [] }); ComponentsManager_1.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 tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.alignmentCollector.getTargets(); }); } getAlignmentResponse() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.alignmentCollector.getAlignment(); }); } getFeatures() { return tslib_1.__awaiter(this, void 0, void 0, function* () { //return (await this.annotationCollector.getAnnotationFeatures()).map(af=>af.features).flat(); return yield this.annotationCollector.getFeatures(); }); } getAnnotationConfigData() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.annotationTracks; }); } build(buildConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { SingletonMap_1.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 tslib_1.__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_1.SequenceTrackFactory(this.getPolymerEntityInstanceTranslator()); if (alignmentResponse.query_sequence) this.referenceTrack = yield sequenceTrackFactory.getTrack(alignmentRequestContext, alignmentResponse.query_sequence); const alignmentBlockFactory = new AlignmentBlockFactory_1.AlignmentBlockFactory((_b = trackFactories === null || trackFactories === void 0 ? void 0 : trackFactories.alignmentTrackFactory) !== null && _b !== void 0 ? _b : new AlignmentTrackFactory_1.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 tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; const defaultAnnotationConfigMap = annotationConfigMap !== null && annotationConfigMap !== void 0 ? annotationConfigMap : acm; const annotationsBlockFactory = new AnnotationsBlockFactory_1.AnnotationsBlockFactory(new AnnotationBlockManager_1.AnnotationBlockManager(new AnnotationTrackManager_1.AnnotationTrackManagerFactory(), new RcsbAnnotationConfig_1.RcsbAnnotationConfig(defaultAnnotationConfigMap), this.getPolymerEntityInstanceTranslator()), new AnnotationsTrackFactory_1.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 tslib_1.__awaiter(this, void 0, void 0, function* () { return this.boardConfigData; }); } getRowsConfig() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.rowConfigData; }); } buildExternalTracks() { return tslib_1.__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; }); } } exports.RcsbFvAbstractModule = RcsbFvAbstractModule;