pdbe-molstar
Version:
Molstar implementation for PDBe
129 lines (128 loc) • 5.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultParams = exports.Encoding = exports.VisualStyle = exports.ComponentType = exports.Lighting = exports.Preset = exports.DefaultPluginUISpec = exports.DefaultPluginSpec = void 0;
exports.resolveVisualStyleSpec = resolveVisualStyleSpec;
exports.validateInitParams = validateInitParams;
const actions_1 = require("molstar/lib/mol-plugin-state/actions");
const volume_1 = require("molstar/lib/mol-plugin-ui/custom/volume");
const behavior_1 = require("molstar/lib/mol-plugin/behavior");
const transformers_1 = require("molstar/lib/mol-plugin/behavior/dynamic/volume-streaming/transformers");
const config_1 = require("molstar/lib/mol-plugin/config");
const spec_1 = require("molstar/lib/mol-plugin/spec");
const labels_1 = require("./labels");
const sifts_mappings_behaviour_1 = require("./sifts-mappings-behaviour");
const DefaultPluginSpec = () => ({
actions: [
spec_1.PluginSpec.Action(actions_1.StateActions.Structure.EnableStructureCustomProps),
],
behaviors: [
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.Representation.HighlightLoci),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.Representation.SelectLoci),
spec_1.PluginSpec.Behavior(labels_1.PDBeLociLabelProvider),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.Representation.FocusLoci),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.Camera.FocusLoci),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.Camera.CameraAxisHelper),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.StructureInfo),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.AccessibleSurfaceArea),
spec_1.PluginSpec.Behavior(sifts_mappings_behaviour_1.PDBeSIFTSMapping, { autoAttach: true, showTooltip: true }),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.Interactions),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.SecondaryStructure),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.ValenceModel),
spec_1.PluginSpec.Behavior(behavior_1.PluginBehaviors.CustomProps.CrossLinkRestraint),
],
// animations: [],
config: [
[config_1.PluginConfig.VolumeStreaming.DefaultServer, 'https://www.ebi.ac.uk/pdbe/volume-server'],
[config_1.PluginConfig.VolumeStreaming.EmdbHeaderServer, 'https://files.wwpdb.org/pub/emdb/structures'],
],
});
exports.DefaultPluginSpec = DefaultPluginSpec;
const DefaultPluginUISpec = () => (Object.assign(Object.assign({}, (0, exports.DefaultPluginSpec)()), { customParamEditors: [
[transformers_1.CreateVolumeStreamingBehavior, volume_1.VolumeStreamingCustomControls],
] }));
exports.DefaultPluginUISpec = DefaultPluginUISpec;
exports.Preset = ['default', 'unitcell', 'all-models', 'supercell'];
exports.Lighting = ['flat', 'matte', 'glossy', 'metallic', 'plastic'];
/** Structure component type ('het' includes Molstar types 'ligand' and 'ion') */
exports.ComponentType = ['polymer', 'het', 'water', 'carbs', 'nonStandard', 'coarse'];
/** Structure representation type */
exports.VisualStyle = ['cartoon', 'ball-and-stick', 'carbohydrate', 'ellipsoid', 'gaussian-surface', 'molecular-surface', 'point', 'putty', 'spacefill'];
/** Normalize a `VisualStylesSpec` to a form {polymer?:{...},het?:{...},...} */
function resolveVisualStyleSpec(spec) {
if (spec === undefined) {
return {};
}
if (typeof spec === 'string' || 'type' in spec) {
const commonStyle = resolveComponentVisualStyleSpec(spec);
return Object.fromEntries(exports.ComponentType.map(type => [type, commonStyle]));
}
return Object.fromEntries(Object.entries(spec).map(([type, compSpec]) => [type, resolveComponentVisualStyleSpec(compSpec)]));
}
function resolveComponentVisualStyleSpec(spec) {
if (spec === undefined)
return undefined;
if (typeof spec === 'string')
return { type: spec };
if ('type' in spec)
return spec;
throw new Error('TypeError');
}
/** Structure file format */
exports.Encoding = ['cif', 'bcif'];
/** Default values for `InitParams` */
exports.DefaultParams = {
moleculeId: undefined,
customData: undefined,
assemblyId: undefined,
defaultPreset: 'default',
ligandView: undefined,
alphafoldView: false,
superposition: false,
superpositionParams: undefined,
selection: undefined,
galleryView: false,
visualStyle: undefined,
hideStructure: [],
loadMaps: false,
mapSettings: undefined,
bgColor: { r: 0, g: 0, b: 0 },
highlightColor: undefined,
selectColor: undefined,
lighting: undefined,
validationAnnotation: false,
domainAnnotation: false,
symmetryAnnotation: false,
pdbeUrl: 'https://www.ebi.ac.uk/pdbe/',
encoding: 'bcif',
lowPrecisionCoords: false,
selectInteraction: true,
selectBindings: undefined,
focusBindings: undefined,
granularity: undefined,
subscribeEvents: false,
hideControls: false,
hideCanvasControls: [],
sequencePanel: false,
leftPanel: true,
rightPanel: true,
logPanel: false,
pdbeLink: true,
loadingOverlay: false,
expanded: false,
landscape: false,
reactive: false,
tabs: 'pdbe',
};
/** Return `undefined` if `params` are valid, an error message otherwise. */
function validateInitParams(params) {
var _a;
if (!params.moleculeId && !((_a = params.customData) === null || _a === void 0 ? void 0 : _a.url))
return 'Option `moleculeId` or `customData` must be defined';
if (params.customData) {
if (!params.customData.url)
return 'Option `customData.url` must be a non-empty string';
if (!params.customData.format)
return 'Option `customData.format` must be a non-empty string';
}
return undefined;
}