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
bcb8419f
Commit
bcb8419f
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
init repr3d and seq view marker with global selection
parent
7d24bcf1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin/behavior/dynamic/representation.ts
+21
-2
21 additions, 2 deletions
src/mol-plugin/behavior/dynamic/representation.ts
src/mol-plugin/ui/sequence.tsx
+28
-20
28 additions, 20 deletions
src/mol-plugin/ui/sequence.tsx
with
49 additions
and
22 deletions
src/mol-plugin/behavior/dynamic/representation.ts
+
21
−
2
View file @
bcb8419f
...
...
@@ -7,9 +7,11 @@
import
{
MarkerAction
}
from
'
../../../mol-util/marker-action
'
;
import
{
PluginContext
}
from
'
../../../mol-plugin/context
'
;
import
{
PluginStateObject
as
SO
}
from
'
../../state/objects
'
;
import
{
labelFirst
}
from
'
../../../mol-theme/label
'
;
import
{
PluginBehavior
}
from
'
../behavior
'
;
import
{
Interaction
}
from
'
../../util/interaction
'
;
import
{
StateTreeSpine
}
from
'
../../../mol-state/tree/spine
'
;
export
const
HighlightLoci
=
PluginBehavior
.
create
({
name
:
'
representation-highlight-loci
'
,
...
...
@@ -17,7 +19,7 @@ export const HighlightLoci = PluginBehavior.create({
ctor
:
class
extends
PluginBehavior
.
Handler
{
private
lociMarkProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
if
(
!
this
.
ctx
.
canvas3d
)
return
;
this
.
ctx
.
canvas3d
.
mark
(
loci
,
action
)
this
.
ctx
.
canvas3d
.
mark
(
{
...
loci
,
repr
:
undefined
}
,
action
)
}
register
()
{
this
.
ctx
.
lociHighlights
.
addProvider
(
this
.
lociMarkProvider
)
...
...
@@ -33,16 +35,33 @@ export const SelectLoci = PluginBehavior.create({
name
:
'
representation-select-loci
'
,
category
:
'
interaction
'
,
ctor
:
class
extends
PluginBehavior
.
Handler
{
private
spine
:
StateTreeSpine
.
Impl
private
lociMarkProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
if
(
!
this
.
ctx
.
canvas3d
)
return
;
this
.
ctx
.
canvas3d
.
mark
(
loci
,
action
)
this
.
ctx
.
canvas3d
.
mark
(
{
...
loci
,
repr
:
undefined
}
,
action
)
}
register
()
{
this
.
ctx
.
lociSelections
.
addProvider
(
this
.
lociMarkProvider
)
this
.
subscribeObservable
(
this
.
ctx
.
events
.
state
.
object
.
created
,
({
ref
,
state
})
=>
{
const
cell
=
this
.
ctx
.
state
.
dataState
.
cells
.
get
(
ref
)
if
(
cell
&&
SO
.
isRepresentation3D
(
cell
.
obj
))
{
this
.
spine
.
current
=
cell
const
so
=
this
.
spine
.
getRootOfType
(
SO
.
Molecule
.
Structure
)
if
(
so
)
{
const
loci
=
this
.
ctx
.
helpers
.
structureSelection
.
get
(
so
.
data
)
this
.
lociMarkProvider
({
loci
},
MarkerAction
.
Select
)
}
}
});
}
unregister
()
{
this
.
ctx
.
lociSelections
.
removeProvider
(
this
.
lociMarkProvider
)
}
constructor
(
ctx
:
PluginContext
,
params
:
{})
{
super
(
ctx
,
params
)
this
.
spine
=
new
StateTreeSpine
.
Impl
(
ctx
.
state
.
dataState
.
cells
)
}
},
display
:
{
name
:
'
Select Loci on Canvas
'
}
});
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/sequence.tsx
+
28
−
20
View file @
bcb8419f
...
...
@@ -15,6 +15,7 @@ import { OrderedSet, Interval } from '../../mol-data/int';
import
{
Loci
}
from
'
../../mol-model/loci
'
;
import
{
applyMarkerAction
,
MarkerAction
}
from
'
../../mol-util/marker-action
'
;
import
{
ButtonsType
,
ModifiersKeys
,
getButtons
,
getModifiers
}
from
'
../../mol-util/input/input-observer
'
;
import
{
ValueBox
}
from
'
../../mol-util
'
;
function
getStructureSeqKey
(
structureSeq
:
StructureSeq
)
{
const
{
structure
,
seq
}
=
structureSeq
...
...
@@ -42,6 +43,20 @@ export class SequenceView extends PluginUIComponent<{ }, { }> {
});
}
private
getMarkerArray
(
structureSeq
:
StructureSeq
):
Uint8Array
{
const
{
structure
,
seq
}
=
structureSeq
const
key
=
getStructureSeqKey
(
structureSeq
)
let
markerArray
=
this
.
markerArrays
.
get
(
key
)
if
(
!
markerArray
)
{
markerArray
=
new
Uint8Array
(
seq
.
sequence
.
sequence
.
length
)
this
.
markerArrays
.
set
(
key
,
markerArray
)
}
const
loci
=
this
.
plugin
.
helpers
.
structureSelection
.
get
(
structure
)
markerArray
.
fill
(
0
)
markResidue
(
loci
,
structureSeq
,
markerArray
,
MarkerAction
.
Select
)
return
markerArray
}
private
getStructure
()
{
const
so
=
this
.
spine
&&
this
.
spine
.
getRootOfType
(
SO
.
Molecule
.
Structure
)
return
so
&&
so
.
data
...
...
@@ -57,12 +72,7 @@ export class SequenceView extends PluginUIComponent<{ }, { }> {
return
<
div
className
=
'msp-sequence'
>
{
seqs
.
map
((
seq
,
i
)
=>
{
const
structureSeq
=
{
structure
,
seq
}
const
key
=
getStructureSeqKey
(
structureSeq
)
let
markerArray
=
this
.
markerArrays
.
get
(
key
)
if
(
!
markerArray
)
{
markerArray
=
new
Uint8Array
(
seq
.
sequence
.
sequence
.
length
)
this
.
markerArrays
.
set
(
key
,
markerArray
)
}
const
markerArray
=
this
.
getMarkerArray
(
structureSeq
)
return
<
EntitySequence
key
=
{
i
}
structureSeq
=
{
structureSeq
}
markerArray
=
{
markerArray
}
/>
})
}
</
div
>;
...
...
@@ -138,31 +148,29 @@ function markResidue(loci: Loci, structureSeq: StructureSeq, array: Uint8Array,
}
type
EntitySequenceProps
=
{
structureSeq
:
StructureSeq
,
markerArray
:
Uint8Array
}
type
EntitySequenceState
=
{
markerData
:
{
array
:
Uint8Array
}
}
type
EntitySequenceState
=
{
markerData
:
ValueBox
<
Uint8Array
>
}
// TODO: this is really inefficient and should be done using a canvas.
class
EntitySequence
extends
PluginUIComponent
<
EntitySequenceProps
,
EntitySequenceState
>
{
state
=
{
markerData
:
{
array
:
new
Uint8Array
(
this
.
props
.
markerArray
)
}
markerData
:
ValueBox
.
create
(
new
Uint8Array
(
this
.
props
.
markerArray
)
)
}
private
lociHighlightProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
const
{
array
}
=
this
.
state
.
markerData
;
const
{
structureSeq
}
=
this
.
props
const
changed
=
markResidue
(
loci
.
loci
,
structureSeq
,
array
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
const
{
markerData
}
=
this
.
state
;
const
changed
=
markResidue
(
loci
.
loci
,
this
.
props
.
structureSeq
,
markerData
.
value
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
ValueBox
.
withValue
(
markerData
,
markerData
.
value
)
})
}
private
lociSelectionProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
const
{
array
}
=
this
.
state
.
markerData
;
const
{
structureSeq
}
=
this
.
props
const
changed
=
markResidue
(
loci
.
loci
,
structureSeq
,
array
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
const
{
markerData
}
=
this
.
state
;
const
changed
=
markResidue
(
loci
.
loci
,
this
.
props
.
structureSeq
,
markerData
.
value
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
ValueBox
.
withValue
(
markerData
,
markerData
.
value
)
})
}
static
getDerivedStateFromProps
(
nextProps
:
EntitySequenceProps
,
prevState
:
EntitySequenceState
)
{
if
(
prevState
.
markerData
.
array
!==
nextProps
.
markerArray
)
{
return
{
markerData
:
{
array
:
nextProps
.
markerArray
}
}
static
getDerivedStateFromProps
(
nextProps
:
EntitySequenceProps
,
prevState
:
EntitySequenceState
)
:
EntitySequenceState
|
null
{
if
(
prevState
.
markerData
.
value
!==
nextProps
.
markerArray
)
{
return
{
markerData
:
ValueBox
.
create
(
nextProps
.
markerArray
)
}
}
return
null
}
...
...
@@ -218,7 +226,7 @@ class EntitySequence extends PluginUIComponent<EntitySequenceProps, EntitySequen
const
elems
:
JSX
.
Element
[]
=
[];
for
(
let
i
=
0
,
_i
=
sequence
.
length
;
i
<
_i
;
i
++
)
{
elems
[
elems
.
length
]
=
<
Residue
seqId
=
{
offset
+
i
+
1
}
letter
=
{
sequence
[
i
]
}
parent
=
{
this
}
marker
=
{
markerData
.
array
[
i
]
}
key
=
{
i
}
/>;
elems
[
elems
.
length
]
=
<
Residue
seqId
=
{
offset
+
i
+
1
}
letter
=
{
sequence
[
i
]
}
parent
=
{
this
}
marker
=
{
markerData
.
value
[
i
]
}
key
=
{
i
}
/>;
}
return
<
div
...
...
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