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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
74c8e512
Commit
74c8e512
authored
5 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
add Structure.atomicResidueCount & SerialMapping.getSerialIndex
parent
52bf9b87
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-model/structure/structure/structure.ts
+44
-6
44 additions, 6 deletions
src/mol-model/structure/structure/structure.ts
with
44 additions
and
6 deletions
src/mol-model/structure/structure/structure.ts
+
44
−
6
View file @
74c8e512
...
...
@@ -5,7 +5,7 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
IntMap
,
SortedArray
,
Iterator
,
Segmentation
,
Interval
}
from
'
../../../mol-data/int
'
import
{
IntMap
,
SortedArray
,
Iterator
,
Segmentation
,
Interval
,
OrderedSet
}
from
'
../../../mol-data/int
'
import
{
UniqueArray
}
from
'
../../../mol-data/generic
'
import
{
SymmetryOperator
}
from
'
../../../mol-math/geometry/symmetry-operator
'
import
{
Model
,
ElementIndex
}
from
'
../model
'
...
...
@@ -59,6 +59,7 @@ class Structure {
elementCount
:
number
,
bondCount
:
number
,
uniqueElementCount
:
number
,
atomicResidueCount
:
number
,
polymerResidueCount
:
number
,
polymerUnitCount
:
number
,
coordinateSystem
:
SymmetryOperator
,
...
...
@@ -71,6 +72,7 @@ class Structure {
elementCount
:
-
1
,
bondCount
:
-
1
,
uniqueElementCount
:
-
1
,
atomicResidueCount
:
-
1
,
polymerResidueCount
:
-
1
,
polymerUnitCount
:
-
1
,
coordinateSystem
:
SymmetryOperator
.
Default
,
...
...
@@ -140,6 +142,13 @@ class Structure {
return
this
.
_props
.
uniqueElementCount
;
}
get
atomicResidueCount
()
{
if
(
this
.
_props
.
atomicResidueCount
===
-
1
)
{
this
.
_props
.
atomicResidueCount
=
getAtomicResidueCount
(
this
)
}
return
this
.
_props
.
atomicResidueCount
;
}
/** Coarse structure, defined as Containing less than twice as many elements as polymer residues */
get
isCoarse
()
{
const
ec
=
this
.
elementCount
...
...
@@ -253,7 +262,8 @@ class Structure {
}
get
entityIndices
()
{
return
this
.
_props
.
entityIndices
||
(
this
.
_props
.
entityIndices
=
getEntityIndices
(
this
));
return
this
.
_props
.
entityIndices
||
(
this
.
_props
.
entityIndices
=
getEntityIndices
(
this
));
}
get
uniqueAtomicResidueIndices
()
{
...
...
@@ -470,16 +480,38 @@ function getPolymerUnitCount(structure: Structure): number {
return
polymerUnitCount
}
function
getAtomicResidueCount
(
structure
:
Structure
):
number
{
const
{
units
}
=
structure
let
atomicResidueCount
=
0
for
(
let
i
=
0
,
_i
=
units
.
length
;
i
<
_i
;
i
++
)
{
const
unit
=
units
[
i
]
if
(
!
Unit
.
isAtomic
(
unit
))
continue
const
{
elements
,
residueIndex
}
=
unit
let
idx
=
-
1
let
prevIdx
=
-
1
for
(
let
j
=
0
,
jl
=
elements
.
length
;
j
<
jl
;
++
j
)
{
idx
=
residueIndex
[
elements
[
j
]]
if
(
idx
!==
prevIdx
)
{
atomicResidueCount
+=
1
prevIdx
=
idx
}
}
}
return
atomicResidueCount
}
interface
SerialMapping
{
/** Cumulative count of elements for each unit */
/** Cumulative count of
preceding
elements for each unit */
cumulativeUnitElementCount
:
ArrayLike
<
number
>
/** Unit index for each serial element in the structure */
unitIndices
:
ArrayLike
<
number
>
/** Element index for each serial element in the structure */
elementIndices
:
ArrayLike
<
ElementIndex
>
/** Get serial index of element in the structure */
getSerialIndex
:
(
unit
:
Unit
,
element
:
ElementIndex
)
=>
Structure
.
SerialIndex
}
function
getSerialMapping
(
structure
:
Structure
):
SerialMapping
{
const
{
units
,
elementCount
}
=
structure
const
{
units
,
elementCount
,
unitIndexMap
}
=
structure
const
cumulativeUnitElementCount
=
new
Uint32Array
(
units
.
length
)
const
unitIndices
=
new
Uint32Array
(
elementCount
)
const
elementIndices
=
new
Uint32Array
(
elementCount
)
as
unknown
as
ElementIndex
[]
...
...
@@ -493,7 +525,13 @@ function getSerialMapping(structure: Structure): SerialMapping {
}
m
+=
elements
.
length
}
return
{
cumulativeUnitElementCount
,
unitIndices
,
elementIndices
}
return
{
cumulativeUnitElementCount
,
unitIndices
,
elementIndices
,
getSerialIndex
:
(
unit
,
element
)
=>
cumulativeUnitElementCount
[
unitIndexMap
.
get
(
unit
.
id
)]
+
OrderedSet
.
indexOf
(
unit
.
elements
,
element
)
as
Structure
.
SerialIndex
}
}
namespace
Structure
{
...
...
@@ -776,7 +814,7 @@ namespace Structure {
return
hashString
(
s
.
units
.
map
(
u
=>
Unit
.
conformationId
(
u
)).
join
(
'
|
'
))
}
// TODO: there should be a version that proper
t
y supports partitioned units
// TODO: there should be a version that proper
l
y supports partitioned units
export
function
areUnitAndIndicesEqual
(
a
:
Structure
,
b
:
Structure
)
{
if
(
a
===
b
)
return
true
;
...
...
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