UNPKG

@rcsb/rcsb-saguaro-app

Version:
90 lines (89 loc) 4.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeatureTools = void 0; const tslib_1 = require("tslib"); const web_resources_json_1 = tslib_1.__importDefault(require("../../RcsbServerConfig/web.resources.json")); const RcsbAnnotationConstants_1 = require("../../RcsbAnnotationConfig/RcsbAnnotationConstants"); class FeatureTools { static mergeBlocks(blocks) { var _a, _b; let merged = false; do { merged = false; for (let n = 0; n < (blocks.length - 1); n++) { const end = blocks[n].end; if (!end) return; if (((_a = blocks[n].oriEnd) !== null && _a !== void 0 ? _a : Number.MIN_SAFE_INTEGER) + 1 == blocks[n + 1].oriBegin && blocks[n].color === blocks[n + 1].color) { if (blocks[n].gaps == null) blocks[n].gaps = []; (_b = blocks[n].gaps) === null || _b === void 0 ? void 0 : _b.push({ begin: end, end: blocks[n + 1].begin, isConnected: true }); blocks[n].end = blocks[n + 1].end; blocks[n].oriEnd = blocks[n + 1].oriEnd; blocks.splice((n + 1), 1); merged = true; break; } } } while (merged); } static parseLink(title) { let match = FeatureTools.rcsbLigand.exec(title); if (match) { return { visibleTex: match[3], url: web_resources_json_1.default.rcsb_ligand.url + match[3], style: { color: RcsbAnnotationConstants_1.RcsbAnnotationConstants.provenanceColorCode.rcsbLink, fontWeight: "bold" } }; } else if (title == "binding_site") { return { visibleTex: "", style: { fontWeight: "bold" } }; } return { visibleTex: title, style: { fontWeight: "bold" } }; } static mergeTrackBuilders(builderA, builderB) { return { addTo(tracks) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; yield ((_a = builderA.addTo) === null || _a === void 0 ? void 0 : _a.call(builderA, tracks)); yield ((_b = builderB === null || builderB === void 0 ? void 0 : builderB.addTo) === null || _b === void 0 ? void 0 : _b.call(builderB, tracks)); }); }, processAlignmentAndFeatures(data) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; yield ((_a = builderA.processAlignmentAndFeatures) === null || _a === void 0 ? void 0 : _a.call(builderA, data)); yield ((_b = builderB === null || builderB === void 0 ? void 0 : builderB.processAlignmentAndFeatures) === null || _b === void 0 ? void 0 : _b.call(builderB, data)); }); }, filterFeatures(data) { return tslib_1.__awaiter(this, void 0, void 0, function* () { let annotations = data.annotations; const rcsbContext = data.rcsbContext; if (builderA.filterFeatures) annotations = yield builderA.filterFeatures({ annotations, rcsbContext }); if (builderB === null || builderB === void 0 ? void 0 : builderB.filterFeatures) annotations = yield builderB.filterFeatures({ annotations, rcsbContext }); return annotations; }); }, filterAlignments(data) { return tslib_1.__awaiter(this, void 0, void 0, function* () { let alignments = data.alignments; const rcsbContext = data.rcsbContext; if (builderA.filterAlignments) alignments = yield builderA.filterAlignments({ alignments, rcsbContext }); if (builderB === null || builderB === void 0 ? void 0 : builderB.filterAlignments) alignments = yield builderB.filterAlignments({ alignments, rcsbContext }); return alignments; }); } }; } } exports.FeatureTools = FeatureTools; FeatureTools.rcsbLigand = new RegExp(/^(ligand)(\s)(\w{1,3})$/);