diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e8354d4cf1303b8aeb313ce30c90317ab6e6d74..5d2891175b5649cad9291a8252a8d38626a9c4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Note that since we don't clearly distinguish between a public and private interf - Support `ignoreHydrogens` in interactions representation - Add hydroxyproline (HYP) commonly present in collagen molecules to the list of amino acids - Fix assemblies for Archive PDB files (do not generate unique `label_asym_id` if `REMARK 350` is present) +- Add cantor-pairing functions to `mol-script` ## [v3.34.0] - 2023-04-16 diff --git a/src/mol-script/language/symbol-table/core.ts b/src/mol-script/language/symbol-table/core.ts index 4661b69bc8305d6f71b91a66fea91a087b1b1800..6692c5d5e19864bc3c59a950f78cc371811be2b4 100644 --- a/src/mol-script/language/symbol-table/core.ts +++ b/src/mol-script/language/symbol-table/core.ts @@ -46,10 +46,6 @@ export const TTargs = Arguments.Dictionary({ 1: Argument(Type.Num) }); -const XX = { test: Argument(Type.Str) }; -const t: Arguments.PropTypes<typeof XX> = 0 as any; -t.test; - const type = { '@header': 'Types', bool: symbol(Arguments.Dictionary({ 0: Argument(Type.AnyValue) }), Type.Bool, 'Convert a value to boolean.'), @@ -116,6 +112,10 @@ const math = { min: binOp(Type.Num), max: binOp(Type.Num), + cantorPairing: binRel(Type.Num, Type.Num), + sortedCantorPairing: binRel(Type.Num, Type.Num), + invertCantorPairing: symbol(Arguments.Dictionary({ 0: Argument(Type.Num) }), Types.List(Type.Num)), + floor: unaryOp(Type.Num), ceil: unaryOp(Type.Num), roundInt: unaryOp(Type.Num), diff --git a/src/mol-script/runtime/query/table.ts b/src/mol-script/runtime/query/table.ts index a87b23c7e6509c4324585904548578e9f8f10dd6..eee428041ad8eb58c8869cfd9c2d8a4ebafa054d 100644 --- a/src/mol-script/runtime/query/table.ts +++ b/src/mol-script/runtime/query/table.ts @@ -12,7 +12,7 @@ import { ElementSymbol, BondType, SecondaryStructureType } from '../../../mol-mo import { SetUtils } from '../../../mol-util/set'; import { upperCaseAny } from '../../../mol-util/string'; import { VdwRadius, AtomWeight, AtomNumber } from '../../../mol-model/structure/model/properties/atomic'; -import { cantorPairing } from '../../../mol-data/util'; +import { cantorPairing, invertCantorPairing, sortedCantorPairing } from '../../../mol-data/util'; import { bundleElementImpl, bundleGenerator } from '../../../mol-model/structure/query/queries/internal'; import { arrayEqual } from '../../../mol-util/array'; @@ -118,6 +118,10 @@ const symbols = [ return ret; }), + C(MolScript.core.math.cantorPairing, (ctx, v) => cantorPairing(v[0](ctx), v[1](ctx))), + C(MolScript.core.math.sortedCantorPairing, (ctx, v) => sortedCantorPairing(v[0](ctx), v[1](ctx))), + C(MolScript.core.math.invertCantorPairing, (ctx, v) => invertCantorPairing([0, 0], v[0](ctx))), + C(MolScript.core.math.floor, (ctx, v) => Math.floor(v[0](ctx))), C(MolScript.core.math.ceil, (ctx, v) => Math.ceil(v[0](ctx))), C(MolScript.core.math.roundInt, (ctx, v) => Math.round(v[0](ctx))), diff --git a/src/mol-script/script/mol-script/symbols.ts b/src/mol-script/script/mol-script/symbols.ts index feb891928cd41da4977ee58ffee8132a15ed0601..fa9243edc6418e7b9c0951352794407cb3012f03 100644 --- a/src/mol-script/script/mol-script/symbols.ts +++ b/src/mol-script/script/mol-script/symbols.ts @@ -54,6 +54,9 @@ export const SymbolTable = [ Alias(MolScript.core.math.mod, 'mod'), Alias(MolScript.core.math.min, 'min'), Alias(MolScript.core.math.max, 'max'), + Alias(MolScript.core.math.cantorPairing, 'cantor-pairing'), + Alias(MolScript.core.math.sortedCantorPairing, 'sorted-cantor-pairing'), + Alias(MolScript.core.math.invertCantorPairing, 'invert-cantor-pairing'), Alias(MolScript.core.math.floor, 'floor'), Alias(MolScript.core.math.ceil, 'ceil'), Alias(MolScript.core.math.roundInt, 'round'),