molstar
Version:
A comprehensive macromolecular library.
52 lines (51 loc) • 3.68 kB
JavaScript
/**
* Copyright (c) 2018-2021 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.BackboneRepresentationProvider = exports.BackboneRepresentation = exports.getBackboneParams = exports.BackboneParams = void 0;
var tslib_1 = require("tslib");
var polymer_backbone_cylinder_1 = require("../visual/polymer-backbone-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 polymer_backbone_sphere_1 = require("../visual/polymer-backbone-sphere");
var polymer_gap_cylinder_1 = require("../visual/polymer-gap-cylinder");
var base_1 = require("../../../mol-geo/geometry/base");
var BackboneVisuals = {
'polymer-backbone-cylinder': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Polymer backbone cylinder', ctx, getParams, polymer_backbone_cylinder_1.PolymerBackboneCylinderVisual); },
'polymer-backbone-sphere': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Polymer backbone sphere', ctx, getParams, polymer_backbone_sphere_1.PolymerBackboneSphereVisual); },
'polymer-gap': function (ctx, getParams) { return (0, units_representation_1.UnitsRepresentation)('Polymer gap cylinder', ctx, getParams, polymer_gap_cylinder_1.PolymerGapVisual); },
};
exports.BackboneParams = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, polymer_backbone_sphere_1.PolymerBackboneSphereParams), polymer_backbone_cylinder_1.PolymerBackboneCylinderParams), polymer_gap_cylinder_1.PolymerGapParams), { sizeAspectRatio: param_definition_1.ParamDefinition.Numeric(1, { min: 0.1, max: 3, step: 0.1 }), visuals: param_definition_1.ParamDefinition.MultiSelect(['polymer-backbone-cylinder', 'polymer-backbone-sphere', 'polymer-gap'], param_definition_1.ParamDefinition.objectToOptions(BackboneVisuals)), bumpFrequency: param_definition_1.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, base_1.BaseGeometry.ShadingCategory) });
function getBackboneParams(ctx, structure) {
var params = param_definition_1.ParamDefinition.clone(exports.BackboneParams);
var hasGaps = false;
structure.units.forEach(function (u) {
if (!hasGaps && u.gapElements.length)
hasGaps = true;
});
params.visuals.defaultValue = ['polymer-backbone-cylinder', 'polymer-backbone-sphere'];
if (hasGaps)
params.visuals.defaultValue.push('polymer-gap');
return params;
}
exports.getBackboneParams = getBackboneParams;
function BackboneRepresentation(ctx, getParams) {
return representation_2.Representation.createMulti('Backbone', ctx, getParams, representation_1.StructureRepresentationStateBuilder, BackboneVisuals);
}
exports.BackboneRepresentation = BackboneRepresentation;
exports.BackboneRepresentationProvider = (0, representation_1.StructureRepresentationProvider)({
name: 'backbone',
label: 'Backbone',
description: 'Displays polymer backbone with cylinders and spheres.',
factory: BackboneRepresentation,
getParams: getBackboneParams,
defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.BackboneParams),
defaultColorTheme: { name: 'chain-id' },
defaultSizeTheme: { name: 'uniform' },
isApplicable: function (structure) { return structure.polymerResidueCount > 0; },
});
;