ソースを参照

proteopedia-wrapper: support bcif

David Sehnal 5 年 前
コミット
573c2a7ad6

+ 1 - 0
src/examples/proteopedia-wrapper/helpers.ts

@@ -84,6 +84,7 @@ export type SupportedFormats = 'cif' | 'pdb'
 export interface LoadParams {
     url: string,
     format?: SupportedFormats,
+    isBinary?: boolean,
     assemblyId?: string,
     representationStyle?: RepresentationStyle
 }

+ 9 - 6
src/examples/proteopedia-wrapper/index.html

@@ -60,6 +60,7 @@
                 <option value='cif' selected>CIF</option>
                 <option value='pdb'>PDB</option>
             </select>
+            <input type='checkbox' id='isBinary' style="display: inline-block; width: auto" /> <label for="isBinary"> Binary</label><br />
         </div>
         <div id="app"></div>
         <div id="volume-streaming-wrapper"></div>
@@ -74,8 +75,8 @@
 
             function $(id) { return document.getElementById(id); }
         
-            var pdbId = '1cbs', assemblyId= 'preferred';
-            var url = 'https://www.ebi.ac.uk/pdbe/static/entry/' + pdbId + '_updated.cif';
+            var pdbId = '1cbs', assemblyId= 'preferred', isBinary = true;
+            var url = 'https://www.ebi.ac.uk/pdbe/entry-files/download/' + pdbId + '.bcif'
             var format = 'cif';
             
             $('url').value = url;
@@ -84,13 +85,15 @@
             $('assemblyId').onchange = function (e) { assemblyId = e.target.value; }
             $('format').value = format;
             $('format').onchange = function (e) { format = e.target.value; }
+            $('isBinary').checked = isBinary;
+            $('isBinary').onchange = function (e) { isBinary = !!e.target.checked; };
 
             // var url = 'https://www.ebi.ac.uk/pdbe/entry-files/pdb' + pdbId + '.ent';
             // var format = 'pdb';
             // var assemblyId = 'deposited';
 
             var representationStyle = {
-                sequence: { coloring: 'proteopedia-custom' }, // or just { }
+                // sequence: { coloring: 'proteopedia-custom' }, // or just { }
                 hetGroups: { kind: 'ball-and-stick' }, // or 'spacefill
                 water: { hide: true },
                 snfg3d: { hide: false }
@@ -100,7 +103,7 @@
                 customColorList: CustomColors
             });
             PluginWrapper.setBackground(0xffffff);
-            PluginWrapper.load({ url: url, format: format, assemblyId: assemblyId, representationStyle: representationStyle });
+            PluginWrapper.load({ url: url, format: format, isBinary: isBinary, assemblyId: assemblyId, representationStyle: representationStyle });
             PluginWrapper.toggleSpin();
 
             PluginWrapper.events.modelInfo.subscribe(function (info) {
@@ -108,8 +111,8 @@
                 listHetGroups(info);
             });
 
-            addControl('Load Asym Unit', () => PluginWrapper.load({ url: url, format: format }));
-            addControl('Load Assembly', () => PluginWrapper.load({ url: url, format: format, assemblyId: assemblyId }));
+            addControl('Load Asym Unit', () => PluginWrapper.load({ url: url, format: format, isBinary }));
+            addControl('Load Assembly', () => PluginWrapper.load({ url: url, format: format, isBinary, assemblyId: assemblyId }));
 
             addSeparator();
 

+ 6 - 6
src/examples/proteopedia-wrapper/index.ts

@@ -33,7 +33,7 @@ require('../../mol-plugin-ui/skin/light.scss');
 
 class MolStarProteopediaWrapper {
     static VERSION_MAJOR = 5;
-    static VERSION_MINOR = 0;
+    static VERSION_MINOR = 1;
 
     private _ev = RxEventHelper.create();
 
@@ -74,8 +74,8 @@ class MolStarProteopediaWrapper {
         return this.plugin.state.data;
     }
 
-    private download(b: StateBuilder.To<PSO.Root>, url: string) {
-        return b.apply(StateTransforms.Data.Download, { url: Asset.Url(url), isBinary: false });
+    private download(b: StateBuilder.To<PSO.Root>, url: string, isBinary: boolean) {
+        return b.apply(StateTransforms.Data.Download, { url: Asset.Url(url), isBinary });
     }
 
     private model(b: StateBuilder.To<PSO.Data.Binary | PSO.Data.String>, format: SupportedFormats) {
@@ -195,8 +195,8 @@ class MolStarProteopediaWrapper {
         return PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree });
     }
 
-    private loadedParams: LoadParams = { url: '', format: 'cif', assemblyId: '' };
-    async load({ url, format = 'cif', assemblyId = 'deposited', representationStyle }: LoadParams) {
+    private loadedParams: LoadParams = { url: '', format: 'cif', isBinary: false, assemblyId: '' };
+    async load({ url, format = 'cif', assemblyId = 'deposited', isBinary = false, representationStyle }: LoadParams) {
         let loadType: 'full' | 'update' = 'full';
 
         const state = this.plugin.state.data;
@@ -209,7 +209,7 @@ class MolStarProteopediaWrapper {
 
         if (loadType === 'full') {
             await PluginCommands.State.RemoveObject(this.plugin, { state, ref: state.tree.root.ref });
-            const modelTree = this.model(this.download(state.build().toRoot(), url), format);
+            const modelTree = this.model(this.download(state.build().toRoot(), url, isBinary), format);
             await this.applyState(modelTree);
             const info = await this.doInfo(true);
             const asmId = (assemblyId === 'preferred' && info && info.preferredAssemblyId) || assemblyId;