@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
63 lines • 4.77 kB
JavaScript
import { AnnotationReference } from "@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes";
import { cloneDeep } from "lodash";
import { FeatureType } from "../../RcsbExport/FeatureType";
export function burialFraction(annotations) {
const burialFractionOut = new Array();
const asaUnboundAnn = 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.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 = 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.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 = 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 = cloneDeep(uF);
feature.type = 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;
}
export function burialFractionFilter(annotations) {
return cloneDeep(annotations).map(ann => {
var _a;
ann.features = (_a = ann.features) === null || _a === void 0 ? void 0 : _a.filter(f => (ann.source !== AnnotationReference.PdbInterface || (f === null || f === void 0 ? void 0 : f.type) === 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); });
}
//# sourceMappingURL=BurialFraction.js.map