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
4aecf4e0
Commit
4aecf4e0
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added ElementSequenceWrapper & ChainSequenceWrapper
parent
d81f37c7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-plugin/ui/sequence.tsx
+23
-7
23 additions, 7 deletions
src/mol-plugin/ui/sequence.tsx
src/mol-plugin/ui/sequence/chain.ts
+69
-0
69 additions, 0 deletions
src/mol-plugin/ui/sequence/chain.ts
src/mol-plugin/ui/sequence/element.ts
+61
-0
61 additions, 0 deletions
src/mol-plugin/ui/sequence/element.ts
with
153 additions
and
7 deletions
src/mol-plugin/ui/sequence.tsx
+
23
−
7
View file @
4aecf4e0
...
...
@@ -18,8 +18,10 @@ import { ParameterControls } from './controls/parameters';
import
{
ParamDefinition
as
PD
}
from
'
../../mol-util/param-definition
'
;
import
{
HeteroSequenceWrapper
}
from
'
./sequence/hetero
'
;
import
{
State
,
StateSelection
}
from
'
../../mol-state
'
;
import
{
ChainSequenceWrapper
}
from
'
./sequence/chain
'
;
import
{
ElementSequenceWrapper
}
from
'
./sequence/element
'
;
const
MaxDisplaySequenceLength
=
10
000
const
MaxDisplaySequenceLength
=
5
000
function
opKey
(
l
:
StructureElement
.
Location
)
{
const
ids
=
SP
.
unit
.
pdbx_struct_oper_list_ids
(
l
)
...
...
@@ -45,19 +47,33 @@ function getSequenceWrapper(state: SequenceViewState, structureSelection: Struct
if
(
unit
.
invariantId
!==
invariantUnitId
)
continue
if
(
opKey
(
l
)
!==
operatorKey
)
continue
const
data
=
{
structure
,
unit
}
let
sw
:
SequenceWrapper
<
any
>
if
(
unit
.
polymerElements
.
length
)
{
const
l
=
StructureElement
.
Location
.
create
(
unit
,
unit
.
elements
[
0
])
const
entitySeq
=
unit
.
model
.
sequence
.
byEntityKey
[
SP
.
entity
.
key
(
l
)]
// check if entity sequence is available
if
(
!
entitySeq
)
return
'
No sequence available
'
// check if sequence is too long
if
(
entitySeq
.
sequence
.
length
>
MaxDisplaySequenceLength
)
{
return
`Sequence too long (
${
entitySeq
.
sequence
.
length
}
residues)`
if
(
entitySeq
&&
entitySeq
.
sequence
.
length
<=
MaxDisplaySequenceLength
)
{
sw
=
new
PolymerSequenceWrapper
(
data
)
}
else
{
if
(
Unit
.
isAtomic
(
unit
)
||
unit
.
polymerElements
.
length
>
MaxDisplaySequenceLength
)
{
sw
=
new
ChainSequenceWrapper
(
data
)
}
else
{
sw
=
new
ElementSequenceWrapper
(
data
)
}
}
}
else
if
(
Unit
.
isAtomic
(
unit
))
{
if
(
unit
.
residueCount
>
MaxDisplaySequenceLength
)
{
sw
=
new
ChainSequenceWrapper
(
data
)
}
else
{
sw
=
new
HeteroSequenceWrapper
(
data
)
}
}
else
{
console
.
warn
(
'
should not happen, expecting coarse units to be polymeric
'
)
sw
=
new
ChainSequenceWrapper
(
data
)
}
const
Wrapper
=
unit
.
polymerElements
.
length
?
PolymerSequenceWrapper
:
HeteroSequenceWrapper
const
sw
=
new
Wrapper
({
structure
,
unit
})
sw
.
markResidue
(
structureSelection
.
get
(
structure
),
MarkerAction
.
Select
)
return
sw
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/sequence/chain.ts
0 → 100644
+
69
−
0
View file @
4aecf4e0
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Structure
,
StructureElement
,
StructureProperties
}
from
'
../../../mol-model/structure
'
;
import
{
SequenceWrapper
,
StructureUnit
}
from
'
./wrapper
'
;
import
{
OrderedSet
,
Interval
}
from
'
../../../mol-data/int
'
;
import
{
Loci
}
from
'
../../../mol-model/loci
'
;
import
{
ColorNames
}
from
'
../../../mol-util/color/names
'
;
export
class
ChainSequenceWrapper
extends
SequenceWrapper
<
StructureUnit
>
{
private
label
:
string
private
indices
:
Interval
<
StructureElement
.
UnitIndex
>
private
loci
:
StructureElement
.
Loci
residueLabel
(
seqIdx
:
number
)
{
return
this
.
label
}
residueColor
(
seqIdx
:
number
)
{
return
ColorNames
.
black
}
eachResidue
(
loci
:
Loci
,
apply
:
(
set
:
OrderedSet
)
=>
boolean
)
{
let
changed
=
false
const
{
structure
,
unit
}
=
this
.
data
if
(
StructureElement
.
Loci
.
is
(
loci
))
{
if
(
!
Structure
.
areRootsEquivalent
(
loci
.
structure
,
structure
))
return
false
loci
=
StructureElement
.
Loci
.
remap
(
loci
,
structure
)
for
(
const
e
of
loci
.
elements
)
{
if
(
e
.
unit
.
id
===
unit
.
id
)
{
if
(
OrderedSet
.
isSubset
(
this
.
indices
,
e
.
indices
))
{
if
(
apply
(
Interval
.
ofSingleton
(
0
)))
changed
=
true
}
}
}
}
else
if
(
Structure
.
isLoci
(
loci
))
{
if
(
!
Structure
.
areRootsEquivalent
(
loci
.
structure
,
structure
))
return
false
if
(
apply
(
Interval
.
ofSingleton
(
0
)))
changed
=
true
}
return
changed
}
getLoci
(
seqIdx
:
number
)
{
return
this
.
loci
}
constructor
(
data
:
StructureUnit
)
{
const
counts
:
string
[]
=
[]
const
l
=
StructureElement
.
Location
.
create
(
data
.
unit
,
data
.
unit
.
elements
[
0
])
const
entitySeq
=
data
.
unit
.
model
.
sequence
.
byEntityKey
[
StructureProperties
.
entity
.
key
(
l
)]
if
(
entitySeq
)
counts
.
push
(
`
${
entitySeq
.
sequence
.
length
}
residues`
)
counts
.
push
(
`
${
data
.
unit
.
elements
.
length
}
elements`
)
const
length
=
1
const
markerArray
=
new
Uint8Array
(
length
)
super
(
data
,
markerArray
,
length
)
this
.
label
=
`Whole Unit (
${
counts
.
join
(
'
,
'
)}
)`
this
.
indices
=
Interval
.
ofBounds
(
0
,
data
.
unit
.
elements
.
length
)
this
.
loci
=
StructureElement
.
Loci
(
this
.
data
.
structure
,
[{
unit
:
this
.
data
.
unit
,
indices
:
this
.
indices
}])
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/sequence/element.ts
0 → 100644
+
61
−
0
View file @
4aecf4e0
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Structure
,
StructureElement
}
from
'
../../../mol-model/structure
'
;
import
{
SequenceWrapper
,
StructureUnit
}
from
'
./wrapper
'
;
import
{
OrderedSet
,
Interval
}
from
'
../../../mol-data/int
'
;
import
{
Loci
}
from
'
../../../mol-model/loci
'
;
import
{
ColorNames
}
from
'
../../../mol-util/color/names
'
;
export
class
ElementSequenceWrapper
extends
SequenceWrapper
<
StructureUnit
>
{
private
indices
:
Interval
<
StructureElement
.
UnitIndex
>
residueLabel
(
seqIdx
:
number
)
{
return
'
X
'
}
residueColor
(
seqIdx
:
number
)
{
return
ColorNames
.
black
}
eachResidue
(
loci
:
Loci
,
apply
:
(
set
:
OrderedSet
)
=>
boolean
)
{
let
changed
=
false
const
{
structure
,
unit
}
=
this
.
data
if
(
StructureElement
.
Loci
.
is
(
loci
))
{
if
(
!
Structure
.
areRootsEquivalent
(
loci
.
structure
,
structure
))
return
false
loci
=
StructureElement
.
Loci
.
remap
(
loci
,
structure
)
for
(
const
e
of
loci
.
elements
)
{
if
(
e
.
unit
.
id
===
unit
.
id
)
{
if
(
OrderedSet
.
isSubset
(
this
.
indices
,
e
.
indices
))
{
if
(
apply
(
e
.
indices
))
changed
=
true
}
}
}
}
else
if
(
Structure
.
isLoci
(
loci
))
{
if
(
!
Structure
.
areRootsEquivalent
(
loci
.
structure
,
structure
))
return
false
if
(
apply
(
this
.
indices
))
changed
=
true
}
return
changed
}
getLoci
(
seqIdx
:
number
)
{
const
elements
:
StructureElement
.
Loci
[
'
elements
'
][
0
][]
=
[{
unit
:
this
.
data
.
unit
,
indices
:
Interval
.
ofSingleton
(
seqIdx
)
}]
return
StructureElement
.
Loci
(
this
.
data
.
structure
,
elements
)
}
constructor
(
data
:
StructureUnit
)
{
const
length
=
data
.
unit
.
elements
.
length
const
markerArray
=
new
Uint8Array
(
length
)
super
(
data
,
markerArray
,
length
)
this
.
indices
=
Interval
.
ofBounds
(
0
,
length
)
}
}
\ No newline at end of file
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