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
0e040d77
Commit
0e040d77
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added occupancy color theme
parent
7600d0a4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-theme/color.ts
+2
-0
2 additions, 0 deletions
src/mol-theme/color.ts
src/mol-theme/color/occupancy.ts
+67
-0
67 additions, 0 deletions
src/mol-theme/color/occupancy.ts
with
69 additions
and
0 deletions
src/mol-theme/color.ts
+
2
−
0
View file @
0e040d77
...
...
@@ -31,6 +31,7 @@ import { EntitySourceColorThemeProvider } from './color/entity-source';
import
{
IllustrativeColorThemeProvider
}
from
'
./color/illustrative
'
;
import
{
HydrophobicityColorThemeProvider
}
from
'
./color/hydrophobicity
'
;
import
{
ModelIndexColorThemeProvider
}
from
'
./color/model-index
'
;
import
{
OccupancyColorThemeProvider
}
from
'
./color/occupancy
'
;
export
type
LocationColor
=
(
location
:
Location
,
isSecondary
:
boolean
)
=>
Color
...
...
@@ -82,6 +83,7 @@ export const BuiltInColorThemes = {
'
illustrative
'
:
IllustrativeColorThemeProvider
,
'
model-index
'
:
ModelIndexColorThemeProvider
,
'
molecule-type
'
:
MoleculeTypeColorThemeProvider
,
'
occupancy
'
:
OccupancyColorThemeProvider
,
'
polymer-id
'
:
PolymerIdColorThemeProvider
,
'
polymer-index
'
:
PolymerIndexColorThemeProvider
,
'
residue-name
'
:
ResidueNameColorThemeProvider
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-theme/color/occupancy.ts
0 → 100644
+
67
−
0
View file @
0e040d77
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Color
,
ColorScale
}
from
'
../../mol-util/color
'
;
import
{
StructureElement
,
Unit
,
Link
,
ElementIndex
}
from
'
../../mol-model/structure
'
;
import
{
Location
}
from
'
../../mol-model/location
'
;
import
{
ColorTheme
}
from
'
../color
'
;
import
{
ParamDefinition
as
PD
}
from
'
../../mol-util/param-definition
'
import
{
ThemeDataContext
}
from
'
../theme
'
;
import
{
ColorListName
,
ColorListOptionsScale
}
from
'
../../mol-util/color/lists
'
;
const
DefaultOccupancyColor
=
Color
(
0xCCCCCC
)
const
Description
=
`Assigns a color based on the occupancy of an atom.`
export
const
OccupancyColorThemeParams
=
{
domain
:
PD
.
Interval
([
0
,
1
]),
list
:
PD
.
ColorList
<
ColorListName
>
(
'
purples
'
,
ColorListOptionsScale
),
}
export
type
OccupancyColorThemeParams
=
typeof
OccupancyColorThemeParams
export
function
getOccupancyColorThemeParams
(
ctx
:
ThemeDataContext
)
{
return
OccupancyColorThemeParams
// TODO return copy
}
export
function
getOccupancy
(
unit
:
Unit
,
element
:
ElementIndex
):
number
{
if
(
Unit
.
isAtomic
(
unit
))
{
return
unit
.
model
.
atomicConformation
.
occupancy
.
value
(
element
)
}
else
{
return
0
}
}
export
function
OccupancyColorTheme
(
ctx
:
ThemeDataContext
,
props
:
PD
.
Values
<
OccupancyColorThemeParams
>
):
ColorTheme
<
OccupancyColorThemeParams
>
{
const
scale
=
ColorScale
.
create
({
reverse
:
false
,
domain
:
props
.
domain
,
listOrName
:
props
.
list
,
})
function
color
(
location
:
Location
):
Color
{
if
(
StructureElement
.
Location
.
is
(
location
))
{
return
scale
.
color
(
getOccupancy
(
location
.
unit
,
location
.
element
))
}
else
if
(
Link
.
isLocation
(
location
))
{
return
scale
.
color
(
getOccupancy
(
location
.
aUnit
,
location
.
aUnit
.
elements
[
location
.
aIndex
]))
}
return
DefaultOccupancyColor
}
return
{
factory
:
OccupancyColorTheme
,
granularity
:
'
group
'
,
color
,
props
,
description
:
Description
,
legend
:
scale
?
scale
.
legend
:
undefined
}
}
export
const
OccupancyColorThemeProvider
:
ColorTheme
.
Provider
<
OccupancyColorThemeParams
>
=
{
label
:
'
Occupancy
'
,
factory
:
OccupancyColorTheme
,
getParams
:
getOccupancyColorThemeParams
,
defaultValues
:
PD
.
getDefaultValues
(
OccupancyColorThemeParams
),
isApplicable
:
(
ctx
:
ThemeDataContext
)
=>
!!
ctx
.
structure
}
\ 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