UNPKG

@rcsb/rcsb-saguaro-app

Version:
86 lines 4.25 kB
import { __awaiter } from "tslib"; import resource from "../../RcsbServerConfig/web.resources.json"; import { RcsbAnnotationConstants } from "../../RcsbAnnotationConfig/RcsbAnnotationConstants"; export 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: resource.rcsb_ligand.url + match[3], style: { color: 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 __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 __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 __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 __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; }); } }; } } FeatureTools.rcsbLigand = new RegExp(/^(ligand)(\s)(\w{1,3})$/); //# sourceMappingURL=FeatureTools.js.map