UNPKG

molstar

Version:

A comprehensive macromolecular library.

75 lines 3.85 kB
/** * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; import { Color, ColorScale } from '../../../../mol-util/color'; import { StructureElement, Model, Bond } from '../../../../mol-model/structure'; import { ValidationReportProvider, ValidationReport } from '../prop'; var DefaultColor = Color(0xCCCCCC); export function DensityFitColorTheme(ctx, props) { var _a; var color = function () { return DefaultColor; }; var scaleRsrz = ColorScale.create({ minLabel: 'Poor', maxLabel: 'Better', domain: [2, 0], listOrName: 'red-yellow-blue', }); var scaleRscc = ColorScale.create({ minLabel: 'Poor', maxLabel: 'Better', domain: [0.678, 1.0], listOrName: 'red-yellow-blue', }); var validationReport = ctx.structure && ValidationReportProvider.get(ctx.structure.models[0]); var contextHash = validationReport === null || validationReport === void 0 ? void 0 : validationReport.version; var model = (_a = ctx.structure) === null || _a === void 0 ? void 0 : _a.models[0]; if ((validationReport === null || validationReport === void 0 ? void 0 : validationReport.value) && model) { var _b = validationReport.value, rsrz_1 = _b.rsrz, rscc_1 = _b.rscc; var residueIndex_1 = model.atomicHierarchy.residueAtomSegments.index; var getColor_1 = function (element) { var rsrzValue = rsrz_1.get(residueIndex_1[element]); if (rsrzValue !== undefined) return scaleRsrz.color(rsrzValue); var rsccValue = rscc_1.get(residueIndex_1[element]); if (rsccValue !== undefined) return scaleRscc.color(rsccValue); return DefaultColor; }; color = function (location) { if (StructureElement.Location.is(location) && location.unit.model === model) { return getColor_1(location.element); } else if (Bond.isLocation(location) && location.aUnit.model === model) { return getColor_1(location.aUnit.elements[location.aIndex]); } return DefaultColor; }; } return { factory: DensityFitColorTheme, granularity: 'group', preferSmoothing: true, color: color, props: props, contextHash: contextHash, description: 'Assigns residue colors according to the density fit using normalized Real Space R (RSRZ) for polymer residues and real space correlation coefficient (RSCC) for ligands. Colors range from poor (RSRZ = 2 or RSCC = 0.678) - to better (RSRZ = 0 or RSCC = 1.0). Data from wwPDB Validation Report, obtained via RCSB PDB.', legend: scaleRsrz.legend }; } export var DensityFitColorThemeProvider = { name: ValidationReport.Tag.DensityFit, label: 'Density Fit', category: "Validation" /* Validation */, factory: DensityFitColorTheme, getParams: function () { return ({}); }, defaultValues: PD.getDefaultValues({}), isApplicable: function (ctx) { return !!ctx.structure && ValidationReport.isApplicable(ctx.structure.models[0]) && Model.isFromXray(ctx.structure.models[0]) && Model.probablyHasDensityMap(ctx.structure.models[0]); }, ensureCustomProperties: { attach: function (ctx, data) { return data.structure ? ValidationReportProvider.attach(ctx, data.structure.models[0], void 0, true) : Promise.resolve(); }, detach: function (data) { return data.structure && ValidationReportProvider.ref(data.structure.models[0], false); } } }; //# sourceMappingURL=density-fit.js.map