molstar
Version:
A comprehensive macromolecular library.
63 lines • 3.2 kB
JavaScript
/**
* 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 RandomCoilIndexColorTheme(ctx, props) {
var _a, _b;
var color = function () { return DefaultColor; };
var scale = ColorScale.create({
reverse: true,
domain: [0, 0.6],
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 rci = (_a = validationReport === null || validationReport === void 0 ? void 0 : validationReport.value) === null || _a === void 0 ? void 0 : _a.rci;
var model = (_b = ctx.structure) === null || _b === void 0 ? void 0 : _b.models[0];
if (rci && model) {
var residueIndex_1 = model.atomicHierarchy.residueAtomSegments.index;
var getColor_1 = function (element) {
var value = rci.get(residueIndex_1[element]);
return value === undefined ? DefaultColor : scale.color(value);
};
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: RandomCoilIndexColorTheme,
granularity: 'group',
preferSmoothing: true,
color: color,
props: props,
contextHash: contextHash,
description: 'Assigns residue colors according to the Random Coil Index value. Data from wwPDB Validation Report, obtained via RCSB PDB.',
legend: scale.legend
};
}
export var RandomCoilIndexColorThemeProvider = {
name: ValidationReport.Tag.RandomCoilIndex,
label: 'Random Coil Index',
category: "Validation" /* Validation */,
factory: RandomCoilIndexColorTheme,
getParams: function () { return ({}); },
defaultValues: PD.getDefaultValues({}),
isApplicable: function (ctx) { return !!ctx.structure && ValidationReport.isApplicable(ctx.structure.models[0]) && Model.isFromNmr(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=random-coil-index.js.map