Browse Source

add option load structure from url

Alexander Rose 5 years ago
parent
commit
eff3db7f1b
2 changed files with 11 additions and 1 deletions
  1. 3 1
      src/structure-viewer/index.html
  2. 8 0
      src/structure-viewer/index.ts

+ 3 - 1
src/structure-viewer/index.html

@@ -46,13 +46,15 @@
             }
 
             const pdbId = getQueryParam('pdbId');
+            const url = getQueryParam('url');
             const assemblyId = getQueryParam('assemblyId') || 'deposited';
 
             // create an instance of the plugin
             var viewer = new app.StructureViewer('app', { showOpenFileControls: !pdbId });
 
-            // load pdbId
+            // load pdbId or url
             if (pdbId) viewer.loadPdbId(pdbId, assemblyId);
+            else if (url) viewer.loadUrl(url, assemblyId);
         </script>
         <div id="menu">
             Examples

+ 8 - 0
src/structure-viewer/index.ts

@@ -103,4 +103,12 @@ export class StructureViewer {
             assemblyId,
         })
     }
+
+    async loadUrl(url: string, assemblyId = 'deposited') {
+        return (this.plugin.customState as StructureViewerState).modelLoader.load({
+            fileOrUrl: url,
+            format: 'cif',
+            assemblyId,
+        })
+    }
 }