UNPKG

@rcsb/rcsb-saguaro-app

Version:
113 lines 7.89 kB
import { __awaiter } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import React from "react"; import { FieldName, OperationType, AnnotationReference, } from "@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes"; import { searchRequestProperty } from "../../RcsbSeacrh/SearchRequestProperty"; import { ReturnType } from "@rcsb/rcsb-api-tools/lib/RcsbSearch/Types/SearchEnums"; import { RcsbTabs } from "../RcsbFvComponents/RcsbTabs"; import { GroupProvenanceId } from "@rcsb/rcsb-api-tools/lib/RcsbDw/Types/DwEnums"; import { SearchQueryTools as SQT } from "../../RcsbSeacrh/SearchQueryTools"; import { GroupPfvApp as GPA } from "./GroupTabs/GroupPfvApp"; import { asyncScheduler } from "rxjs"; const ALIGNMENT = "alignment"; const STRUCTURAL_FEATURES = "structural-features"; const BINDING_SITES = "binding-sites"; export class GroupPfvTabs extends React.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 === GroupProvenanceId.ProvenanceMatchingUniprotAccession ? _jsx("div", { id: ALIGNMENT + RcsbTabs.SELECT_SUFFIX, style: { height: 38 } }) : undefined }; return (_jsx(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 __awaiter(this, void 0, void 0, function* () { if (this.props.searchQuery && this.props.searchQuery.query) { this.filterEntities = yield searchRequestProperty.requestMembers(Object.assign(Object.assign({}, this.props.searchQuery), { query: SQT.addGroupNodeToSearchQuery(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery.query), return_type: ReturnType.PolymerEntity })); this.entityCount = this.filterEntities.length; this.filterInstances = yield searchRequestProperty.requestMembers(Object.assign(Object.assign({}, this.props.searchQuery), { query: SQT.addGroupNodeToSearchQuery(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery.query), return_type: ReturnType.PolymerInstance })); yield this.onSelect(this.currentTab); } else { this.filterInstances = yield searchRequestProperty.requestMembers({ query: SQT.searchGroupQuery(this.props.groupProvenanceId, this.props.groupId), return_type: ReturnType.PolymerInstance }); this.entityCount = yield searchRequestProperty.requestCount({ query: SQT.searchGroupQuery(this.props.groupProvenanceId, this.props.groupId), return_type: 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 __awaiter(this, void 0, void 0, function* () { asyncScheduler.schedule(() => __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 __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 GPA.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 GPA.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: AnnotationReference.PdbInstance, field: FieldName.TargetId, operation: OperationType.Equals, values: (_d = this.filterInstances) !== null && _d !== void 0 ? _d : [] }] : undefined }))); break; case STRUCTURAL_FEATURES: this.featureViewers.set(tabKey, yield GPA.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: AnnotationReference.PdbInstance, field: FieldName.TargetId, operation: OperationType.Equals, values: (_g = this.filterInstances) !== null && _g !== void 0 ? _g : [] }, { source: AnnotationReference.PdbEntity, field: FieldName.TargetId, operation: OperationType.Equals, values: (_h = this.filterEntities) !== null && _h !== void 0 ? _h : [] }] : undefined }))); break; } }); } } //# sourceMappingURL=GroupPfvTabs.js.map