@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
67 lines (66 loc) • 5.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.burialFraction = burialFraction;
exports.burialFractionFilter = burialFractionFilter;
const GqlTypes_1 = require("@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes");
const lodash_1 = require("lodash");
const FeatureType_1 = require("../../RcsbExport/FeatureType");
function burialFraction(annotations) {
const burialFractionOut = new Array();
const asaUnboundAnn = (0, lodash_1.cloneDeep)(annotations).map(ann => {
var _a;
ann.features = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.filter(f => ((f === null || f === void 0 ? void 0 : f.type) === FeatureType_1.FeatureType.AsaUnbound));
return ann;
}).filter(ann => { var _a, _b; return (((_b = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0); });
const asaBoundAnn = (0, lodash_1.cloneDeep)(annotations).map(ann => {
var _a;
ann.features = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.filter(f => ((f === null || f === void 0 ? void 0 : f.type) === FeatureType_1.FeatureType.AsaBound));
return ann;
}).filter(ann => { var _a, _b; return (((_b = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0); });
asaUnboundAnn.forEach((asaUnbound) => {
var _a, _b, _c;
const asaBound = asaBoundAnn.find((ann) => { var _a, _b, _c, _d; return (((_a = ann.target_identifiers) === null || _a === void 0 ? void 0 : _a.target_id) === ((_b = asaUnbound.target_identifiers) === null || _b === void 0 ? void 0 : _b.target_id) && ((_c = ann.target_identifiers) === null || _c === void 0 ? void 0 : _c.interface_partner_index) === ((_d = asaUnbound.target_identifiers) === null || _d === void 0 ? void 0 : _d.interface_partner_index)); });
if (asaUnbound && asaBound) {
if (((_a = asaBound.features) === null || _a === void 0 ? void 0 : _a.length) != ((_b = asaUnbound.features) === null || _b === void 0 ? void 0 : _b.length))
throw "Inconsistent bound and unbound ASA features, different array lengths";
const burialFraction = (0, lodash_1.cloneDeep)(asaUnbound);
burialFraction.features = [];
(_c = asaUnbound.features) === null || _c === void 0 ? void 0 : _c.forEach((uF, l) => {
var _a, _b, _c, _d;
const bF = (_b = (_a = asaBound.features) === null || _a === void 0 ? void 0 : _a[l]) !== null && _b !== void 0 ? _b : undefined;
if (bF && uF) {
const feature = (0, lodash_1.cloneDeep)(uF);
feature.type = FeatureType_1.FeatureType.BurialFraction;
feature.name = "Interface residues buried fraction";
feature.description = "(1 - bASA/uASA)";
feature.feature_positions = [];
(_c = uF === null || uF === void 0 ? void 0 : uF.feature_positions) === null || _c === void 0 ? void 0 : _c.forEach((uP, n) => {
var _a, _b, _c, _d;
const bP = (_b = (_a = bF.feature_positions) === null || _a === void 0 ? void 0 : _a[n]) !== null && _b !== void 0 ? _b : undefined;
if (bP)
(_c = feature.feature_positions) === null || _c === void 0 ? void 0 : _c.push({
beg_seq_id: uP === null || uP === void 0 ? void 0 : uP.beg_seq_id,
values: (_d = uP === null || uP === void 0 ? void 0 : uP.values) === null || _d === void 0 ? void 0 : _d.map((uV, m) => {
var _a, _b;
const bV = (_b = (_a = bP.values) === null || _a === void 0 ? void 0 : _a[m]) !== null && _b !== void 0 ? _b : 0;
if (uV === 0)
return 0;
return Math.floor((1 - bV / (uV !== null && uV !== void 0 ? uV : 1)) * 100) / 100;
})
});
});
(_d = burialFraction.features) === null || _d === void 0 ? void 0 : _d.push(feature);
}
});
burialFractionOut.push(burialFraction);
}
});
return burialFractionOut;
}
function burialFractionFilter(annotations) {
return (0, lodash_1.cloneDeep)(annotations).map(ann => {
var _a;
ann.features = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.filter(f => (ann.source !== GqlTypes_1.AnnotationReference.PdbInterface || (f === null || f === void 0 ? void 0 : f.type) === FeatureType_1.FeatureType.BurialFraction));
return ann;
}).filter(ann => { var _a, _b; return (((_b = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0); });
}