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
44b8f5c1
Commit
44b8f5c1
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added molecule-type color scheme
parent
4dfafb53
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-view/theme/color.ts
+3
-0
3 additions, 0 deletions
src/mol-view/theme/color.ts
src/mol-view/theme/color/molecule-type.ts
+59
-0
59 additions, 0 deletions
src/mol-view/theme/color/molecule-type.ts
with
62 additions
and
0 deletions
src/mol-view/theme/color.ts
+
3
−
0
View file @
44b8f5c1
...
@@ -21,6 +21,7 @@ import { CustomColorTheme } from './color/custom';
...
@@ -21,6 +21,7 @@ import { CustomColorTheme } from './color/custom';
import
{
ResidueNameColorTheme
}
from
'
./color/residue-name
'
;
import
{
ResidueNameColorTheme
}
from
'
./color/residue-name
'
;
import
{
SequenceIdColorTheme
}
from
'
./color/sequence-id
'
;
import
{
SequenceIdColorTheme
}
from
'
./color/sequence-id
'
;
import
{
SecondaryStructureColorTheme
}
from
'
./color/secondary-structure
'
;
import
{
SecondaryStructureColorTheme
}
from
'
./color/secondary-structure
'
;
import
{
MoleculeTypeColorTheme
}
from
'
./color/molecule-type
'
;
export
type
LocationColor
=
(
location
:
Location
,
isSecondary
:
boolean
)
=>
Color
export
type
LocationColor
=
(
location
:
Location
,
isSecondary
:
boolean
)
=>
Color
...
@@ -57,6 +58,7 @@ export function ColorTheme(props: ColorThemeProps): ColorTheme {
...
@@ -57,6 +58,7 @@ export function ColorTheme(props: ColorThemeProps): ColorTheme {
case
'
custom
'
:
return
CustomColorTheme
(
props
)
case
'
custom
'
:
return
CustomColorTheme
(
props
)
case
'
element-index
'
:
return
ElementIndexColorTheme
(
props
)
case
'
element-index
'
:
return
ElementIndexColorTheme
(
props
)
case
'
element-symbol
'
:
return
ElementSymbolColorTheme
(
props
)
case
'
element-symbol
'
:
return
ElementSymbolColorTheme
(
props
)
case
'
molecule-type
'
:
return
MoleculeTypeColorTheme
(
props
)
case
'
residue-name
'
:
return
ResidueNameColorTheme
(
props
)
case
'
residue-name
'
:
return
ResidueNameColorTheme
(
props
)
case
'
secondary-structure
'
:
return
SecondaryStructureColorTheme
(
props
)
case
'
secondary-structure
'
:
return
SecondaryStructureColorTheme
(
props
)
case
'
sequence-id
'
:
return
SequenceIdColorTheme
(
props
)
case
'
sequence-id
'
:
return
SequenceIdColorTheme
(
props
)
...
@@ -84,6 +86,7 @@ export const ColorThemeInfo = {
...
@@ -84,6 +86,7 @@ export const ColorThemeInfo = {
'
custom
'
:
{},
'
custom
'
:
{},
'
element-index
'
:
{},
'
element-index
'
:
{},
'
element-symbol
'
:
{},
'
element-symbol
'
:
{},
'
molecule-type
'
:
{},
'
residue-name
'
:
{},
'
residue-name
'
:
{},
'
secondary-structure
'
:
{},
'
secondary-structure
'
:
{},
'
sequence-id
'
:
{},
'
sequence-id
'
:
{},
...
...
This diff is collapsed.
Click to expand it.
src/mol-view/theme/color/molecule-type.ts
0 → 100644
+
59
−
0
View file @
44b8f5c1
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Color
,
ColorMap
}
from
'
mol-util/color
'
;
import
{
StructureElement
,
Unit
,
Link
,
ElementIndex
}
from
'
mol-model/structure
'
;
import
{
Location
}
from
'
mol-model/location
'
;
import
{
ColorThemeProps
,
ColorTheme
,
TableLegend
}
from
'
../color
'
;
import
{
MoleculeType
}
from
'
mol-model/structure/model/types
'
;
import
{
getElementMoleculeType
}
from
'
mol-model/structure/util
'
;
const
MoleculeTypeColors
=
ColorMap
({
water
:
0x386cb0
,
ion
:
0xf0027f
,
protein
:
0xbeaed4
,
RNA
:
0xfdc086
,
DNA
:
0xbf5b17
,
PNA
:
0x42A49A
,
saccharide
:
0x7fc97f
,
})
const
DefaultMoleculeTypeColor
=
Color
(
0xffff99
)
const
Description
=
'
Assigns a color based on the molecule type of a residue.
'
export
function
moleculeTypeColor
(
unit
:
Unit
,
element
:
ElementIndex
):
Color
{
const
moleculeType
=
getElementMoleculeType
(
unit
,
element
)
switch
(
moleculeType
)
{
case
MoleculeType
.
water
:
return
MoleculeTypeColors
.
water
case
MoleculeType
.
ion
:
return
MoleculeTypeColors
.
ion
case
MoleculeType
.
protein
:
return
MoleculeTypeColors
.
protein
case
MoleculeType
.
RNA
:
return
MoleculeTypeColors
.
RNA
case
MoleculeType
.
DNA
:
return
MoleculeTypeColors
.
DNA
case
MoleculeType
.
PNA
:
return
MoleculeTypeColors
.
PNA
case
MoleculeType
.
saccharide
:
return
MoleculeTypeColors
.
saccharide
}
return
DefaultMoleculeTypeColor
}
export
function
MoleculeTypeColorTheme
(
props
:
ColorThemeProps
):
ColorTheme
{
function
color
(
location
:
Location
):
Color
{
if
(
StructureElement
.
isLocation
(
location
))
{
return
moleculeTypeColor
(
location
.
unit
,
location
.
element
)
}
else
if
(
Link
.
isLocation
(
location
))
{
return
moleculeTypeColor
(
location
.
aUnit
,
location
.
aUnit
.
elements
[
location
.
aIndex
])
}
return
DefaultMoleculeTypeColor
}
return
{
granularity
:
'
group
'
,
color
,
description
:
Description
,
legend
:
TableLegend
(
Object
.
keys
(
MoleculeTypeColors
).
map
(
name
=>
{
return
[
name
,
(
MoleculeTypeColors
as
any
)[
name
]
as
Color
]
as
[
string
,
Color
]
}).
concat
([[
'
Other/unknown
'
,
DefaultMoleculeTypeColor
]]))
}
}
\ 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