@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
138 lines • 9.59 kB
JavaScript
import { __awaiter } from "tslib";
import { GroupProvenanceId } from "@rcsb/rcsb-api-tools/lib/RcsbDw/Types/DwEnums";
import { RcsbFvUniprotBuilder } from "../../RcsbFvBuilder/RcsbFvUniprotBuilder";
import { groupExternalTrackBuilder } from "../../../RcsbUtils/TrackGenerators/GroupExternalTrackBuilder";
import { RcsbFvGroupBuilder } from "../../RcsbFvBuilder/RcsbFvGroupBuilder";
import { AnnotationReference, FeaturesType, FieldName, GroupReference, OperationType, SequenceReference } from "@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes";
import { alignmentGlobalLigandBindingSite } from "../../../RcsbUtils/TrackGenerators/AlignmentGlobalBindingSite";
import { RcsbTabs } from "../../RcsbFvComponents/RcsbTabs";
import { GroupPfvUI } from "../../../RcsbFvUI/GroupPfvUI";
import { ActionMethods } from "../../../RcsbFvUI/Helper/ActionMethods";
import { PaginationItemComponent } from "../../../RcsbFvUI/Components/PaginationItemComponent";
export var GroupPfvApp;
(function (GroupPfvApp) {
function alignment(elementId, groupProvenanceId, groupId, entityCount, additionalConfig) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
switch (groupProvenanceId) {
case GroupProvenanceId.ProvenanceMatchingUniprotAccession:
return RcsbFvUniprotBuilder.buildUniprotMultipleEntitySequenceFv(elementId, elementId + RcsbTabs.SELECT_SUFFIX, groupId, {}, additionalConfig);
default:
additionalConfig = Object.assign(Object.assign({}, additionalConfig), { externalTrackBuilder: groupExternalTrackBuilder(groupProvenanceId) });
// SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes
const pfvArgs = [
getReferenceFromGroupProvenance(groupProvenanceId),
groupId,
SequenceReference.PdbEntity,
SequenceReference.Uniprot
];
const pfv = yield RcsbFvGroupBuilder.buildGroupAlignmentFv(elementId, ...pfvArgs, additionalConfig);
const paginationCallback = ActionMethods.paginationCallback();
const uiComp = {
component: 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.buildGroupAlignmentFv, pfvArgs, Object.assign(Object.assign({}, additionalConfig), { page: {
first: state.first,
after: state.after
}, excludeLogo: true }));
}
}
};
GroupPfvUI.fvUI(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 __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: FieldName.Type,
values: [FeaturesType.HelixP, FeaturesType.Sheet, FeaturesType.Cath, FeaturesType.Scop],
operation: OperationType.Equals,
source: AnnotationReference.PdbInstance
}, {
field: FieldName.Type,
values: [FeaturesType.Pfam],
operation: OperationType.Equals,
source: AnnotationReference.PdbEntity
}], sources: [AnnotationReference.PdbInstance, AnnotationReference.PdbEntity], annotationProcessing: annotationPositionFrequencyProcessing(nTargets), externalTrackBuilder: groupExternalTrackBuilder(groupProvenanceId) });
// SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes
const pfvArgs = [
getReferenceFromGroupProvenance(groupProvenanceId),
groupId,
SequenceReference.PdbEntity,
SequenceReference.Uniprot
];
return yield RcsbFvGroupBuilder.buildGroupAnnotationFv(elementId, ...pfvArgs, additionalConfig);
});
}
GroupPfvApp.structure = structure;
function bindingSites(elementId, groupProvenanceId, groupId, nTargets, additionalConfig) {
return __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: FieldName.Type,
values: [FeaturesType.BindingSite],
operation: OperationType.Equals,
source: AnnotationReference.PdbInstance
}], sources: [AnnotationReference.PdbInstance], annotationProcessing: annotationPositionFrequencyProcessing(nTargets), externalTrackBuilder: alignmentGlobalLigandBindingSite(groupProvenanceId), isAnnotationsGroupSummary: false });
// SequenceReference.PdbEntity && SequenceReference.Uniprot are needed to add row prefixes
const pfvArgs = [
getReferenceFromGroupProvenance(groupProvenanceId),
groupId,
SequenceReference.PdbEntity,
SequenceReference.Uniprot
];
return yield RcsbFvGroupBuilder.buildGroupAnnotationFv(elementId, ...pfvArgs, additionalConfig);
});
}
GroupPfvApp.bindingSites = bindingSites;
})(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(FeaturesType.Cath) || type.includes(FeaturesType.Scop) || type.includes(FeaturesType.BindingSite) || type.includes(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 != AnnotationReference.PdbInterface)
ann.value = Math.round(100 * ann.value / (N !== null && N !== void 0 ? N : 1)) / 100;
});
});
}
};
}
export function getReferenceFromGroupProvenance(groupProvenanceId) {
switch (groupProvenanceId) {
case GroupProvenanceId.ProvenanceMatchingDepositGroupId:
throw `Undefined reference for provenance ${groupProvenanceId}`;
case GroupProvenanceId.ProvenanceSequenceIdentity:
return GroupReference.SequenceIdentity;
case GroupProvenanceId.ProvenanceMatchingUniprotAccession:
return GroupReference.MatchingUniprotAccession;
}
}
//# sourceMappingURL=GroupPfvApp.js.map