UNPKG

molstar

Version:

A comprehensive macromolecular library.

109 lines 4.81 kB
/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> */ import { StructureQualityReport, StructureQualityReportProvider } from './prop'; import { Bond, StructureElement } from '../../../mol-model/structure'; import { Color } from '../../../mol-util/color'; import { TableLegend } from '../../../mol-util/legend'; import { ParamDefinition as PD } from '../../../mol-util/param-definition'; var ValidationColors = [ Color.fromRgb(170, 170, 170), Color.fromRgb(0, 255, 0), Color.fromRgb(255, 255, 0), Color.fromRgb(255, 128, 0), Color.fromRgb(255, 0, 0), // 3 or more ]; var ValidationColorTable = [ ['No Issues', ValidationColors[1]], ['One Issue', ValidationColors[2]], ['Two Issues', ValidationColors[3]], ['Three Or More Issues', ValidationColors[4]], ['Not Applicable', ValidationColors[9]] ]; export var StructureQualityReportColorThemeParams = { type: PD.MappedStatic('issue-count', { 'issue-count': PD.Group({}), 'specific-issue': PD.Group({ kind: PD.Text() }) }) }; export function StructureQualityReportColorTheme(ctx, props) { var color; if (ctx.structure && !ctx.structure.isEmpty && ctx.structure.models[0].customProperties.has(StructureQualityReportProvider.descriptor)) { var getIssues_1 = StructureQualityReport.getIssues; var l_1 = StructureElement.Location.create(ctx.structure); if (props.type.name === 'issue-count') { color = function (location) { if (StructureElement.Location.is(location)) { return ValidationColors[Math.min(3, getIssues_1(location).length) + 1]; } else if (Bond.isLocation(location)) { l_1.unit = location.aUnit; l_1.element = location.aUnit.elements[location.aIndex]; return ValidationColors[Math.min(3, getIssues_1(l_1).length) + 1]; } return ValidationColors[0]; }; } else { var issue_1 = props.type.params.kind; color = function (location) { if (StructureElement.Location.is(location) && getIssues_1(location).indexOf(issue_1) >= 0) { return ValidationColors[4]; } else if (Bond.isLocation(location)) { l_1.unit = location.aUnit; l_1.element = location.aUnit.elements[location.aIndex]; return ValidationColors[Math.min(3, getIssues_1(l_1).length) + 1]; } return ValidationColors[0]; }; } } else { color = function () { return ValidationColors[0]; }; } return { factory: StructureQualityReportColorTheme, granularity: 'group', preferSmoothing: true, color: color, props: props, description: 'Assigns residue colors according to the number of quality issues or a specific quality issue. Data from wwPDB Validation Report, obtained via PDBe.', legend: TableLegend(ValidationColorTable) }; } export var StructureQualityReportColorThemeProvider = { name: 'pdbe-structure-quality-report', label: 'Structure Quality Report', category: "Validation" /* Validation */, factory: StructureQualityReportColorTheme, getParams: function (ctx) { var issueTypes = StructureQualityReport.getIssueTypes(ctx.structure); if (issueTypes.length === 0) { return { type: PD.MappedStatic('issue-count', { 'issue-count': PD.Group({}) }) }; } return { type: PD.MappedStatic('issue-count', { 'issue-count': PD.Group({}), 'specific-issue': PD.Group({ kind: PD.Select(issueTypes[0], PD.arrayToOptions(issueTypes)) }, { isFlat: true }) }) }; }, defaultValues: PD.getDefaultValues(StructureQualityReportColorThemeParams), isApplicable: function (ctx) { var _a; return StructureQualityReport.isApplicable((_a = ctx.structure) === null || _a === void 0 ? void 0 : _a.models[0]); }, ensureCustomProperties: { attach: function (ctx, data) { return data.structure ? StructureQualityReportProvider.attach(ctx, data.structure.models[0], void 0, true) : Promise.resolve(); }, detach: function (data) { return data.structure && StructureQualityReportProvider.ref(data.structure.models[0], false); } } }; //# sourceMappingURL=color.js.map