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
2b5e49d2
Commit
2b5e49d2
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
use LociStructureSelection in plugin structure tools
parent
b88bf9bd
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/util/structure-representation-helper.ts
+14
-21
14 additions, 21 deletions
src/mol-plugin/util/structure-representation-helper.ts
with
14 additions
and
21 deletions
src/mol-plugin/util/structure-representation-helper.ts
+
14
−
21
View file @
2b5e49d2
...
...
@@ -10,11 +10,7 @@ import { StateTransformer, StateSelection, StateObjectCell, StateTransform } fro
import
{
StructureElement
}
from
'
../../mol-model/structure
'
;
import
{
isEmptyLoci
}
from
'
../../mol-model/loci
'
;
import
{
PluginContext
}
from
'
../context
'
;
import
{
parseMolScript
}
from
'
../../mol-script/language/parser
'
;
import
{
StructureRepresentation3DHelpers
}
from
'
../state/transforms/representation
'
;
import
Expression
from
'
../../mol-script/language/expression
'
;
import
{
formatMolScript
}
from
'
../../mol-script/language/expression-formatter
'
;
import
{
MolScriptBuilder
as
MS
}
from
'
../../mol-script/language/builder
'
;
type
StructureTransform
=
StateObjectCell
<
PluginStateObject
.
Molecule
.
Structure
,
StateTransform
<
StateTransformer
<
any
,
PluginStateObject
.
Molecule
.
Structure
,
any
>>>
const
RepresentationManagerTag
=
'
representation-controls
'
...
...
@@ -23,19 +19,19 @@ function getRepresentationManagerTag(type: string) {
return
`
${
RepresentationManagerTag
}
-
${
type
}
`
}
function
getCombined
Expression
(
modifier
:
SelectionModifier
,
expression
:
Expression
,
currentExpression
:
Expression
):
Expression
{
switch
(
mod
ifier
)
{
case
'
add
'
:
return
MS
.
s
truct
.
combinator
.
merge
([
currentExpression
,
expression
]
)
case
'
remove
'
:
return
MS
.
s
truct
.
modifier
.
exceptBy
({
0
:
currentExpression
,
by
:
expression
}
)
case
'
only
'
:
return
expression
case
'
all
'
:
return
MS
.
s
truct
.
generator
.
all
(
)
function
getCombined
Loci
(
mode
:
SelectionModifier
,
loci
:
StructureElement
.
Loci
,
currentLoci
:
StructureElement
.
Loci
):
StructureElement
.
Loci
{
switch
(
mod
e
)
{
case
'
add
'
:
return
S
truct
ureElement
.
Loci
.
union
(
loci
,
currentLoci
)
case
'
remove
'
:
return
S
truct
ureElement
.
Loci
.
subtract
(
currentLoci
,
loci
)
case
'
only
'
:
return
loci
case
'
all
'
:
return
S
truct
ureElement
.
Loci
.
all
(
loci
.
structure
)
}
}
type
SelectionModifier
=
'
add
'
|
'
remove
'
|
'
only
'
|
'
all
'
export
class
StructureRepresentationHelper
{
async
set
(
modifier
:
SelectionModifier
,
type
:
string
,
expression
:
Expression
,
structure
:
StructureTransform
)
{
async
set
(
modifier
:
SelectionModifier
,
type
:
string
,
loci
:
StructureElement
.
Loci
,
structure
:
StructureTransform
)
{
const
state
=
this
.
plugin
.
state
.
dataState
const
update
=
state
.
build
();
const
s
=
structure
.
obj
!
.
data
...
...
@@ -43,23 +39,21 @@ export class StructureRepresentationHelper {
const
selections
=
state
.
select
(
StateSelection
.
Generators
.
ofType
(
PluginStateObject
.
Molecule
.
Structure
,
structure
.
transform
.
ref
).
withTag
(
getRepresentationManagerTag
(
type
)));
if
(
selections
.
length
>
0
)
{
const
parsedExpressions
=
parseMolScript
(
selections
[
0
].
params
!
.
values
.
query
.
expression
)
if
(
parsedExpressions
.
length
===
0
)
return
const
currentExpression
=
parsedExpressions
[
0
]
const
combinedExpression
=
getCombinedExpression
(
modifier
,
expression
,
currentExpression
)
const
currentLoci
=
StructureElement
.
Query
.
toLoci
(
selections
[
0
].
params
!
.
values
.
query
,
s
)
const
combinedLoci
=
getCombinedLoci
(
modifier
,
loci
,
currentLoci
)
update
.
to
(
selections
[
0
]).
update
({
...
selections
[
0
].
params
!
.
values
,
query
:
{
language
:
'
mol-script
'
,
expression
:
formatMolScript
(
combinedExpression
)
}
query
:
StructureElement
.
Query
.
fromLoci
(
combinedLoci
)
})
}
else
{
const
combined
Expression
=
getCombined
Expression
(
modifier
,
expression
,
MS
.
struct
.
generator
.
empty
(
))
const
combined
Loci
=
getCombined
Loci
(
modifier
,
loci
,
StructureElement
.
Loci
(
s
,
[]
))
update
.
to
(
structure
.
transform
.
ref
)
.
apply
(
StateTransforms
.
Model
.
User
StructureSelection
,
StateTransforms
.
Model
.
Loci
StructureSelection
,
{
query
:
{
language
:
'
mol-script
'
,
expression
:
formatMolScript
(
combinedExpression
)
}
,
query
:
StructureElement
.
Query
.
fromLoci
(
combinedLoci
)
,
label
:
type
},
{
tags
:
[
RepresentationManagerTag
,
getRepresentationManagerTag
(
type
)
]
}
...
...
@@ -81,9 +75,8 @@ export class StructureRepresentationHelper {
const
s
=
structure
.
obj
!
.
data
const
_loci
=
this
.
plugin
.
helpers
.
structureSelectionManager
.
get
(
s
)
const
loci
=
isEmptyLoci
(
_loci
)
?
StructureElement
.
Loci
(
s
,
[])
:
_loci
const
expression
=
StructureElement
.
Loci
.
toScriptExpression
(
loci
)
await
this
.
set
(
modifier
,
type
,
expression
,
structure
)
await
this
.
set
(
modifier
,
type
,
loci
,
structure
)
}
}
...
...
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