Jelajahi Sumber

add Download providers to Config

Alexander Rose 5 tahun lalu
induk
melakukan
2a7d258715

+ 13 - 8
src/mol-plugin-state/actions/structure.ts

@@ -17,6 +17,7 @@ import { StateTransforms } from '../transforms';
 import { Download } from '../transforms/data';
 import { CustomModelProperties, CustomStructureProperties, TrajectoryFromModelAndCoordinates } from '../transforms/model';
 import { Asset } from '../../mol-util/assets';
+import { PluginConfig } from '../../mol-plugin/config';
 
 const DownloadModelRepresentationOptions = (plugin: PluginContext) => PD.Group({
     type: RootStructureDefinition.getParams(void 0, 'auto').type,
@@ -26,6 +27,16 @@ const DownloadModelRepresentationOptions = (plugin: PluginContext) => PD.Group({
     asTrajectory: PD.Optional(PD.Boolean(false, { description: 'Load all entries into a single trajectory.' }))
 }, { isExpanded: false });
 
+export const PdbDownloadProvider = {
+    'rcsb': PD.Group({
+        encoding: PD.Select('bcif', [['cif', 'cif'], ['bcif', 'bcif']] as ['cif' | 'bcif', string][]),
+    }, { label: 'RCSB PDB', isFlat: true }),
+    'pdbe': PD.Group({
+        variant: PD.Select('updated-bcif', [['updated-bcif', 'Updated (bcif)'], ['updated', 'Updated'], ['archival', 'Archival']] as ['updated' | 'archival', string][]),
+    }, { label: 'PDBe', isFlat: true }),
+};
+export type PdbDownloadProvider = keyof typeof PdbDownloadProvider;
+
 export { DownloadStructure };
 type DownloadStructure = typeof DownloadStructure
 const DownloadStructure = StateAction.build({
@@ -33,19 +44,13 @@ const DownloadStructure = StateAction.build({
     display: { name: 'Download Structure', description: 'Load a structure from the provided source and create its representation.' },
     params: (_, plugin: PluginContext) => {
         const options = DownloadModelRepresentationOptions(plugin);
+        const defaultPdbProvider = plugin.config.get(PluginConfig.Download.DefaultPdbProvider) || 'pdbe';
         return {
             source: PD.MappedStatic('pdb', {
                 'pdb': PD.Group({
                     provider: PD.Group({
                         id: PD.Text('1tqn', { label: 'PDB Id(s)', description: 'One or more comma/space separated PDB ids.' }),
-                        server: PD.MappedStatic('pdbe', {
-                            'rcsb': PD.Group({
-                                encoding: PD.Select('bcif', [['cif', 'cif'], ['bcif', 'bcif']] as ['cif' | 'bcif', string][]),
-                            }, { label: 'RCSB PDB', isFlat: true }),
-                            'pdbe': PD.Group({
-                                variant: PD.Select('updated-bcif', [['updated-bcif', 'Updated (bcif)'], ['updated', 'Updated'], ['archival', 'Archival']] as ['updated' | 'archival', string][]),
-                            }, { label: 'PDBe', isFlat: true }),
-                        }),
+                        server: PD.MappedStatic(defaultPdbProvider, PdbDownloadProvider),
                     }, { pivot: 'id' }),
                     options
                 }, { isFlat: true, label: 'PDB' }),

+ 3 - 1
src/mol-plugin-state/actions/volume.ts

@@ -16,6 +16,8 @@ import { DataFormatProvider } from '../formats/provider';
 import { Asset } from '../../mol-util/assets';
 import { StateTransforms } from '../transforms';
 
+export type EmdbDownloadProvider = 'pdbe' | 'rcsb'
+
 export { DownloadDensity };
 type DownloadDensity = typeof DownloadDensity
 const DownloadDensity = StateAction.build({
@@ -42,7 +44,7 @@ const DownloadDensity = StateAction.build({
                 'pdb-emd-ds': PD.Group({
                     provider: PD.Group({
                         id: PD.Text('emd-8004', { label: 'Id' }),
-                        server: PD.Select('pdbe', [['pdbe', 'PDBe'], ['rcsb', 'RCSB PDB']]),
+                        server: PD.Select<EmdbDownloadProvider>('pdbe', [['pdbe', 'PDBe'], ['rcsb', 'RCSB PDB']]),
                     }, { pivot: 'id' }),
                     detail: PD.Numeric(3, { min: 0, max: 10, step: 1 }, { label: 'Detail' }),
                 }, { isFlat: true }),

+ 1 - 1
src/mol-plugin-state/formats/volume.ts

@@ -176,7 +176,7 @@ export const DscifProvider = DataFormatProvider({
         if (volumes.length > 0) {
             visuals[0] = tree
                 .to(volumes[0])
-                .apply(StateTransforms.Representation.VolumeRepresentation3D, VolumeRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'isosurface', { isoValue: VolumeIsoValue.relative(1.5), alpha: 0.3 }, 'uniform', { value: ColorNames.teal }))
+                .apply(StateTransforms.Representation.VolumeRepresentation3D, VolumeRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'isosurface', { isoValue: VolumeIsoValue.relative(1.5), alpha: 1 }, 'uniform', { value: ColorNames.teal }))
                 .selector;
         }
 

+ 2 - 2
src/mol-plugin-ui/state/tree.tsx

@@ -49,8 +49,8 @@ export class StateTree extends PluginUIComponent<{ state: State }, { showActions
         const ref = this.props.state.tree.root.ref;
         if (this.state.showActions) {
             return <div style={{ margin: '10px', cursor: 'default' }}>
-                <p>Nothing to see here.</p>
-                <p>Structures can be loaded from the <Icon svg={HomeOutlined} /> tab.</p>
+                <p>Nothing to see here yet.</p>
+                <p>Structures and Volumes can be loaded from the <Icon svg={HomeOutlined} /> tab.</p>
             </div>;
         }
         return <StateTreeNode cell={this.props.state.cells.get(ref)!} depth={0} />;

+ 6 - 0
src/mol-plugin/config.ts

@@ -7,6 +7,8 @@
 
 import { Structure, Model } from '../mol-model/structure';
 import { PluginContext } from './context';
+import { PdbDownloadProvider } from '../mol-plugin-state/actions/structure';
+import { EmdbDownloadProvider } from '../mol-plugin-state/actions/volume';
 
 export class PluginConfigItem<T = any> {
     toString() { return this.key; }
@@ -36,6 +38,10 @@ export const PluginConfig = {
         ShowExpand: item('viewer.show-expand-button', true),
         ShowSelectionMode: item('viewer.show-selection-model-button', true),
         ShowAnimation: item('viewer.show-animation-button', true),
+    },
+    Download: {
+        DefaultPdbProvider: item<PdbDownloadProvider>('download.default-pdb-provider', 'pdbe'),
+        DefaultEmdbProvider: item<EmdbDownloadProvider>('download.default-emdb-provider', 'pdbe'),
     }
 };