From 7384bebf4eb59d8953924415b5940e96001da5f3 Mon Sep 17 00:00:00 2001 From: David Sehnal <dsehnal@users.noreply.github.com> Date: Sat, 31 Dec 2022 11:22:05 +0100 Subject: [PATCH] Fix some cyclic imports & reduce const enum usage (#680) * fix mol-theme/color * fix mol-theme/size * remove unnecessary const enums * remove Column.ValueType const enum * NumberTypes * ValueKindConst => ValueKinds * more const enum fixes * more const enums * readme * update filename * typing * FeatureTypes --- CHANGELOG.md | 2 ++ src/extensions/cellpack/data.ts | 2 +- src/mol-canvas3d/helper/camera-helper.ts | 2 +- src/mol-canvas3d/helper/interaction-events.ts | 2 +- src/mol-data/db/column.ts | 31 ++++++++++++++----- src/mol-data/db/table.ts | 4 +-- src/mol-gl/renderer.ts | 4 +-- src/mol-io/common/binary-cif/encoding.ts | 4 +-- src/mol-io/reader/_spec/common.spec.ts | 26 ++++++++-------- src/mol-io/reader/cif/binary/field.ts | 8 ++--- src/mol-io/reader/cif/data-model.ts | 30 +++++++++--------- src/mol-io/reader/cif/schema.ts | 2 +- src/mol-io/reader/common/text/column/fixed.ts | 2 +- src/mol-io/reader/common/text/column/token.ts | 2 +- .../reader/common/text/number-parser.ts | 30 +++++++++++------- src/mol-io/writer/cif/encoder/binary.ts | 8 ++--- src/mol-io/writer/cif/encoder/text.ts | 6 ++-- .../structure/basic/atomic.ts | 4 +-- .../structure/basic/parser.ts | 8 ++--- src/mol-model-formats/structure/basic/sort.ts | 2 +- src/mol-model-formats/structure/basic/util.ts | 2 +- .../structure/property/bonds/struct_conn.ts | 2 +- .../structure/property/secondary-structure.ts | 12 +++---- .../computed/accessible-surface-area.ts | 4 +-- .../accessible-surface-area/shrake-rupley.ts | 15 ++++++--- .../computed/chemistry/geometry.ts | 2 +- .../computed/interactions/common.ts | 24 ++++++++++++-- src/mol-model-props/sequence/sifts-mapping.ts | 2 +- src/mol-model/sequence/sequence.ts | 2 +- .../categories/atom_site_operator_mapping.ts | 4 +-- .../export/categories/secondary-structure.ts | 4 +-- src/mol-model/structure/model/model.ts | 2 +- src/mol-model/structure/model/types.ts | 2 +- .../query/utils/structure-distance.ts | 8 ++--- .../structure/carbohydrates/constants.ts | 4 +-- src/mol-model/structure/structure/unit.ts | 5 ++- src/mol-theme/clipping.ts | 2 +- src/mol-theme/color.ts | 10 ++---- src/mol-theme/color/atom-id.ts | 5 +-- src/mol-theme/color/carbohydrate-symbol.ts | 5 +-- src/mol-theme/color/categories.ts | 14 +++++++++ src/mol-theme/color/chain-id.ts | 5 +-- src/mol-theme/color/element-index.ts | 5 +-- src/mol-theme/color/element-symbol.ts | 5 +-- src/mol-theme/color/entity-id.ts | 5 +-- src/mol-theme/color/entity-source.ts | 9 +++--- src/mol-theme/color/external-volume.ts | 5 +-- src/mol-theme/color/hydrophobicity.ts | 5 +-- src/mol-theme/color/illustrative.ts | 5 +-- src/mol-theme/color/model-index.ts | 5 +-- src/mol-theme/color/molecule-type.ts | 5 +-- src/mol-theme/color/occupancy.ts | 5 +-- src/mol-theme/color/operator-hkl.ts | 5 +-- src/mol-theme/color/operator-name.ts | 5 +-- src/mol-theme/color/partial-charge.ts | 5 +-- src/mol-theme/color/polymer-id.ts | 5 +-- src/mol-theme/color/polymer-index.ts | 5 +-- src/mol-theme/color/residue-name.ts | 5 +-- src/mol-theme/color/secondary-structure.ts | 5 +-- src/mol-theme/color/sequence-id.ts | 5 +-- src/mol-theme/color/shape-group.ts | 5 +-- src/mol-theme/color/structure-index.ts | 5 +-- src/mol-theme/color/trajectory-index.ts | 5 +-- src/mol-theme/color/uncertainty.ts | 5 +-- src/mol-theme/color/uniform.ts | 5 +-- src/mol-theme/color/unit-index.ts | 5 +-- src/mol-theme/color/volume-segment.ts | 5 +-- src/mol-theme/color/volume-value.ts | 5 +-- src/mol-theme/label.ts | 2 +- src/mol-theme/size/physical.ts | 2 +- src/mol-theme/size/shape-group.ts | 2 +- src/mol-theme/size/uncertainty.ts | 2 +- src/mol-theme/size/uniform.ts | 2 +- src/mol-util/input/input-observer.ts | 4 +-- src/servers/model/server/query.ts | 2 +- src/servers/volume/server/query/encode.ts | 2 +- 76 files changed, 278 insertions(+), 188 deletions(-) create mode 100644 src/mol-theme/color/categories.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c434e06ed..992f4a754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Note that since we don't clearly distinguish between a public and private interf - `meshes` extension: Fixed a bug in mesh visualization (show backfaces when opacity < 1) - Add color quick select control to Volume controls +- Fix `dropFiles` bug +- Fix some cyclic imports and reduce the use of const enums. This should make it easier to use the library with the `isolatedModules: true` TS config. - Fix `dropFiles` bug (#679) - Add `input type='color'` picker to `CombinedColorControl` - Set `ParameterMappingControl` disabled when state is updating diff --git a/src/extensions/cellpack/data.ts b/src/extensions/cellpack/data.ts index 6764ddc7f..41522f136 100644 --- a/src/extensions/cellpack/data.ts +++ b/src/extensions/cellpack/data.ts @@ -52,7 +52,7 @@ export interface Compartment { } // Primitives discribing a compartment -export const enum CompartmentPrimitiveType { +export enum CompartmentPrimitiveType { MetaBall = 0, Sphere = 1, Cube = 2, diff --git a/src/mol-canvas3d/helper/camera-helper.ts b/src/mol-canvas3d/helper/camera-helper.ts index 4d26b81ce..facc81a7a 100644 --- a/src/mol-canvas3d/helper/camera-helper.ts +++ b/src/mol-canvas3d/helper/camera-helper.ts @@ -135,7 +135,7 @@ export class CameraHelper { } } -export const enum CameraHelperAxis { +export enum CameraHelperAxis { None = 0, X, Y, diff --git a/src/mol-canvas3d/helper/interaction-events.ts b/src/mol-canvas3d/helper/interaction-events.ts index 48e6c13ba..30145c951 100644 --- a/src/mol-canvas3d/helper/interaction-events.ts +++ b/src/mol-canvas3d/helper/interaction-events.ts @@ -19,7 +19,7 @@ type HoverEvent = import('../canvas3d').Canvas3D.HoverEvent type DragEvent = import('../canvas3d').Canvas3D.DragEvent type ClickEvent = import('../canvas3d').Canvas3D.ClickEvent -const enum InputEvent { Move, Click, Drag } +enum InputEvent { Move, Click, Drag } const tmpPosA = Vec3(); const tmpPos = Vec3(); diff --git a/src/mol-data/db/column.ts b/src/mol-data/db/column.ts index c65d7552b..3120b6a47 100644 --- a/src/mol-data/db/column.ts +++ b/src/mol-data/db/column.ts @@ -93,20 +93,35 @@ namespace Column { return !!v && !!(v as Column<any>).schema && !!(v as Column<any>).value; } - export const enum ValueKind { + // Value kinds are accessed very of often + // Using a const enum is an internal optimization and is defined separately to better support + // compiling with isolatedModules flag in 3rd party use-cases of Mol*. + export const enum ValueKinds { + /** Defined value (= 0) */ Present = 0, - /** Expressed in CIF as `.` */ + /** Expressed in CIF as `.` (= 1) */ NotPresent = 1, - /** Expressed in CIF as `?` */ + /** Expressed in CIF as `?` (= 2) */ Unknown = 2 } + export const ValueKind = { + /** Defined value (= 0) */ + Present: ValueKinds.Present, + /** Expressed in CIF as `.` (= 1) */ + NotPresent: ValueKinds.NotPresent, + /** Expressed in CIF as `?` (= 2) */ + Unknown: ValueKinds.Unknown + } as const; + export type ValueKind = (typeof ValueKind)[keyof typeof ValueKinds]; + + export function Undefined<T extends Schema>(rowCount: number, schema: T): Column<T['T']> { - return constColumn(schema['T'], rowCount, schema, ValueKind.NotPresent); + return constColumn(schema['T'], rowCount, schema, ValueKinds.NotPresent); } export function ofConst<T extends Schema>(v: T['T'], rowCount: number, type: T): Column<T['T']> { - return constColumn(v, rowCount, type, ValueKind.Present); + return constColumn(v, rowCount, type, ValueKinds.Present); } export function ofLambda<T extends Schema>(spec: LambdaSpec<T>): Column<T['T']> { @@ -256,7 +271,7 @@ function constColumn<T extends Column.Schema>(v: T['T'], rowCount: number, schem return { schema: schema, __array: void 0, - isDefined: valueKind === Column.ValueKind.Present, + isDefined: valueKind === Column.ValueKinds.Present, rowCount, value, valueKind: row => valueKind, @@ -276,7 +291,7 @@ function lambdaColumn<T extends Column.Schema>({ value, valueKind, areValuesEqua isDefined: true, rowCount, value, - valueKind: valueKind ? valueKind : row => Column.ValueKind.Present, + valueKind: valueKind ? valueKind : row => Column.ValueKinds.Present, toArray: params => { const { array, start } = ColumnHelpers.createArray(rowCount, params); for (let i = 0, _i = array.length; i < _i; i++) array[i] = value(i + start); @@ -304,7 +319,7 @@ function arrayColumn<T extends Column.Schema>({ array, schema, valueKind }: Colu isDefined: true, rowCount, value, - valueKind: valueKind ? valueKind : row => Column.ValueKind.Present, + valueKind: valueKind ? valueKind : row => Column.ValueKinds.Present, toArray: schema.valueType === 'str' ? (schema as Column.Schema.Str).transform === 'lowercase' ? params => { diff --git a/src/mol-data/db/table.ts b/src/mol-data/db/table.ts index cc0ed0258..5545c0fd9 100644 --- a/src/mol-data/db/table.ts +++ b/src/mol-data/db/table.ts @@ -85,7 +85,7 @@ namespace Table { rowCount, schema: schema[k], value: r => rows[r][k], - valueKind: r => typeof rows[r][k] === 'undefined' ? Column.ValueKind.NotPresent : Column.ValueKind.Present + valueKind: r => typeof rows[r][k] === 'undefined' ? Column.ValueKinds.NotPresent : Column.ValueKinds.Present }); } return ret as R; @@ -267,7 +267,7 @@ namespace Table { StringBuilder.write(sb, '|'); for (let i = 0; i < cols.length; i++) { const c = table[cols[i]]; - if (c.valueKind(r) === Column.ValueKind.Present) { + if (c.valueKind(r) === Column.ValueKinds.Present) { StringBuilder.write(sb, c.value(r)); StringBuilder.write(sb, '|'); } else { diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts index c41bf3283..1b7cb22b6 100644 --- a/src/mol-gl/renderer.ts +++ b/src/mol-gl/renderer.ts @@ -38,14 +38,14 @@ export interface RendererStats { instancedDrawCount: number } -export const enum PickType { +export enum PickType { None = 0, Object = 1, Instance = 2, Group = 3, } -export const enum MarkingType { +export enum MarkingType { None = 0, Depth = 1, Mask = 2, diff --git a/src/mol-io/common/binary-cif/encoding.ts b/src/mol-io/common/binary-cif/encoding.ts index f69792b55..21d5511e2 100644 --- a/src/mol-io/common/binary-cif/encoding.ts +++ b/src/mol-io/common/binary-cif/encoding.ts @@ -57,7 +57,7 @@ export interface EncodedData { export namespace Encoding { - export const enum IntDataType { + export enum IntDataType { Int8 = 1, Int16 = 2, Int32 = 3, @@ -66,7 +66,7 @@ export namespace Encoding { Uint32 = 6, } - export const enum FloatDataType { + export enum FloatDataType { Float32 = 32, Float64 = 33 } diff --git a/src/mol-io/reader/_spec/common.spec.ts b/src/mol-io/reader/_spec/common.spec.ts index ba94d4694..a237a87e2 100644 --- a/src/mol-io/reader/_spec/common.spec.ts +++ b/src/mol-io/reader/_spec/common.spec.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { parseFloat as fastParseFloat, parseInt as fastParseInt, getNumberType, NumberType } from '../../../mol-io/reader/common/text/number-parser'; +import { parseFloat as fastParseFloat, parseInt as fastParseInt, getNumberType, NumberTypes } from '../../../mol-io/reader/common/text/number-parser'; describe('common', () => { it('number-parser fastParseFloat', () => { @@ -24,17 +24,17 @@ describe('common', () => { }); it('number-parser getNumberType', () => { - expect(getNumberType('11')).toBe(NumberType.Int); - expect(getNumberType('5E93')).toBe(NumberType.Scientific); - expect(getNumberType('0.42')).toBe(NumberType.Float); - expect(getNumberType('Foo123')).toBe(NumberType.NaN); - expect(getNumberType('11.0829(23)')).toBe(NumberType.NaN); - expect(getNumberType('1..2')).toBe(NumberType.NaN); - expect(getNumberType('.')).toBe(NumberType.NaN); - expect(getNumberType('-.')).toBe(NumberType.NaN); - expect(getNumberType('e')).toBe(NumberType.NaN); - expect(getNumberType('-e')).toBe(NumberType.NaN); - expect(getNumberType('1e')).toBe(NumberType.Scientific); - expect(getNumberType('-1e')).toBe(NumberType.Scientific); + expect(getNumberType('11')).toBe(NumberTypes.Int); + expect(getNumberType('5E93')).toBe(NumberTypes.Scientific); + expect(getNumberType('0.42')).toBe(NumberTypes.Float); + expect(getNumberType('Foo123')).toBe(NumberTypes.NaN); + expect(getNumberType('11.0829(23)')).toBe(NumberTypes.NaN); + expect(getNumberType('1..2')).toBe(NumberTypes.NaN); + expect(getNumberType('.')).toBe(NumberTypes.NaN); + expect(getNumberType('-.')).toBe(NumberTypes.NaN); + expect(getNumberType('e')).toBe(NumberTypes.NaN); + expect(getNumberType('-e')).toBe(NumberTypes.NaN); + expect(getNumberType('1e')).toBe(NumberTypes.Scientific); + expect(getNumberType('-1e')).toBe(NumberTypes.Scientific); }); }); \ No newline at end of file diff --git a/src/mol-io/reader/cif/binary/field.ts b/src/mol-io/reader/cif/binary/field.ts index e80a5852f..892001ebe 100644 --- a/src/mol-io/reader/cif/binary/field.ts +++ b/src/mol-io/reader/cif/binary/field.ts @@ -17,10 +17,10 @@ export function Field(column: EncodedColumn): Data.CifField { const str: Data.CifField['str'] = isNumeric ? mask - ? row => mask[row] === Column.ValueKind.Present ? '' + data[row] : '' + ? row => mask[row] === Column.ValueKinds.Present ? '' + data[row] : '' : row => '' + data[row] : mask - ? row => mask[row] === Column.ValueKind.Present ? data[row] : '' + ? row => mask[row] === Column.ValueKinds.Present ? data[row] : '' : row => data[row]; const int: Data.CifField['int'] = isNumeric @@ -32,8 +32,8 @@ export function Field(column: EncodedColumn): Data.CifField { : row => { const v = data[row]; return fastParseFloat(v, 0, v.length); }; const valueKind: Data.CifField['valueKind'] = mask - ? row => mask[row] - : row => Column.ValueKind.Present; + ? row => mask[row] as Column.ValueKind + : row => Column.ValueKinds.Present; const rowCount = data.length; diff --git a/src/mol-io/reader/cif/data-model.ts b/src/mol-io/reader/cif/data-model.ts index af9a713cd..b5adb854d 100644 --- a/src/mol-io/reader/cif/data-model.ts +++ b/src/mol-io/reader/cif/data-model.ts @@ -7,7 +7,7 @@ import { Column, ColumnHelpers, Table } from '../../../mol-data/db'; import { Tensor } from '../../../mol-math/linear-algebra'; -import { getNumberType, NumberType, parseInt as fastParseInt, parseFloat as fastParseFloat } from '../common/text/number-parser'; +import { getNumberType, NumberTypes, parseInt as fastParseInt, parseFloat as fastParseFloat } from '../common/text/number-parser'; import { Encoding } from '../../common/binary-cif'; import { Tokens } from '../common/text/tokenizer'; import { areValuesEqualProvider } from '../common/text/column/token'; @@ -124,12 +124,12 @@ export namespace CifField { const float: CifField['float'] = row => { const v = values[row]; return fastParseFloat(v, 0, v.length) || 0; }; const valueKind: CifField['valueKind'] = row => { const v = values[row], l = v.length; - if (l > 1) return Column.ValueKind.Present; - if (l === 0) return Column.ValueKind.NotPresent; + if (l > 1) return Column.ValueKinds.Present; + if (l === 0) return Column.ValueKinds.NotPresent; const c = v.charCodeAt(0); - if (c === 46 /* . */) return Column.ValueKind.NotPresent; - if (c === 63 /* ? */) return Column.ValueKind.Unknown; - return Column.ValueKind.Present; + if (c === 46 /* . */) return Column.ValueKinds.NotPresent; + if (c === 63 /* ? */) return Column.ValueKinds.Unknown; + return Column.ValueKinds.Present; }; return { @@ -152,7 +152,7 @@ export namespace CifField { const rowCount = values.length; const str: CifField['str'] = row => { return '' + values[row]; }; const float: CifField['float'] = row => values[row]; - const valueKind: CifField['valueKind'] = row => Column.ValueKind.Present; + const valueKind: CifField['valueKind'] = row => Column.ValueKinds.Present; const toFloatArray = (params: Column.ToArrayParams<number>) => { if (!params || params.array && values instanceof params.array) { @@ -197,12 +197,12 @@ export namespace CifField { const valueKind: CifField['valueKind'] = row => { const s = indices[2 * row], l = indices[2 * row + 1] - s; - if (l > 1) return Column.ValueKind.Present; - if (l === 0) return Column.ValueKind.NotPresent; + if (l > 1) return Column.ValueKinds.Present; + if (l === 0) return Column.ValueKinds.NotPresent; const v = data.charCodeAt(s); - if (v === 46 /* . */) return Column.ValueKind.NotPresent; - if (v === 63 /* ? */) return Column.ValueKind.Unknown; - return Column.ValueKind.Present; + if (v === 46 /* . */) return Column.ValueKinds.NotPresent; + if (v === 63 /* ? */) return Column.ValueKinds.Unknown; + return Column.ValueKinds.Present; }; return { @@ -328,13 +328,13 @@ export function getCifFieldType(field: CifField): Column.Schema.Int | Column.Sch let floatCount = 0, hasStringOrScientific = false, undefinedCount = 0; for (let i = 0, _i = field.rowCount; i < _i; i++) { const k = field.valueKind(i); - if (k !== Column.ValueKind.Present) { + if (k !== Column.ValueKinds.Present) { undefinedCount++; continue; } const type = getNumberType(field.str(i)); - if (type === NumberType.Int) continue; - else if (type === NumberType.Float) floatCount++; + if (type === NumberTypes.Int) continue; + else if (type === NumberTypes.Float) floatCount++; else { hasStringOrScientific = true; break; } } diff --git a/src/mol-io/reader/cif/schema.ts b/src/mol-io/reader/cif/schema.ts index d5d809d13..305e5f6df 100644 --- a/src/mol-io/reader/cif/schema.ts +++ b/src/mol-io/reader/cif/schema.ts @@ -101,7 +101,7 @@ function createListColumn<T extends number | string>(schema: Column.Schema.List< isDefined: !!f, rowCount: category.rowCount, value, - valueKind: f ? f.valueKind : () => Column.ValueKind.NotPresent, + valueKind: f ? f.valueKind : () => Column.ValueKinds.NotPresent, areValuesEqual: (rowA, rowB) => arrayEqual(value(rowA), value(rowB)), toArray }; diff --git a/src/mol-io/reader/common/text/column/fixed.ts b/src/mol-io/reader/common/text/column/fixed.ts index c1bea2da4..bebf4ca7d 100644 --- a/src/mol-io/reader/common/text/column/fixed.ts +++ b/src/mol-io/reader/common/text/column/fixed.ts @@ -39,7 +39,7 @@ export function FixedColumn<T extends Column.Schema>(lines: Tokens, offset: numb isDefined: true, rowCount, value, - valueKind: row => Column.ValueKind.Present, + valueKind: row => Column.ValueKinds.Present, toArray: params => ColumnHelpers.createAndFillArray(rowCount, value, params), areValuesEqual: (rowA, rowB) => value(rowA) === value(rowB) }; diff --git a/src/mol-io/reader/common/text/column/token.ts b/src/mol-io/reader/common/text/column/token.ts index 8560c80ec..1026a0221 100644 --- a/src/mol-io/reader/common/text/column/token.ts +++ b/src/mol-io/reader/common/text/column/token.ts @@ -32,7 +32,7 @@ export function TokenColumn<T extends Column.Schema>(tokens: Tokens, schema: T): isDefined: true, rowCount, value, - valueKind: row => Column.ValueKind.Present, + valueKind: row => Column.ValueKinds.Present, toArray: params => ColumnHelpers.createAndFillArray(rowCount, value, params), areValuesEqual: areValuesEqualProvider(tokens) }; diff --git a/src/mol-io/reader/common/text/number-parser.ts b/src/mol-io/reader/common/text/number-parser.ts index a38e5a1d0..67d383604 100644 --- a/src/mol-io/reader/common/text/number-parser.ts +++ b/src/mol-io/reader/common/text/number-parser.ts @@ -87,13 +87,21 @@ export function parseFloat(str: string, start: number, end: number) { return neg * ret; } -export const enum NumberType { - Int, - Float, - Scientific, - NaN +export const enum NumberTypes { + Int = 0, + Float = 1, + Scientific = 2, + NaN = 3 } +export const NumberType = { + Int: NumberTypes.Int, + Float: NumberTypes.Float, + Scientific: NumberTypes.Scientific, + NaN: NumberTypes.NaN +} as const; +export type NumberType = (typeof NumberType)[keyof typeof NumberType]; + function isInt(str: string, start: number, end: number) { if (str.charCodeAt(start) === 45 /* - */) { start++; } for (; start < end; start++) { @@ -107,7 +115,7 @@ function isInt(str: string, start: number, end: number) { function getNumberTypeScientific(str: string, start: number, end: number) { // handle + in '1e+1' separately. if (str.charCodeAt(start) === 43 /* + */) start++; - return isInt(str, start, end) ? NumberType.Scientific : NumberType.NaN; + return isInt(str, start, end) ? NumberTypes.Scientific : NumberTypes.NaN; } /** The whole range must match, otherwise returns NaN */ @@ -121,7 +129,7 @@ export function getNumberType(str: string): NumberType { // string is . or -. if (str.charCodeAt(start) === 46 && end - start === 1) { - return NumberType.NaN; + return NumberTypes.NaN; } while (start < end) { @@ -139,18 +147,18 @@ export function getNumberType(str: string): NumberType { } else if (c === 53 || c === 21) { // 'e'/'E' return getNumberTypeScientific(str, start + 1, end); } else { - return NumberType.NaN; + return NumberTypes.NaN; } } - return hasDigit ? NumberType.Float : NumberType.Int; + return hasDigit ? NumberTypes.Float : NumberTypes.Int; } else if (c === 53 || c === 21) { // 'e'/'E' if (start === 0 || start === 1 && str.charCodeAt(0) === 45) { - return NumberType.NaN; // string starts with e/E or -e/-E + return NumberTypes.NaN; // string starts with e/E or -e/-E } return getNumberTypeScientific(str, start + 1, end); } else { break; } } - return start === end ? NumberType.Int : NumberType.NaN; + return start === end ? NumberTypes.Int : NumberTypes.NaN; } diff --git a/src/mol-io/writer/cif/encoder/binary.ts b/src/mol-io/writer/cif/encoder/binary.ts index 9222e22b7..43d66a301 100644 --- a/src/mol-io/writer/cif/encoder/binary.ts +++ b/src/mol-io/writer/cif/encoder/binary.ts @@ -184,8 +184,8 @@ function getFieldData(field: Field<any, any>, arrayCtor: ArrayCtor<string | numb const keys = data[_d].keys(); while (keys.hasNext) { const key = keys.move(); - const p = valueKind ? valueKind(key, d) : Column.ValueKind.Present; - if (p !== Column.ValueKind.Present) { + const p = valueKind ? valueKind(key, d) : Column.ValueKinds.Present; + if (p !== Column.ValueKinds.Present) { mask[offset] = p; if (isStr) array[offset] = ''; @@ -193,10 +193,10 @@ function getFieldData(field: Field<any, any>, arrayCtor: ArrayCtor<string | numb } else { const value = getter(key, d, offset); if (typeof value === 'string' && !value) { - mask[offset] = Column.ValueKind.NotPresent; + mask[offset] = Column.ValueKinds.NotPresent; allPresent = false; } else { - mask[offset] = Column.ValueKind.Present; + mask[offset] = Column.ValueKinds.Present; } array[offset] = value; } diff --git a/src/mol-io/writer/cif/encoder/text.ts b/src/mol-io/writer/cif/encoder/text.ts index 8603bb10a..8840a72f0 100644 --- a/src/mol-io/writer/cif/encoder/text.ts +++ b/src/mol-io/writer/cif/encoder/text.ts @@ -82,9 +82,9 @@ export class TextEncoder implements Encoder<string> { function writeValue(builder: StringBuilder, data: any, key: any, f: Field<any, any>, floatPrecision: number, index: number): boolean { const kind = f.valueKind; - const p = kind ? kind(key, data) : Column.ValueKind.Present; - if (p !== Column.ValueKind.Present) { - if (p === Column.ValueKind.NotPresent) writeNotPresent(builder); + const p = kind ? kind(key, data) : Column.ValueKinds.Present; + if (p !== Column.ValueKinds.Present) { + if (p === Column.ValueKinds.NotPresent) writeNotPresent(builder); else writeUnknown(builder); } else { const val = f.value(key, data, index); diff --git a/src/mol-model-formats/structure/basic/atomic.ts b/src/mol-model-formats/structure/basic/atomic.ts index 8f9cda30a..ed58a4296 100644 --- a/src/mol-model-formats/structure/basic/atomic.ts +++ b/src/mol-model-formats/structure/basic/atomic.ts @@ -111,13 +111,13 @@ function createChainOperatorMappingAndSubstituteNames(hierarchy: AtomicData, for const authMap = new Map<string, string>(); for (let i = 0; i < entries._rowCount; i++) { - const assembly: SymmetryOperator['assembly'] = entries.assembly_operator_id.valueKind(i) === Column.ValueKind.Present + const assembly: SymmetryOperator['assembly'] = entries.assembly_operator_id.valueKind(i) === Column.ValueKinds.Present ? { id: entries.assembly_id.value(i), operList: [], operId: entries.assembly_operator_id.value(i) } : void 0; const operator = SymmetryOperator.create(entries.operator_name.value(i), Mat4.identity(), { assembly, - spgrOp: entries.symmetry_operator_index.valueKind(i) === Column.ValueKind.Present ? entries.symmetry_operator_index.value(i) : void 0, + spgrOp: entries.symmetry_operator_index.valueKind(i) === Column.ValueKinds.Present ? entries.symmetry_operator_index.value(i) : void 0, hkl: Vec3.ofArray(entries.symmetry_hkl.value(i)), ncsId: entries.ncs_id.value(i) }); diff --git a/src/mol-model-formats/structure/basic/parser.ts b/src/mol-model-formats/structure/basic/parser.ts index cc1b53ffb..eca95e3a0 100644 --- a/src/mol-model-formats/structure/basic/parser.ts +++ b/src/mol-model-formats/structure/basic/parser.ts @@ -65,12 +65,12 @@ function createStandardModel(data: BasicData, atom_site: AtomSite, sourceIndex: const atomicRanges = getAtomicRanges(atomic.hierarchy, entities, atomic.conformation, sequence); const structAsymMap = getStructAsymMap(atomic.hierarchy); - const entry = data.entry.id.valueKind(0) === Column.ValueKind.Present + const entry = data.entry.id.valueKind(0) === Column.ValueKinds.Present ? data.entry.id.value(0) : format.name; const label: string[] = []; if (entry) label.push(entry); - if (data.struct.title.valueKind(0) === Column.ValueKind.Present) label.push(data.struct.title.value(0)); + if (data.struct.title.valueKind(0) === Column.ValueKinds.Present) label.push(data.struct.title.value(0)); return { id: UUID.create22(), @@ -105,12 +105,12 @@ function createIntegrativeModel(data: BasicData, ihm: CoarseData, properties: Co const sequence = getSequence(data, ihm.entities, atomic.hierarchy, coarse.hierarchy); const atomicRanges = getAtomicRanges(atomic.hierarchy, ihm.entities, atomic.conformation, sequence); - const entry = data.entry.id.valueKind(0) === Column.ValueKind.Present + const entry = data.entry.id.valueKind(0) === Column.ValueKinds.Present ? data.entry.id.value(0) : format.name; const label: string[] = []; if (entry) label.push(entry); - if (data.struct.title.valueKind(0) === Column.ValueKind.Present) label.push(data.struct.title.value(0)); + if (data.struct.title.valueKind(0) === Column.ValueKinds.Present) label.push(data.struct.title.value(0)); if (ihm.model_name) label.push(ihm.model_name); if (ihm.model_group_name) label.push(ihm.model_group_name); diff --git a/src/mol-model-formats/structure/basic/sort.ts b/src/mol-model-formats/structure/basic/sort.ts index c5fe5cd40..3968dc277 100644 --- a/src/mol-model-formats/structure/basic/sort.ts +++ b/src/mol-model-formats/structure/basic/sort.ts @@ -26,7 +26,7 @@ export async function sortAtomSite(ctx: RuntimeContext, atom_site: AtomSite, sta for (let cI = 0, _cI = chainBuckets.length - 1; cI < _cI; cI++) { const aI = chainBuckets[cI]; // are we in HETATM territory? - if (label_seq_id.valueKind(aI) !== Column.ValueKind.Present) continue; + if (label_seq_id.valueKind(aI) !== Column.ValueKinds.Present) continue; makeBuckets(indices, label_seq_id.value, { sort: true, start: aI, end: chainBuckets[cI + 1] }); if (ctx.shouldUpdate) await ctx.update(); diff --git a/src/mol-model-formats/structure/basic/util.ts b/src/mol-model-formats/structure/basic/util.ts index 03d028e5e..b5ea2424d 100644 --- a/src/mol-model-formats/structure/basic/util.ts +++ b/src/mol-model-formats/structure/basic/util.ts @@ -23,7 +23,7 @@ export function getModelGroupName(model_id: number, data: BasicData) { function hasPresentValues(column: Column<any>) { for (let i = 0, il = column.rowCount; i < il; i++) { - if (column.valueKind(i) === Column.ValueKind.Present) return true; + if (column.valueKind(i) === Column.ValueKinds.Present) return true; } return false; } diff --git a/src/mol-model-formats/structure/property/bonds/struct_conn.ts b/src/mol-model-formats/structure/property/bonds/struct_conn.ts index f5f38998e..135b81b68 100644 --- a/src/mol-model-formats/structure/property/bonds/struct_conn.ts +++ b/src/mol-model-formats/structure/property/bonds/struct_conn.ts @@ -113,7 +113,7 @@ export namespace StructConn { const entityIds = Array.from(model.entities.data.id.toArray()); const _p = (row: number, ps: typeof p1) => { - if (ps.label_asym_id.valueKind(row) !== Column.ValueKind.Present) return void 0; + if (ps.label_asym_id.valueKind(row) !== Column.ValueKinds.Present) return void 0; const asymId = ps.label_asym_id.value(row); const atomName = ps.label_atom_id.value(row); // turns out "mismat" records might not have atom name value diff --git a/src/mol-model-formats/structure/property/secondary-structure.ts b/src/mol-model-formats/structure/property/secondary-structure.ts index 7bab0504e..9cb946a33 100644 --- a/src/mol-model-formats/structure/property/secondary-structure.ts +++ b/src/mol-model-formats/structure/property/secondary-structure.ts @@ -54,9 +54,9 @@ namespace ModelSecondaryStructure { function getCoordinateType(conf: StructConf, sheetRange: StructSheetRange): CoordinateType { if (conf._rowCount > 0) { - if (conf.beg_label_seq_id.valueKind(0) !== Column.ValueKind.Present || conf.end_label_seq_id.valueKind(0) !== Column.ValueKind.Present) return 'auth'; + if (conf.beg_label_seq_id.valueKind(0) !== Column.ValueKinds.Present || conf.end_label_seq_id.valueKind(0) !== Column.ValueKinds.Present) return 'auth'; } else if (sheetRange) { - if (sheetRange.beg_label_seq_id.valueKind(0) !== Column.ValueKind.Present || sheetRange.end_label_seq_id.valueKind(0) !== Column.ValueKind.Present) return 'auth'; + if (sheetRange.beg_label_seq_id.valueKind(0) !== Column.ValueKinds.Present || sheetRange.end_label_seq_id.valueKind(0) !== Column.ValueKinds.Present) return 'auth'; } return 'label'; } @@ -83,18 +83,18 @@ function addHelices(cat: StructConf, coordinates: CoordinateType, map: Secondary const end_seq_id = coordinates === 'label' ? end_label_seq_id : end_auth_seq_id; for (let i = 0, _i = cat._rowCount; i < _i; i++) { - const type = SecondaryStructureType.create(pdbx_PDB_helix_class.valueKind(i) === Column.ValueKind.Present + const type = SecondaryStructureType.create(pdbx_PDB_helix_class.valueKind(i) === Column.ValueKinds.Present ? SecondaryStructureType.SecondaryStructurePdb[pdbx_PDB_helix_class.value(i)] - : conf_type_id.valueKind(i) === Column.ValueKind.Present + : conf_type_id.valueKind(i) === Column.ValueKinds.Present ? SecondaryStructureType.SecondaryStructureMmcif[conf_type_id.value(i)] : SecondaryStructureType.Flag.NA); const element: SecondaryStructure.Helix = { kind: 'helix', flags: type, - type_id: conf_type_id.valueKind(i) === Column.ValueKind.Present ? conf_type_id.value(i) : 'helx_p', + type_id: conf_type_id.valueKind(i) === Column.ValueKinds.Present ? conf_type_id.value(i) : 'helx_p', helix_class: pdbx_PDB_helix_class.value(i), - details: details.valueKind(i) === Column.ValueKind.Present ? details.value(i) : void 0 + details: details.valueKind(i) === Column.ValueKinds.Present ? details.value(i) : void 0 }; const entry: SecondaryStructureEntry = { startSeqId: beg_seq_id.value(i), diff --git a/src/mol-model-props/computed/accessible-surface-area.ts b/src/mol-model-props/computed/accessible-surface-area.ts index 775e18840..177ff0219 100644 --- a/src/mol-model-props/computed/accessible-surface-area.ts +++ b/src/mol-model-props/computed/accessible-surface-area.ts @@ -27,7 +27,7 @@ export const AccessibleSurfaceAreaSymbols = { if (!Unit.isAtomic(ctx.element.unit)) return false; const accessibleSurfaceArea = AccessibleSurfaceAreaProvider.get(ctx.element.structure).value; if (!accessibleSurfaceArea) return false; - return AccessibleSurfaceArea.getFlag(ctx.element, accessibleSurfaceArea) === AccessibleSurfaceArea.Flag.Buried; + return AccessibleSurfaceArea.getFlag(ctx.element, accessibleSurfaceArea) === AccessibleSurfaceArea.Flags.Buried; } ), isAccessible: QuerySymbolRuntime.Dynamic(CustomPropSymbol('computed', 'accessible-surface-area.is-accessible', Type.Bool), @@ -35,7 +35,7 @@ export const AccessibleSurfaceAreaSymbols = { if (!Unit.isAtomic(ctx.element.unit)) return false; const accessibleSurfaceArea = AccessibleSurfaceAreaProvider.get(ctx.element.structure).value; if (!accessibleSurfaceArea) return false; - return AccessibleSurfaceArea.getFlag(ctx.element, accessibleSurfaceArea) === AccessibleSurfaceArea.Flag.Accessible; + return AccessibleSurfaceArea.getFlag(ctx.element, accessibleSurfaceArea) === AccessibleSurfaceArea.Flags.Accessible; } ), }; diff --git a/src/mol-model-props/computed/accessible-surface-area/shrake-rupley.ts b/src/mol-model-props/computed/accessible-surface-area/shrake-rupley.ts index 6d7259c9c..c9727a796 100644 --- a/src/mol-model-props/computed/accessible-surface-area/shrake-rupley.ts +++ b/src/mol-model-props/computed/accessible-surface-area/shrake-rupley.ts @@ -89,12 +89,19 @@ namespace AccessibleSurfaceArea { return points; } - export const enum Flag { + export const enum Flags { NA = 0x0, Buried = 0x1, Accessible = 0x2 } + export const Flag = { + NA: Flags.NA, + Buried: Flags.Buried, + Accessible: Flags.Accessible + } as const; + export type Flag = (typeof Flag)[keyof typeof Flag]; + /** Get relative area for a given component id */ export function normalize(compId: string, asa: number) { const maxAsa = MaxAsa[compId] || DefaultMaxAsa; @@ -115,8 +122,8 @@ namespace AccessibleSurfaceArea { export function getFlag(location: StructureElement.Location, accessibleSurfaceArea: AccessibleSurfaceArea) { const value = getNormalizedValue(location, accessibleSurfaceArea); - return value === -1 ? Flag.NA : - value < 0.16 ? Flag.Buried : - Flag.Accessible; + return value === -1 ? Flags.NA : + value < 0.16 ? Flags.Buried : + Flags.Accessible; } } \ No newline at end of file diff --git a/src/mol-model-props/computed/chemistry/geometry.ts b/src/mol-model-props/computed/chemistry/geometry.ts index 5caa0b2e9..36fa5466e 100644 --- a/src/mol-model-props/computed/chemistry/geometry.ts +++ b/src/mol-model-props/computed/chemistry/geometry.ts @@ -15,7 +15,7 @@ import { Elements } from '../../../mol-model/structure/model/properties/atomic/t * Numbering mostly inline with coordination number from VSEPR, * breaks with `SquarePlanar = 7` */ -export const enum AtomGeometry { +export enum AtomGeometry { Spherical = 0, Terminal = 1, Linear = 2, diff --git a/src/mol-model-props/computed/interactions/common.ts b/src/mol-model-props/computed/interactions/common.ts index 1a057a1d2..7f149ea29 100644 --- a/src/mol-model-props/computed/interactions/common.ts +++ b/src/mol-model-props/computed/interactions/common.ts @@ -118,12 +118,12 @@ namespace InteractionsInterContacts { export type Props = { type: InteractionType, flag: InteractionFlag } } -export const enum InteractionFlag { +export enum InteractionFlag { None = 0, Filtered = 1, } -export const enum InteractionType { +export enum InteractionType { Unknown = 0, Ionic = 1, CationPi = 2, @@ -175,6 +175,24 @@ export const enum FeatureType { IonicTypeMetal = 13 } +// to use with isolatedModules +export enum FeatureTypes { + None = FeatureType.None, + PositiveCharge = FeatureType.PositiveCharge, + NegativeCharge = FeatureType.NegativeCharge, + AromaticRing = FeatureType.AromaticRing, + HydrogenDonor = FeatureType.HydrogenDonor, + HydrogenAcceptor = FeatureType.HydrogenAcceptor, + HalogenDonor = FeatureType.HalogenDonor, + HalogenAcceptor = FeatureType.HalogenAcceptor, + HydrophobicAtom = FeatureType.HydrophobicAtom, + WeakHydrogenDonor = FeatureType.WeakHydrogenDonor, + IonicTypePartner = FeatureType.IonicTypePartner, + DativeBondPartner = FeatureType.DativeBondPartner, + TransitionMetal = FeatureType.TransitionMetal, + IonicTypeMetal = FeatureType.IonicTypeMetal +} + export function featureTypeLabel(type: FeatureType): string { switch (type) { case FeatureType.None: @@ -208,7 +226,7 @@ export function featureTypeLabel(type: FeatureType): string { } } -export const enum FeatureGroup { +export enum FeatureGroup { None = 0, QuaternaryAmine = 1, TertiaryAmine = 2, diff --git a/src/mol-model-props/sequence/sifts-mapping.ts b/src/mol-model-props/sequence/sifts-mapping.ts index 1c28307f8..0a6036abc 100644 --- a/src/mol-model-props/sequence/sifts-mapping.ts +++ b/src/mol-model-props/sequence/sifts-mapping.ts @@ -90,7 +90,7 @@ namespace SIFTSMapping { for (let i = 0; i < count; i++) { const row = atomSourceIndex.value(residueOffsets[i]); - if (db_name.valueKind(row) !== Column.ValueKind.Present) { + if (db_name.valueKind(row) !== Column.ValueKinds.Present) { dbName[i] = ''; accession[i] = ''; num[i] = ''; diff --git a/src/mol-model/sequence/sequence.ts b/src/mol-model/sequence/sequence.ts index e68daae6b..89c72ec26 100644 --- a/src/mol-model/sequence/sequence.ts +++ b/src/mol-model/sequence/sequence.ts @@ -14,7 +14,7 @@ import { assertUnreachable } from '../../mol-util/type-helpers'; type Sequence = Sequence.Protein | Sequence.DNA | Sequence.RNA | Sequence.Generic namespace Sequence { - export const enum Kind { + export enum Kind { Protein = 'protein', RNA = 'RNA', DNA = 'DNA', diff --git a/src/mol-model/structure/export/categories/atom_site_operator_mapping.ts b/src/mol-model/structure/export/categories/atom_site_operator_mapping.ts index 11faadf08..a844972d7 100644 --- a/src/mol-model/structure/export/categories/atom_site_operator_mapping.ts +++ b/src/mol-model/structure/export/categories/atom_site_operator_mapping.ts @@ -41,8 +41,8 @@ export const AtomSiteOperatorMappingSchema = { } }; -const asmValueKind = (i: number, xs: Entry[]) => typeof xs[i].operator.assembly === 'undefined' ? Column.ValueKind.NotPresent : Column.ValueKind.Present; -const symmetryValueKind = (i: number, xs: Entry[]) => xs[i].operator.spgrOp === -1 ? Column.ValueKind.NotPresent : Column.ValueKind.Present; +const asmValueKind = (i: number, xs: Entry[]) => typeof xs[i].operator.assembly === 'undefined' ? Column.ValueKinds.NotPresent : Column.ValueKinds.Present; +const symmetryValueKind = (i: number, xs: Entry[]) => xs[i].operator.spgrOp === -1 ? Column.ValueKinds.NotPresent : Column.ValueKinds.Present; const Fields = CifWriter.fields<number, Entry[], keyof (typeof AtomSiteOperatorMappingSchema)['molstar_atom_site_operator_mapping']>() .str('label_asym_id', (i, xs) => xs[i].label_asym_id) diff --git a/src/mol-model/structure/export/categories/secondary-structure.ts b/src/mol-model/structure/export/categories/secondary-structure.ts index da330f9e4..ef592c16e 100644 --- a/src/mol-model/structure/export/categories/secondary-structure.ts +++ b/src/mol-model/structure/export/categories/secondary-structure.ts @@ -49,7 +49,7 @@ const struct_conf_fields = (): CifField[] => [ ...residueIdFields<number, SSElement<SecondaryStructure.Helix>[]>((i, e) => e[i].end, { prefix: 'end' }), CifField.str<number, SSElement<SecondaryStructure.Helix>[]>('pdbx_PDB_helix_class', (i, data) => data[i].element.helix_class), CifField.str<number, SSElement<SecondaryStructure.Helix>[]>('details', (i, data) => data[i].element.details || '', { - valueKind: (i, d) => !!d[i].element.details ? Column.ValueKind.Present : Column.ValueKind.Unknown + valueKind: (i, d) => !!d[i].element.details ? Column.ValueKinds.Present : Column.ValueKinds.Unknown }), CifField.int<number, SSElement<SecondaryStructure.Helix>[]>('pdbx_PDB_helix_length', (i, data) => data[i].length) ]; @@ -59,7 +59,7 @@ const struct_sheet_range_fields = (): CifField[] => [ CifField.index('id'), ...residueIdFields<number, SSElement<SecondaryStructure.Sheet>[]>((i, e) => e[i].start, { prefix: 'beg' }), ...residueIdFields<number, SSElement<SecondaryStructure.Sheet>[]>((i, e) => e[i].end, { prefix: 'end' }), - CifField.str('symmetry', (i, data) => '', { valueKind: (i, d) => Column.ValueKind.Unknown }) + CifField.str('symmetry', (i, data) => '', { valueKind: (i, d) => Column.ValueKinds.Unknown }) ]; interface SSElement<T extends SecondaryStructure.Element> { diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 76e9c4077..206d98f91 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -415,7 +415,7 @@ export namespace Model { !db.exptl.method.isDefined || (isFromXray(model) && ( !db.pdbx_database_status.status_code_sf.isDefined || - db.pdbx_database_status.status_code_sf.valueKind(0) === Column.ValueKind.Unknown + db.pdbx_database_status.status_code_sf.valueKind(0) === Column.ValueKinds.Unknown )) || (isFromEm(model) && ( !db.pdbx_database_related.db_name.isDefined diff --git a/src/mol-model/structure/model/types.ts b/src/mol-model/structure/model/types.ts index 9795bdb62..2643c4d8f 100644 --- a/src/mol-model/structure/model/types.ts +++ b/src/mol-model/structure/model/types.ts @@ -47,7 +47,7 @@ export function getElementFromAtomicNumber(n: number) { } /** Entity types as defined in the mmCIF dictionary */ -export const enum EntityType { +export enum EntityType { 'unknown', 'polymer', 'non-polymer', 'macrolide', 'water', 'branched' } diff --git a/src/mol-model/structure/query/utils/structure-distance.ts b/src/mol-model/structure/query/utils/structure-distance.ts index 9e3b83378..fbe7e083e 100644 --- a/src/mol-model/structure/query/utils/structure-distance.ts +++ b/src/mol-model/structure/query/utils/structure-distance.ts @@ -23,7 +23,7 @@ export function checkStructureMaxRadiusDistance(ctx: QueryContext, a: Structure, } namespace MinMaxDist { - export const enum Result { + const enum Result { BelowMin, WithinMax, Miss @@ -44,7 +44,7 @@ namespace MinMaxDist { return withinRange ? Result.WithinMax : Result.Miss; } - export function toPoint(ctx: QueryContext, s: Structure, point: Vec3, radius: number, minDist: number, maxDist: number, elementRadius: QueryFn<number>) { + function toPoint(ctx: QueryContext, s: Structure, point: Vec3, radius: number, minDist: number, maxDist: number, elementRadius: QueryFn<number>) { const { units } = s; let withinRange = false; for (let i = 0, _i = units.length; i < _i; i++) { @@ -70,7 +70,7 @@ namespace MinMaxDist { const e = elements[i]; ctx.element.element = e; const tp = toPoint(ctx, b, position(e, distPivot), elementRadius(ctx), minDist, maxDist, elementRadius); - if (tp === Result.BelowMin) return Result.BelowMin; + if (tp === Result.BelowMin) return false; if (tp === Result.WithinMax) withinRange = true; } } @@ -91,7 +91,7 @@ namespace MaxRadiusDist { return false; } - export function toPoint(ctx: QueryContext, s: Structure, point: Vec3, radius: number, maxDist: number, elementRadius: QueryFn<number>) { + function toPoint(ctx: QueryContext, s: Structure, point: Vec3, radius: number, maxDist: number, elementRadius: QueryFn<number>) { const { units } = s; for (let i = 0, _i = units.length; i < _i; i++) { if (inUnit(ctx, units[i], point, radius, maxDist, elementRadius)) return true; diff --git a/src/mol-model/structure/structure/carbohydrates/constants.ts b/src/mol-model/structure/structure/carbohydrates/constants.ts index aeb5fd82a..b85835115 100644 --- a/src/mol-model/structure/structure/carbohydrates/constants.ts +++ b/src/mol-model/structure/structure/carbohydrates/constants.ts @@ -10,7 +10,7 @@ import { SaccharideNames } from '../../model/types/saccharides'; // follows community standard from https://www.ncbi.nlm.nih.gov/glycans/snfg.html -export const enum SaccharideShape { +export enum SaccharideShape { // standard shapes FilledSphere, FilledCube, CrossedCube, DividedDiamond, FilledCone, DevidedCone, FlatBox, FilledStar, FilledDiamond, FlatDiamond, FlatHexagon, Pentagon, @@ -33,7 +33,7 @@ export const SaccharideColors = ColorMap({ Secondary: 0xf1ece1 }); -export const enum SaccharideType { +export enum SaccharideType { Hexose, HexNAc, Hexosamine, Hexuronate, Deoxyhexose, DeoxyhexNAc, DiDeoxyhexose, Pentose, Deoxynonulosonate, DiDeoxynonulosonate, Unknown, Assigned } diff --git a/src/mol-model/structure/structure/unit.ts b/src/mol-model/structure/structure/unit.ts index 8d64234ad..b6c8fc172 100644 --- a/src/mol-model/structure/structure/unit.ts +++ b/src/mol-model/structure/structure/unit.ts @@ -36,6 +36,9 @@ type Unit = Unit.Atomic | Unit.Spheres | Unit.Gaussians namespace Unit { export const enum Kind { Atomic, Spheres, Gaussians } + // To use with isolatedModules + export enum Kinds { Atomic = Kind.Atomic, Spheres = Kind.Spheres, Gaussians = Kind.Gaussians } + export function isAtomic(u: Unit): u is Atomic { return u.kind === Kind.Atomic; } export function isCoarse(u: Unit): u is Spheres | Gaussians { return u.kind === Kind.Spheres || u.kind === Kind.Gaussians; } export function isSpheres(u: Unit): u is Spheres { return u.kind === Kind.Spheres; } @@ -122,7 +125,7 @@ namespace Unit { } export type Traits = BitFlags<Trait> - export const enum Trait { + export enum Trait { None = 0x0, MultiChain = 0x1, Partitioned = 0x2 diff --git a/src/mol-theme/clipping.ts b/src/mol-theme/clipping.ts index 04dd03558..bbb22aea3 100644 --- a/src/mol-theme/clipping.ts +++ b/src/mol-theme/clipping.ts @@ -26,7 +26,7 @@ namespace Clipping { export type Groups = BitFlags<Groups.Flag> export namespace Groups { export const is: (g: Groups, f: Flag) => boolean = BitFlags.has; - export const enum Flag { + export enum Flag { None = 0x0, One = 0x1, Two = 0x2, diff --git a/src/mol-theme/color.ts b/src/mol-theme/color.ts index 90de9ea13..ff40261e1 100644 --- a/src/mol-theme/color.ts +++ b/src/mol-theme/color.ts @@ -42,6 +42,7 @@ import { ModelIndexColorThemeProvider } from './color/model-index'; import { StructureIndexColorThemeProvider } from './color/structure-index'; import { VolumeSegmentColorThemeProvider } from './color/volume-segment'; import { ExternalVolumeColorThemeProvider } from './color/external-volume'; +import { ColorThemeCategory } from './color/categories'; export type LocationColor = (location: Location, isSecondary: boolean) => Color @@ -87,14 +88,7 @@ type ColorTheme<P extends PD.Params, G extends ColorType = ColorTypeLocation> = G extends ColorTypeDirect ? ColorThemeDirect<P> : never namespace ColorTheme { - export const enum Category { - Atom = 'Atom Property', - Chain = 'Chain Property', - Residue = 'Residue Property', - Symmetry = 'Symmetry', - Validation = 'Validation', - Misc = 'Miscellaneous', - } + export const Category = ColorThemeCategory; export interface Palette { filter?: TextureFilter, diff --git a/src/mol-theme/color/atom-id.ts b/src/mol-theme/color/atom-id.ts index 6a44911a0..b40569d6e 100644 --- a/src/mol-theme/color/atom-id.ts +++ b/src/mol-theme/color/atom-id.ts @@ -7,11 +7,12 @@ import { StructureProperties, StructureElement, Bond, Structure } from '../../mol-model/structure'; import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'many-distinct'; const DefaultColor = Color(0xFAFAFA); @@ -83,7 +84,7 @@ export function AtomIdColorTheme(ctx: ThemeDataContext, props: PD.Values<AtomIdC export const AtomIdColorThemeProvider: ColorTheme.Provider<AtomIdColorThemeParams, 'atom-id'> = { name: 'atom-id', label: 'Atom Id', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: AtomIdColorTheme, getParams: getAtomIdColorThemeParams, defaultValues: PD.getDefaultValues(AtomIdColorThemeParams), diff --git a/src/mol-theme/color/carbohydrate-symbol.ts b/src/mol-theme/color/carbohydrate-symbol.ts index 928b78500..ff615b21e 100644 --- a/src/mol-theme/color/carbohydrate-symbol.ts +++ b/src/mol-theme/color/carbohydrate-symbol.ts @@ -7,11 +7,12 @@ import { StructureElement, Bond, ElementIndex, Unit, Model } from '../../mol-model/structure'; import { SaccharideColors, MonosaccharidesColorTable } from '../../mol-model/structure/structure/carbohydrates/constants'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { Color } from '../../mol-util/color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { TableLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).'; @@ -63,7 +64,7 @@ export function CarbohydrateSymbolColorTheme(ctx: ThemeDataContext, props: PD.Va export const CarbohydrateSymbolColorThemeProvider: ColorTheme.Provider<CarbohydrateSymbolColorThemeParams, 'carbohydrate-symbol'> = { name: 'carbohydrate-symbol', label: 'Carbohydrate Symbol', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: CarbohydrateSymbolColorTheme, getParams: getCarbohydrateSymbolColorThemeParams, defaultValues: PD.getDefaultValues(CarbohydrateSymbolColorThemeParams), diff --git a/src/mol-theme/color/categories.ts b/src/mol-theme/color/categories.ts new file mode 100644 index 000000000..9c23cbf22 --- /dev/null +++ b/src/mol-theme/color/categories.ts @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +export const ColorThemeCategory = { + Atom: 'Atom Property', + Chain: 'Chain Property', + Residue: 'Residue Property', + Symmetry: 'Symmetry', + Validation: 'Validation', + Misc: 'Miscellaneous', +}; \ No newline at end of file diff --git a/src/mol-theme/color/chain-id.ts b/src/mol-theme/color/chain-id.ts index 936a67c6b..0797e7e74 100644 --- a/src/mol-theme/color/chain-id.ts +++ b/src/mol-theme/color/chain-id.ts @@ -7,11 +7,12 @@ import { Unit, StructureProperties, StructureElement, Bond, Structure, Model } from '../../mol-model/structure'; import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'many-distinct'; const DefaultColor = Color(0xFAFAFA); @@ -119,7 +120,7 @@ export function ChainIdColorTheme(ctx: ThemeDataContext, props: PD.Values<ChainI export const ChainIdColorThemeProvider: ColorTheme.Provider<ChainIdColorThemeParams, 'chain-id'> = { name: 'chain-id', label: 'Chain Id', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: ChainIdColorTheme, getParams: getChainIdColorThemeParams, defaultValues: PD.getDefaultValues(ChainIdColorThemeParams), diff --git a/src/mol-theme/color/element-index.ts b/src/mol-theme/color/element-index.ts index 21118f9cd..cd6b06fdd 100644 --- a/src/mol-theme/color/element-index.ts +++ b/src/mol-theme/color/element-index.ts @@ -8,11 +8,12 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond } from '../../mol-model/structure'; import { OrderedSet } from '../../mol-data/int'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.'; @@ -75,7 +76,7 @@ export function ElementIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<E export const ElementIndexColorThemeProvider: ColorTheme.Provider<ElementIndexColorThemeParams, 'element-index'> = { name: 'element-index', label: 'Element Index', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: ElementIndexColorTheme, getParams: getElementIndexColorThemeParams, defaultValues: PD.getDefaultValues(ElementIndexColorThemeParams), diff --git a/src/mol-theme/color/element-symbol.ts b/src/mol-theme/color/element-symbol.ts index a466848df..29d49ad9d 100644 --- a/src/mol-theme/color/element-symbol.ts +++ b/src/mol-theme/color/element-symbol.ts @@ -8,7 +8,7 @@ import { ElementSymbol } from '../../mol-model/structure/model/types'; import { Color, ColorMap } from '../../mol-util/color'; import { StructureElement, Unit, Bond } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { TableLegend } from '../../mol-util/legend'; @@ -21,6 +21,7 @@ import { assertUnreachable } from '../../mol-util/type-helpers'; import { EntitySourceColorTheme, EntitySourceColorThemeParams } from './entity-source'; import { ModelIndexColorTheme, ModelIndexColorThemeParams } from './model-index'; import { StructureIndexColorTheme, StructureIndexColorThemeParams } from './structure-index'; +import { ColorThemeCategory } from './categories'; // from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF) export const ElementSymbolColors = ColorMap({ @@ -112,7 +113,7 @@ export function ElementSymbolColorTheme(ctx: ThemeDataContext, props: PD.Values< export const ElementSymbolColorThemeProvider: ColorTheme.Provider<ElementSymbolColorThemeParams, 'element-symbol'> = { name: 'element-symbol', label: 'Element Symbol', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: ElementSymbolColorTheme, getParams: getElementSymbolColorThemeParams, defaultValues: PD.getDefaultValues(ElementSymbolColorThemeParams), diff --git a/src/mol-theme/color/entity-id.ts b/src/mol-theme/color/entity-id.ts index 2a89b5523..3c8dcde14 100644 --- a/src/mol-theme/color/entity-id.ts +++ b/src/mol-theme/color/entity-id.ts @@ -7,11 +7,12 @@ import { StructureProperties, StructureElement, Bond, Structure, Unit } from '../../mol-model/structure'; import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'many-distinct'; const DefaultColor = Color(0xFAFAFA); @@ -113,7 +114,7 @@ export function EntityIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Entit export const EntityIdColorThemeProvider: ColorTheme.Provider<EntityIdColorThemeParams, 'entity-id'> = { name: 'entity-id', label: 'Entity Id', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: EntityIdColorTheme, getParams: getEntityIdColorThemeParams, defaultValues: PD.getDefaultValues(EntityIdColorThemeParams), diff --git a/src/mol-theme/color/entity-source.ts b/src/mol-theme/color/entity-source.ts index cb136024a..d6638e679 100644 --- a/src/mol-theme/color/entity-source.ts +++ b/src/mol-theme/color/entity-source.ts @@ -7,7 +7,7 @@ import { StructureProperties, StructureElement, Bond, Model } from '../../mol-model/structure'; import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { Table, Column } from '../../mol-data/db'; @@ -17,6 +17,7 @@ import { TableLegend, ScaleLegend } from '../../mol-util/legend'; import { isInteger } from '../../mol-util/number'; import { ColorLists, getColorListFromName } from '../../mol-util/color/lists'; import { MmcifFormat } from '../../mol-model-formats/structure/mmcif'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'dark-2'; const DefaultColor = Color(0xFAFAFA); @@ -78,8 +79,8 @@ function addSrc(seqToSrcByModelEntity: Map<string, Int16Array>, srcKeySerialMap: const sK = srcKey(modelIndex, entityId, scientific_name.value(j), pdbx_src_id.value(j), plasmid, gene); // may not be given (= 0) indicating src is for the whole seq - const beg = pdbx_beg_seq_num.valueKind(j) === Column.ValueKind.Present ? pdbx_beg_seq_num.value(j) : 1; - const end = pdbx_end_seq_num.valueKind(j) === Column.ValueKind.Present ? pdbx_end_seq_num.value(j) : seqToSrc.length; + const beg = pdbx_beg_seq_num.valueKind(j) === Column.ValueKinds.Present ? pdbx_beg_seq_num.value(j) : 1; + const end = pdbx_end_seq_num.valueKind(j) === Column.ValueKinds.Present ? pdbx_end_seq_num.value(j) : seqToSrc.length; let srcIndex: number; // serial no starting from 1 if (srcKeySerialMap.has(sK)) { @@ -178,7 +179,7 @@ export function EntitySourceColorTheme(ctx: ThemeDataContext, props: PD.Values<E export const EntitySourceColorThemeProvider: ColorTheme.Provider<EntitySourceColorThemeParams, 'entity-source'> = { name: 'entity-source', label: 'Entity Source', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: EntitySourceColorTheme, getParams: getEntitySourceColorThemeParams, defaultValues: PD.getDefaultValues(EntitySourceColorThemeParams), diff --git a/src/mol-theme/color/external-volume.ts b/src/mol-theme/color/external-volume.ts index 43fce54d9..5b9ac1624 100644 --- a/src/mol-theme/color/external-volume.ts +++ b/src/mol-theme/color/external-volume.ts @@ -6,7 +6,7 @@ import { Color, ColorScale } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { Grid, Volume } from '../../mol-model/volume'; @@ -14,6 +14,7 @@ import { type PluginContext } from '../../mol-plugin/context'; import { isPositionLocation } from '../../mol-geo/util/location-iterator'; import { Mat4, Vec3 } from '../../mol-math/linear-algebra'; import { lerp } from '../../mol-math/interpolate'; +import { ColorThemeCategory } from './categories'; const Description = `Assigns a color based volume value at a given vertex.`; @@ -151,7 +152,7 @@ export function ExternalVolumeColorTheme(ctx: ThemeDataContext, props: PD.Values export const ExternalVolumeColorThemeProvider: ColorTheme.Provider<ExternalVolumeColorThemeParams, 'external-volume'> = { name: 'external-volume', label: 'External Volume', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: ExternalVolumeColorTheme, getParams: () => ExternalVolumeColorThemeParams, defaultValues: PD.getDefaultValues(ExternalVolumeColorThemeParams), diff --git a/src/mol-theme/color/hydrophobicity.ts b/src/mol-theme/color/hydrophobicity.ts index 40484ca75..3feb165ef 100644 --- a/src/mol-theme/color/hydrophobicity.ts +++ b/src/mol-theme/color/hydrophobicity.ts @@ -7,10 +7,11 @@ import { Color, ColorScale } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { ResidueHydrophobicity } from '../../mol-model/structure/model/types'; +import { ColorThemeCategory } from './categories'; const Description = 'Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).'; @@ -95,7 +96,7 @@ export function HydrophobicityColorTheme(ctx: ThemeDataContext, props: PD.Values export const HydrophobicityColorThemeProvider: ColorTheme.Provider<HydrophobicityColorThemeParams, 'hydrophobicity'> = { name: 'hydrophobicity', label: 'Hydrophobicity', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: HydrophobicityColorTheme, getParams: getHydrophobicityColorThemeParams, defaultValues: PD.getDefaultValues(HydrophobicityColorThemeParams), diff --git a/src/mol-theme/color/illustrative.ts b/src/mol-theme/color/illustrative.ts index 18510ef68..b364e4d89 100644 --- a/src/mol-theme/color/illustrative.ts +++ b/src/mol-theme/color/illustrative.ts @@ -8,7 +8,7 @@ import { ElementSymbol } from '../../mol-model/structure/model/types'; import { Color } from '../../mol-util/color'; import { StructureElement, Unit, Bond } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id'; @@ -19,6 +19,7 @@ import { MoleculeTypeColorTheme, MoleculeTypeColorThemeParams } from './molecule import { EntitySourceColorTheme, EntitySourceColorThemeParams } from './entity-source'; import { ModelIndexColorTheme, ModelIndexColorThemeParams } from './model-index'; import { StructureIndexColorTheme, StructureIndexColorThemeParams } from './structure-index'; +import { ColorThemeCategory } from './categories'; const DefaultIllustrativeColor = Color(0xEEEEEE); const Description = `Assigns an illustrative color that gives every chain a color based on the chosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).`; @@ -83,7 +84,7 @@ export function IllustrativeColorTheme(ctx: ThemeDataContext, props: PD.Values<I export const IllustrativeColorThemeProvider: ColorTheme.Provider<IllustrativeColorThemeParams, 'illustrative'> = { name: 'illustrative', label: 'Illustrative', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: IllustrativeColorTheme, getParams: getIllustrativeColorThemeParams, defaultValues: PD.getDefaultValues(IllustrativeColorThemeParams), diff --git a/src/mol-theme/color/model-index.ts b/src/mol-theme/color/model-index.ts index cbdfd683f..457aee9b5 100644 --- a/src/mol-theme/color/model-index.ts +++ b/src/mol-theme/color/model-index.ts @@ -8,11 +8,12 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond, Model } from '../../mol-model/structure'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every model a unique color based on its index.'; @@ -61,7 +62,7 @@ export function ModelIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<Mod export const ModelIndexColorThemeProvider: ColorTheme.Provider<ModelIndexColorThemeParams, 'model-index'> = { name: 'model-index', label: 'Model Index', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: ModelIndexColorTheme, getParams: getModelIndexColorThemeParams, defaultValues: PD.getDefaultValues(ModelIndexColorThemeParams), diff --git a/src/mol-theme/color/molecule-type.ts b/src/mol-theme/color/molecule-type.ts index 723e5734c..75953becf 100644 --- a/src/mol-theme/color/molecule-type.ts +++ b/src/mol-theme/color/molecule-type.ts @@ -7,7 +7,7 @@ import { Color, ColorMap } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { MoleculeType } from '../../mol-model/structure/model/types'; import { getElementMoleculeType } from '../../mol-model/structure/util'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; @@ -15,6 +15,7 @@ import { ThemeDataContext } from '../theme'; import { TableLegend } from '../../mol-util/legend'; import { getAdjustedColorMap } from '../../mol-util/color/color'; import { getColorMapParams } from '../../mol-util/color/params'; +import { ColorThemeCategory } from './categories'; export const MoleculeTypeColors = ColorMap({ water: 0x386cb0, @@ -84,7 +85,7 @@ export function MoleculeTypeColorTheme(ctx: ThemeDataContext, props: PD.Values<M export const MoleculeTypeColorThemeProvider: ColorTheme.Provider<MoleculeTypeColorThemeParams, 'molecule-type'> = { name: 'molecule-type', label: 'Molecule Type', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: MoleculeTypeColorTheme, getParams: getMoleculeTypeColorThemeParams, defaultValues: PD.getDefaultValues(MoleculeTypeColorThemeParams), diff --git a/src/mol-theme/color/occupancy.ts b/src/mol-theme/color/occupancy.ts index a00f434a7..26ed6f4ad 100644 --- a/src/mol-theme/color/occupancy.ts +++ b/src/mol-theme/color/occupancy.ts @@ -7,9 +7,10 @@ import { Color, ColorScale } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; +import { ColorThemeCategory } from './categories'; const DefaultOccupancyColor = Color(0xCCCCCC); const Description = `Assigns a color based on the occupancy of an atom.`; @@ -61,7 +62,7 @@ export function OccupancyColorTheme(ctx: ThemeDataContext, props: PD.Values<Occu export const OccupancyColorThemeProvider: ColorTheme.Provider<OccupancyColorThemeParams, 'occupancy'> = { name: 'occupancy', label: 'Occupancy', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: OccupancyColorTheme, getParams: getOccupancyColorThemeParams, defaultValues: PD.getDefaultValues(OccupancyColorThemeParams), diff --git a/src/mol-theme/color/operator-hkl.ts b/src/mol-theme/color/operator-hkl.ts index 3062dfc2f..0c8e3d13a 100644 --- a/src/mol-theme/color/operator-hkl.ts +++ b/src/mol-theme/color/operator-hkl.ts @@ -7,7 +7,7 @@ import { Color } from '../../mol-util/color'; import { StructureElement, Bond, Structure } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; @@ -15,6 +15,7 @@ import { ScaleLegend, TableLegend } from '../../mol-util/legend'; import { Vec3 } from '../../mol-math/linear-algebra'; import { integerDigitCount } from '../../mol-util/number'; import { ColorLists, getColorListFromName } from '../../mol-util/color/lists'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'dark-2'; const DefaultColor = Color(0xCCCCCC); @@ -122,7 +123,7 @@ export function OperatorHklColorTheme(ctx: ThemeDataContext, props: PD.Values<Op export const OperatorHklColorThemeProvider: ColorTheme.Provider<OperatorHklColorThemeParams, 'operator-hkl'> = { name: 'operator-hkl', label: 'Operator HKL', - category: ColorTheme.Category.Symmetry, + category: ColorThemeCategory.Symmetry, factory: OperatorHklColorTheme, getParams: getOperatorHklColorThemeParams, defaultValues: PD.getDefaultValues(OperatorHklColorThemeParams), diff --git a/src/mol-theme/color/operator-name.ts b/src/mol-theme/color/operator-name.ts index f77e5b0c2..cc793c2fe 100644 --- a/src/mol-theme/color/operator-name.ts +++ b/src/mol-theme/color/operator-name.ts @@ -7,11 +7,12 @@ import { Color } from '../../mol-util/color'; import { StructureElement, Bond, Structure } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { ScaleLegend, TableLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'many-distinct'; const DefaultColor = Color(0xCCCCCC); @@ -76,7 +77,7 @@ export function OperatorNameColorTheme(ctx: ThemeDataContext, props: PD.Values<O export const OperatorNameColorThemeProvider: ColorTheme.Provider<OperatorNameColorThemeParams, 'operator-name'> = { name: 'operator-name', label: 'Operator Name', - category: ColorTheme.Category.Symmetry, + category: ColorThemeCategory.Symmetry, factory: OperatorNameColorTheme, getParams: getOperatorNameColorThemeParams, defaultValues: PD.getDefaultValues(OperatorNameColorThemeParams), diff --git a/src/mol-theme/color/partial-charge.ts b/src/mol-theme/color/partial-charge.ts index 6baadd9ee..eff097b13 100644 --- a/src/mol-theme/color/partial-charge.ts +++ b/src/mol-theme/color/partial-charge.ts @@ -7,10 +7,11 @@ import { Color, ColorScale } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { AtomPartialCharge } from '../../mol-model-formats/structure/property/partial-charge'; +import { ColorThemeCategory } from './categories'; const DefaultPartialChargeColor = Color(0xffff99); const Description = `Assigns a color based on the partial charge of an atom.`; @@ -59,7 +60,7 @@ export function PartialChargeColorTheme(ctx: ThemeDataContext, props: PD.Values< export const PartialChargeColorThemeProvider: ColorTheme.Provider<PartialChargeColorThemeParams, 'partial-charge'> = { name: 'partial-charge', label: 'Partial Charge', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: PartialChargeColorTheme, getParams: getPartialChargeColorThemeParams, defaultValues: PD.getDefaultValues(PartialChargeColorThemeParams), diff --git a/src/mol-theme/color/polymer-id.ts b/src/mol-theme/color/polymer-id.ts index 1bbe42baf..3392bef34 100644 --- a/src/mol-theme/color/polymer-id.ts +++ b/src/mol-theme/color/polymer-id.ts @@ -8,13 +8,14 @@ import { Unit, StructureProperties, StructureElement, Bond, Structure } from '.. import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPalette, getPaletteParams } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; import { Segmentation } from '../../mol-data/int'; import { ColorLists, getColorListFromName } from '../../mol-util/color/lists'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'dark-2'; const DefaultColor = Color(0xFAFAFA); @@ -129,7 +130,7 @@ export function PolymerIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Poly export const PolymerIdColorThemeProvider: ColorTheme.Provider<PolymerIdColorThemeParams, 'polymer-id'> = { name: 'polymer-id', label: 'Polymer Chain Id', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: PolymerIdColorTheme, getParams: getPolymerIdColorThemeParams, defaultValues: PD.getDefaultValues(PolymerIdColorThemeParams), diff --git a/src/mol-theme/color/polymer-index.ts b/src/mol-theme/color/polymer-index.ts index aaf23e153..8655aaf39 100644 --- a/src/mol-theme/color/polymer-index.ts +++ b/src/mol-theme/color/polymer-index.ts @@ -7,12 +7,13 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond, Structure } from '../../mol-model/structure'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { ColorLists, getColorListFromName } from '../../mol-util/color/lists'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'dark-2'; const DefaultColor = Color(0xCCCCCC); @@ -89,7 +90,7 @@ export function PolymerIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<P export const PolymerIndexColorThemeProvider: ColorTheme.Provider<PolymerIndexColorThemeParams, 'polymer-index'> = { name: 'polymer-index', label: 'Polymer Chain Instance', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: PolymerIndexColorTheme, getParams: getPolymerIndexColorThemeParams, defaultValues: PD.getDefaultValues(PolymerIndexColorThemeParams), diff --git a/src/mol-theme/color/residue-name.ts b/src/mol-theme/color/residue-name.ts index 57e981248..d43b88073 100644 --- a/src/mol-theme/color/residue-name.ts +++ b/src/mol-theme/color/residue-name.ts @@ -7,12 +7,13 @@ import { Color, ColorMap } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { TableLegend } from '../../mol-util/legend'; import { getAdjustedColorMap } from '../../mol-util/color/color'; import { getColorMapParams } from '../../mol-util/color/params'; +import { ColorThemeCategory } from './categories'; // protein colors from Jmol http://jmol.sourceforge.net/jscolors/ export const ResidueNameColors = ColorMap({ @@ -137,7 +138,7 @@ export function ResidueNameColorTheme(ctx: ThemeDataContext, props: PD.Values<Re export const ResidueNameColorThemeProvider: ColorTheme.Provider<ResidueNameColorThemeParams, 'residue-name'> = { name: 'residue-name', label: 'Residue Name', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: ResidueNameColorTheme, getParams: getResidueNameColorThemeParams, defaultValues: PD.getDefaultValues(ResidueNameColorThemeParams), diff --git a/src/mol-theme/color/secondary-structure.ts b/src/mol-theme/color/secondary-structure.ts index 5a3734fa4..0a61cef08 100644 --- a/src/mol-theme/color/secondary-structure.ts +++ b/src/mol-theme/color/secondary-structure.ts @@ -7,7 +7,7 @@ import { Color, ColorMap } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { SecondaryStructureType, MoleculeType } from '../../mol-model/structure/model/types'; import { getElementMoleculeType } from '../../mol-model/structure/util'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; @@ -18,6 +18,7 @@ import { getAdjustedColorMap } from '../../mol-util/color/color'; import { getColorMapParams } from '../../mol-util/color/params'; import { CustomProperty } from '../../mol-model-props/common/custom-property'; import { hash2 } from '../../mol-data/util'; +import { ColorThemeCategory } from './categories'; // from Jmol http://jmol.sourceforge.net/jscolors/ (shapely) const SecondaryStructureColors = ColorMap({ @@ -121,7 +122,7 @@ export function SecondaryStructureColorTheme(ctx: ThemeDataContext, props: PD.Va export const SecondaryStructureColorThemeProvider: ColorTheme.Provider<SecondaryStructureColorThemeParams, 'secondary-structure'> = { name: 'secondary-structure', label: 'Secondary Structure', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: SecondaryStructureColorTheme, getParams: getSecondaryStructureColorThemeParams, defaultValues: PD.getDefaultValues(SecondaryStructureColorThemeParams), diff --git a/src/mol-theme/color/sequence-id.ts b/src/mol-theme/color/sequence-id.ts index 01c3b347f..72389efe1 100644 --- a/src/mol-theme/color/sequence-id.ts +++ b/src/mol-theme/color/sequence-id.ts @@ -8,9 +8,10 @@ import { Unit, StructureElement, Bond, ElementIndex } from '../../mol-model/stru import { ColorScale, Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every polymer residue a color based on its `seq_id` value.'; @@ -113,7 +114,7 @@ export function SequenceIdColorTheme(ctx: ThemeDataContext, props: PD.Values<Seq export const SequenceIdColorThemeProvider: ColorTheme.Provider<SequenceIdColorThemeParams, 'sequence-id'> = { name: 'sequence-id', label: 'Sequence Id', - category: ColorTheme.Category.Residue, + category: ColorThemeCategory.Residue, factory: SequenceIdColorTheme, getParams: getSequenceIdColorThemeParams, defaultValues: PD.getDefaultValues(SequenceIdColorThemeParams), diff --git a/src/mol-theme/color/shape-group.ts b/src/mol-theme/color/shape-group.ts index 68d1b840a..ba4b17144 100644 --- a/src/mol-theme/color/shape-group.ts +++ b/src/mol-theme/color/shape-group.ts @@ -4,12 +4,13 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { ShapeGroup } from '../../mol-model/shape'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Assigns colors as defined by the shape object.'; @@ -38,7 +39,7 @@ export function ShapeGroupColorTheme(ctx: ThemeDataContext, props: PD.Values<Sha export const ShapeGroupColorThemeProvider: ColorTheme.Provider<ShapeGroupColorThemeParams, 'shape-group'> = { name: 'shape-group', label: 'Shape Group', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: ShapeGroupColorTheme, getParams: getShapeGroupColorThemeParams, defaultValues: PD.getDefaultValues(ShapeGroupColorThemeParams), diff --git a/src/mol-theme/color/structure-index.ts b/src/mol-theme/color/structure-index.ts index 28dda9280..6f5cea462 100644 --- a/src/mol-theme/color/structure-index.ts +++ b/src/mol-theme/color/structure-index.ts @@ -7,11 +7,12 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond, Structure } from '../../mol-model/structure'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every structure a unique color based on its index.'; @@ -59,7 +60,7 @@ export function StructureIndexColorTheme(ctx: ThemeDataContext, props: PD.Values export const StructureIndexColorThemeProvider: ColorTheme.Provider<StructureIndexColorThemeParams, 'structure-index'> = { name: 'structure-index', label: 'Structure Index', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: StructureIndexColorTheme, getParams: getStructureIndexColorThemeParams, defaultValues: PD.getDefaultValues(StructureIndexColorThemeParams), diff --git a/src/mol-theme/color/trajectory-index.ts b/src/mol-theme/color/trajectory-index.ts index 87b1b9955..2c027767e 100644 --- a/src/mol-theme/color/trajectory-index.ts +++ b/src/mol-theme/color/trajectory-index.ts @@ -7,11 +7,12 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond, Model } from '../../mol-model/structure'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every model (frame) a unique color based on the index in its trajectory.'; @@ -67,7 +68,7 @@ export function TrajectoryIndexColorTheme(ctx: ThemeDataContext, props: PD.Value export const TrajectoryIndexColorThemeProvider: ColorTheme.Provider<TrajectoryIndexColorThemeParams, 'trajectory-index'> = { name: 'trajectory-index', label: 'Trajectory Index', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: TrajectoryIndexColorTheme, getParams: getTrajectoryIndexColorThemeParams, defaultValues: PD.getDefaultValues(TrajectoryIndexColorThemeParams), diff --git a/src/mol-theme/color/uncertainty.ts b/src/mol-theme/color/uncertainty.ts index 891bc7abb..a37505803 100644 --- a/src/mol-theme/color/uncertainty.ts +++ b/src/mol-theme/color/uncertainty.ts @@ -7,9 +7,10 @@ import { Color, ColorScale } from '../../mol-util/color'; import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; +import { ColorThemeCategory } from './categories'; const DefaultUncertaintyColor = Color(0xffff99); const Description = `Assigns a color based on the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.`; @@ -65,7 +66,7 @@ export function UncertaintyColorTheme(ctx: ThemeDataContext, props: PD.Values<Un export const UncertaintyColorThemeProvider: ColorTheme.Provider<UncertaintyColorThemeParams, 'uncertainty'> = { name: 'uncertainty', label: 'Uncertainty/Disorder', - category: ColorTheme.Category.Atom, + category: ColorThemeCategory.Atom, factory: UncertaintyColorTheme, getParams: getUncertaintyColorThemeParams, defaultValues: PD.getDefaultValues(UncertaintyColorThemeParams), diff --git a/src/mol-theme/color/uniform.ts b/src/mol-theme/color/uniform.ts index a3cbb003e..dd5d296dc 100644 --- a/src/mol-theme/color/uniform.ts +++ b/src/mol-theme/color/uniform.ts @@ -4,12 +4,13 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { Color } from '../../mol-util/color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { TableLegend } from '../../mol-util/legend'; import { defaults } from '../../mol-util'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives everything the same, uniform color.'; @@ -38,7 +39,7 @@ export function UniformColorTheme(ctx: ThemeDataContext, props: PD.Values<Unifor export const UniformColorThemeProvider: ColorTheme.Provider<UniformColorThemeParams, 'uniform'> = { name: 'uniform', label: 'Uniform', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: UniformColorTheme, getParams: getUniformColorThemeParams, defaultValues: PD.getDefaultValues(UniformColorThemeParams), diff --git a/src/mol-theme/color/unit-index.ts b/src/mol-theme/color/unit-index.ts index 54c5ef835..5368b0c33 100644 --- a/src/mol-theme/color/unit-index.ts +++ b/src/mol-theme/color/unit-index.ts @@ -7,12 +7,13 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; import { StructureElement, Bond } from '../../mol-model/structure'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; import { ColorLists, getColorListFromName } from '../../mol-util/color/lists'; +import { ColorThemeCategory } from './categories'; const DefaultList = 'dark-2'; const DefaultColor = Color(0xCCCCCC); @@ -74,7 +75,7 @@ export function UnitIndexColorTheme(ctx: ThemeDataContext, props: PD.Values<Unit export const UnitIndexColorThemeProvider: ColorTheme.Provider<UnitIndexColorThemeParams, 'unit-index'> = { name: 'unit-index', label: 'Chain Instance', - category: ColorTheme.Category.Chain, + category: ColorThemeCategory.Chain, factory: UnitIndexColorTheme, getParams: getUnitIndexColorThemeParams, defaultValues: PD.getDefaultValues(UnitIndexColorThemeParams), diff --git a/src/mol-theme/color/volume-segment.ts b/src/mol-theme/color/volume-segment.ts index 12bfd83bc..e81353cc7 100644 --- a/src/mol-theme/color/volume-segment.ts +++ b/src/mol-theme/color/volume-segment.ts @@ -6,12 +6,13 @@ import { Color } from '../../mol-util/color'; import { Location } from '../../mol-model/location'; -import { ColorTheme, LocationColor } from '../color'; +import type { ColorTheme, LocationColor } from '../color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; import { getPaletteParams, getPalette } from '../../mol-util/color/palette'; import { TableLegend, ScaleLegend } from '../../mol-util/legend'; import { Volume } from '../../mol-model/volume/volume'; +import { ColorThemeCategory } from './categories'; const DefaultColor = Color(0xCCCCCC); const Description = 'Gives every volume segment a unique color.'; @@ -60,7 +61,7 @@ export function VolumeSegmentColorTheme(ctx: ThemeDataContext, props: PD.Values< export const VolumeSegmentColorThemeProvider: ColorTheme.Provider<VolumeSegmentColorThemeParams, 'volume-segment'> = { name: 'volume-segment', label: 'Volume Segment', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: VolumeSegmentColorTheme, getParams: getVolumeSegmentColorThemeParams, defaultValues: PD.getDefaultValues(VolumeSegmentColorThemeParams), diff --git a/src/mol-theme/color/volume-value.ts b/src/mol-theme/color/volume-value.ts index 71c6c9322..aac13ae7b 100644 --- a/src/mol-theme/color/volume-value.ts +++ b/src/mol-theme/color/volume-value.ts @@ -4,13 +4,14 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { ColorTheme } from '../color'; +import type { ColorTheme } from '../color'; import { Color, ColorScale } from '../../mol-util/color'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../theme'; import { ColorNames } from '../../mol-util/color/names'; import { ColorTypeDirect } from '../../mol-geo/geometry/color-data'; import { Volume } from '../../mol-model/volume/volume'; +import { ColorThemeCategory } from './categories'; const Description = 'Assign color based on the given value of a volume cell.'; @@ -54,7 +55,7 @@ export function VolumeValueColorTheme(ctx: ThemeDataContext, props: PD.Values<Vo export const VolumeValueColorThemeProvider: ColorTheme.Provider<VolumeValueColorThemeParams, 'volume-value'> = { name: 'volume-value', label: 'Volume Value', - category: ColorTheme.Category.Misc, + category: ColorThemeCategory.Misc, factory: VolumeValueColorTheme, getParams: getVolumeValueColorThemeParams, defaultValues: PD.getDefaultValues(VolumeValueColorThemeParams), diff --git a/src/mol-theme/label.ts b/src/mol-theme/label.ts index 28f50a6e0..f04c8f658 100644 --- a/src/mol-theme/label.ts +++ b/src/mol-theme/label.ts @@ -254,7 +254,7 @@ function _atomicElementLabel(location: StructureElement.Location<Unit.Atomic>, g const label_asym_id = Props.chain.label_asym_id(location); const auth_asym_id = Props.chain.auth_asym_id(location); - const has_label_seq_id = location.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(rI) === Column.ValueKind.Present; + const has_label_seq_id = location.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(rI) === Column.ValueKinds.Present; const label_seq_id = Props.residue.label_seq_id(location); const auth_seq_id = Props.residue.auth_seq_id(location); const ins_code = Props.residue.pdbx_PDB_ins_code(location); diff --git a/src/mol-theme/size/physical.ts b/src/mol-theme/size/physical.ts index fdd6ff0fd..c46ca41d6 100644 --- a/src/mol-theme/size/physical.ts +++ b/src/mol-theme/size/physical.ts @@ -6,7 +6,7 @@ import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { SizeTheme } from '../size'; +import type { SizeTheme } from '../size'; import { VdwRadius } from '../../mol-model/structure/model/properties/atomic'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; diff --git a/src/mol-theme/size/shape-group.ts b/src/mol-theme/size/shape-group.ts index 226d1c72a..f885cdea4 100644 --- a/src/mol-theme/size/shape-group.ts +++ b/src/mol-theme/size/shape-group.ts @@ -8,7 +8,7 @@ import { Location } from '../../mol-model/location'; import { ShapeGroup } from '../../mol-model/shape'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; -import { SizeTheme } from '../../mol-theme/size'; +import type { SizeTheme } from '../../mol-theme/size'; const DefaultSize = 1; const Description = 'Assigns sizes as defined by the shape object.'; diff --git a/src/mol-theme/size/uncertainty.ts b/src/mol-theme/size/uncertainty.ts index 1e042e899..10bdf62cf 100644 --- a/src/mol-theme/size/uncertainty.ts +++ b/src/mol-theme/size/uncertainty.ts @@ -6,7 +6,7 @@ import { StructureElement, Unit, Bond, ElementIndex } from '../../mol-model/structure'; import { Location } from '../../mol-model/location'; -import { SizeTheme } from '../size'; +import type { SizeTheme } from '../size'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; diff --git a/src/mol-theme/size/uniform.ts b/src/mol-theme/size/uniform.ts index 3bcbe9808..b429c3470 100644 --- a/src/mol-theme/size/uniform.ts +++ b/src/mol-theme/size/uniform.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { SizeTheme } from '../size'; +import type { SizeTheme } from '../size'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { ThemeDataContext } from '../../mol-theme/theme'; diff --git a/src/mol-util/input/input-observer.ts b/src/mol-util/input/input-observer.ts index 56154c531..f83b7e11a 100644 --- a/src/mol-util/input/input-observer.ts +++ b/src/mol-util/input/input-observer.ts @@ -106,7 +106,7 @@ export namespace ButtonsType { export const has: (btn: ButtonsType, f: Flag) => boolean = BitFlags.has; export const create: (fs: Flag) => ButtonsType = BitFlags.create; - export const enum Flag { + export enum Flag { /** No button or un-initialized */ None = 0x0, /** Primary button (usually left) */ @@ -191,7 +191,7 @@ export type ResizeInput = { } -const enum DraggingState { +enum DraggingState { Stopped = 0, Started = 1, Moving = 2 diff --git a/src/servers/model/server/query.ts b/src/servers/model/server/query.ts index ba71804ff..110decb3c 100644 --- a/src/servers/model/server/query.ts +++ b/src/servers/model/server/query.ts @@ -289,7 +289,7 @@ export function abortingObserver(p: Progress) { function string<T>(name: string, str: (data: T, i: number) => string, isSpecified?: (data: T) => boolean): CifField<number, T> { if (isSpecified) { - return CifField.str(name, (i, d) => str(d, i), { valueKind: (i, d) => isSpecified(d) ? Column.ValueKind.Present : Column.ValueKind.NotPresent }); + return CifField.str(name, (i, d) => str(d, i), { valueKind: (i, d) => isSpecified(d) ? Column.ValueKinds.Present : Column.ValueKinds.NotPresent }); } return CifField.str(name, (i, d) => str(d, i)); } diff --git a/src/servers/volume/server/query/encode.ts b/src/servers/volume/server/query/encode.ts index 6cc789f37..c4e51958b 100644 --- a/src/servers/volume/server/query/encode.ts +++ b/src/servers/volume/server/query/encode.ts @@ -29,7 +29,7 @@ interface ResultContext { function string<T>(name: string, str: (data: T) => string, isSpecified?: (data: T) => boolean): CifWriter.Field<number, T> { if (isSpecified) { - return CifWriter.Field.str(name, (i, d) => str(d), { valueKind: (i, d) => isSpecified(d) ? Column.ValueKind.Present : Column.ValueKind.NotPresent }); + return CifWriter.Field.str(name, (i, d) => str(d), { valueKind: (i, d) => isSpecified(d) ? Column.ValueKinds.Present : Column.ValueKinds.NotPresent }); } return CifWriter.Field.str(name, (i, d) => str(d)); } -- GitLab