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
a2bf4890
Commit
a2bf4890
authored
4 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
fix bond ordering when creating structure from Topology
parent
aca49b9b
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-model/structure/model/model.ts
+12
-2
12 additions, 2 deletions
src/mol-model/structure/model/model.ts
with
12 additions
and
2 deletions
src/mol-model/structure/model/model.ts
+
12
−
2
View file @
a2bf4890
...
@@ -120,16 +120,26 @@ export namespace Model {
...
@@ -120,16 +120,26 @@ export namespace Model {
return
_trajectoryFromModelAndCoordinates
(
model
,
coordinates
).
trajectory
;
return
_trajectoryFromModelAndCoordinates
(
model
,
coordinates
).
trajectory
;
}
}
function
invertIndex
(
xs
:
ArrayLike
<
number
>
)
{
const
ret
=
new
Int32Array
(
xs
.
length
);
for
(
let
i
=
0
,
_i
=
xs
.
length
;
i
<
_i
;
i
++
)
{
ret
[
xs
[
i
]]
=
i
;
}
return
ret
;
}
export
function
trajectoryFromTopologyAndCoordinates
(
topology
:
Topology
,
coordinates
:
Coordinates
):
Task
<
Trajectory
>
{
export
function
trajectoryFromTopologyAndCoordinates
(
topology
:
Topology
,
coordinates
:
Coordinates
):
Task
<
Trajectory
>
{
return
Task
.
create
(
'
Create Trajectory
'
,
async
ctx
=>
{
return
Task
.
create
(
'
Create Trajectory
'
,
async
ctx
=>
{
const
model
=
(
await
createModels
(
topology
.
basic
,
topology
.
sourceData
,
ctx
))[
0
];
const
model
=
(
await
createModels
(
topology
.
basic
,
topology
.
sourceData
,
ctx
))[
0
];
if
(
!
model
)
throw
new
Error
(
'
found no model
'
);
if
(
!
model
)
throw
new
Error
(
'
found no model
'
);
const
{
trajectory
,
srcIndexArray
}
=
_trajectoryFromModelAndCoordinates
(
model
,
coordinates
);
const
{
trajectory
,
srcIndexArray
}
=
_trajectoryFromModelAndCoordinates
(
model
,
coordinates
);
// TODO: cache the inverted index somewhere?
const
invertedIndex
=
srcIndexArray
?
invertIndex
(
srcIndexArray
)
:
void
0
;
const
pairs
=
srcIndexArray
const
pairs
=
srcIndexArray
?
{
?
{
indexA
:
Column
.
ofIntArray
(
Column
.
mapToArray
(
topology
.
bonds
.
indexA
,
i
=>
srcIndexArray
[
i
],
Int32Array
)),
indexA
:
Column
.
ofIntArray
(
Column
.
mapToArray
(
topology
.
bonds
.
indexA
,
i
=>
invertedIndex
!
[
i
],
Int32Array
)),
indexB
:
Column
.
ofIntArray
(
Column
.
mapToArray
(
topology
.
bonds
.
indexB
,
i
=>
srcIndexArray
[
i
],
Int32Array
)),
indexB
:
Column
.
ofIntArray
(
Column
.
mapToArray
(
topology
.
bonds
.
indexB
,
i
=>
invertedIndex
!
[
i
],
Int32Array
)),
order
:
topology
.
bonds
.
order
order
:
topology
.
bonds
.
order
}
}
:
topology
.
bonds
;
:
topology
.
bonds
;
...
...
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