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
f6b2c0b2
Commit
f6b2c0b2
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
wip, sequence view
parent
ea419c68
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
+41
-14
41 additions, 14 deletions
src/mol-plugin/ui/sequence.tsx
with
41 additions
and
14 deletions
src/mol-plugin/ui/sequence.tsx
+
41
−
14
View file @
f6b2c0b2
...
@@ -16,9 +16,15 @@ import { Loci } from '../../mol-model/loci';
...
@@ -16,9 +16,15 @@ import { Loci } from '../../mol-model/loci';
import
{
applyMarkerAction
,
MarkerAction
}
from
'
../../mol-geo/geometry/marker-data
'
;
import
{
applyMarkerAction
,
MarkerAction
}
from
'
../../mol-geo/geometry/marker-data
'
;
import
{
ButtonsType
,
ModifiersKeys
,
getButtons
,
getModifiers
}
from
'
../../mol-util/input/input-observer
'
;
import
{
ButtonsType
,
ModifiersKeys
,
getButtons
,
getModifiers
}
from
'
../../mol-util/input/input-observer
'
;
function
getStructureSeqKey
(
structureSeq
:
StructureSeq
)
{
const
{
structure
,
seq
}
=
structureSeq
const
strucHash
=
structure
.
parent
?
structure
.
parent
.
hashCode
:
structure
.
hashCode
return
`
${
strucHash
}
|
${
seq
.
entityId
}
`
}
export
class
SequenceView
extends
PluginUIComponent
<
{
},
{
}
>
{
export
class
SequenceView
extends
PluginUIComponent
<
{
},
{
}
>
{
private
spine
:
StateTreeSpine
.
Impl
private
spine
:
StateTreeSpine
.
Impl
private
markerArrays
=
new
Map
<
string
,
Uint8Array
>
()
componentDidMount
()
{
componentDidMount
()
{
this
.
spine
=
new
StateTreeSpine
.
Impl
(
this
.
plugin
.
state
.
dataState
.
cells
);
this
.
spine
=
new
StateTreeSpine
.
Impl
(
this
.
plugin
.
state
.
dataState
.
cells
);
...
@@ -42,14 +48,23 @@ export class SequenceView extends PluginUIComponent<{ }, { }> {
...
@@ -42,14 +48,23 @@ export class SequenceView extends PluginUIComponent<{ }, { }> {
}
}
render
()
{
render
()
{
const
s
=
this
.
getStructure
();
const
s
tructure
=
this
.
getStructure
();
if
(
!
s
)
return
<
div
className
=
'msp-sequence'
>
if
(
!
s
tructure
)
return
<
div
className
=
'msp-sequence'
>
<
div
className
=
'msp-sequence-entity'
>
No structure available
</
div
>
<
div
className
=
'msp-sequence-entity'
>
No structure available
</
div
>
</
div
>;
</
div
>;
const
seqs
=
s
.
models
[
0
].
sequence
.
sequences
;
const
seqs
=
s
tructure
.
models
[
0
].
sequence
.
sequences
;
return
<
div
className
=
'msp-sequence'
>
return
<
div
className
=
'msp-sequence'
>
{
seqs
.
map
((
seq
,
i
)
=>
<
EntitySequence
key
=
{
i
}
seq
=
{
seq
}
structure
=
{
s
}
/>
)
}
{
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
)
}
return
<
EntitySequence
key
=
{
i
}
structureSeq
=
{
structureSeq
}
markerArray
=
{
markerArray
}
/>
})
}
</
div
>;
</
div
>;
}
}
}
}
...
@@ -127,26 +142,36 @@ function markResidue(loci: Loci, structureSeq: StructureSeq, array: Uint8Array,
...
@@ -127,26 +142,36 @@ function markResidue(loci: Loci, structureSeq: StructureSeq, array: Uint8Array,
})
})
}
}
type
EntitySequenceProps
=
{
structureSeq
:
StructureSeq
,
markerArray
:
Uint8Array
}
type
EntitySequenceState
=
{
markerData
:
{
array
:
Uint8Array
}
}
// TODO: this is really inefficient and should be done using a canvas.
// TODO: this is really inefficient and should be done using a canvas.
class
EntitySequence
extends
PluginUIComponent
<
{
seq
:
StructureSequence
.
Entity
,
structure
:
Structure
},
{
markerData
:
{
array
:
Uint8Array
}
}
>
{
class
EntitySequence
extends
PluginUIComponent
<
EntitySequenceProps
,
EntitySequenceState
>
{
state
=
{
state
=
{
markerData
:
{
array
:
new
Uint8Array
(
this
.
props
.
seq
.
sequence
.
sequence
.
length
)
}
markerData
:
{
array
:
new
Uint8Array
(
this
.
props
.
markerArray
)
}
}
}
private
lociHighlightProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
private
lociHighlightProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
const
{
array
}
=
this
.
state
.
markerData
;
const
{
array
}
=
this
.
state
.
markerData
;
const
{
structure
,
s
eq
}
=
this
.
props
const
{
structure
S
eq
}
=
this
.
props
const
changed
=
markResidue
(
loci
.
loci
,
{
structure
,
seq
}
,
array
,
action
)
const
changed
=
markResidue
(
loci
.
loci
,
structure
Seq
,
array
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
}
}
private
lociSelectionProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
private
lociSelectionProvider
=
(
loci
:
Interaction
.
Loci
,
action
:
MarkerAction
)
=>
{
const
{
array
}
=
this
.
state
.
markerData
;
const
{
array
}
=
this
.
state
.
markerData
;
const
{
structure
,
s
eq
}
=
this
.
props
const
{
structure
S
eq
}
=
this
.
props
const
changed
=
markResidue
(
loci
.
loci
,
{
structure
,
seq
}
,
array
,
action
)
const
changed
=
markResidue
(
loci
.
loci
,
structure
Seq
,
array
,
action
)
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
if
(
changed
)
this
.
setState
({
markerData
:
{
array
}
})
}
}
static
getDerivedStateFromProps
(
nextProps
:
EntitySequenceProps
,
prevState
:
EntitySequenceState
)
{
if
(
prevState
.
markerData
.
array
!==
nextProps
.
markerArray
)
{
return
{
markerData
:
{
array
:
nextProps
.
markerArray
}
}
}
return
null
}
componentDidMount
()
{
componentDidMount
()
{
this
.
plugin
.
lociHighlights
.
addProvider
(
this
.
lociHighlightProvider
)
this
.
plugin
.
lociHighlights
.
addProvider
(
this
.
lociHighlightProvider
)
this
.
plugin
.
lociSelections
.
addProvider
(
this
.
lociSelectionProvider
)
this
.
plugin
.
lociSelections
.
addProvider
(
this
.
lociSelectionProvider
)
...
@@ -158,8 +183,9 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
...
@@ -158,8 +183,9 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
}
}
getLoci
(
seqId
:
number
)
{
getLoci
(
seqId
:
number
)
{
const
query
=
createQuery
(
this
.
props
.
seq
.
entityId
,
seqId
);
const
{
structure
,
seq
}
=
this
.
props
.
structureSeq
return
StructureSelection
.
toLoci2
(
StructureQuery
.
run
(
query
,
this
.
props
.
structure
));
const
query
=
createQuery
(
seq
.
entityId
,
seqId
);
return
StructureSelection
.
toLoci2
(
StructureQuery
.
run
(
query
,
structure
));
}
}
highlight
(
seqId
?:
number
,
modifiers
?:
ModifiersKeys
)
{
highlight
(
seqId
?:
number
,
modifiers
?:
ModifiersKeys
)
{
...
@@ -192,7 +218,7 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
...
@@ -192,7 +218,7 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
render
()
{
render
()
{
const
{
markerData
}
=
this
.
state
;
const
{
markerData
}
=
this
.
state
;
const
{
seq
}
=
this
.
props
;
const
{
seq
}
=
this
.
props
.
structureSeq
;
const
{
offset
,
sequence
}
=
seq
.
sequence
;
const
{
offset
,
sequence
}
=
seq
.
sequence
;
const
elems
:
JSX
.
Element
[]
=
[];
const
elems
:
JSX
.
Element
[]
=
[];
...
@@ -205,7 +231,7 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
...
@@ -205,7 +231,7 @@ class EntitySequence extends PluginUIComponent<{ seq: StructureSequence.Entity,
onContextMenu
=
{
this
.
contextMenu
}
onContextMenu
=
{
this
.
contextMenu
}
onMouseDown
=
{
this
.
mouseDown
}
onMouseDown
=
{
this
.
mouseDown
}
>
>
<
span
style
=
{
{
fontWeight
:
'
bold
'
}
}
>
{
this
.
props
.
seq
.
entityId
}
:
{
offset
}
</
span
>
<
span
style
=
{
{
fontWeight
:
'
bold
'
}
}
>
{
seq
.
entityId
}
:
{
offset
}
</
span
>
{
elems
}
{
elems
}
</
div
>;
</
div
>;
}
}
...
@@ -233,6 +259,7 @@ class Residue extends PluginUIComponent<{ seqId: number, letter: string, parent:
...
@@ -233,6 +259,7 @@ class Residue extends PluginUIComponent<{ seqId: number, letter: string, parent:
// TODO make marker color configurable
// TODO make marker color configurable
if
(
this
.
props
.
marker
===
0
)
return
''
if
(
this
.
props
.
marker
===
0
)
return
''
if
(
this
.
props
.
marker
%
2
===
0
)
return
'
rgb(51, 255, 25)
'
// selected
if
(
this
.
props
.
marker
%
2
===
0
)
return
'
rgb(51, 255, 25)
'
// selected
if
(
this
.
props
.
marker
===
undefined
)
console
.
error
(
'
unexpected marker value
'
)
return
'
rgb(255, 102, 153)
'
// highlighted
return
'
rgb(255, 102, 153)
'
// highlighted
}
}
...
...
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