Skip to content
Snippets Groups Projects
Commit 3cba621f authored by Alexander Rose's avatar Alexander Rose
Browse files

add cantor-pairing functions to mol-script

parent d79a2077
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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),
......
......@@ -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))),
......
......@@ -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'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment