@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
98 lines • 4.86 kB
JavaScript
import { __awaiter } from "tslib";
import { RcsbAnnotationConstants } from "../../RcsbAnnotationConfig/RcsbAnnotationConstants";
import { groupExternalTrackBuilder } from "./GroupExternalTrackBuilder";
import { Assertions } from "../Helpers/Assertions";
var assertDefined = Assertions.assertDefined;
export function alignmentGlobalLigandBindingSite(groupProvenance) {
const trackName = "GLOBAL BINDING";
const bindingSiteMap = new Map();
let max = 0;
const groupTrackBuilder = groupExternalTrackBuilder(groupProvenance);
return {
addTo(tracks) {
return __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.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 __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 __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;
}
}
}
});
});
});
}
}
//# sourceMappingURL=AlignmentGlobalBindingSite.js.map