drugflow-molstar 0.1.0 → 0.1.2

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.
package/lib/helpers.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare type LoadParams = {
9
9
  assemblyId?: string;
10
10
  isHetView?: boolean;
11
11
  isBinary?: boolean;
12
+ pdb_string?: string;
12
13
  };
13
14
  export declare namespace PDBeVolumes {
14
15
  function mapParams(defaultParams: any, mapParams: any, ref?: string | number): any;
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ var subscribe_events_1 = require("./subscribe-events");
18
18
  var pdbe_left_panel_1 = require("./ui/pdbe-left-panel");
19
19
  var superposition_1 = require("./superposition");
20
20
  var custom_events_1 = require("./custom-events");
21
- var assets_1 = require("Molstar/mol-util/assets");
21
+ // import { Asset } from 'Molstar/mol-util/assets';
22
22
  var config_1 = require("Molstar/mol-plugin/config");
23
23
  var color_1 = require("Molstar/mol-util/color/color");
24
24
  var component_1 = require("Molstar/mol-plugin-state/manager/structure/component");
@@ -610,7 +610,7 @@ var PDBeMolstarPlugin = /** @class */ (function () {
610
610
  this.plugin.behaviors.layout.leftPanelTabName.next('none');
611
611
  dataSource = this.getMoleculeSrcUrl();
612
612
  if (dataSource) {
613
- this.load({ url: dataSource.url, format: dataSource.format, assemblyId: this.initParams.assemblyId, isBinary: dataSource.isBinary });
613
+ this.load({ url: dataSource.url, format: dataSource.format, assemblyId: this.initParams.assemblyId, isBinary: dataSource.isBinary, pdb_string: dataSource.pdb_string });
614
614
  }
615
615
  // Binding to other PDB Component events
616
616
  if (this.initParams.subscribeEvents) {
@@ -650,8 +650,13 @@ var PDBeMolstarPlugin = /** @class */ (function () {
650
650
  var url = "".concat(this.initParams.pdbeUrl, "model-server/v1/").concat(id, "/").concat(query).concat(sep, "encoding=").concat(this.initParams.encoding).concat(this.initParams.lowPrecisionCoords ? '&lowPrecisionCoords=1' : '');
651
651
  var isBinary = this.initParams.encoding === 'bcif' ? true : false;
652
652
  var format = 'mmcif';
653
+ var pdb_string = undefined;
654
+ console.log('drugflow_test');
653
655
  if (this.initParams.customData) {
654
- if (!this.initParams.customData.url || !this.initParams.customData.format) {
656
+ if (!this.initParams.customData.url && !this.initParams.customData.pdb_string) {
657
+ throw new Error("Provide all custom data parameters");
658
+ }
659
+ if (!this.initParams.customData.format) {
655
660
  throw new Error("Provide all custom data parameters");
656
661
  }
657
662
  url = this.initParams.customData.url;
@@ -662,12 +667,14 @@ var PDBeMolstarPlugin = /** @class */ (function () {
662
667
  if (supportedFormats.indexOf(format) === -1) {
663
668
  throw new Error("".concat(format, " not supported."));
664
669
  }
670
+ pdb_string = this.initParams.customData.pdb_string;
665
671
  isBinary = this.initParams.customData.binary ? this.initParams.customData.binary : false;
666
672
  }
667
673
  return {
668
674
  url: url,
669
675
  format: format,
670
- isBinary: isBinary
676
+ isBinary: isBinary,
677
+ pdb_string: pdb_string
671
678
  };
672
679
  };
673
680
  Object.defineProperty(PDBeMolstarPlugin.prototype, "state", {
@@ -765,48 +772,54 @@ var PDBeMolstarPlugin = /** @class */ (function () {
765
772
  });
766
773
  };
767
774
  PDBeMolstarPlugin.prototype.load = function (_a, fullLoad) {
768
- var url = _a.url, _b = _a.format, format = _b === void 0 ? 'mmcif' : _b, _c = _a.isBinary, isBinary = _c === void 0 ? false : _c, _d = _a.assemblyId, assemblyId = _d === void 0 ? '' : _d;
775
+ var url = _a.url, _b = _a.format, format = _b === void 0 ? 'mmcif' : _b, _c = _a.isBinary, isBinary = _c === void 0 ? false : _c, _d = _a.assemblyId, assemblyId = _d === void 0 ? '' : _d, _e = _a.pdb_string, pdb_string = _e === void 0 ? '' : _e;
769
776
  if (fullLoad === void 0) { fullLoad = true; }
770
777
  return tslib_1.__awaiter(this, void 0, void 0, function () {
771
- var isHetView, downloadOptions, isBranchedView, data, trajectory, model, pivotIndex, pivot, asm, defaultMapParams, pdbeMapParams;
772
- return tslib_1.__generator(this, function (_e) {
773
- switch (_e.label) {
778
+ var isHetView, isBranchedView, data, trajectory, model, pivotIndex, pivot, asm, defaultMapParams, pdbeMapParams;
779
+ return tslib_1.__generator(this, function (_f) {
780
+ switch (_f.label) {
774
781
  case 0:
775
782
  if (fullLoad)
776
783
  this.clear();
777
784
  isHetView = this.initParams.ligandView ? true : false;
778
- downloadOptions = void 0;
779
785
  isBranchedView = false;
780
786
  if (this.initParams.ligandView && this.initParams.ligandView.label_comp_id_list) {
781
787
  isBranchedView = true;
782
- downloadOptions = { body: JSON.stringify(this.initParams.ligandView.label_comp_id_list), headers: [['Content-type', 'application/json']] };
788
+ // downloadOptions = { body: JSON.stringify(this.initParams.ligandView!.label_comp_id_list), headers: [['Content-type', 'application/json']]};
783
789
  }
784
- return [4 /*yield*/, this.plugin.builders.data.download({ url: assets_1.Asset.Url(url, downloadOptions), isBinary: isBinary }, { state: { isGhost: true } })];
790
+ data = null;
791
+ if (!pdb_string) return [3 /*break*/, 2];
792
+ return [4 /*yield*/, this.plugin.builders.data.rawData({ data: pdb_string }, { state: { isGhost: true } })];
785
793
  case 1:
786
- data = _e.sent();
787
- return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(data, format)];
788
- case 2:
789
- trajectory = _e.sent();
790
- if (!!isHetView) return [3 /*break*/, 4];
794
+ data = _f.sent();
795
+ return [3 /*break*/, 4];
796
+ case 2: return [4 /*yield*/, this.plugin.builders.data.download({ url: url }, { state: { isGhost: true } })];
797
+ case 3:
798
+ data = _f.sent();
799
+ _f.label = 4;
800
+ case 4: return [4 /*yield*/, this.plugin.builders.structure.parseTrajectory(data, format)];
801
+ case 5:
802
+ trajectory = _f.sent();
803
+ if (!!isHetView) return [3 /*break*/, 7];
791
804
  return [4 /*yield*/, this.plugin.builders.structure.hierarchy.applyPreset(trajectory, this.initParams.defaultPreset, {
792
805
  structure: assemblyId ? (assemblyId === 'preferred') ? void 0 : { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: {} },
793
806
  showUnitcell: false,
794
807
  representationPreset: 'auto'
795
808
  })];
796
- case 3:
797
- _e.sent();
809
+ case 6:
810
+ _f.sent();
798
811
  if (this.initParams.hideStructure || this.initParams.visualStyle) {
799
812
  this.applyVisualParams();
800
813
  }
801
- return [3 /*break*/, 7];
802
- case 4: return [4 /*yield*/, this.plugin.builders.structure.createModel(trajectory)];
803
- case 5:
804
- model = _e.sent();
814
+ return [3 /*break*/, 10];
815
+ case 7: return [4 /*yield*/, this.plugin.builders.structure.createModel(trajectory)];
816
+ case 8:
817
+ model = _f.sent();
805
818
  return [4 /*yield*/, this.plugin.builders.structure.createStructure(model, { name: 'model', params: {} })];
806
- case 6:
807
- _e.sent();
808
- _e.label = 7;
809
- case 7:
819
+ case 9:
820
+ _f.sent();
821
+ _f.label = 10;
822
+ case 10:
810
823
  // show selection if param is set
811
824
  if (this.initParams.selection) {
812
825
  this.visual.select(this.initParams.selection);
@@ -815,26 +828,26 @@ var PDBeMolstarPlugin = /** @class */ (function () {
815
828
  pivot = this.plugin.managers.structure.hierarchy.selection.structures[pivotIndex];
816
829
  if (pivot && pivot.cell.parent)
817
830
  this.assemblyRef = pivot.cell.transform.ref;
818
- if (!this.initParams.loadMaps) return [3 /*break*/, 9];
831
+ if (!this.initParams.loadMaps) return [3 /*break*/, 12];
819
832
  if (this.assemblyRef === '')
820
833
  return [2 /*return*/];
821
834
  asm = this.state.select(this.assemblyRef)[0].obj;
822
835
  defaultMapParams = transformers_1.InitVolumeStreaming.createDefaultParams(asm, this.plugin);
823
836
  pdbeMapParams = helpers_1.PDBeVolumes.mapParams(defaultMapParams, this.initParams.mapSettings, '');
824
- if (!pdbeMapParams) return [3 /*break*/, 9];
837
+ if (!pdbeMapParams) return [3 /*break*/, 12];
825
838
  return [4 /*yield*/, this.plugin.runTask(this.state.applyAction(transformers_1.InitVolumeStreaming, pdbeMapParams, this.assemblyRef))];
826
- case 8:
827
- _e.sent();
839
+ case 11:
840
+ _f.sent();
828
841
  if (pdbeMapParams.method !== 'em' && !this.initParams.ligandView)
829
842
  helpers_1.PDBeVolumes.displayUsibilityMessage(this.plugin);
830
- _e.label = 9;
831
- case 9:
832
- if (!isHetView) return [3 /*break*/, 11];
843
+ _f.label = 12;
844
+ case 12:
845
+ if (!isHetView) return [3 /*break*/, 14];
833
846
  return [4 /*yield*/, this.createLigandStructure(isBranchedView)];
834
- case 10:
835
- _e.sent();
836
- _e.label = 11;
837
- case 11:
847
+ case 13:
848
+ _f.sent();
849
+ _f.label = 14;
850
+ case 14:
838
851
  this.events.loadComplete.next(true);
839
852
  return [2 /*return*/];
840
853
  }
package/lib/spec.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare type InitParams = {
37
37
  url: string;
38
38
  format: string;
39
39
  binary: boolean;
40
+ pdb_string: string;
40
41
  };
41
42
  loadCartoonsOnly?: boolean;
42
43
  alphafoldView?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drugflow-molstar",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Molstar implementation for DrugFlow",
5
5
  "main": "index.js",
6
6
  "scripts": {