UNPKG

@rcsb/rcsb-saguaro-app

Version:
101 lines (100 loc) 5.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.alignmentGlobalLigandBindingSite = alignmentGlobalLigandBindingSite; const tslib_1 = require("tslib"); const RcsbAnnotationConstants_1 = require("../../RcsbAnnotationConfig/RcsbAnnotationConstants"); const GroupExternalTrackBuilder_1 = require("./GroupExternalTrackBuilder"); const Assertions_1 = require("../Helpers/Assertions"); var assertDefined = Assertions_1.Assertions.assertDefined; function alignmentGlobalLigandBindingSite(groupProvenance) { const trackName = "GLOBAL BINDING"; const bindingSiteMap = new Map(); let max = 0; const groupTrackBuilder = (0, GroupExternalTrackBuilder_1.groupExternalTrackBuilder)(groupProvenance); return { addTo(tracks) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a; if (Array.from(bindingSiteMap.values()).length > 0) tracks.annotationTracks.unshift({ trackId: "annotationTrack_GLOBAL_BINDINGS", trackHeight: 40, displayType: "area" /* RcsbFvDisplayTypes.AREA */, overlap: true, trackColor: "#F9F9F9", displayColor: "#c4124b", titleFlagColor: RcsbAnnotationConstants_1.RcsbAnnotationConstants.provenanceColorCode.rcsbPdb, rowTitle: trackName, displayDomain: [0, max], interpolationType: "step" /* InterpolationTypes.STEP */, trackData: Array.from(bindingSiteMap.values()) }); yield ((_a = groupTrackBuilder.addTo) === null || _a === void 0 ? void 0 : _a.call(groupTrackBuilder, tracks)); }); }, processAlignmentAndFeatures(data) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a; yield ((_a = groupTrackBuilder.processAlignmentAndFeatures) === null || _a === void 0 ? void 0 : _a.call(groupTrackBuilder, data)); processFeatures(data.annotations); }); }, filterFeatures(data) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; const annotations = (_b = yield ((_a = groupTrackBuilder.filterFeatures) === null || _a === void 0 ? void 0 : _a.call(groupTrackBuilder, data))) !== null && _b !== void 0 ? _b : []; annotations.forEach(ann => { var _a; ann.features = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.filter(f => { var _a; return f ? (_a = f.name) === null || _a === void 0 ? void 0 : _a.includes("ligand") : false; }); }); return new Promise((resolve => { resolve(annotations); })); }); }, filterAlignments(data) { assertDefined(groupTrackBuilder.filterAlignments); return groupTrackBuilder.filterAlignments(data); } }; function processFeatures(annotations) { // position > ligand name const ligandMap = new Map(); annotations.forEach(ann => { var _a; (_a = ann.features) === null || _a === void 0 ? void 0 : _a.forEach(d => { var _a; if (d) (_a = d.feature_positions) === null || _a === void 0 ? void 0 : _a.forEach(p => { var _a, _b; if (p === null || p === void 0 ? void 0 : p.beg_seq_id) { const key = (p.beg_seq_id).toString(); if (!ligandMap.has(key)) ligandMap.set(key, new Set()); if (d.name && !((_a = ligandMap.get(key)) === null || _a === void 0 ? void 0 : _a.has(d.name))) (_b = ligandMap.get(key)) === null || _b === void 0 ? void 0 : _b.add(d.name); else return; const bs = bindingSiteMap.get(key); if (!bs) { bindingSiteMap.set(key, { begin: p.beg_seq_id, type: trackName, value: 1 }); if (max == 0) max = 1; } else { if (bs) { bs.value += 1; if (bs.value > max) max = bs.value; } } } }); }); }); } }