UNPKG

molstar

Version:

A comprehensive macromolecular library.

54 lines (53 loc) 3.33 kB
"use strict"; /** * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PuttyRepresentationProvider = exports.PuttyRepresentation = exports.getPuttyParams = exports.PuttyParams = void 0; var tslib_1 = require("tslib"); var polymer_tube_mesh_1 = require("../visual/polymer-tube-mesh"); var polymer_gap_cylinder_1 = require("../visual/polymer-gap-cylinder"); var param_definition_1 = require("../../../mol-util/param-definition"); var units_representation_1 = require("../units-representation"); var representation_1 = require("../representation"); var representation_2 = require("../../../mol-repr/representation"); var structure_1 = require("../../../mol-model/structure"); var base_1 = require("../../../mol-geo/geometry/base"); var PuttyVisuals = { 'polymer-tube': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Polymer tube mesh', ctx, getParams, polymer_tube_mesh_1.PolymerTubeVisual); }, 'polymer-gap': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Polymer gap cylinder', ctx, getParams, polymer_gap_cylinder_1.PolymerGapVisual); }, }; exports.PuttyParams = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, polymer_tube_mesh_1.PolymerTubeParams), polymer_gap_cylinder_1.PolymerGapParams), { sizeFactor: param_definition_1.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: param_definition_1.ParamDefinition.MultiSelect(['polymer-tube', 'polymer-gap'], param_definition_1.ParamDefinition.objectToOptions(PuttyVisuals)), bumpFrequency: param_definition_1.ParamDefinition.Numeric(2, { min: 0, max: 10, step: 0.1 }, base_1.BaseGeometry.ShadingCategory) }); function getPuttyParams(ctx, structure) { var params = param_definition_1.ParamDefinition.clone(exports.PuttyParams); var hasNucleotides = false; var hasGaps = false; structure.units.forEach(function (u) { if (!hasNucleotides && structure_1.Unit.isAtomic(u) && u.nucleotideElements.length) hasNucleotides = true; if (!hasGaps && u.gapElements.length) hasGaps = true; }); params.visuals.defaultValue = ['polymer-tube']; if (hasGaps) params.visuals.defaultValue.push('polymer-gap'); return params; } exports.getPuttyParams = getPuttyParams; function PuttyRepresentation(ctx, getParams) { return representation_2.Representation.createMulti('Putty', ctx, getParams, representation_1.StructureRepresentationStateBuilder, PuttyVisuals); } exports.PuttyRepresentation = PuttyRepresentation; exports.PuttyRepresentationProvider = (0, representation_1.StructureRepresentationProvider)({ name: 'putty', label: 'Putty', description: 'Displays a tube smoothly following the trace atoms of polymers.', factory: PuttyRepresentation, getParams: getPuttyParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.PuttyParams), defaultColorTheme: { name: 'chain-id' }, defaultSizeTheme: { name: 'uncertainty' }, isApplicable: function (structure) { return structure.polymerResidueCount > 0; }, });