UNPKG

@rcsb/rcsb-saguaro-app

Version:
142 lines (141 loc) 10.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupPfvApp = void 0; exports.getReferenceFromGroupProvenance = getReferenceFromGroupProvenance; const tslib_1 = require("tslib"); const DwEnums_1 = require("@rcsb/rcsb-api-tools/lib/RcsbDw/Types/DwEnums"); const RcsbFvUniprotBuilder_1 = require("../../RcsbFvBuilder/RcsbFvUniprotBuilder"); const GroupExternalTrackBuilder_1 = require("../../../RcsbUtils/TrackGenerators/GroupExternalTrackBuilder"); const RcsbFvGroupBuilder_1 = require("../../RcsbFvBuilder/RcsbFvGroupBuilder"); const GqlTypes_1 = require("@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes"); const AlignmentGlobalBindingSite_1 = require("../../../RcsbUtils/TrackGenerators/AlignmentGlobalBindingSite"); const RcsbTabs_1 = require("../../RcsbFvComponents/RcsbTabs"); const GroupPfvUI_1 = require("../../../RcsbFvUI/GroupPfvUI"); const ActionMethods_1 = require("../../../RcsbFvUI/Helper/ActionMethods"); const PaginationItemComponent_1 = require("../../../RcsbFvUI/Components/PaginationItemComponent"); var GroupPfvApp; (function (GroupPfvApp) { function alignment(elementId, groupProvenanceId, groupId, entityCount, additionalConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j; switch (groupProvenanceId) { case DwEnums_1.GroupProvenanceId.ProvenanceMatchingUniprotAccession: return RcsbFvUniprotBuilder_1.RcsbFvUniprotBuilder.buildUniprotMultipleEntitySequenceFv(elementId, elementId + RcsbTabs_1.RcsbTabs.SELECT_SUFFIX, groupId, {}, additionalConfig); default: additionalConfig = Object.assign(Object.assign({}, additionalConfig), { externalTrackBuilder: (0, GroupExternalTrackBuilder_1.groupExternalTrackBuilder)(groupProvenanceId) }); // SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes const pfvArgs = [ getReferenceFromGroupProvenance(groupProvenanceId), groupId, GqlTypes_1.SequenceReference.PdbEntity, GqlTypes_1.SequenceReference.Uniprot ]; const pfv = yield RcsbFvGroupBuilder_1.RcsbFvGroupBuilder.buildGroupAlignmentFv(elementId, ...pfvArgs, additionalConfig); const paginationCallback = ActionMethods_1.ActionMethods.paginationCallback(); const uiComp = { component: PaginationItemComponent_1.PaginationItemComponent, props: { count: entityCount, after: (_b = (_a = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.page) === null || _a === void 0 ? void 0 : _a.after) !== null && _b !== void 0 ? _b : 0, first: (_d = (_c = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.page) === null || _c === void 0 ? void 0 : _c.first) !== null && _d !== void 0 ? _d : 50, stateChange: (state, prevState) => { paginationCallback(elementId, pfv, RcsbFvGroupBuilder_1.RcsbFvGroupBuilder.buildGroupAlignmentFv, pfvArgs, Object.assign(Object.assign({}, additionalConfig), { page: { first: state.first, after: state.after }, excludeLogo: true })); } } }; GroupPfvUI_1.GroupPfvUI.fvUI(GroupPfvUI_1.GroupPfvUI.addBootstrapElement(elementId), (_f = (_e = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.externalUiComponents) === null || _e === void 0 ? void 0 : _e.replace) !== null && _f !== void 0 ? _f : (entityCount > ((_h = (_g = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.page) === null || _g === void 0 ? void 0 : _g.first) !== null && _h !== void 0 ? _h : 50) ? [uiComp] : []).concat(((_j = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.externalUiComponents) === null || _j === void 0 ? void 0 : _j.add) ? additionalConfig.externalUiComponents.add : [])); return pfv; } }); } GroupPfvApp.alignment = alignment; function structure(elementId, groupProvenanceId, groupId, nTargets, additionalConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a; additionalConfig = Object.assign(Object.assign({}, additionalConfig), { filters: [...((_a = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.filters) !== null && _a !== void 0 ? _a : []), { field: GqlTypes_1.FieldName.Type, values: [GqlTypes_1.FeaturesType.HelixP, GqlTypes_1.FeaturesType.Sheet, GqlTypes_1.FeaturesType.Cath, GqlTypes_1.FeaturesType.Scop], operation: GqlTypes_1.OperationType.Equals, source: GqlTypes_1.AnnotationReference.PdbInstance }, { field: GqlTypes_1.FieldName.Type, values: [GqlTypes_1.FeaturesType.Pfam], operation: GqlTypes_1.OperationType.Equals, source: GqlTypes_1.AnnotationReference.PdbEntity }], sources: [GqlTypes_1.AnnotationReference.PdbInstance, GqlTypes_1.AnnotationReference.PdbEntity], annotationProcessing: annotationPositionFrequencyProcessing(nTargets), externalTrackBuilder: (0, GroupExternalTrackBuilder_1.groupExternalTrackBuilder)(groupProvenanceId) }); // SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes const pfvArgs = [ getReferenceFromGroupProvenance(groupProvenanceId), groupId, GqlTypes_1.SequenceReference.PdbEntity, GqlTypes_1.SequenceReference.Uniprot ]; return yield RcsbFvGroupBuilder_1.RcsbFvGroupBuilder.buildGroupAnnotationFv(elementId, ...pfvArgs, additionalConfig); }); } GroupPfvApp.structure = structure; function bindingSites(elementId, groupProvenanceId, groupId, nTargets, additionalConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a; additionalConfig = Object.assign(Object.assign({}, additionalConfig), { filters: [...((_a = additionalConfig === null || additionalConfig === void 0 ? void 0 : additionalConfig.filters) !== null && _a !== void 0 ? _a : []), { field: GqlTypes_1.FieldName.Type, values: [GqlTypes_1.FeaturesType.BindingSite], operation: GqlTypes_1.OperationType.Equals, source: GqlTypes_1.AnnotationReference.PdbInstance }], sources: [GqlTypes_1.AnnotationReference.PdbInstance], annotationProcessing: annotationPositionFrequencyProcessing(nTargets), externalTrackBuilder: (0, AlignmentGlobalBindingSite_1.alignmentGlobalLigandBindingSite)(groupProvenanceId), isAnnotationsGroupSummary: false }); // SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes const pfvArgs = [ getReferenceFromGroupProvenance(groupProvenanceId), groupId, GqlTypes_1.SequenceReference.PdbEntity, GqlTypes_1.SequenceReference.Uniprot ]; return yield RcsbFvGroupBuilder_1.RcsbFvGroupBuilder.buildGroupAnnotationFv(elementId, ...pfvArgs, additionalConfig); }); } GroupPfvApp.bindingSites = bindingSites; })(GroupPfvApp || (exports.GroupPfvApp = GroupPfvApp = {})); function annotationPositionFrequencyProcessing(nTargets) { const targetValues = new Map(); const targetSet = new Map(); return { getAnnotationValue: (feature) => { var _a, _b, _c, _d; if (!targetValues.has(feature.type)) targetValues.set(feature.type, 0); if (!targetSet.has(feature.type)) targetSet.set(feature.type, new Set()); if (feature.type === "SCOP:Prokaryotic (50S subunit)") console.log(feature); if (typeof feature.d.value === "number") targetValues.set(feature.type, (_a = feature.d.value) !== null && _a !== void 0 ? _a : 0); else (_b = targetSet.get(feature.type)) === null || _b === void 0 ? void 0 : _b.add(feature.targetId); return (_d = (_c = feature.p.values) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 1; }, computeAnnotationValue: (annotationTracks) => { annotationTracks.forEach((at, type) => { var _a; const isType = (type.includes(GqlTypes_1.FeaturesType.Cath) || type.includes(GqlTypes_1.FeaturesType.Scop) || type.includes(GqlTypes_1.FeaturesType.BindingSite) || type.includes(GqlTypes_1.FeaturesType.Pfam)); const N = isType ? (targetValues.get(type) != 0 ? targetValues.get(type) : (_a = targetSet.get(type)) === null || _a === void 0 ? void 0 : _a.size) : nTargets; at.forEach((ann, positionKey) => { if (ann.source != GqlTypes_1.AnnotationReference.PdbInterface) ann.value = Math.round(100 * ann.value / (N !== null && N !== void 0 ? N : 1)) / 100; }); }); } }; } function getReferenceFromGroupProvenance(groupProvenanceId) { switch (groupProvenanceId) { case DwEnums_1.GroupProvenanceId.ProvenanceMatchingDepositGroupId: throw `Undefined reference for provenance ${groupProvenanceId}`; case DwEnums_1.GroupProvenanceId.ProvenanceSequenceIdentity: return GqlTypes_1.GroupReference.SequenceIdentity; case DwEnums_1.GroupProvenanceId.ProvenanceMatchingUniprotAccession: return GqlTypes_1.GroupReference.MatchingUniprotAccession; } }