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
322b6016
Commit
322b6016
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added InterUnitLinks.getBondIndices
parent
6d9c41b9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-model/structure/structure/unit/links/data.ts
+30
-7
30 additions, 7 deletions
src/mol-model/structure/structure/unit/links/data.ts
with
30 additions
and
7 deletions
src/mol-model/structure/structure/unit/links/data.ts
+
30
−
7
View file @
322b6016
...
...
@@ -23,6 +23,7 @@ class InterUnitBonds {
/** Array of inter-unit bonds */
readonly
bonds
:
ReadonlyArray
<
InterUnitBonds
.
Bond
>
private
readonly
bondKeyIndex
:
Map
<
string
,
number
>
private
readonly
elementKeyIndex
:
Map
<
string
,
number
[]
>
/** Get an array of unit-pair-bonds that are linked to the given unit */
getLinkedUnits
(
unit
:
Unit
):
ReadonlyArray
<
InterUnitBonds
.
UnitPairBonds
>
{
...
...
@@ -32,8 +33,8 @@ class InterUnitBonds {
/** Index into this.bonds */
getBondIndex
(
indexA
:
StructureElement
.
UnitIndex
,
unitA
:
Unit
,
indexB
:
StructureElement
.
UnitIndex
,
unitB
:
Unit
):
number
{
const
k
ey
=
InterUnitBonds
.
getBondKey
(
indexA
,
unitA
,
indexB
,
unitB
)
const
index
=
this
.
bondKeyIndex
.
get
(
k
ey
)
const
bondK
ey
=
InterUnitBonds
.
getBondKey
(
indexA
,
unitA
,
indexB
,
unitB
)
const
index
=
this
.
bondKeyIndex
.
get
(
bondK
ey
)
return
index
!==
undefined
?
index
:
-
1
}
...
...
@@ -48,26 +49,44 @@ class InterUnitBonds {
return
this
.
getBond
(
l
.
aIndex
,
l
.
aUnit
,
l
.
bIndex
,
l
.
bUnit
);
}
/** Indices into this.bonds */
getBondIndices
(
index
:
StructureElement
.
UnitIndex
,
unit
:
Unit
):
ReadonlyArray
<
number
>
{
const
elementKey
=
InterUnitBonds
.
getElementKey
(
index
,
unit
)
const
indices
=
this
.
elementKeyIndex
.
get
(
elementKey
)
return
indices
!==
undefined
?
indices
:
[]
}
constructor
(
private
map
:
Map
<
number
,
InterUnitBonds
.
UnitPairBonds
[]
>
)
{
let
count
=
0
const
bonds
:
(
InterUnitBonds
.
Bond
)[]
=
[]
const
bondKeyIndex
=
new
Map
<
string
,
number
>
()
const
elementKeyIndex
=
new
Map
<
string
,
number
[]
>
()
this
.
map
.
forEach
(
pairBondsArray
=>
{
pairBondsArray
.
forEach
(
pairBonds
=>
{
count
+=
pairBonds
.
bondCount
pairBonds
.
linkedElementIndices
.
forEach
(
indexA
=>
{
pairBonds
.
getBonds
(
indexA
).
forEach
(
bondInfo
=>
{
const
{
unitA
,
unitB
}
=
pairBonds
const
key
=
InterUnitBonds
.
getBondKey
(
indexA
,
unitA
,
bondInfo
.
indexB
,
unitB
)
bondKeyIndex
.
set
(
key
,
bonds
.
length
)
const
bondKey
=
InterUnitBonds
.
getBondKey
(
indexA
,
unitA
,
bondInfo
.
indexB
,
unitB
)
bondKeyIndex
.
set
(
bondKey
,
bonds
.
length
)
const
elementKey
=
InterUnitBonds
.
getElementKey
(
indexA
,
unitA
)
const
e
=
elementKeyIndex
.
get
(
elementKey
)
if
(
e
===
undefined
)
elementKeyIndex
.
set
(
elementKey
,
[
bonds
.
length
])
else
e
.
push
(
bonds
.
length
)
bonds
.
push
({
...
bondInfo
,
indexA
,
unitA
,
unitB
})
})
})
})
})
this
.
bondCount
=
count
this
.
bonds
=
bonds
this
.
bondKeyIndex
=
bondKeyIndex
this
.
elementKeyIndex
=
elementKeyIndex
}
}
...
...
@@ -102,15 +121,19 @@ namespace InterUnitBonds {
export
interface
Bond
{
readonly
unitA
:
Unit
.
Atomic
,
readonly
unitB
:
Unit
.
Atomic
,
readonly
indexA
:
number
,
readonly
indexB
:
number
,
readonly
indexA
:
StructureElement
.
UnitIndex
,
readonly
indexB
:
StructureElement
.
UnitIndex
,
readonly
order
:
number
,
readonly
flag
:
LinkType
.
Flag
}
export
function
getBondKey
(
indexA
:
number
,
unitA
:
Unit
,
indexB
:
number
,
unitB
:
Unit
)
{
export
function
getBondKey
(
indexA
:
StructureElement
.
UnitIndex
,
unitA
:
Unit
,
indexB
:
StructureElement
.
UnitIndex
,
unitB
:
Unit
)
{
return
`
${
indexA
}
|
${
unitA
.
id
}
|
${
indexB
}
|
${
unitB
.
id
}
`
}
export
function
getElementKey
(
index
:
StructureElement
.
UnitIndex
,
unit
:
Unit
)
{
return
`
${
index
}
|
${
unit
.
id
}
`
}
}
const
emptyArray
:
any
[]
=
[];
...
...
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