Browse Source

added EmdbHeaderServer plugin config item

Alexander Rose 5 years ago
parent
commit
9942fbe549

+ 2 - 2
src/mol-plugin/behavior/dynamic/volume-streaming/transformers.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -46,7 +46,7 @@ export const InitVolumeStreaming = StateAction.build({
             options: PD.Group({
                 serverUrl: PD.Text(plugin.config.get(PluginConfig.VolumeStreaming.DefaultServer) || 'https://ds.litemol.org'),
                 behaviorRef: PD.Text('', { isHidden: true }),
-                emContourProvider: PD.Select<'wwpdb' | 'pdbe'>('wwpdb', [['wwpdb', 'wwPDB'], ['pdbe', 'PDBe']], { isHidden: true }),
+                emContourProvider: PD.Select<'emdb' | 'pdbe'>('emdb', [['emdb', 'EMDB'], ['pdbe', 'PDBe']], { isHidden: true }),
                 channelParams: PD.Value<VolumeStreaming.DefaultChannelParams>({}, { isHidden: true })
             })
         };

+ 6 - 5
src/mol-plugin/behavior/dynamic/volume-streaming/util.ts

@@ -10,6 +10,7 @@ import { VolumeServerInfo } from './model';
 import { PluginContext } from '../../../../mol-plugin/context';
 import { RuntimeContext } from '../../../../mol-task';
 import { MmcifFormat } from '../../../../mol-model-formats/structure/mmcif';
+import { PluginConfig } from '../../../config';
 
 export function getStreamingMethod(s?: Structure, defaultKind: VolumeServerInfo.Kind = 'x-ray'): VolumeServerInfo.Kind {
     if (!s) return defaultKind;
@@ -58,16 +59,16 @@ export function getIds(method: VolumeServerInfo.Kind, s?: Structure): string[] {
     }
 }
 
-export async function getContourLevel(provider: 'wwpdb' | 'pdbe', plugin: PluginContext, taskCtx: RuntimeContext, emdbId: string) {
+export async function getContourLevel(provider: 'emdb' | 'pdbe', plugin: PluginContext, taskCtx: RuntimeContext, emdbId: string) {
     switch (provider) {
-        case 'wwpdb': return getContourLevelWwpdb(plugin, taskCtx, emdbId)
+        case 'emdb': return getContourLevelEmdb(plugin, taskCtx, emdbId)
         case 'pdbe': return getContourLevelPdbe(plugin, taskCtx, emdbId)
     }
 }
 
-export async function getContourLevelWwpdb(plugin: PluginContext, taskCtx: RuntimeContext, emdbId: string) {
-    // TODO: parametrize to a differnt URL? in plugin settings perhaps
-    const header = await plugin.fetch({ url: `https://ftp.wwpdb.org/pub/emdb/structures/${emdbId.toUpperCase()}/header/${emdbId.toLowerCase()}.xml`, type: 'xml' }).runInContext(taskCtx);
+export async function getContourLevelEmdb(plugin: PluginContext, taskCtx: RuntimeContext, emdbId: string) {
+    const emdbHeaderServer = plugin.config.get(PluginConfig.VolumeStreaming.EmdbHeaderServer);
+    const header = await plugin.fetch({ url: `${emdbHeaderServer}/${emdbId.toUpperCase()}/header/${emdbId.toLowerCase()}.xml`, type: 'xml' }).runInContext(taskCtx);
     const map = header.getElementsByTagName('map')[0]
     const contourLevel = parseFloat(map.getElementsByTagName('contourLevel')[0].textContent!)
 

+ 2 - 1
src/mol-plugin/config.ts

@@ -31,7 +31,8 @@ export const PluginConfig = {
             return s.models.length === 1 && (Model.hasDensityMap(s.models[0])
                 // the following test is to include e.g. 'updated' files from PDBe
                 || (!Model.isFromPdbArchive(s.models[0]) && s.models[0].entryId.length === 4))
-        })
+        }),
+        EmdbHeaderServer: item('volume-streaming.emdb-header-server', 'https://ftp.wwpdb.org/pub/emdb/structures'),
     },
     Viewport: {
         ShowExpand: item('viewer.show-expand-button', true)