|
@@ -1,75 +0,0 @@
|
|
|
-
|
|
|
- * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
- *
|
|
|
- * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
|
|
|
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
- */
|
|
|
-
|
|
|
-import { ParamDefinition as PD } from '../../../mol-util/param-definition';
|
|
|
-import { Color, ColorScale } from '../../../mol-util/color';
|
|
|
-import { ThemeDataContext } from '../../../mol-theme/theme';
|
|
|
-import { ColorTheme, LocationColor } from '../../../mol-theme/color';
|
|
|
-import { CustomProperty } from '../../common/custom-property';
|
|
|
-import { Location } from '../../../mol-model/location';
|
|
|
-
|
|
|
-const DefaultColor = Color(0xFAFAFA);
|
|
|
-const Description = 'Assigns a color based on the membrane topology of a residue.';
|
|
|
-
|
|
|
-export const TopologyColorThemeParams = {
|
|
|
- list: PD.ColorList('rainbow', { presetKind: 'scale' })
|
|
|
-};
|
|
|
-export type TopologyColorThemeParams = typeof TopologyColorThemeParams
|
|
|
-export function getTopologyColorThemeParams(ctx: ThemeDataContext) {
|
|
|
- return TopologyColorThemeParams;
|
|
|
-}
|
|
|
-export function TopologyColorTheme(ctx: ThemeDataContext, props: PD.Values<TopologyColorThemeParams>): ColorTheme<TopologyColorThemeParams> {
|
|
|
- let color: LocationColor;
|
|
|
-
|
|
|
- const scale = ColorScale.create({
|
|
|
- listOrName: props.list.colors,
|
|
|
- minLabel: 'membrane',
|
|
|
- maxLabel: 'non-membrane',
|
|
|
- domain: [0.0, 1.0]
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if ( ctx.structure) {
|
|
|
-
|
|
|
-
|
|
|
- color = (location: Location): Color => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return DefaultColor;
|
|
|
- };
|
|
|
- } else {
|
|
|
- color = () => DefaultColor;
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- factory: TopologyColorTheme,
|
|
|
- granularity: 'group',
|
|
|
- color,
|
|
|
- props,
|
|
|
- '',
|
|
|
- description: Description,
|
|
|
- legend: scale ? scale.legend : undefined
|
|
|
- };
|
|
|
-}
|
|
|
-
|
|
|
-export const TopologyColorThemeProvider: ColorTheme.Provider<TopologyColorThemeParams, 'topology'> = {
|
|
|
- name: 'topology',
|
|
|
- label: 'Membrane Topology',
|
|
|
- category: ColorTheme.Category.Residue,
|
|
|
- factory: TopologyColorTheme,
|
|
|
- getParams: getTopologyColorThemeParams,
|
|
|
- defaultValues: PD.getDefaultValues(TopologyColorThemeParams),
|
|
|
- isApplicable: (ctx: ThemeDataContext) => !!ctx.structure,
|
|
|
- ensureCustomProperties: {
|
|
|
- attach: (ctx: CustomProperty.Context, data: ThemeDataContext) => data.structure ? TopologyProvider.attach(ctx, data.structure, void 0, true) : Promise.resolve(),
|
|
|
- detach: (data) => data.structure && data.structure.customPropertyDescriptors.reference(TopologyProvider.descriptor, false)
|
|
|
- }
|
|
|
-};
|