molstar 3.0.0-dev.8 → 3.0.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/build/viewer/molstar.js +1 -1
  2. package/lib/apps/viewer/app.d.ts +230 -0
  3. package/lib/apps/viewer/app.js +515 -0
  4. package/lib/apps/viewer/index.d.ts +2 -225
  5. package/lib/apps/viewer/index.js +2 -509
  6. package/lib/commonjs/apps/viewer/app.d.ts +230 -0
  7. package/lib/commonjs/apps/viewer/app.js +521 -0
  8. package/lib/commonjs/apps/viewer/index.d.ts +2 -225
  9. package/lib/commonjs/apps/viewer/index.js +2 -512
  10. package/lib/commonjs/mol-canvas3d/canvas3d.js +1 -1
  11. package/lib/commonjs/mol-io/reader/mol2/parser.d.ts +1 -1
  12. package/lib/commonjs/mol-io/reader/mol2/parser.js +33 -3
  13. package/lib/commonjs/mol-io/reader/mol2/schema.d.ts +12 -1
  14. package/lib/commonjs/mol-io/reader/mol2/schema.js +1 -1
  15. package/lib/commonjs/mol-model/structure/structure/element/stats.js +8 -0
  16. package/lib/commonjs/mol-model/structure/structure/unit/bonds/common.d.ts +2 -1
  17. package/lib/commonjs/mol-model/structure/structure/unit/bonds/common.js +11 -2
  18. package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -1
  19. package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.js +20 -10
  20. package/lib/commonjs/mol-model/structure/structure/unit/bonds/intra-compute.d.ts +1 -1
  21. package/lib/commonjs/mol-model/structure/structure/unit/bonds/intra-compute.js +21 -11
  22. package/lib/commonjs/mol-model-formats/structure/mol2.d.ts +1 -1
  23. package/lib/commonjs/mol-model-formats/structure/mol2.js +37 -7
  24. package/lib/commonjs/mol-model-formats/structure/property/bonds/index-pair.d.ts +18 -1
  25. package/lib/commonjs/mol-model-formats/structure/property/bonds/index-pair.js +18 -5
  26. package/lib/commonjs/mol-plugin/config.d.ts +1 -1
  27. package/lib/commonjs/mol-plugin-state/actions/structure.d.ts +1 -0
  28. package/lib/commonjs/mol-plugin-state/actions/structure.js +41 -8
  29. package/lib/mol-canvas3d/canvas3d.js +1 -1
  30. package/lib/mol-io/reader/mol2/parser.d.ts +1 -1
  31. package/lib/mol-io/reader/mol2/parser.js +33 -3
  32. package/lib/mol-io/reader/mol2/schema.d.ts +12 -1
  33. package/lib/mol-io/reader/mol2/schema.js +1 -1
  34. package/lib/mol-model/structure/structure/element/stats.js +8 -0
  35. package/lib/mol-model/structure/structure/unit/bonds/common.d.ts +2 -1
  36. package/lib/mol-model/structure/structure/unit/bonds/common.js +9 -1
  37. package/lib/mol-model/structure/structure/unit/bonds/inter-compute.d.ts +1 -1
  38. package/lib/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -11
  39. package/lib/mol-model/structure/structure/unit/bonds/intra-compute.d.ts +1 -1
  40. package/lib/mol-model/structure/structure/unit/bonds/intra-compute.js +22 -12
  41. package/lib/mol-model-formats/structure/mol2.d.ts +1 -1
  42. package/lib/mol-model-formats/structure/mol2.js +37 -7
  43. package/lib/mol-model-formats/structure/property/bonds/index-pair.d.ts +18 -1
  44. package/lib/mol-model-formats/structure/property/bonds/index-pair.js +18 -5
  45. package/lib/mol-plugin/config.d.ts +1 -1
  46. package/lib/mol-plugin/version.js +2 -2
  47. package/lib/mol-plugin-state/actions/structure.d.ts +1 -0
  48. package/lib/mol-plugin-state/actions/structure.js +41 -8
  49. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author David Sehnal <david.sehnal@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -17,4 +17,5 @@ export declare const MetalsSet: Set<number>;
17
17
  export declare function getElementIdx(e: ElementSymbol): number;
18
18
  export declare function getElementPairThreshold(i: number, j: number): number;
19
19
  export declare function getElementThreshold(i: number): number;
20
+ export declare function getPairingThreshold(elementIndexA: number, elementIndexB: number, thresholdA: number, thresholdB: number): number;
20
21
  export declare function isHydrogen(i: number): boolean;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
4
4
  *
5
5
  * @author David Sehnal <david.sehnal@gmail.com>
6
6
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.isHydrogen = exports.getElementThreshold = exports.getElementPairThreshold = exports.getElementIdx = exports.MetalsSet = exports.DefaultBondComputationProps = exports.DefaultBondMaxRadius = void 0;
9
+ exports.isHydrogen = exports.getPairingThreshold = exports.getElementThreshold = exports.getElementPairThreshold = exports.getElementIdx = exports.MetalsSet = exports.DefaultBondComputationProps = exports.DefaultBondMaxRadius = void 0;
10
10
  /** Default for atomic bonds */
11
11
  exports.DefaultBondMaxRadius = 4;
12
12
  exports.DefaultBondComputationProps = {
@@ -105,6 +105,15 @@ function getElementThreshold(i) {
105
105
  return r;
106
106
  }
107
107
  exports.getElementThreshold = getElementThreshold;
108
+ function getPairingThreshold(elementIndexA, elementIndexB, thresholdA, thresholdB) {
109
+ var thresholdAB = getElementPairThreshold(elementIndexA, elementIndexB);
110
+ return thresholdAB > 0
111
+ ? thresholdAB
112
+ : elementIndexB < 0
113
+ ? thresholdA
114
+ : (thresholdA + thresholdB) / 1.95; // not sure if avg or min but max is too big
115
+ }
116
+ exports.getPairingThreshold = getPairingThreshold;
108
117
  var H_ID = __ElementIndex['H'];
109
118
  function isHydrogen(i) {
110
119
  return i === H_ID;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author David Sehnal <david.sehnal@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
4
4
  *
5
5
  * @author David Sehnal <david.sehnal@gmail.com>
6
6
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -70,11 +70,26 @@ function findPairBonds(unitA, unitB, props, builder) {
70
70
  var _bI = int_1.SortedArray.indexOf(unitB.elements, bI);
71
71
  if (_bI < 0)
72
72
  continue;
73
- if (type_symbolA.value(aI) === 'H' && type_symbolB.value(bI) === 'H')
74
- continue;
73
+ var aeI_1 = (0, common_1.getElementIdx)(type_symbolA.value(aI));
74
+ var beI = (0, common_1.getElementIdx)(type_symbolA.value(bI));
75
75
  var d = distance[i];
76
76
  var dist = getDistance(unitA, aI, unitB, bI);
77
- if ((d !== -1 && (0, common_2.equalEps)(dist, d, 0.5)) || dist < maxDistance) {
77
+ var add = false;
78
+ if (d >= 0) {
79
+ add = (0, common_2.equalEps)(dist, d, 0.3);
80
+ }
81
+ else if (maxDistance >= 0) {
82
+ add = dist < maxDistance;
83
+ }
84
+ else {
85
+ var pairingThreshold = (0, common_1.getPairingThreshold)(aeI_1, beI, (0, common_1.getElementThreshold)(aeI_1), (0, common_1.getElementThreshold)(beI));
86
+ add = dist < pairingThreshold;
87
+ if ((0, common_1.isHydrogen)(aeI_1) && (0, common_1.isHydrogen)(beI)) {
88
+ // TODO handle molecular hydrogen
89
+ add = false;
90
+ }
91
+ }
92
+ if (add) {
78
93
  builder.add(_aI, _bI, { order: order[i], flag: flag[i] });
79
94
  }
80
95
  }
@@ -138,12 +153,7 @@ function findPairBonds(unitA, unitB, props, builder) {
138
153
  var dist = Math.sqrt(squaredDistances[ni]);
139
154
  if (dist === 0)
140
155
  continue;
141
- var thresholdAB = (0, common_1.getElementPairThreshold)(aeI, beI);
142
- var pairingThreshold = thresholdAB > 0
143
- ? thresholdAB
144
- : beI < 0
145
- ? thresholdA
146
- : (thresholdA + (0, common_1.getElementThreshold)(beI)) / 1.95; // not sure if avg or min but max is too big
156
+ var pairingThreshold = (0, common_1.getPairingThreshold)(aeI, beI, thresholdA, (0, common_1.getElementThreshold)(beI));
147
157
  if (dist <= pairingThreshold) {
148
158
  var atomIdB = label_atom_idB.value(bI);
149
159
  var compIdB = label_comp_idB.value(residueIndexB[bI]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author David Sehnal <david.sehnal@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
4
4
  *
5
5
  * @author David Sehnal <david.sehnal@gmail.com>
6
6
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -53,7 +53,8 @@ function findIndexPairBonds(unit) {
53
53
  var orders = [];
54
54
  for (var _aI = 0; _aI < atomCount; _aI++) {
55
55
  var aI = atoms[_aI];
56
- var isHa = type_symbol.value(aI) === 'H';
56
+ var aeI = (0, common_1.getElementIdx)(type_symbol.value(aI));
57
+ var isHa = (0, common_1.isHydrogen)(aeI);
57
58
  var srcA = sourceIndex.value(aI);
58
59
  for (var i = offset[srcA], il = offset[srcA + 1]; i < il; ++i) {
59
60
  var bI = invertedIndex[b[i]];
@@ -62,11 +63,25 @@ function findIndexPairBonds(unit) {
62
63
  var _bI = int_1.SortedArray.indexOf(unit.elements, bI);
63
64
  if (_bI < 0)
64
65
  continue;
65
- if (isHa && type_symbol.value(bI) === 'H')
66
- continue;
66
+ var beI = (0, common_1.getElementIdx)(type_symbol.value(bI));
67
67
  var d = distance[i];
68
68
  var dist = getDistance(unit, aI, bI);
69
- if ((d !== -1 && (0, common_2.equalEps)(dist, d, 0.5)) || dist < maxDistance) {
69
+ var add = false;
70
+ if (d >= 0) {
71
+ add = (0, common_2.equalEps)(dist, d, 0.3);
72
+ }
73
+ else if (maxDistance >= 0) {
74
+ add = dist < maxDistance;
75
+ }
76
+ else {
77
+ var pairingThreshold = (0, common_1.getPairingThreshold)(aeI, beI, (0, common_1.getElementThreshold)(aeI), (0, common_1.getElementThreshold)(beI));
78
+ add = dist < pairingThreshold;
79
+ if (isHa && (0, common_1.isHydrogen)(beI)) {
80
+ // TODO handle molecular hydrogen
81
+ add = false;
82
+ }
83
+ }
84
+ if (add) {
70
85
  atomA[atomA.length] = _aI;
71
86
  atomB[atomB.length] = _bI;
72
87
  orders[orders.length] = order[i];
@@ -190,12 +205,7 @@ function findBonds(unit, props) {
190
205
  var dist = Math.sqrt(squaredDistances[ni]);
191
206
  if (dist === 0)
192
207
  continue;
193
- var thresholdAB = (0, common_1.getElementPairThreshold)(aeI, beI);
194
- var pairingThreshold = thresholdAB > 0
195
- ? thresholdAB
196
- : beI < 0
197
- ? thresholdA
198
- : (thresholdA + (0, common_1.getElementThreshold)(beI)) / 1.95; // not sure if avg or min but max is too big
208
+ var pairingThreshold = (0, common_1.getPairingThreshold)(aeI, beI, thresholdA, (0, common_1.getElementThreshold)(beI));
199
209
  if (dist <= pairingThreshold) {
200
210
  atomA[atomA.length] = _aI;
201
211
  atomB[atomB.length] = _bI;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
5
5
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
4
4
  *
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
6
6
  */
@@ -17,9 +17,12 @@ var index_pair_1 = require("./property/bonds/index-pair");
17
17
  var partial_charge_1 = require("./property/partial-charge");
18
18
  var structure_1 = require("../../mol-model/structure");
19
19
  var util_1 = require("./util");
20
+ var symmetry_1 = require("./property/symmetry");
21
+ var geometry_1 = require("../../mol-math/geometry");
22
+ var linear_algebra_1 = require("../../mol-math/linear-algebra");
20
23
  function getModels(mol2, ctx) {
21
24
  return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
22
- var models, i, il, _a, atoms, bonds, molecule, A, type_symbol, i_1, atom_site, entityBuilder, componentBuilder, i_2, il_1, basics, _models, indexA, indexB, order, flag, pairBonds, first;
25
+ var models, i, il, _a, molecule, atoms, bonds, crysin, A, type_symbol, hasAtomType, i_1, i_2, atom_site, entityBuilder, componentBuilder, i_3, il_1, basics, _models, indexA, indexB, key, order, flag, pairBonds, first, symmetry;
23
26
  return (0, tslib_1.__generator)(this, function (_b) {
24
27
  switch (_b.label) {
25
28
  case 0:
@@ -28,11 +31,20 @@ function getModels(mol2, ctx) {
28
31
  _b.label = 1;
29
32
  case 1:
30
33
  if (!(i < il)) return [3 /*break*/, 4];
31
- _a = mol2.structures[i], atoms = _a.atoms, bonds = _a.bonds, molecule = _a.molecule;
34
+ _a = mol2.structures[i], molecule = _a.molecule, atoms = _a.atoms, bonds = _a.bonds, crysin = _a.crysin;
32
35
  A = db_1.Column.ofConst('A', atoms.count, db_1.Column.Schema.str);
33
36
  type_symbol = new Array(atoms.count);
37
+ hasAtomType = false;
34
38
  for (i_1 = 0; i_1 < atoms.count; ++i_1) {
35
- type_symbol[i_1] = (0, util_1.guessElementSymbolString)(atoms.atom_name.value(i_1));
39
+ if (atoms.atom_type.value(i_1).includes('.')) {
40
+ hasAtomType = true;
41
+ break;
42
+ }
43
+ }
44
+ for (i_2 = 0; i_2 < atoms.count; ++i_2) {
45
+ type_symbol[i_2] = hasAtomType
46
+ ? atoms.atom_type.value(i_2).split('.')[0].toUpperCase()
47
+ : (0, util_1.guessElementSymbolString)(atoms.atom_name.value(i_2));
36
48
  }
37
49
  atom_site = db_1.Table.ofPartialColumns(schema_1.BasicSchema.atom_site, {
38
50
  auth_asym_id: A,
@@ -56,8 +68,8 @@ function getModels(mol2, ctx) {
56
68
  entityBuilder.setNames([['MOL', molecule.mol_name || 'Unknown Entity']]);
57
69
  entityBuilder.getEntityId('MOL', 0 /* Unknown */, 'A');
58
70
  componentBuilder = new component_1.ComponentBuilder(atoms.subst_id, atoms.atom_name);
59
- for (i_2 = 0, il_1 = atoms.subst_name.rowCount; i_2 < il_1; ++i_2) {
60
- componentBuilder.add(atoms.subst_name.value(i_2), i_2);
71
+ for (i_3 = 0, il_1 = atoms.subst_name.rowCount; i_3 < il_1; ++i_3) {
72
+ componentBuilder.add(atoms.subst_name.value(i_3), i_3);
61
73
  }
62
74
  basics = (0, schema_1.createBasic)({
63
75
  entity: entityBuilder.getEntityTable(),
@@ -70,6 +82,7 @@ function getModels(mol2, ctx) {
70
82
  if (_models.frameCount > 0) {
71
83
  indexA = db_1.Column.ofIntArray(db_1.Column.mapToArray(bonds.origin_atom_id, function (x) { return x - 1; }, Int32Array));
72
84
  indexB = db_1.Column.ofIntArray(db_1.Column.mapToArray(bonds.target_atom_id, function (x) { return x - 1; }, Int32Array));
85
+ key = bonds.bond_id;
73
86
  order = db_1.Column.ofIntArray(db_1.Column.mapToArray(bonds.bond_type, function (x) {
74
87
  switch (x) {
75
88
  case 'ar': // aromatic
@@ -96,13 +109,18 @@ function getModels(mol2, ctx) {
96
109
  return 1 /* Covalent */;
97
110
  }
98
111
  }, Int8Array));
99
- pairBonds = index_pair_1.IndexPairBonds.fromData({ pairs: { indexA: indexA, indexB: indexB, order: order, flag: flag }, count: atoms.count });
112
+ pairBonds = index_pair_1.IndexPairBonds.fromData({ pairs: { key: key, indexA: indexA, indexB: indexB, order: order, flag: flag }, count: atoms.count });
100
113
  first = _models.representative;
101
114
  index_pair_1.IndexPairBonds.Provider.set(first, pairBonds);
102
115
  partial_charge_1.AtomPartialCharge.Provider.set(first, {
103
116
  data: atoms.charge,
104
117
  type: molecule.charge_type
105
118
  });
119
+ if (crysin) {
120
+ symmetry = getSymmetry(crysin);
121
+ if (symmetry)
122
+ symmetry_1.ModelSymmetry.Provider.set(first, symmetry);
123
+ }
106
124
  models.push(first);
107
125
  }
108
126
  _b.label = 3;
@@ -114,6 +132,18 @@ function getModels(mol2, ctx) {
114
132
  });
115
133
  });
116
134
  }
135
+ function getSymmetry(crysin) {
136
+ // TODO handle `crysin.setting`
137
+ if (crysin.setting !== 1)
138
+ return;
139
+ var spaceCell = geometry_1.SpacegroupCell.create(crysin.spaceGroup, linear_algebra_1.Vec3.create(crysin.a, crysin.b, crysin.c), linear_algebra_1.Vec3.scale((0, linear_algebra_1.Vec3)(), linear_algebra_1.Vec3.create(crysin.alpha, crysin.beta, crysin.gamma), Math.PI / 180));
140
+ return {
141
+ spacegroup: geometry_1.Spacegroup.create(spaceCell),
142
+ assemblies: [],
143
+ isNonStandardCrystalFrame: false,
144
+ ncsOperators: []
145
+ };
146
+ }
117
147
  var Mol2Format;
118
148
  (function (Mol2Format) {
119
149
  function is(x) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2019-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2019-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
5
5
  */
@@ -10,6 +10,7 @@ import { FormatPropertyProvider } from '../../common/property';
10
10
  import { BondType } from '../../../../mol-model/structure/model/types';
11
11
  import { ElementIndex } from '../../../../mol-model/structure';
12
12
  export declare type IndexPairsProps = {
13
+ readonly key: ArrayLike<number>;
13
14
  readonly order: ArrayLike<number>;
14
15
  readonly distance: ArrayLike<number>;
15
16
  readonly flag: ArrayLike<BondType.Flag>;
@@ -26,13 +27,29 @@ export declare namespace IndexPairBonds {
26
27
  pairs: {
27
28
  indexA: Column<number>;
28
29
  indexB: Column<number>;
30
+ key?: Column<number>;
29
31
  order?: Column<number>;
32
+ /**
33
+ * Useful for bonds in periodic cells. That is, only bonds within the given
34
+ * distance are added. This allows for bond between periodic image but
35
+ * avoids unwanted bonds with wrong distances. If negative, test using the
36
+ * `maxDistance` option from `Props`.
37
+ */
30
38
  distance?: Column<number>;
31
39
  flag?: Column<BondType.Flag>;
32
40
  };
33
41
  count: number;
34
42
  };
35
43
  const DefaultProps: {
44
+ /**
45
+ * If negative, test using element-based threshold, otherwise distance in Angstrom.
46
+ *
47
+ * This option exists to handle bonds in periodic cells. For systems that are
48
+ * made from beads (as opposed to atomic elements), set to a specific distance.
49
+ *
50
+ * Note that `Data` has a `distance` field which allows specifying a distance
51
+ * for each bond individually which takes precedence over this option.
52
+ */
36
53
  maxDistance: number;
37
54
  };
38
55
  type Props = typeof DefaultProps;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2019-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
+ * Copyright (c) 2019-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
4
4
  *
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
6
6
  */
@@ -9,19 +9,20 @@ exports.IndexPairBonds = void 0;
9
9
  var tslib_1 = require("tslib");
10
10
  var graph_1 = require("../../../../mol-math/graph");
11
11
  var property_1 = require("../../common/property");
12
- var common_1 = require("../../../../mol-model/structure/structure/unit/bonds/common");
13
12
  function getGraph(indexA, indexB, props, count) {
14
13
  var builder = new graph_1.IntAdjacencyGraph.EdgeBuilder(count, indexA, indexB);
14
+ var key = new Int32Array(builder.slotCount);
15
15
  var order = new Int8Array(builder.slotCount);
16
16
  var distance = new Array(builder.slotCount);
17
17
  var flag = new Array(builder.slotCount);
18
18
  for (var i = 0, _i = builder.edgeCount; i < _i; i++) {
19
19
  builder.addNextEdge();
20
+ builder.assignProperty(key, props.key ? props.key[i] : -1);
20
21
  builder.assignProperty(order, props.order ? props.order[i] : 1);
21
22
  builder.assignProperty(distance, props.distance ? props.distance[i] : -1);
22
23
  builder.assignProperty(flag, props.flag ? props.flag[i] : 1 /* Covalent */);
23
24
  }
24
- return builder.createGraph({ order: order, distance: distance, flag: flag });
25
+ return builder.createGraph({ key: key, order: order, distance: distance, flag: flag });
25
26
  }
26
27
  var IndexPairBonds;
27
28
  (function (IndexPairBonds) {
@@ -29,18 +30,30 @@ var IndexPairBonds;
29
30
  name: 'index_pair_bonds',
30
31
  };
31
32
  IndexPairBonds.Provider = property_1.FormatPropertyProvider.create(IndexPairBonds.Descriptor);
32
- IndexPairBonds.DefaultProps = { maxDistance: common_1.DefaultBondMaxRadius };
33
+ IndexPairBonds.DefaultProps = {
34
+ /**
35
+ * If negative, test using element-based threshold, otherwise distance in Angstrom.
36
+ *
37
+ * This option exists to handle bonds in periodic cells. For systems that are
38
+ * made from beads (as opposed to atomic elements), set to a specific distance.
39
+ *
40
+ * Note that `Data` has a `distance` field which allows specifying a distance
41
+ * for each bond individually which takes precedence over this option.
42
+ */
43
+ maxDistance: -1
44
+ };
33
45
  function fromData(data, props) {
34
46
  if (props === void 0) { props = {}; }
35
47
  var p = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, IndexPairBonds.DefaultProps), props);
36
48
  var pairs = data.pairs, count = data.count;
37
49
  var indexA = pairs.indexA.toArray();
38
50
  var indexB = pairs.indexB.toArray();
51
+ var key = pairs.key && pairs.key.toArray();
39
52
  var order = pairs.order && pairs.order.toArray();
40
53
  var distance = pairs.distance && pairs.distance.toArray();
41
54
  var flag = pairs.flag && pairs.flag.toArray();
42
55
  return {
43
- bonds: getGraph(indexA, indexB, { order: order, distance: distance, flag: flag }, count),
56
+ bonds: getGraph(indexA, indexB, { key: key, order: order, distance: distance, flag: flag }, count),
44
57
  maxDistance: p.maxDistance
45
58
  };
46
59
  }
@@ -47,7 +47,7 @@ export declare const PluginConfig: {
47
47
  ShowAnimation: PluginConfigItem<boolean>;
48
48
  };
49
49
  Download: {
50
- DefaultPdbProvider: PluginConfigItem<"rcsb" | "pdbe">;
50
+ DefaultPdbProvider: PluginConfigItem<"rcsb" | "pdbe" | "pdbj">;
51
51
  DefaultEmdbProvider: PluginConfigItem<EmdbDownloadProvider>;
52
52
  };
53
53
  Structure: {
@@ -14,6 +14,7 @@ export declare const PdbDownloadProvider: {
14
14
  pdbe: PD.Group<PD.Normalize<{
15
15
  variant: "updated" | "updated-bcif" | "updtaed-bcif" | "archival";
16
16
  }>>;
17
+ pdbj: PD.Group<PD.Normalize<unknown>>;
17
18
  };
18
19
  export declare type PdbDownloadProvider = keyof typeof PdbDownloadProvider;
19
20
  export { DownloadStructure };
@@ -20,6 +20,7 @@ var model_1 = require("../transforms/model");
20
20
  var assets_1 = require("../../mol-util/assets");
21
21
  var config_1 = require("../../mol-plugin/config");
22
22
  var file_info_1 = require("../../mol-util/file-info");
23
+ var type_helpers_1 = require("../../mol-util/type-helpers");
23
24
  var DownloadModelRepresentationOptions = function (plugin) {
24
25
  var representationDefault = plugin.config.get(config_1.PluginConfig.Structure.DefaultRepresentationPreset) || representation_preset_1.PresetStructureRepresentations.auto.id;
25
26
  return param_definition_1.ParamDefinition.Group({
@@ -36,6 +37,7 @@ exports.PdbDownloadProvider = {
36
37
  'pdbe': param_definition_1.ParamDefinition.Group({
37
38
  variant: param_definition_1.ParamDefinition.Select('updated-bcif', [['updated-bcif', 'Updated (bcif)'], ['updated', 'Updated'], ['archival', 'Archival']]),
38
39
  }, { label: 'PDBe', isFlat: true }),
40
+ 'pdbj': param_definition_1.ParamDefinition.EmptyGroup({ label: 'PDBj' }),
39
41
  };
40
42
  var DownloadStructure = mol_state_1.StateAction.build({
41
43
  from: objects_1.PluginStateObject.Root,
@@ -110,14 +112,12 @@ var DownloadStructure = mol_state_1.StateAction.build({
110
112
  format = src.params.format;
111
113
  return [3 /*break*/, 15];
112
114
  case 2: return [4 /*yield*/, (src.params.provider.server.name === 'pdbe'
113
- ? src.params.provider.server.params.variant === 'updated'
114
- ? getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/static/entry/".concat(id.toLowerCase(), "_updated.cif"); }, function (id) { return "PDBe: ".concat(id, " (updated cif)"); }, false)
115
- : src.params.provider.server.params.variant === 'updated-bcif'
116
- ? getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/entry-files/download/".concat(id.toLowerCase(), ".bcif"); }, function (id) { return "PDBe: ".concat(id, " (updated cif)"); }, true)
117
- : getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/static/entry/".concat(id.toLowerCase(), ".cif"); }, function (id) { return "PDBe: ".concat(id, " (cif)"); }, false)
118
- : src.params.provider.server.params.encoding === 'cif'
119
- ? getDownloadParams(src.params.provider.id, function (id) { return "https://files.rcsb.org/download/".concat(id.toUpperCase(), ".cif"); }, function (id) { return "RCSB: ".concat(id, " (cif)"); }, false)
120
- : getDownloadParams(src.params.provider.id, function (id) { return "https://models.rcsb.org/".concat(id.toUpperCase(), ".bcif"); }, function (id) { return "RCSB: ".concat(id, " (bcif)"); }, true))];
115
+ ? getPdbeDownloadParams(src)
116
+ : src.params.provider.server.name === 'pdbj'
117
+ ? getPdbjDownloadParams(src)
118
+ : src.params.provider.server.name === 'rcsb'
119
+ ? getRcsbDownloadParams(src)
120
+ : (0, type_helpers_1.assertUnreachable)(src))];
121
121
  case 3:
122
122
  downloadParams = _b.sent();
123
123
  asTrajectory = !!src.params.options.asTrajectory;
@@ -270,6 +270,39 @@ function getDownloadParams(src, url, label, isBinary) {
270
270
  });
271
271
  });
272
272
  }
273
+ function getPdbeDownloadParams(src) {
274
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
275
+ return (0, tslib_1.__generator)(this, function (_a) {
276
+ if (src.name !== 'pdb' || src.params.provider.server.name !== 'pdbe')
277
+ throw new Error('expected pdbe');
278
+ return [2 /*return*/, src.params.provider.server.params.variant === 'updated'
279
+ ? getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/static/entry/".concat(id.toLowerCase(), "_updated.cif"); }, function (id) { return "PDBe: ".concat(id, " (updated cif)"); }, false)
280
+ : src.params.provider.server.params.variant === 'updated-bcif'
281
+ ? getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/entry-files/download/".concat(id.toLowerCase(), ".bcif"); }, function (id) { return "PDBe: ".concat(id, " (updated cif)"); }, true)
282
+ : getDownloadParams(src.params.provider.id, function (id) { return "https://www.ebi.ac.uk/pdbe/static/entry/".concat(id.toLowerCase(), ".cif"); }, function (id) { return "PDBe: ".concat(id, " (cif)"); }, false)];
283
+ });
284
+ });
285
+ }
286
+ function getPdbjDownloadParams(src) {
287
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
288
+ return (0, tslib_1.__generator)(this, function (_a) {
289
+ if (src.name !== 'pdb' || src.params.provider.server.name !== 'pdbj')
290
+ throw new Error('expected pdbj');
291
+ return [2 /*return*/, getDownloadParams(src.params.provider.id, function (id) { return "https://data.pdbjbk1.pdbj.org/pub/pdb/data/structures/divided/mmCIF/".concat(id.toLowerCase().substring(1, 3), "/").concat(id.toLowerCase(), ".cif"); }, function (id) { return "PDBj: ".concat(id, " (cif)"); }, false)];
292
+ });
293
+ });
294
+ }
295
+ function getRcsbDownloadParams(src) {
296
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
297
+ return (0, tslib_1.__generator)(this, function (_a) {
298
+ if (src.name !== 'pdb' || src.params.provider.server.name !== 'rcsb')
299
+ throw new Error('expected rcsb');
300
+ return [2 /*return*/, src.params.provider.server.params.encoding === 'cif'
301
+ ? getDownloadParams(src.params.provider.id, function (id) { return "https://files.rcsb.org/download/".concat(id.toUpperCase(), ".cif"); }, function (id) { return "RCSB PDB: ".concat(id, " (cif)"); }, false)
302
+ : getDownloadParams(src.params.provider.id, function (id) { return "https://models.rcsb.org/".concat(id.toUpperCase(), ".bcif"); }, function (id) { return "RCSB PDB: ".concat(id, " (bcif)"); }, true)];
303
+ });
304
+ });
305
+ }
273
306
  exports.UpdateTrajectory = mol_state_1.StateAction.build({
274
307
  display: { name: 'Update Trajectory' },
275
308
  params: {
@@ -330,7 +330,7 @@ var Canvas3D;
330
330
  return;
331
331
  }
332
332
  draw();
333
- if (!camera.transition.inTransition && !controls.props.spin && !webgl.isContextLost) {
333
+ if (!camera.transition.inTransition && !webgl.isContextLost) {
334
334
  interactionHelper.tick(currentTime);
335
335
  }
336
336
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Zepei Xu <xuzepei19950617@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Zepei Xu <xuzepei19950617@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -241,9 +241,38 @@ function handleBonds(state) {
241
241
  });
242
242
  });
243
243
  }
244
+ function handleCrysin(state) {
245
+ var tokenizer = state.tokenizer;
246
+ while (tokenizer.position < tokenizer.data.length) {
247
+ var l = getTokenString(tokenizer);
248
+ if (l === '@<TRIPOS>MOLECULE') {
249
+ return;
250
+ }
251
+ else if (l === '@<TRIPOS>CRYSIN') {
252
+ break;
253
+ }
254
+ else {
255
+ markLine(tokenizer);
256
+ }
257
+ }
258
+ if (tokenizer.position >= tokenizer.data.length)
259
+ return;
260
+ markLine(tokenizer);
261
+ var values = getTokenString(tokenizer).trim().split(reWhitespace);
262
+ return {
263
+ a: parseFloat(values[0]),
264
+ b: parseFloat(values[1]),
265
+ c: parseFloat(values[2]),
266
+ alpha: parseFloat(values[3]),
267
+ beta: parseFloat(values[4]),
268
+ gamma: parseFloat(values[5]),
269
+ spaceGroup: parseInt(values[6], 10),
270
+ setting: parseInt(values[7], 10),
271
+ };
272
+ }
244
273
  function parseInternal(ctx, data, name) {
245
274
  return __awaiter(this, void 0, void 0, function () {
246
- var tokenizer, structures, state, atoms, bonds, result;
275
+ var tokenizer, structures, state, atoms, bonds, crysin, result;
247
276
  return __generator(this, function (_a) {
248
277
  switch (_a.label) {
249
278
  case 0:
@@ -261,7 +290,8 @@ function parseInternal(ctx, data, name) {
261
290
  return [4 /*yield*/, handleBonds(state)];
262
291
  case 3:
263
292
  bonds = _a.sent();
264
- structures.push({ molecule: state.molecule, atoms: atoms, bonds: bonds });
293
+ crysin = handleCrysin(state);
294
+ structures.push({ molecule: state.molecule, atoms: atoms, bonds: bonds, crysin: crysin });
265
295
  skipWhitespace(tokenizer);
266
296
  while (getTokenString(tokenizer) !== '@<TRIPOS>MOLECULE' && tokenizer.position < tokenizer.data.length) {
267
297
  markLine(tokenizer);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
5
5
  */
@@ -37,10 +37,21 @@ export interface Mol2Bonds {
37
37
  bond_type: Column<string>;
38
38
  status_bits: Column<string>;
39
39
  }
40
+ export interface Mol2Crysin {
41
+ a: number;
42
+ b: number;
43
+ c: number;
44
+ alpha: number;
45
+ beta: number;
46
+ gamma: number;
47
+ spaceGroup: number;
48
+ setting: number;
49
+ }
40
50
  export interface Mol2Structure {
41
51
  molecule: Readonly<Mol2Molecule>;
42
52
  atoms: Readonly<Mol2Atoms>;
43
53
  bonds: Readonly<Mol2Bonds>;
54
+ crysin?: Readonly<Mol2Crysin>;
44
55
  }
45
56
  export interface Mol2File {
46
57
  name: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
5
5
  */
@@ -49,6 +49,7 @@ export var Stats;
49
49
  }
50
50
  else if (size === 1) {
51
51
  if (Unit.Traits.is(unit.traits, 1 /* MultiChain */)) {
52
+ // handled in `handleUnitChainsSimple`
52
53
  return;
53
54
  }
54
55
  else {
@@ -174,6 +175,13 @@ export var Stats;
174
175
  Location.set(stats.firstChainLoc, structure, unit, offsets[cI]);
175
176
  }
176
177
  }
178
+ else if (size === 1) {
179
+ // need to handle here, skipped in `handleElement`
180
+ stats.elementCount += 1;
181
+ if (stats.elementCount === 1) {
182
+ Location.set(stats.firstElementLoc, structure, unit, eI);
183
+ }
184
+ }
177
185
  }
178
186
  }
179
187
  function handleUnitChainsPartitioned(stats, structure, lociElements, start, end) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2017-2021 Mol* contributors, licensed under MIT, See LICENSE file for more info.
2
+ * Copyright (c) 2017-2022 Mol* contributors, licensed under MIT, See LICENSE file for more info.
3
3
  *
4
4
  * @author David Sehnal <david.sehnal@gmail.com>
5
5
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -17,4 +17,5 @@ export declare const MetalsSet: Set<number>;
17
17
  export declare function getElementIdx(e: ElementSymbol): number;
18
18
  export declare function getElementPairThreshold(i: number, j: number): number;
19
19
  export declare function getElementThreshold(i: number): number;
20
+ export declare function getPairingThreshold(elementIndexA: number, elementIndexB: number, thresholdA: number, thresholdB: number): number;
20
21
  export declare function isHydrogen(i: number): boolean;