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
1a041254
Commit
1a041254
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
Fixed parsing density server data
parent
d47c2ebe
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-math/linear-algebra/tensor.ts
+21
-0
21 additions, 0 deletions
src/mol-math/linear-algebra/tensor.ts
src/mol-model/volume/formats/density-server.ts
+16
-4
16 additions, 4 deletions
src/mol-model/volume/formats/density-server.ts
with
37 additions
and
4 deletions
src/mol-math/linear-algebra/tensor.ts
+
21
−
0
View file @
1a041254
...
...
@@ -202,4 +202,25 @@ export namespace Tensor {
}
return
o
;
}
// Convers "slow to fast" axis order to "fast to slow" and vice versa.
export
function
invertAxisOrder
(
v
:
number
[])
{
const
ret
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
v
.
length
;
i
++
)
{
ret
[
i
]
=
v
[
v
.
length
-
i
-
1
];
}
return
ret
;
}
export
function
getCanonicalAxisIndicesFastToSlow
(
order
:
number
[])
{
const
indices
=
new
Int32Array
(
order
.
length
)
as
any
as
number
[];
for
(
let
i
=
0
;
i
<
order
.
length
;
i
++
)
indices
[
order
[
i
]]
=
i
;
return
indices
;
}
export
function
getCanonicalAxisIndicesSlowToFast
(
order
:
number
[])
{
const
indices
=
new
Int32Array
(
order
.
length
)
as
any
as
number
[];
for
(
let
i
=
0
;
i
<
order
.
length
;
i
++
)
indices
[
order
[
order
.
length
-
i
-
1
]]
=
i
;
return
indices
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-model/volume/formats/density-server.ts
+
16
−
4
View file @
1a041254
...
...
@@ -10,6 +10,10 @@ import { Task } from 'mol-task';
import
{
SpacegroupCell
,
Box3D
}
from
'
mol-math/geometry
'
;
import
{
Tensor
,
Vec3
}
from
'
mol-math/linear-algebra
'
;
function
normalizeOrder
(
v
:
number
[],
indices
:
number
[])
{
return
Vec3
.
create
(
v
[
indices
[
0
]],
v
[
indices
[
1
]],
v
[
indices
[
2
]])
}
function
parseDensityServerData
(
source
:
DensityServer_Data_Database
):
Task
<
VolumeData
>
{
return
Task
.
create
<
VolumeData
>
(
'
Parse Volume Data
'
,
async
ctx
=>
{
const
{
volume_data_3d_info
:
info
,
volume_data_3d
:
values
}
=
source
;
...
...
@@ -19,11 +23,19 @@ function parseDensityServerData(source: DensityServer_Data_Database): Task<Volum
Vec3
.
scale
(
Vec3
.
zero
(),
Vec3
.
ofArray
(
info
.
spacegroup_cell_angles
.
value
(
0
)),
Math
.
PI
/
180
)
);
const
tensorSpace
=
Tensor
.
Space
(
info
.
sample_count
.
value
(
0
),
info
.
axis_order
.
value
(
0
),
Float32Array
);
const
data
=
Tensor
.
create
(
tensorSpace
,
Tensor
.
Data1
(
values
.
values
.
toArray
()));
const
axis_order_fast_to_slow
=
info
.
axis_order
.
value
(
0
);
const
indices
=
Tensor
.
getCanonicalAxisIndicesFastToSlow
(
axis_order_fast_to_slow
);
// sample count is in "axis order" and needs to be reordered
const
sample_count
=
normalizeOrder
(
info
.
sample_count
.
value
(
0
),
indices
);
const
tensorSpace
=
Tensor
.
Space
(
sample_count
,
Tensor
.
invertAxisOrder
(
axis_order_fast_to_slow
),
Float32Array
);
const
data
=
Tensor
.
create
(
tensorSpace
,
Tensor
.
Data1
(
values
.
values
.
toArray
({
array
:
Float32Array
})));
const
origin
=
Vec3
.
ofArray
(
info
.
origin
.
value
(
0
))
const
dimensions
=
Vec3
.
ofArray
(
info
.
dimensions
.
value
(
0
));
// origin and dimensions are in "axis order" and need to be reordered
const
origin
=
normalizeOrder
(
info
.
origin
.
value
(
0
),
indices
)
const
dimensions
=
normalizeOrder
(
info
.
dimensions
.
value
(
0
),
indices
);
return
{
cell
,
...
...
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