@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
91 lines (90 loc) • 6.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RcsbFvGroupAlignment = void 0;
const tslib_1 = require("tslib");
const RcsbFvAbstractModule_1 = require("./RcsbFvAbstractModule");
const GqlTypes_1 = require("@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes");
const MsaAlignmentTrackFactory_1 = require("../RcsbFvFactories/RcsbFvTrackFactory/TrackFactoryImpl/MsaAlignmentTrackFactory");
const Assertions_1 = require("../../RcsbUtils/Helpers/Assertions");
var assertDefined = Assertions_1.Assertions.assertDefined;
const Operator_1 = require("../../RcsbUtils/Helpers/Operator");
const RcsbRequestContextManager_1 = require("../../RcsbRequest/RcsbRequestContextManager");
class RcsbFvGroupAlignment extends RcsbFvAbstractModule_1.RcsbFvAbstractModule {
protectedBuild() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const buildConfig = this.buildConfig;
assertDefined(buildConfig.groupId), assertDefined(buildConfig.group), assertDefined((_a = buildConfig.additionalConfig) === null || _a === void 0 ? void 0 : _a.page);
const alignmentRequestContext = {
group: buildConfig.group,
groupId: buildConfig.groupId,
filter: (_b = buildConfig.additionalConfig) === null || _b === void 0 ? void 0 : _b.alignmentFilter,
page: (_c = buildConfig.additionalConfig) === null || _c === void 0 ? void 0 : _c.page,
excludeLogo: (_d = buildConfig.additionalConfig) === null || _d === void 0 ? void 0 : _d.excludeLogo,
from: buildConfig.from,
to: buildConfig.to,
dynamicDisplay: false,
fitTitleWidth: true,
excludeFirstRowLink: true,
sequencePrefix: (_f = (_e = buildConfig.additionalConfig) === null || _e === void 0 ? void 0 : _e.sequencePrefix) !== null && _f !== void 0 ? _f : "",
externalTrackBuilder: (_g = buildConfig.additionalConfig) === null || _g === void 0 ? void 0 : _g.externalTrackBuilder
};
const alignmentResponse = yield this.alignmentCollector.collect(alignmentRequestContext, (_h = buildConfig.additionalConfig) === null || _h === void 0 ? void 0 : _h.alignmentFilter);
const trackFactory = new MsaAlignmentTrackFactory_1.MsaAlignmentTrackFactory(this.getPolymerEntityInstanceTranslator());
const targetList = yield uniqueTargetList(alignmentResponse);
const alignmentFeatures = yield collectFeatures({
groupId: buildConfig.groupId,
externalTrackBuilder: (_j = buildConfig.additionalConfig) === null || _j === void 0 ? void 0 : _j.externalTrackBuilder,
targetList
}, this.annotationCollector);
yield trackFactory.prepareFeatures(alignmentFeatures.map(af => { var _a; return (Object.assign(Object.assign({}, af), { feature: (_a = af.features) === null || _a === void 0 ? void 0 : _a.filter(f => (f === null || f === void 0 ? void 0 : f.type) == GqlTypes_1.FeaturesType.UnobservedResidueXyz) })); }), alignmentFeatures.map(af => { var _a; return (Object.assign(Object.assign({}, af), { feature: (_a = af.features) === null || _a === void 0 ? void 0 : _a.filter(f => (f === null || f === void 0 ? void 0 : f.type) == GqlTypes_1.FeaturesType.MaQaMetricLocalTypePlddt) })); }));
yield this.buildAlignmentTracks(alignmentRequestContext, alignmentResponse, {
alignmentTrackFactory: trackFactory
});
return void 0;
});
}
concatAlignmentAndAnnotationTracks() {
this.rowConfigData = this.referenceTrack ? [this.referenceTrack].concat(this.alignmentTracks) : this.alignmentTracks;
}
getBoardConfig() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return Object.assign(Object.assign({}, this.boardConfigData), { length: yield this.alignmentCollector.getAlignmentLength(), includeAxis: true });
});
}
}
exports.RcsbFvGroupAlignment = RcsbFvGroupAlignment;
function uniqueTargetList(alignmentResponse) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b;
const entityIds = Operator_1.Operator.uniqueValues((_b = (_a = alignmentResponse.target_alignments) === null || _a === void 0 ? void 0 : _a.map(ta => {
assertDefined(ta === null || ta === void 0 ? void 0 : ta.target_id);
return ta.target_id;
})) !== null && _b !== void 0 ? _b : []);
const instanceIds = (yield RcsbRequestContextManager_1.rcsbRequestCtxManager.getEntityProperties(entityIds)).map(e => e.rcsbId);
return Operator_1.Operator.uniqueValues(instanceIds !== null && instanceIds !== void 0 ? instanceIds : []);
});
}
function collectFeatures(annotationsContext, annotationCollector) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield annotationCollector.collect(Object.assign(Object.assign({}, buildGroupAnnotationQuery(annotationsContext)), { isSummary: false, externalTrackBuilder: annotationsContext.externalTrackBuilder }));
});
}
function buildGroupAnnotationQuery(annotationsContext) {
return {
group: GqlTypes_1.GroupReference.SequenceIdentity,
groupId: annotationsContext.groupId,
sources: [GqlTypes_1.AnnotationReference.PdbInstance],
filters: [{
source: GqlTypes_1.AnnotationReference.PdbInstance,
operation: GqlTypes_1.OperationType.Equals,
field: GqlTypes_1.FieldName.Type,
values: [GqlTypes_1.FeaturesType.UnobservedResidueXyz, GqlTypes_1.FeaturesType.MaQaMetricLocalTypePlddt]
}, {
source: GqlTypes_1.AnnotationReference.PdbInstance,
operation: GqlTypes_1.OperationType.Equals,
field: GqlTypes_1.FieldName.TargetId,
values: annotationsContext.targetList
}]
};
}