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
61ef5603
Commit
61ef5603
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
simplified chain-id coloring
parent
ee43a971
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-geo/theme/structure/color/chain-id.ts
+26
-81
26 additions, 81 deletions
src/mol-geo/theme/structure/color/chain-id.ts
with
26 additions
and
81 deletions
src/mol-geo/theme/structure/color/chain-id.ts
+
26
−
81
View file @
61ef5603
...
@@ -7,66 +7,33 @@
...
@@ -7,66 +7,33 @@
import
{
Unit
,
Queries
,
Element
}
from
'
mol-model/structure
'
;
import
{
Unit
,
Queries
,
Element
}
from
'
mol-model/structure
'
;
import
{
StructureColorDataProps
}
from
'
.
'
;
import
{
StructureColorDataProps
}
from
'
.
'
;
import
{
ColorData
,
createElementColor
}
from
'
../../../util/color-data
'
;
import
{
ColorData
,
createElementColor
,
createUniformColor
}
from
'
../../../util/color-data
'
;
import
{
ColorScale
}
from
'
mol-util/color
'
;
import
{
ColorScale
}
from
'
mol-util/color
'
;
import
{
Column
}
from
'
mol-data/db
'
;
function
createChainIdMap
(
unit
:
Unit
)
{
function
getAsymId
(
unit
:
Unit
):
Element
.
Property
<
string
>
{
const
map
=
new
Map
<
string
,
number
>
()
switch
(
unit
.
kind
)
{
let
index
=
0
case
Unit
.
Kind
.
Atomic
:
return
Queries
.
props
.
chain
.
label_asym_id
let
count
:
number
case
Unit
.
Kind
.
Spheres
:
let
asym_id
:
Column
<
string
>
case
Unit
.
Kind
.
Gaussians
:
if
(
Unit
.
isAtomic
(
unit
))
{
return
Queries
.
props
.
coarse
.
asym_id
asym_id
=
unit
.
model
.
atomicHierarchy
.
chains
.
label_asym_id
count
=
unit
.
model
.
atomicHierarchy
.
chains
.
_rowCount
}
else
if
(
Unit
.
isCoarse
(
unit
))
{
asym_id
=
unit
.
coarseElements
.
asym_id
count
=
unit
.
coarseElements
.
count
}
else
{
console
.
warn
(
'
Unknown unit type
'
)
return
{
map
,
count
:
index
}
}
for
(
let
i
=
0
;
i
<
count
;
++
i
)
{
const
chainId
=
asym_id
.
value
(
i
)
if
(
map
.
get
(
chainId
)
===
undefined
)
{
map
.
set
(
chainId
,
index
)
index
+=
1
}
}
}
return
{
map
,
count
:
index
}
}
}
export
function
chainIdColorData
(
props
:
StructureColorDataProps
,
locationFn
:
(
l
:
Element
.
Location
,
renderElementIdx
:
number
)
=>
void
,
colorData
?:
ColorData
)
{
export
function
chainIdColorData
(
props
:
StructureColorDataProps
,
locationFn
:
(
l
:
Element
.
Location
,
renderElementIdx
:
number
)
=>
void
,
colorData
?:
ColorData
)
{
const
{
group
:
{
units
},
elementCount
}
=
props
const
{
group
:
{
units
},
elementCount
}
=
props
const
unit
=
units
[
0
]
const
unit
=
units
[
0
]
const
{
map
,
count
}
=
createChainIdMap
(
unit
)
const
map
=
unit
.
model
.
properties
.
asymIdSerialMap
const
count
=
map
.
size
const
domain
=
[
0
,
count
-
1
]
const
domain
=
[
0
,
count
-
1
]
const
scale
=
ColorScale
.
create
({
domain
})
const
scale
=
ColorScale
.
create
({
domain
})
const
asym_id
=
getAsymId
(
unit
)
let
asym_id
:
Element
.
Property
<
string
>
if
(
Unit
.
isAtomic
(
unit
))
{
asym_id
=
Queries
.
props
.
chain
.
label_asym_id
}
else
if
(
Unit
.
isCoarse
(
unit
))
{
asym_id
=
Queries
.
props
.
coarse
.
asym_id
}
else
{
throw
new
Error
(
'
unhandled unit kind
'
)
}
const
l
=
Element
.
Location
()
const
l
=
Element
.
Location
()
l
.
unit
=
unit
l
.
unit
=
unit
// return createAttributeOrElementColor(vertexMap, {
// colorFn: (renderElementIdx: number) => {
// locationFn(l, renderElementIdx)
// console.log(l.element, asym_id(l))
// return scale.color(map.get(asym_id(l)) || 0)
// },
// vertexMap
// }, colorData)
return
createElementColor
({
return
createElementColor
({
colorFn
:
(
renderElementIdx
:
number
)
=>
{
colorFn
:
(
renderElementIdx
:
number
)
=>
{
locationFn
(
l
,
renderElementIdx
)
locationFn
(
l
,
renderElementIdx
)
...
@@ -82,44 +49,22 @@ export function chainIdElementColorData(props: StructureColorDataProps, colorDat
...
@@ -82,44 +49,22 @@ export function chainIdElementColorData(props: StructureColorDataProps, colorDat
l
.
element
=
elements
[
renderElementIdx
]
l
.
element
=
elements
[
renderElementIdx
]
}
}
return
chainIdColorData
(
props
,
locationFn
,
colorData
)
return
chainIdColorData
(
props
,
locationFn
,
colorData
)
// const { group: { units, elements }, vertexMap } = props
// const unit = units[0]
// const { map, count } = createChainIdMap(unit)
// const domain = [ 0, count - 1 ]
// const scale = ColorScale.create({ domain })
// let asym_id: Element.Property<string>
// if (Unit.isAtomic(unit)) {
// asym_id = Queries.props.chain.label_asym_id
// } else if (Unit.isCoarse(unit)) {
// asym_id = Queries.props.coarse.asym_id
// }
// const l = Element.Location()
// l.unit = unit
// return createAttributeOrElementColor(vertexMap, {
// colorFn: (elementIdx: number) => {
// l.element = elements[elementIdx]
// return scale.color(map.get(asym_id(l)) || 0)
// },
// vertexMap
// }, colorData)
}
}
export
function
chainIdLinkColorData
(
props
:
StructureColorDataProps
,
colorData
?:
ColorData
)
{
export
function
chainIdLinkColorData
(
props
:
StructureColorDataProps
,
colorData
?:
ColorData
):
ColorData
{
const
{
group
:
{
units
}
}
=
props
const
unit
=
props
.
group
.
units
[
0
]
const
elements
=
props
.
group
.
units
[
0
].
elements
const
elements
=
unit
.
elements
const
links
=
(
units
[
0
]
as
Unit
.
Atomic
).
links
let
locationFn
:
(
l
:
Element
.
Location
,
renderElementIdx
:
number
)
=>
void
// const { edgeCount, a, b } = links
switch
(
unit
.
kind
)
{
const
{
a
}
=
links
case
Unit
.
Kind
.
Atomic
:
const
{
a
}
=
unit
.
links
function
locationFn
(
l
:
Element
.
Location
,
renderElementIdx
:
number
)
{
locationFn
=
(
l
:
Element
.
Location
,
renderElementIdx
:
number
)
=>
{
const
aI
=
elements
[
a
[
renderElementIdx
]]
l
.
element
=
elements
[
a
[
renderElementIdx
]]
// const bI = elements[b[renderElementIdx]];
}
l
.
element
=
aI
return
chainIdColorData
(
props
,
locationFn
,
colorData
)
case
Unit
.
Kind
.
Spheres
:
case
Unit
.
Kind
.
Gaussians
:
// no chainId link color for coarse units, return uniform grey color
return
createUniformColor
({
value
:
0xCCCCCC
},
colorData
)
}
}
return
chainIdColorData
(
props
,
locationFn
,
colorData
)
}
}
\ 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