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
52a02fa9
Commit
52a02fa9
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: structure transform3d
parent
9c348e05
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-model/structure/structure/structure.ts
+15
-1
15 additions, 1 deletion
src/mol-model/structure/structure/structure.ts
src/mol-plugin/state/transforms/model.ts
+5
-2
5 additions, 2 deletions
src/mol-plugin/state/transforms/model.ts
with
20 additions
and
3 deletions
src/mol-model/structure/structure/structure.ts
+
15
−
1
View file @
52a02fa9
...
...
@@ -21,7 +21,7 @@ import StructureProperties from './properties';
import
{
ResidueIndex
,
ChainIndex
,
EntityIndex
}
from
'
../model/indexing
'
;
import
{
Carbohydrates
}
from
'
./carbohydrates/data
'
;
import
{
computeCarbohydrates
}
from
'
./carbohydrates/compute
'
;
import
{
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
Vec3
,
Mat4
}
from
'
mol-math/linear-algebra
'
;
import
{
idFactory
}
from
'
mol-util/id-factory
'
;
import
{
GridLookup3D
}
from
'
mol-math/geometry
'
;
import
{
UUID
}
from
'
mol-util
'
;
...
...
@@ -344,6 +344,20 @@ namespace Structure {
}
}
export
function
transform
(
s
:
Structure
,
transform
:
Mat4
)
{
if
(
Mat4
.
isIdentity
(
transform
))
return
s
;
if
(
!
Mat4
.
isRotationAndTranslation
(
transform
))
throw
new
Error
(
'
Only rotation/translation combination can be applied.
'
);
const
units
:
Unit
[]
=
[];
for
(
const
u
of
s
.
units
)
{
const
old
=
u
.
conformation
.
operator
;
const
op
=
SymmetryOperator
.
create
(
old
.
name
,
transform
,
old
.
hkl
);
units
.
push
(
u
.
applyOperator
(
u
.
id
,
op
));
}
return
new
Structure
(
units
);
}
export
class
StructureBuilder
{
private
units
:
Unit
[]
=
[];
private
invariantId
=
idFactory
()
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/state/transforms/model.ts
+
5
−
2
View file @
52a02fa9
...
...
@@ -11,6 +11,7 @@ import { Model, Format, Structure, ModelSymmetry, StructureSymmetry, QueryContex
import
{
ParamDefinition
as
PD
}
from
'
mol-util/param-definition
'
;
import
Expression
from
'
mol-script/language/expression
'
;
import
{
compile
}
from
'
mol-script/runtime/query/compiler
'
;
import
{
Mat4
}
from
'
mol-math/linear-algebra
'
;
export
{
ParseModelsFromMmCif
}
namespace
ParseModelsFromMmCif
{
export
interface
Params
{
blockHeader
?:
string
}
}
...
...
@@ -46,7 +47,7 @@ const ParseModelsFromMmCif = PluginStateTransform.Create<SO.Data.Cif, SO.Models,
});
export
{
CreateStructureFromModel
}
namespace
CreateStructureFromModel
{
export
interface
Params
{
modelIndex
:
number
}
}
namespace
CreateStructureFromModel
{
export
interface
Params
{
modelIndex
:
number
,
transform3d
?:
Mat4
}
}
const
CreateStructureFromModel
=
PluginStateTransform
.
Create
<
SO
.
Models
,
SO
.
Structure
,
CreateStructureFromModel
.
Params
>
({
name
:
'
create-structure-from-model
'
,
display
:
{
...
...
@@ -59,9 +60,11 @@ const CreateStructureFromModel = PluginStateTransform.Create<SO.Models, SO.Struc
default
:
()
=>
({
modelIndex
:
0
}),
controls
:
a
=>
({
modelIndex
:
PD
.
Range
(
'
Model Index
'
,
'
Model Index
'
,
0
,
0
,
Math
.
max
(
0
,
a
.
data
.
length
-
1
),
1
)
})
},
isApplicable
:
a
=>
a
.
data
.
length
>
0
,
apply
({
a
,
params
})
{
if
(
params
.
modelIndex
<
0
||
params
.
modelIndex
>=
a
.
data
.
length
)
throw
new
Error
(
`Invalid modelIndex
${
params
.
modelIndex
}
`
);
const
s
=
Structure
.
ofModel
(
a
.
data
[
params
.
modelIndex
]);
let
s
=
Structure
.
ofModel
(
a
.
data
[
params
.
modelIndex
]);
if
(
params
.
transform3d
)
s
=
Structure
.
transform
(
s
,
params
.
transform3d
);
return
new
SO
.
Structure
({
label
:
`Model
${
s
.
models
[
0
].
modelNum
}
`
,
description
:
s
.
elementCount
===
1
?
'
1 element
'
:
`
${
s
.
elementCount
}
elements`
},
s
);
}
});
...
...
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