Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
72dd2fbe
Commit
72dd2fbe
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: tweaks
parent
9c27896a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-plugin/index.ts
+3
-3
3 additions, 3 deletions
src/mol-plugin/index.ts
src/mol-plugin/state/actions/basic.ts
+17
-19
17 additions, 19 deletions
src/mol-plugin/state/actions/basic.ts
src/mol-util/param-definition.ts
+1
-0
1 addition, 0 deletions
src/mol-util/param-definition.ts
with
21 additions
and
22 deletions
src/mol-plugin/index.ts
+
3
−
3
View file @
72dd2fbe
...
...
@@ -10,7 +10,7 @@ import * as React from 'react';
import
*
as
ReactDOM
from
'
react-dom
'
;
import
{
PluginCommands
}
from
'
./command
'
;
import
{
PluginSpec
}
from
'
./spec
'
;
import
{
Download
Atomic
Structure
,
CreateComplexRepresentation
,
Open
Atomic
Structure
}
from
'
./state/actions/basic
'
;
import
{
DownloadStructure
,
CreateComplexRepresentation
,
OpenStructure
}
from
'
./state/actions/basic
'
;
import
{
StateTransforms
}
from
'
./state/transforms
'
;
import
{
PluginBehaviors
}
from
'
./behavior
'
;
...
...
@@ -21,8 +21,8 @@ function getParam(name: string, regex: string): string {
const
DefaultSpec
:
PluginSpec
=
{
actions
:
[
PluginSpec
.
Action
(
Download
Atomic
Structure
),
PluginSpec
.
Action
(
Open
Atomic
Structure
),
PluginSpec
.
Action
(
DownloadStructure
),
PluginSpec
.
Action
(
OpenStructure
),
PluginSpec
.
Action
(
CreateComplexRepresentation
),
PluginSpec
.
Action
(
StateTransforms
.
Data
.
Download
),
PluginSpec
.
Action
(
StateTransforms
.
Data
.
ParseCif
),
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/state/actions/basic.ts
+
17
−
19
View file @
72dd2fbe
...
...
@@ -17,32 +17,30 @@ import { StateTreeBuilder } from 'mol-state/tree/builder';
// TODO: "structure parser provider"
export
{
DownloadAtomicStructure
}
namespace
DownloadAtomicStructure
{
export
type
Sources
=
'
pdbe-updated
'
|
'
rcsb
'
|
'
bcif-static
'
|
'
url
'
export
type
Source
=
ObtainStructureHelpers
.
MapParams
<
Sources
,
typeof
ObtainStructureHelpers
.
ControlMap
>
export
{
DownloadStructure
}
namespace
DownloadStructure
{
export
type
Source
=
PD
.
NamedParamUnion
<
ObtainStructureHelpers
.
ControlMap
>
export
interface
Params
{
source
:
Source
}
}
namespace
ObtainStructureHelpers
{
export
const
SourceOptions
:
[
DownloadAtomicStructure
.
Sources
,
string
][]
=
[
[
'
pdbe-updated
'
,
'
PDBe Updated
'
],
[
'
rcsb
'
,
'
RCSB
'
],
[
'
bcif-static
'
,
'
BinaryCIF (static PDBe Updated)
'
],
[
'
url
'
,
'
URL
'
]
];
export
const
ControlMap
=
{
'
pdbe-updated
'
:
PD
.
Text
(
'
1cbs
'
,
{
label
:
'
Id
'
}),
'
rcsb
'
:
PD
.
Text
(
'
1tqn
'
,
{
label
:
'
Id
'
}),
'
bcif-static
'
:
PD
.
Text
(
'
1tqn
'
,
{
label
:
'
Id
'
}),
'
url
'
:
PD
.
Group
({
url
:
PD
.
Text
(
''
),
isBinary
:
PD
.
Boolean
(
false
)
},
{
isExpanded
:
true
})
}
export
function
getControls
(
key
:
string
)
{
return
(
ControlMap
as
any
)[
key
];
}
export
type
MapParams
<
P
extends
DownloadAtomicStructure
.
Sources
,
Map
extends
{
[
K
in
P
]:
PD
.
Any
}
>
=
P
extends
DownloadAtomicStructure
.
Sources
?
PD
.
NamedParams
<
Map
[
P
][
'
defaultValue
'
],
P
>
:
never
export
type
ControlMap
=
typeof
ControlMap
export
const
SourceOptions
:
[
keyof
ControlMap
,
string
][]
=
[
[
'
pdbe-updated
'
,
'
PDBe Updated
'
],
[
'
rcsb
'
,
'
RCSB
'
],
[
'
bcif-static
'
,
'
BinaryCIF (static PDBe Updated)
'
],
[
'
url
'
,
'
URL
'
]
];
export
function
getUrl
(
src
:
DownloadAtomicStructure
.
Source
):
Download
.
Params
{
export
function
getControls
(
key
:
string
)
{
return
(
ControlMap
as
any
)[
key
];
}
export
function
getUrl
(
src
:
DownloadStructure
.
Source
):
Download
.
Params
{
switch
(
src
.
name
)
{
case
'
url
'
:
return
src
.
params
;
case
'
pdbe-updated
'
:
return
{
url
:
`https://www.ebi.ac.uk/pdbe/static/entry/
${
src
.
params
.
toLowerCase
()}
_updated.cif`
,
isBinary
:
false
,
label
:
`PDBe:
${
src
.
params
}
`
};
...
...
@@ -52,7 +50,7 @@ namespace ObtainStructureHelpers {
}
}
}
const
Download
Atomic
Structure
=
StateAction
.
create
<
PluginStateObject
.
Root
,
void
,
Download
Atomic
Structure
.
Params
>
({
const
DownloadStructure
=
StateAction
.
create
<
PluginStateObject
.
Root
,
void
,
DownloadStructure
.
Params
>
({
from
:
[
PluginStateObject
.
Root
],
display
:
{
name
:
'
Download Structure
'
,
...
...
@@ -76,11 +74,11 @@ const DownloadAtomicStructure = StateAction.create<PluginStateObject.Root, void,
const
url
=
ObtainStructureHelpers
.
getUrl
(
params
.
source
);
const
data
=
b
.
toRoot
().
apply
(
StateTransforms
.
Data
.
Download
,
url
);
return
state
.
update
(
atomic
StructureTree
(
data
));
return
state
.
update
(
create
StructureTree
(
data
));
}
});
export
const
Open
Atomic
Structure
=
StateAction
.
create
<
PluginStateObject
.
Root
,
void
,
{
file
:
File
}
>
({
export
const
OpenStructure
=
StateAction
.
create
<
PluginStateObject
.
Root
,
void
,
{
file
:
File
}
>
({
from
:
[
PluginStateObject
.
Root
],
display
:
{
name
:
'
Open Structure
'
,
...
...
@@ -90,11 +88,11 @@ export const OpenAtomicStructure = StateAction.create<PluginStateObject.Root, vo
apply
({
params
,
state
})
{
const
b
=
state
.
build
();
const
data
=
b
.
toRoot
().
apply
(
StateTransforms
.
Data
.
ReadFile
,
{
file
:
params
.
file
,
isBinary
:
/
\.
bcif$/i
.
test
(
params
.
file
.
name
)
});
return
state
.
update
(
atomic
StructureTree
(
data
));
return
state
.
update
(
create
StructureTree
(
data
));
}
});
function
atomic
StructureTree
(
b
:
StateTreeBuilder
.
To
<
PluginStateObject
.
Data
.
Binary
|
PluginStateObject
.
Data
.
String
>
):
StateTree
{
function
create
StructureTree
(
b
:
StateTreeBuilder
.
To
<
PluginStateObject
.
Data
.
Binary
|
PluginStateObject
.
Data
.
String
>
):
StateTree
{
const
root
=
b
.
apply
(
StateTransforms
.
Data
.
ParseCif
)
.
apply
(
StateTransforms
.
Model
.
TrajectoryFromMmCif
,
{})
...
...
This diff is collapsed.
Click to expand it.
src/mol-util/param-definition.ts
+
1
−
0
View file @
72dd2fbe
...
...
@@ -146,6 +146,7 @@ export namespace ParamDefinition {
}
export
interface
NamedParams
<
T
=
any
,
K
=
string
>
{
name
:
K
,
params
:
T
}
export
type
NamedParamUnion
<
P
extends
Params
,
K
=
keyof
P
>
=
K
extends
any
?
NamedParams
<
P
[
K
][
'
defaultValue
'
],
K
>
:
never
export
interface
Mapped
<
T
>
extends
Base
<
NamedParams
<
T
>>
{
type
:
'
mapped
'
,
select
:
Select
<
string
>
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment