@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
117 lines (116 loc) • 8.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupPfvTabs = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const GqlTypes_1 = require("@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes");
const SearchRequestProperty_1 = require("../../RcsbSeacrh/SearchRequestProperty");
const SearchEnums_1 = require("@rcsb/rcsb-api-tools/lib/RcsbSearch/Types/SearchEnums");
const RcsbTabs_1 = require("../RcsbFvComponents/RcsbTabs");
const DwEnums_1 = require("@rcsb/rcsb-api-tools/lib/RcsbDw/Types/DwEnums");
const SearchQueryTools_1 = require("../../RcsbSeacrh/SearchQueryTools");
const GroupPfvApp_1 = require("./GroupTabs/GroupPfvApp");
const rxjs_1 = require("rxjs");
const ALIGNMENT = "alignment";
const STRUCTURAL_FEATURES = "structural-features";
const BINDING_SITES = "binding-sites";
class GroupPfvTabs extends react_1.default.Component {
constructor(props) {
super(props);
this.featureViewers = new Map();
this.filterInstances = undefined;
this.filterEntities = undefined;
this.entityCount = undefined;
this.currentTab = ALIGNMENT;
}
render() {
const additionalComponent = {
additionalComponent: this.props.groupProvenanceId === DwEnums_1.GroupProvenanceId.ProvenanceMatchingUniprotAccession ? (0, jsx_runtime_1.jsx)("div", { id: ALIGNMENT + RcsbTabs_1.RcsbTabs.SELECT_SUFFIX, style: { height: 38 } }) : undefined
};
return ((0, jsx_runtime_1.jsx)(RcsbTabs_1.RcsbTabs, { id: "group-id", tabList: [
Object.assign({ key: ALIGNMENT, title: "Sequence Alignments" }, additionalComponent),
Object.assign({ key: STRUCTURAL_FEATURES, title: "Structural Features" }, additionalComponent),
Object.assign({ key: BINDING_SITES, title: "Binding Sites" }, additionalComponent)
], default: "alignment", onMount: this.onMount.bind(this), onSelect: this.onSelect.bind(this) }));
}
onMount() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (this.props.searchQuery && this.props.searchQuery.query) {
this.filterEntities = yield SearchRequestProperty_1.searchRequestProperty.requestMembers(Object.assign(Object.assign({}, this.props.searchQuery), { query: SearchQueryTools_1.SearchQueryTools.addGroupNodeToSearchQuery(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery.query), return_type: SearchEnums_1.ReturnType.PolymerEntity }));
this.entityCount = this.filterEntities.length;
this.filterInstances = yield SearchRequestProperty_1.searchRequestProperty.requestMembers(Object.assign(Object.assign({}, this.props.searchQuery), { query: SearchQueryTools_1.SearchQueryTools.addGroupNodeToSearchQuery(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery.query), return_type: SearchEnums_1.ReturnType.PolymerInstance }));
yield this.onSelect(this.currentTab);
}
else {
this.filterInstances = yield SearchRequestProperty_1.searchRequestProperty.requestMembers({ query: SearchQueryTools_1.SearchQueryTools.searchGroupQuery(this.props.groupProvenanceId, this.props.groupId), return_type: SearchEnums_1.ReturnType.PolymerInstance });
this.entityCount = yield SearchRequestProperty_1.searchRequestProperty.requestCount({ query: SearchQueryTools_1.SearchQueryTools.searchGroupQuery(this.props.groupProvenanceId, this.props.groupId), return_type: SearchEnums_1.ReturnType.PolymerEntity });
yield this.onSelect(this.currentTab);
}
});
}
syncPositionAndHighlight(tabKey) {
var _a, _b, _c, _d, _e, _f, _g;
if (tabKey !== this.currentTab) {
const dom = (_a = this.featureViewers.get(this.currentTab)) === null || _a === void 0 ? void 0 : _a.getFv().getDomain();
if (dom)
(_b = this.featureViewers.get(tabKey)) === null || _b === void 0 ? void 0 : _b.getFv().setDomain(dom);
const sel = (_c = this.featureViewers.get(this.currentTab)) === null || _c === void 0 ? void 0 : _c.getFv().getSelection("select");
if (sel && (sel === null || sel === void 0 ? void 0 : sel.length) > 0) {
(_d = this.featureViewers.get(tabKey)) === null || _d === void 0 ? void 0 : _d.getFv().clearSelection("select");
(_e = this.featureViewers.get(tabKey)) === null || _e === void 0 ? void 0 : _e.getFv().setSelection({
elements: (_f = sel === null || sel === void 0 ? void 0 : sel.map((s) => ({
begin: s.rcsbFvTrackDataElement.begin,
end: s.rcsbFvTrackDataElement.end
}))) !== null && _f !== void 0 ? _f : [],
mode: "select"
});
}
else {
(_g = this.featureViewers.get(tabKey)) === null || _g === void 0 ? void 0 : _g.getFv().clearSelection("select");
}
}
}
onSelect(tabKey) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
rxjs_1.asyncScheduler.schedule(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!this.featureViewers.has(tabKey))
yield this.renderPositionalFeatureViewer(tabKey);
this.syncPositionAndHighlight(tabKey);
this.currentTab = tabKey;
}), 10);
});
}
renderPositionalFeatureViewer(tabKey) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h;
switch (tabKey) {
case ALIGNMENT:
this.featureViewers.set(tabKey, yield GroupPfvApp_1.GroupPfvApp.alignment(tabKey.toString(), this.props.groupProvenanceId, this.props.groupId, (_a = this.entityCount) !== null && _a !== void 0 ? _a : 0, Object.assign(Object.assign({ page: { first: 50, after: 0 } }, this.props.additionalConfig), { alignmentFilter: this.filterEntities })));
break;
case BINDING_SITES:
this.featureViewers.set(tabKey, yield GroupPfvApp_1.GroupPfvApp.bindingSites(tabKey.toString(), this.props.groupProvenanceId, this.props.groupId, (_c = (_b = this.filterInstances) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0, Object.assign(Object.assign({ page: { first: 1, after: 0 } }, this.props.additionalConfig), { alignmentFilter: this.props.searchQuery ? this.filterEntities : undefined, filters: this.props.searchQuery ? [{
source: GqlTypes_1.AnnotationReference.PdbInstance,
field: GqlTypes_1.FieldName.TargetId,
operation: GqlTypes_1.OperationType.Equals,
values: (_d = this.filterInstances) !== null && _d !== void 0 ? _d : []
}] : undefined })));
break;
case STRUCTURAL_FEATURES:
this.featureViewers.set(tabKey, yield GroupPfvApp_1.GroupPfvApp.structure(tabKey.toString(), this.props.groupProvenanceId, this.props.groupId, (_f = (_e = this.filterInstances) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0, Object.assign(Object.assign({ page: { first: 1, after: 0 } }, this.props.additionalConfig), { alignmentFilter: this.props.searchQuery ? this.filterEntities : undefined, filters: this.props.searchQuery ? [{
source: GqlTypes_1.AnnotationReference.PdbInstance,
field: GqlTypes_1.FieldName.TargetId,
operation: GqlTypes_1.OperationType.Equals,
values: (_g = this.filterInstances) !== null && _g !== void 0 ? _g : []
}, {
source: GqlTypes_1.AnnotationReference.PdbEntity,
field: GqlTypes_1.FieldName.TargetId,
operation: GqlTypes_1.OperationType.Equals,
values: (_h = this.filterEntities) !== null && _h !== void 0 ? _h : []
}] : undefined })));
break;
}
});
}
}
exports.GroupPfvTabs = GroupPfvTabs;