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
a5556e8c
Commit
a5556e8c
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
imroved sequence widget entity dropdown
parent
0ce2966c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-plugin/ui/sequence.tsx
+43
-26
43 additions, 26 deletions
src/mol-plugin/ui/sequence.tsx
with
43 additions
and
26 deletions
src/mol-plugin/ui/sequence.tsx
+
43
−
26
View file @
a5556e8c
...
@@ -27,11 +27,18 @@ function opKey(l: StructureElement.Location) {
...
@@ -27,11 +27,18 @@ function opKey(l: StructureElement.Location) {
return
`
${
ids
.
sort
().
join
(
'
,
'
)}
|
${
ncs
}
|
${
hkl
}
|
${
spgrOp
}
`
return
`
${
ids
.
sort
().
join
(
'
,
'
)}
|
${
ncs
}
|
${
hkl
}
|
${
spgrOp
}
`
}
}
function
splitModelEntityId
(
modelEntityId
:
string
)
{
const
[
modelIdx
,
entityId
]
=
modelEntityId
.
split
(
'
|
'
)
return
[
parseInt
(
modelIdx
),
entityId
]
}
function
getSequenceWrapper
(
state
:
SequenceViewState
,
structureSelection
:
StructureElementSelectionManager
):
SequenceWrapper
.
Any
|
undefined
{
function
getSequenceWrapper
(
state
:
SequenceViewState
,
structureSelection
:
StructureElementSelectionManager
):
SequenceWrapper
.
Any
|
undefined
{
const
{
structure
,
e
ntityId
,
invariantUnitId
,
operatorKey
}
=
state
const
{
structure
,
modelE
ntityId
,
invariantUnitId
,
operatorKey
}
=
state
const
l
=
StructureElement
.
Location
.
create
()
const
l
=
StructureElement
.
Location
.
create
()
const
[
modelIdx
,
entityId
]
=
splitModelEntityId
(
modelEntityId
)
for
(
const
unit
of
structure
.
units
)
{
for
(
const
unit
of
structure
.
units
)
{
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
if
(
structure
.
getModelIndex
(
unit
.
model
)
!==
modelIdx
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
if
(
unit
.
invariantId
!==
invariantUnitId
)
continue
if
(
unit
.
invariantId
!==
invariantUnitId
)
continue
if
(
opKey
(
l
)
!==
operatorKey
)
continue
if
(
opKey
(
l
)
!==
operatorKey
)
continue
...
@@ -43,7 +50,7 @@ function getSequenceWrapper(state: SequenceViewState, structureSelection: Struct
...
@@ -43,7 +50,7 @@ function getSequenceWrapper(state: SequenceViewState, structureSelection: Struct
}
}
}
}
function
getEntityOptions
(
structure
:
Structure
)
{
function
get
Model
EntityOptions
(
structure
:
Structure
)
{
const
options
:
[
string
,
string
][]
=
[]
const
options
:
[
string
,
string
][]
=
[]
const
l
=
StructureElement
.
Location
.
create
()
const
l
=
StructureElement
.
Location
.
create
()
const
seen
=
new
Set
<
string
>
()
const
seen
=
new
Set
<
string
>
()
...
@@ -51,25 +58,33 @@ function getEntityOptions(structure: Structure) {
...
@@ -51,25 +58,33 @@ function getEntityOptions(structure: Structure) {
for
(
const
unit
of
structure
.
units
)
{
for
(
const
unit
of
structure
.
units
)
{
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
const
id
=
SP
.
entity
.
id
(
l
)
const
id
=
SP
.
entity
.
id
(
l
)
if
(
seen
.
has
(
id
))
continue
const
modelIdx
=
structure
.
getModelIndex
(
unit
.
model
)
const
key
=
`
${
modelIdx
}
|
${
id
}
`
if
(
seen
.
has
(
key
))
continue
const
label
=
`
${
id
}
:
${
SP
.
entity
.
pdbx_description
(
l
).
join
(
'
,
'
)}
`
let
description
=
SP
.
entity
.
pdbx_description
(
l
).
join
(
'
,
'
)
options
.
push
([
id
,
label
])
if
(
description
.
startsWith
(
'
Polymer
'
)
&&
structure
.
models
.
length
>
1
)
{
seen
.
add
(
id
)
description
+=
` (
${
structure
.
models
[
modelIdx
].
entry
}
)`
}
const
label
=
`
${
id
}
:
${
description
}
`
options
.
push
([
key
,
label
])
seen
.
add
(
key
)
}
}
if
(
options
.
length
===
0
)
options
.
push
([
''
,
'
No entities
'
])
if
(
options
.
length
===
0
)
options
.
push
([
''
,
'
No entities
'
])
return
options
return
options
}
}
function
getUnitOptions
(
structure
:
Structure
,
e
ntityId
:
string
)
{
function
getUnitOptions
(
structure
:
Structure
,
modelE
ntityId
:
string
)
{
const
options
:
[
number
,
string
][]
=
[]
const
options
:
[
number
,
string
][]
=
[]
const
l
=
StructureElement
.
Location
.
create
()
const
l
=
StructureElement
.
Location
.
create
()
const
seen
=
new
Set
<
number
>
()
const
seen
=
new
Set
<
number
>
()
const
water
=
new
Map
<
string
,
number
>
()
const
water
=
new
Map
<
string
,
number
>
()
const
[
modelIdx
,
entityId
]
=
splitModelEntityId
(
modelEntityId
)
for
(
const
unit
of
structure
.
units
)
{
for
(
const
unit
of
structure
.
units
)
{
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
if
(
structure
.
getModelIndex
(
unit
.
model
)
!==
modelIdx
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
const
id
=
unit
.
invariantId
const
id
=
unit
.
invariantId
...
@@ -98,13 +113,15 @@ function getUnitOptions(structure: Structure, entityId: string) {
...
@@ -98,13 +113,15 @@ function getUnitOptions(structure: Structure, entityId: string) {
return
options
return
options
}
}
function
getOperatorOptions
(
structure
:
Structure
,
e
ntityId
:
string
,
invariantUnitId
:
number
)
{
function
getOperatorOptions
(
structure
:
Structure
,
modelE
ntityId
:
string
,
invariantUnitId
:
number
)
{
const
options
:
[
string
,
string
][]
=
[]
const
options
:
[
string
,
string
][]
=
[]
const
l
=
StructureElement
.
Location
.
create
()
const
l
=
StructureElement
.
Location
.
create
()
const
seen
=
new
Set
<
string
>
()
const
seen
=
new
Set
<
string
>
()
const
[
modelIdx
,
entityId
]
=
splitModelEntityId
(
modelEntityId
)
for
(
const
unit
of
structure
.
units
)
{
for
(
const
unit
of
structure
.
units
)
{
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
StructureElement
.
Location
.
set
(
l
,
unit
,
unit
.
elements
[
0
])
if
(
structure
.
getModelIndex
(
unit
.
model
)
!==
modelIdx
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
if
(
SP
.
entity
.
id
(
l
)
!==
entityId
)
continue
if
(
unit
.
invariantId
!==
invariantUnitId
)
continue
if
(
unit
.
invariantId
!==
invariantUnitId
)
continue
...
@@ -135,13 +152,13 @@ function getStructureOptions(state: State) {
...
@@ -135,13 +152,13 @@ function getStructureOptions(state: State) {
type
SequenceViewState
=
{
type
SequenceViewState
=
{
structure
:
Structure
,
structure
:
Structure
,
structureRef
:
string
,
structureRef
:
string
,
e
ntityId
:
string
,
modelE
ntityId
:
string
,
invariantUnitId
:
number
,
invariantUnitId
:
number
,
operatorKey
:
string
operatorKey
:
string
}
}
export
class
SequenceView
extends
PluginUIComponent
<
{
},
SequenceViewState
>
{
export
class
SequenceView
extends
PluginUIComponent
<
{
},
SequenceViewState
>
{
state
=
{
structure
:
Structure
.
Empty
,
structureRef
:
''
,
e
ntityId
:
''
,
invariantUnitId
:
-
1
,
operatorKey
:
''
}
state
=
{
structure
:
Structure
.
Empty
,
structureRef
:
''
,
modelE
ntityId
:
''
,
invariantUnitId
:
-
1
,
operatorKey
:
''
}
componentDidMount
()
{
componentDidMount
()
{
if
(
this
.
plugin
.
state
.
dataState
.
select
(
StateSelection
.
Generators
.
rootsOfType
(
PSO
.
Molecule
.
Structure
)).
length
>
0
)
this
.
setState
(
this
.
getInitialState
())
if
(
this
.
plugin
.
state
.
dataState
.
select
(
StateSelection
.
Generators
.
rootsOfType
(
PSO
.
Molecule
.
Structure
)).
length
>
0
)
this
.
setState
(
this
.
getInitialState
())
...
@@ -180,18 +197,18 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
...
@@ -180,18 +197,18 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
// TODO reuse selected values from previous state if applicable
// TODO reuse selected values from previous state if applicable
const
structureRef
=
getStructureOptions
(
this
.
plugin
.
state
.
dataState
)[
0
][
0
]
const
structureRef
=
getStructureOptions
(
this
.
plugin
.
state
.
dataState
)[
0
][
0
]
const
structure
=
this
.
getStructure
(
structureRef
)
const
structure
=
this
.
getStructure
(
structureRef
)
const
e
ntityId
=
getEntityOptions
(
structure
)[
0
][
0
]
const
modelE
ntityId
=
get
Model
EntityOptions
(
structure
)[
0
][
0
]
const
invariantUnitId
=
getUnitOptions
(
structure
,
e
ntityId
)[
0
][
0
]
const
invariantUnitId
=
getUnitOptions
(
structure
,
modelE
ntityId
)[
0
][
0
]
const
operatorKey
=
getOperatorOptions
(
structure
,
e
ntityId
,
invariantUnitId
)[
0
][
0
]
const
operatorKey
=
getOperatorOptions
(
structure
,
modelE
ntityId
,
invariantUnitId
)[
0
][
0
]
return
{
structure
,
structureRef
,
e
ntityId
,
invariantUnitId
,
operatorKey
}
return
{
structure
,
structureRef
,
modelE
ntityId
,
invariantUnitId
,
operatorKey
}
}
}
private
get
params
()
{
private
get
params
()
{
const
{
structure
,
e
ntityId
,
invariantUnitId
}
=
this
.
state
const
{
structure
,
modelE
ntityId
,
invariantUnitId
}
=
this
.
state
const
structureOptions
=
getStructureOptions
(
this
.
plugin
.
state
.
dataState
)
const
structureOptions
=
getStructureOptions
(
this
.
plugin
.
state
.
dataState
)
const
entityOptions
=
getEntityOptions
(
structure
)
const
entityOptions
=
get
Model
EntityOptions
(
structure
)
const
unitOptions
=
getUnitOptions
(
structure
,
e
ntityId
)
const
unitOptions
=
getUnitOptions
(
structure
,
modelE
ntityId
)
const
operatorOptions
=
getOperatorOptions
(
structure
,
e
ntityId
,
invariantUnitId
)
const
operatorOptions
=
getOperatorOptions
(
structure
,
modelE
ntityId
,
invariantUnitId
)
return
{
return
{
structure
:
PD
.
Select
(
structureOptions
[
0
][
0
],
structureOptions
,
{
shortLabel
:
true
}),
structure
:
PD
.
Select
(
structureOptions
[
0
][
0
],
structureOptions
,
{
shortLabel
:
true
}),
entity
:
PD
.
Select
(
entityOptions
[
0
][
0
],
entityOptions
,
{
shortLabel
:
true
}),
entity
:
PD
.
Select
(
entityOptions
[
0
][
0
],
entityOptions
,
{
shortLabel
:
true
}),
...
@@ -203,7 +220,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
...
@@ -203,7 +220,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
private
get
values
():
PD
.
Values
<
SequenceView
[
'
params
'
]
>
{
private
get
values
():
PD
.
Values
<
SequenceView
[
'
params
'
]
>
{
return
{
return
{
structure
:
this
.
state
.
structureRef
,
structure
:
this
.
state
.
structureRef
,
entity
:
this
.
state
.
e
ntityId
,
entity
:
this
.
state
.
modelE
ntityId
,
unit
:
this
.
state
.
invariantUnitId
,
unit
:
this
.
state
.
invariantUnitId
,
operator
:
this
.
state
.
operatorKey
operator
:
this
.
state
.
operatorKey
}
}
...
@@ -217,18 +234,18 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
...
@@ -217,18 +234,18 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
case
'
structure
'
:
case
'
structure
'
:
state
.
structureRef
=
p
.
value
state
.
structureRef
=
p
.
value
state
.
structure
=
this
.
getStructure
(
p
.
value
)
state
.
structure
=
this
.
getStructure
(
p
.
value
)
state
.
e
ntityId
=
getEntityOptions
(
state
.
structure
)[
0
][
0
]
state
.
modelE
ntityId
=
get
Model
EntityOptions
(
state
.
structure
)[
0
][
0
]
state
.
invariantUnitId
=
getUnitOptions
(
state
.
structure
,
state
.
e
ntityId
)[
0
][
0
]
state
.
invariantUnitId
=
getUnitOptions
(
state
.
structure
,
state
.
modelE
ntityId
)[
0
][
0
]
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
e
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
modelE
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
break
break
case
'
entity
'
:
case
'
entity
'
:
state
.
e
ntityId
=
p
.
value
state
.
modelE
ntityId
=
p
.
value
state
.
invariantUnitId
=
getUnitOptions
(
state
.
structure
,
state
.
e
ntityId
)[
0
][
0
]
state
.
invariantUnitId
=
getUnitOptions
(
state
.
structure
,
state
.
modelE
ntityId
)[
0
][
0
]
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
e
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
modelE
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
break
break
case
'
unit
'
:
case
'
unit
'
:
state
.
invariantUnitId
=
p
.
value
state
.
invariantUnitId
=
p
.
value
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
e
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
state
.
operatorKey
=
getOperatorOptions
(
state
.
structure
,
state
.
modelE
ntityId
,
state
.
invariantUnitId
)[
0
][
0
]
break
break
case
'
operator
'
:
case
'
operator
'
:
state
.
operatorKey
=
p
.
value
state
.
operatorKey
=
p
.
value
...
...
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