drugflow-molstar 0.4.6 → 0.4.8

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 (54) hide show
  1. package/build/drugflow-molstar-0.4.8.css +1 -0
  2. package/build/drugflow-molstar-component-0.4.8.js +25 -0
  3. package/build/drugflow-molstar-plugin-0.4.8.js +2 -0
  4. package/build/drugflow-molstar-plugin-0.4.8.js.LICENSE.txt +39 -0
  5. package/lib/alphafold-transparency.js +157 -62
  6. package/lib/contact.d.ts +7 -14
  7. package/lib/contact.js +68 -72
  8. package/lib/custom-events.js +15 -15
  9. package/lib/domain-annotations/behavior.d.ts +1 -1
  10. package/lib/domain-annotations/behavior.js +24 -20
  11. package/lib/domain-annotations/color.js +22 -22
  12. package/lib/domain-annotations/prop.js +111 -62
  13. package/lib/drugflow-molstar-component-build-0.4.7.js +2 -0
  14. package/lib/drugflow-molstar-component-build-0.4.7.js.LICENSE.txt +24 -0
  15. package/lib/drugflow-molstar-component-build-0.4.8.js +2 -0
  16. package/lib/drugflow-molstar-component-build-0.4.8.js.LICENSE.txt +24 -0
  17. package/lib/helpers.d.ts +3 -3
  18. package/lib/helpers.js +94 -89
  19. package/lib/index.d.ts +902 -1
  20. package/lib/index.js +2836 -1806
  21. package/lib/labels.d.ts +1 -1
  22. package/lib/labels.js +34 -20
  23. package/lib/loci-details.js +46 -34
  24. package/lib/sifts-mapping.js +32 -28
  25. package/lib/sifts-mappings-behaviour.d.ts +1 -1
  26. package/lib/sifts-mappings-behaviour.js +30 -26
  27. package/lib/spec.js +40 -52
  28. package/lib/structure_contact3d.d.ts +14 -21
  29. package/lib/structure_contact3d.js +46 -25
  30. package/lib/subscribe-events.js +18 -19
  31. package/lib/superposition-export.js +178 -102
  32. package/lib/superposition-focus-representation.d.ts +2 -2
  33. package/lib/superposition-focus-representation.js +131 -73
  34. package/lib/superposition-sifts-mapping.js +150 -105
  35. package/lib/superposition.js +810 -495
  36. package/lib/ui/alphafold-superposition.d.ts +1 -1
  37. package/lib/ui/alphafold-superposition.js +118 -94
  38. package/lib/ui/alphafold-tranparency.js +43 -27
  39. package/lib/ui/annotation-controls.js +89 -83
  40. package/lib/ui/export-superposition.d.ts +0 -1
  41. package/lib/ui/export-superposition.js +50 -32
  42. package/lib/ui/pdbe-left-panel.d.ts +0 -1
  43. package/lib/ui/pdbe-left-panel.js +105 -82
  44. package/lib/ui/pdbe-screenshot-controls.js +83 -54
  45. package/lib/ui/pdbe-structure-controls.js +57 -34
  46. package/lib/ui/pdbe-viewport-controls.js +29 -23
  47. package/lib/ui/segment-tree.js +663 -440
  48. package/lib/ui/superposition-components.js +312 -208
  49. package/lib/ui/superposition-viewport.js +18 -11
  50. package/package.json +3 -3
  51. package/build/drugflow-molstar-0.4.6.css +0 -1
  52. package/build/drugflow-molstar-component-0.4.6.js +0 -25
  53. package/build/drugflow-molstar-plugin-0.4.6.js +0 -2
  54. package/build/drugflow-molstar-plugin-0.4.6.js.LICENSE.txt +0 -64
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SuperpositionFocusRepresentation = exports.SuperpositionFocusRepresentationTags = void 0;
4
- const structure_1 = require("Molstar/mol-model/structure");
5
- const structure_representation_params_1 = require("Molstar/mol-plugin-state/helpers/structure-representation-params");
6
- const transforms_1 = require("Molstar/mol-plugin-state/transforms");
7
- const behavior_1 = require("Molstar/mol-plugin/behavior");
8
- const builder_1 = require("Molstar/mol-script/language/builder");
9
- const mol_state_1 = require("Molstar/mol-state");
10
- const param_definition_1 = require("Molstar/mol-util/param-definition");
11
- const commands_1 = require("Molstar/mol-plugin/commands");
12
- const loci_details_1 = require("./loci-details");
13
- const SuperpositionFocusRepresentationParams = (plugin) => {
14
- const reprParams = transforms_1.StateTransforms.Representation.StructureRepresentation3D.definition.params(void 0, plugin);
4
+ var tslib_1 = require("tslib");
5
+ var structure_1 = require("Molstar/mol-model/structure");
6
+ var structure_representation_params_1 = require("Molstar/mol-plugin-state/helpers/structure-representation-params");
7
+ var transforms_1 = require("Molstar/mol-plugin-state/transforms");
8
+ var behavior_1 = require("Molstar/mol-plugin/behavior");
9
+ var builder_1 = require("Molstar/mol-script/language/builder");
10
+ var mol_state_1 = require("Molstar/mol-state");
11
+ var param_definition_1 = require("Molstar/mol-util/param-definition");
12
+ var commands_1 = require("Molstar/mol-plugin/commands");
13
+ var loci_details_1 = require("./loci-details");
14
+ var SuperpositionFocusRepresentationParams = function (plugin) {
15
+ var reprParams = transforms_1.StateTransforms.Representation.StructureRepresentation3D.definition.params(void 0, plugin);
15
16
  return {
16
17
  expandRadius: param_definition_1.ParamDefinition.Numeric(5, { min: 1, max: 10, step: 1 }),
17
18
  surroundingsParams: param_definition_1.ParamDefinition.Group(reprParams, {
@@ -25,13 +26,21 @@ var SuperpositionFocusRepresentationTags;
25
26
  SuperpositionFocusRepresentationTags["SurrSel"] = "superposition-focus-surr-sel";
26
27
  SuperpositionFocusRepresentationTags["SurrRepr"] = "superposition-focus-surr-repr";
27
28
  })(SuperpositionFocusRepresentationTags || (exports.SuperpositionFocusRepresentationTags = SuperpositionFocusRepresentationTags = {}));
28
- const TagSet = new Set([SuperpositionFocusRepresentationTags.SurrSel, SuperpositionFocusRepresentationTags.SurrRepr]);
29
- class SuperpositionFocusRepresentationBehavior extends behavior_1.PluginBehavior.WithSubscribers {
30
- get surrLabel() { return `[Focus] Surroundings (${this.params.expandRadius} Å)`; }
31
- ensureShape(cell) {
32
- const state = this.plugin.state.data, tree = state.tree;
33
- const builder = state.build();
34
- const refs = mol_state_1.StateSelection.findUniqueTagsInSubtree(tree, cell.transform.ref, TagSet);
29
+ var TagSet = new Set([SuperpositionFocusRepresentationTags.SurrSel, SuperpositionFocusRepresentationTags.SurrRepr]);
30
+ var SuperpositionFocusRepresentationBehavior = /** @class */ (function (_super) {
31
+ tslib_1.__extends(SuperpositionFocusRepresentationBehavior, _super);
32
+ function SuperpositionFocusRepresentationBehavior() {
33
+ return _super !== null && _super.apply(this, arguments) || this;
34
+ }
35
+ Object.defineProperty(SuperpositionFocusRepresentationBehavior.prototype, "surrLabel", {
36
+ get: function () { return "[Focus] Surroundings (".concat(this.params.expandRadius, " \u00C5)"); },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ SuperpositionFocusRepresentationBehavior.prototype.ensureShape = function (cell) {
41
+ var state = this.plugin.state.data, tree = state.tree;
42
+ var builder = state.build();
43
+ var refs = mol_state_1.StateSelection.findUniqueTagsInSubtree(tree, cell.transform.ref, TagSet);
35
44
  // Selections
36
45
  if (!refs[SuperpositionFocusRepresentationTags.SurrSel]) {
37
46
  refs[SuperpositionFocusRepresentationTags.SurrSel] = builder
@@ -44,72 +53,121 @@ class SuperpositionFocusRepresentationBehavior extends behavior_1.PluginBehavior
44
53
  .to(refs[SuperpositionFocusRepresentationTags.SurrSel])
45
54
  .apply(transforms_1.StateTransforms.Representation.StructureRepresentation3D, this.params.surroundingsParams, { tags: SuperpositionFocusRepresentationTags.SurrRepr }).ref;
46
55
  }
47
- return { state, builder, refs };
48
- }
49
- clear(root) {
50
- const state = this.plugin.state.data;
51
- const surrs = state.select(mol_state_1.StateSelection.Generators.byRef(root).subtree().withTag(SuperpositionFocusRepresentationTags.SurrSel));
56
+ return { state: state, builder: builder, refs: refs };
57
+ };
58
+ SuperpositionFocusRepresentationBehavior.prototype.clear = function (root) {
59
+ var e_1, _a;
60
+ var state = this.plugin.state.data;
61
+ var surrs = state.select(mol_state_1.StateSelection.Generators.byRef(root).subtree().withTag(SuperpositionFocusRepresentationTags.SurrSel));
52
62
  if (surrs.length === 0)
53
63
  return;
54
- const update = state.build();
55
- const expression = builder_1.MolScriptBuilder.struct.generator.empty();
56
- for (const s of surrs) {
57
- update.to(s).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, old => ({ ...old, expression }));
64
+ var update = state.build();
65
+ var expression = builder_1.MolScriptBuilder.struct.generator.empty();
66
+ try {
67
+ for (var surrs_1 = tslib_1.__values(surrs), surrs_1_1 = surrs_1.next(); !surrs_1_1.done; surrs_1_1 = surrs_1.next()) {
68
+ var s = surrs_1_1.value;
69
+ update.to(s).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, function (old) { return (tslib_1.__assign(tslib_1.__assign({}, old), { expression: expression })); });
70
+ }
58
71
  }
59
- return commands_1.PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
60
- }
61
- async focus(sourceLoci) {
62
- const parent = this.plugin.helpers.substructureParent.get(sourceLoci.structure);
63
- if (!parent || !parent.obj)
64
- return;
65
- const loci = structure_1.StructureElement.Loci.remap(sourceLoci, parent.obj.data);
66
- const residueLoci = structure_1.StructureElement.Loci.extendToWholeResidues(loci);
67
- const residueBundle = structure_1.StructureElement.Bundle.fromLoci(residueLoci);
68
- const target = structure_1.StructureElement.Bundle.toExpression(residueBundle);
69
- let surroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
70
- 0: target,
71
- radius: this.params.expandRadius,
72
- 'as-whole-residues': true
73
- });
74
- const lociDeatils = (0, loci_details_1.lociDetails)(sourceLoci);
75
- if (!lociDeatils) {
76
- surroundings = builder_1.MolScriptBuilder.struct.modifier.exceptBy({
77
- 0: surroundings,
78
- by: target
79
- });
72
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
73
+ finally {
74
+ try {
75
+ if (surrs_1_1 && !surrs_1_1.done && (_a = surrs_1.return)) _a.call(surrs_1);
76
+ }
77
+ finally { if (e_1) throw e_1.error; }
80
78
  }
81
- const { state, builder, refs } = this.ensureShape(parent);
82
- builder.to(refs[SuperpositionFocusRepresentationTags.SurrSel]).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, old => ({ ...old, expression: surroundings, label: this.surrLabel }));
83
- await commands_1.PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
84
- }
85
- register(ref) {
86
- this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current, (entry) => {
79
+ return commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
80
+ };
81
+ SuperpositionFocusRepresentationBehavior.prototype.focus = function (sourceLoci) {
82
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
83
+ var parent, loci, residueLoci, residueBundle, target, surroundings, lociDeatils, _a, state, builder, refs;
84
+ var _this = this;
85
+ return tslib_1.__generator(this, function (_b) {
86
+ switch (_b.label) {
87
+ case 0:
88
+ parent = this.plugin.helpers.substructureParent.get(sourceLoci.structure);
89
+ if (!parent || !parent.obj)
90
+ return [2 /*return*/];
91
+ loci = structure_1.StructureElement.Loci.remap(sourceLoci, parent.obj.data);
92
+ residueLoci = structure_1.StructureElement.Loci.extendToWholeResidues(loci);
93
+ residueBundle = structure_1.StructureElement.Bundle.fromLoci(residueLoci);
94
+ target = structure_1.StructureElement.Bundle.toExpression(residueBundle);
95
+ surroundings = builder_1.MolScriptBuilder.struct.modifier.includeSurroundings({
96
+ 0: target,
97
+ radius: this.params.expandRadius,
98
+ 'as-whole-residues': true
99
+ });
100
+ lociDeatils = (0, loci_details_1.lociDetails)(sourceLoci);
101
+ if (!lociDeatils) {
102
+ surroundings = builder_1.MolScriptBuilder.struct.modifier.exceptBy({
103
+ 0: surroundings,
104
+ by: target
105
+ });
106
+ }
107
+ _a = this.ensureShape(parent), state = _a.state, builder = _a.builder, refs = _a.refs;
108
+ builder.to(refs[SuperpositionFocusRepresentationTags.SurrSel]).update(transforms_1.StateTransforms.Model.StructureSelectionFromExpression, function (old) { return (tslib_1.__assign(tslib_1.__assign({}, old), { expression: surroundings, label: _this.surrLabel })); });
109
+ return [4 /*yield*/, commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } })];
110
+ case 1:
111
+ _b.sent();
112
+ return [2 /*return*/];
113
+ }
114
+ });
115
+ });
116
+ };
117
+ SuperpositionFocusRepresentationBehavior.prototype.register = function (ref) {
118
+ var _this = this;
119
+ this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current, function (entry) {
87
120
  // if (entry) this.focus(entry.loci);
88
121
  // else this.clear(StateTransform.RootRef);
89
- this.clear(mol_state_1.StateTransform.RootRef);
122
+ _this.clear(mol_state_1.StateTransform.RootRef);
90
123
  if (entry)
91
- this.focus(entry.loci);
124
+ _this.focus(entry.loci);
92
125
  });
93
- }
94
- async update(params) {
95
- const old = this.params;
96
- this.params = params;
97
- const state = this.plugin.state.data;
98
- const builder = state.build();
99
- const all = mol_state_1.StateSelection.Generators.root.subtree();
100
- for (const repr of state.select(all.withTag(SuperpositionFocusRepresentationTags.SurrRepr))) {
101
- builder.to(repr).update(this.params.surroundingsParams);
102
- }
103
- await commands_1.PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } });
104
- if (params.expandRadius !== old.expandRadius)
105
- await this.clear(mol_state_1.StateTransform.RootRef);
106
- return true;
107
- }
108
- }
126
+ };
127
+ SuperpositionFocusRepresentationBehavior.prototype.update = function (params) {
128
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
129
+ var old, state, builder, all, _a, _b, repr;
130
+ var e_2, _c;
131
+ return tslib_1.__generator(this, function (_d) {
132
+ switch (_d.label) {
133
+ case 0:
134
+ old = this.params;
135
+ this.params = params;
136
+ state = this.plugin.state.data;
137
+ builder = state.build();
138
+ all = mol_state_1.StateSelection.Generators.root.subtree();
139
+ try {
140
+ for (_a = tslib_1.__values(state.select(all.withTag(SuperpositionFocusRepresentationTags.SurrRepr))), _b = _a.next(); !_b.done; _b = _a.next()) {
141
+ repr = _b.value;
142
+ builder.to(repr).update(this.params.surroundingsParams);
143
+ }
144
+ }
145
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
146
+ finally {
147
+ try {
148
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
149
+ }
150
+ finally { if (e_2) throw e_2.error; }
151
+ }
152
+ return [4 /*yield*/, commands_1.PluginCommands.State.Update(this.plugin, { state: state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } })];
153
+ case 1:
154
+ _d.sent();
155
+ if (!(params.expandRadius !== old.expandRadius)) return [3 /*break*/, 3];
156
+ return [4 /*yield*/, this.clear(mol_state_1.StateTransform.RootRef)];
157
+ case 2:
158
+ _d.sent();
159
+ _d.label = 3;
160
+ case 3: return [2 /*return*/, true];
161
+ }
162
+ });
163
+ });
164
+ };
165
+ return SuperpositionFocusRepresentationBehavior;
166
+ }(behavior_1.PluginBehavior.WithSubscribers));
109
167
  exports.SuperpositionFocusRepresentation = behavior_1.PluginBehavior.create({
110
168
  name: 'create-superposition-focus-representation',
111
169
  display: { name: 'Superposition Focus Representation' },
112
170
  category: 'interaction',
113
171
  ctor: SuperpositionFocusRepresentationBehavior,
114
- params: (_, plugin) => SuperpositionFocusRepresentationParams(plugin)
172
+ params: function (_, plugin) { return SuperpositionFocusRepresentationParams(plugin); }
115
173
  });
@@ -1,90 +1,124 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alignAndSuperposeWithSIFTSMapping = void 0;
4
- const int_1 = require("Molstar/mol-data/int");
5
- const minimize_rmsd_1 = require("Molstar/mol-math/linear-algebra/3d/minimize-rmsd");
6
- const sifts_mapping_1 = require("./sifts-mapping");
7
- const element_1 = require("Molstar/mol-model/structure/structure/element");
3
+ exports.alignAndSuperposeWithSIFTSMapping = alignAndSuperposeWithSIFTSMapping;
4
+ var tslib_1 = require("tslib");
5
+ var int_1 = require("Molstar/mol-data/int");
6
+ var minimize_rmsd_1 = require("Molstar/mol-math/linear-algebra/3d/minimize-rmsd");
7
+ var sifts_mapping_1 = require("./sifts-mapping");
8
+ var element_1 = require("Molstar/mol-model/structure/structure/element");
8
9
  function alignAndSuperposeWithSIFTSMapping(structures, options) {
9
- const indexMap = new Map();
10
- for (let i = 0; i < structures.length; i++) {
11
- let includeResidueTest = options?.includeResidueTest ?? _includeAllResidues;
12
- if (options?.applyTestIndex && !options.applyTestIndex.includes(i))
10
+ var e_1, _a;
11
+ var _b, _c;
12
+ var indexMap = new Map();
13
+ for (var i = 0; i < structures.length; i++) {
14
+ var includeResidueTest = (_b = options === null || options === void 0 ? void 0 : options.includeResidueTest) !== null && _b !== void 0 ? _b : _includeAllResidues;
15
+ if ((options === null || options === void 0 ? void 0 : options.applyTestIndex) && !options.applyTestIndex.includes(i))
13
16
  includeResidueTest = _includeAllResidues;
14
- buildIndex(structures[i], indexMap, i, options?.traceOnly ?? true, includeResidueTest);
17
+ buildIndex(structures[i], indexMap, i, (_c = options === null || options === void 0 ? void 0 : options.traceOnly) !== null && _c !== void 0 ? _c : true, includeResidueTest);
15
18
  }
16
- const index = Array.from(indexMap.values());
19
+ var index = Array.from(indexMap.values());
17
20
  // TODO: support non-first structure pivots
18
- const pairs = findPairs(structures.length, index);
19
- const zeroOverlapPairs = [];
20
- const failedPairs = [];
21
- const entries = [];
22
- for (const p of pairs) {
23
- if (p.count === 0) {
24
- zeroOverlapPairs.push([p.i, p.j]);
25
- }
26
- else {
27
- const [a, b] = getPositionTables(index, p.i, p.j, p.count);
28
- const transform = minimize_rmsd_1.MinimizeRmsd.compute({ a, b });
29
- if (Number.isNaN(transform.rmsd)) {
30
- failedPairs.push([p.i, p.j]);
21
+ var pairs = findPairs(structures.length, index);
22
+ var zeroOverlapPairs = [];
23
+ var failedPairs = [];
24
+ var entries = [];
25
+ try {
26
+ for (var pairs_1 = tslib_1.__values(pairs), pairs_1_1 = pairs_1.next(); !pairs_1_1.done; pairs_1_1 = pairs_1.next()) {
27
+ var p = pairs_1_1.value;
28
+ if (p.count === 0) {
29
+ zeroOverlapPairs.push([p.i, p.j]);
31
30
  }
32
31
  else {
33
- entries.push({ transform, pivot: p.i, other: p.j });
32
+ var _d = tslib_1.__read(getPositionTables(index, p.i, p.j, p.count), 2), a = _d[0], b = _d[1];
33
+ var transform = minimize_rmsd_1.MinimizeRmsd.compute({ a: a, b: b });
34
+ if (Number.isNaN(transform.rmsd)) {
35
+ failedPairs.push([p.i, p.j]);
36
+ }
37
+ else {
38
+ entries.push({ transform: transform, pivot: p.i, other: p.j });
39
+ }
34
40
  }
35
41
  }
36
42
  }
37
- return { entries, zeroOverlapPairs, failedPairs };
43
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
44
+ finally {
45
+ try {
46
+ if (pairs_1_1 && !pairs_1_1.done && (_a = pairs_1.return)) _a.call(pairs_1);
47
+ }
48
+ finally { if (e_1) throw e_1.error; }
49
+ }
50
+ return { entries: entries, zeroOverlapPairs: zeroOverlapPairs, failedPairs: failedPairs };
38
51
  }
39
- exports.alignAndSuperposeWithSIFTSMapping = alignAndSuperposeWithSIFTSMapping;
40
52
  function getPositionTables(index, pivot, other, N) {
41
- const xs = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
42
- const ys = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
43
- let o = 0;
44
- for (const { pivots } of index) {
45
- const a = pivots[pivot];
46
- const b = pivots[other];
47
- if (!a || !b)
48
- continue;
49
- const l = Math.min(a[2] - a[1], b[2] - b[1]);
50
- // TODO: check if residue types match?
51
- for (let i = 0; i < l; i++) {
52
- let eI = (a[1] + i);
53
- xs.x[o] = a[0].conformation.x(eI);
54
- xs.y[o] = a[0].conformation.y(eI);
55
- xs.z[o] = a[0].conformation.z(eI);
56
- eI = (b[1] + i);
57
- ys.x[o] = b[0].conformation.x(eI);
58
- ys.y[o] = b[0].conformation.y(eI);
59
- ys.z[o] = b[0].conformation.z(eI);
60
- o++;
53
+ var e_2, _a;
54
+ var xs = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
55
+ var ys = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
56
+ var o = 0;
57
+ try {
58
+ for (var index_1 = tslib_1.__values(index), index_1_1 = index_1.next(); !index_1_1.done; index_1_1 = index_1.next()) {
59
+ var pivots = index_1_1.value.pivots;
60
+ var a = pivots[pivot];
61
+ var b = pivots[other];
62
+ if (!a || !b)
63
+ continue;
64
+ var l = Math.min(a[2] - a[1], b[2] - b[1]);
65
+ // TODO: check if residue types match?
66
+ for (var i = 0; i < l; i++) {
67
+ var eI = (a[1] + i);
68
+ xs.x[o] = a[0].conformation.x(eI);
69
+ xs.y[o] = a[0].conformation.y(eI);
70
+ xs.z[o] = a[0].conformation.z(eI);
71
+ eI = (b[1] + i);
72
+ ys.x[o] = b[0].conformation.x(eI);
73
+ ys.y[o] = b[0].conformation.y(eI);
74
+ ys.z[o] = b[0].conformation.z(eI);
75
+ o++;
76
+ }
77
+ }
78
+ }
79
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
80
+ finally {
81
+ try {
82
+ if (index_1_1 && !index_1_1.done && (_a = index_1.return)) _a.call(index_1);
61
83
  }
84
+ finally { if (e_2) throw e_2.error; }
62
85
  }
63
86
  return [xs, ys];
64
87
  }
65
88
  function findPairs(N, index) {
66
- const pairwiseCounts = [];
67
- for (let i = 0; i < N; i++) {
89
+ var e_3, _a;
90
+ var pairwiseCounts = [];
91
+ for (var i = 0; i < N; i++) {
68
92
  pairwiseCounts[i] = [];
69
- for (let j = 0; j < N; j++)
93
+ for (var j = 0; j < N; j++)
70
94
  pairwiseCounts[i][j] = 0;
71
95
  }
72
- for (const { pivots } of index) {
73
- for (let i = 0; i < N; i++) {
74
- if (!pivots[i])
75
- continue;
76
- const lI = pivots[i][2] - pivots[i][1];
77
- for (let j = i + 1; j < N; j++) {
78
- if (!pivots[j])
96
+ try {
97
+ for (var index_2 = tslib_1.__values(index), index_2_1 = index_2.next(); !index_2_1.done; index_2_1 = index_2.next()) {
98
+ var pivots = index_2_1.value.pivots;
99
+ for (var i = 0; i < N; i++) {
100
+ if (!pivots[i])
79
101
  continue;
80
- const lJ = pivots[j][2] - pivots[j][1];
81
- pairwiseCounts[i][j] = pairwiseCounts[i][j] + Math.min(lI, lJ);
102
+ var lI = pivots[i][2] - pivots[i][1];
103
+ for (var j = i + 1; j < N; j++) {
104
+ if (!pivots[j])
105
+ continue;
106
+ var lJ = pivots[j][2] - pivots[j][1];
107
+ pairwiseCounts[i][j] = pairwiseCounts[i][j] + Math.min(lI, lJ);
108
+ }
82
109
  }
83
110
  }
84
111
  }
85
- const ret = [];
86
- for (let j = 1; j < N; j++) {
87
- ret[j - 1] = { i: 0, j, count: pairwiseCounts[0][j] };
112
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
113
+ finally {
114
+ try {
115
+ if (index_2_1 && !index_2_1.done && (_a = index_2.return)) _a.call(index_2);
116
+ }
117
+ finally { if (e_3) throw e_3.error; }
118
+ }
119
+ var ret = [];
120
+ for (var j = 1; j < N; j++) {
121
+ ret[j - 1] = { i: 0, j: j, count: pairwiseCounts[0][j] };
88
122
  }
89
123
  // TODO: support non-first structure pivots
90
124
  // for (let i = 0; i < N - 1; i++) {
@@ -101,53 +135,64 @@ function findPairs(N, index) {
101
135
  }
102
136
  function _includeAllResidues() { return true; }
103
137
  function buildIndex(structure, index, sI, traceOnly, includeTest) {
104
- const loc = element_1.StructureElement.Location.create(structure);
105
- for (const unit of structure.units) {
106
- if (unit.kind !== 0 /* Unit.Kind.Atomic */)
107
- continue;
108
- const { elements, model } = unit;
109
- loc.unit = unit;
110
- const map = sifts_mapping_1.SIFTSMapping.Provider.get(model).value;
111
- if (!map)
112
- return;
113
- const { dbName, accession, num } = map;
114
- const chainsIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.chainAtomSegments, elements);
115
- const residuesIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
116
- const traceElementIndex = unit.model.atomicHierarchy.derived.residue.traceElementIndex;
117
- while (chainsIt.hasNext) {
118
- const chainSegment = chainsIt.move();
119
- residuesIt.setSegment(chainSegment);
120
- while (residuesIt.hasNext) {
121
- const residueSegment = residuesIt.move();
122
- const rI = residueSegment.index;
123
- if (!dbName[rI])
124
- continue;
125
- const traceElement = traceElementIndex[rI];
126
- let start, end;
127
- if (traceOnly) {
128
- start = traceElement;
129
- if (start === -1)
138
+ var e_4, _a, _b;
139
+ var loc = element_1.StructureElement.Location.create(structure);
140
+ try {
141
+ for (var _c = tslib_1.__values(structure.units), _d = _c.next(); !_d.done; _d = _c.next()) {
142
+ var unit = _d.value;
143
+ if (unit.kind !== 0 /* Unit.Kind.Atomic */)
144
+ continue;
145
+ var elements = unit.elements, model = unit.model;
146
+ loc.unit = unit;
147
+ var map = sifts_mapping_1.SIFTSMapping.Provider.get(model).value;
148
+ if (!map)
149
+ return;
150
+ var dbName = map.dbName, accession = map.accession, num = map.num;
151
+ var chainsIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.chainAtomSegments, elements);
152
+ var residuesIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
153
+ var traceElementIndex = unit.model.atomicHierarchy.derived.residue.traceElementIndex;
154
+ while (chainsIt.hasNext) {
155
+ var chainSegment = chainsIt.move();
156
+ residuesIt.setSegment(chainSegment);
157
+ while (residuesIt.hasNext) {
158
+ var residueSegment = residuesIt.move();
159
+ var rI = residueSegment.index;
160
+ if (!dbName[rI])
130
161
  continue;
131
- end = start + 1;
132
- }
133
- else {
134
- start = elements[residueSegment.start];
135
- end = elements[residueSegment.end - 1] + 1;
136
- }
137
- loc.element = (traceElement >= 0 ? traceElement : start);
138
- if (!includeTest(loc, rI, start, end))
139
- continue;
140
- const key = `${dbName[rI]}-${accession[rI].split('-')[0]}-${num[rI]}`;
141
- if (!index.has(key)) {
142
- index.set(key, { key, pivots: { [sI]: [unit, start, end] } });
143
- }
144
- else {
145
- const entry = index.get(key);
146
- if (!entry.pivots[sI]) {
147
- entry.pivots[sI] = [unit, start, end];
162
+ var traceElement = traceElementIndex[rI];
163
+ var start = void 0, end = void 0;
164
+ if (traceOnly) {
165
+ start = traceElement;
166
+ if (start === -1)
167
+ continue;
168
+ end = start + 1;
169
+ }
170
+ else {
171
+ start = elements[residueSegment.start];
172
+ end = elements[residueSegment.end - 1] + 1;
173
+ }
174
+ loc.element = (traceElement >= 0 ? traceElement : start);
175
+ if (!includeTest(loc, rI, start, end))
176
+ continue;
177
+ var key = "".concat(dbName[rI], "-").concat(accession[rI].split('-')[0], "-").concat(num[rI]);
178
+ if (!index.has(key)) {
179
+ index.set(key, { key: key, pivots: (_b = {}, _b[sI] = [unit, start, end], _b) });
180
+ }
181
+ else {
182
+ var entry = index.get(key);
183
+ if (!entry.pivots[sI]) {
184
+ entry.pivots[sI] = [unit, start, end];
185
+ }
148
186
  }
149
187
  }
150
188
  }
151
189
  }
152
190
  }
191
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
192
+ finally {
193
+ try {
194
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
195
+ }
196
+ finally { if (e_4) throw e_4.error; }
197
+ }
153
198
  }