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
d84d5f38
Commit
d84d5f38
authored
5 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-model: implemented includeConnected query
parent
2fc28f60
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-model/structure/query/queries/modifiers.ts
+91
-70
91 additions, 70 deletions
src/mol-model/structure/query/queries/modifiers.ts
src/mol-script/runtime/query/table.ts
+6
-0
6 additions, 0 deletions
src/mol-script/runtime/query/table.ts
with
97 additions
and
70 deletions
src/mol-model/structure/query/queries/modifiers.ts
+
91
−
70
View file @
d84d5f38
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* @author David Sehnal <david.sehnal@gmail.com>
* @author David Sehnal <david.sehnal@gmail.com>
*/
*/
import
{
Segmentation
}
from
'
../../../../mol-data/int
'
;
import
{
Segmentation
,
SortedArray
}
from
'
../../../../mol-data/int
'
;
import
{
Structure
,
Unit
}
from
'
../../structure
'
;
import
{
Structure
,
Unit
}
from
'
../../structure
'
;
import
{
StructureQuery
}
from
'
../query
'
;
import
{
StructureQuery
}
from
'
../query
'
;
import
{
StructureSelection
}
from
'
../selection
'
;
import
{
StructureSelection
}
from
'
../selection
'
;
...
@@ -304,78 +304,99 @@ export interface IncludeConnectedParams {
...
@@ -304,78 +304,99 @@ export interface IncludeConnectedParams {
}
}
export
function
includeConnected
({
query
,
layerCount
,
wholeResidues
,
bondTest
}:
IncludeConnectedParams
):
StructureQuery
{
export
function
includeConnected
({
query
,
layerCount
,
wholeResidues
,
bondTest
}:
IncludeConnectedParams
):
StructureQuery
{
const
bt
=
bondTest
||
defaultBondTest
;
const
lc
=
Math
.
max
(
layerCount
,
0
);
return
ctx
=>
{
return
ctx
=>
{
return
0
as
any
;
const
builder
=
StructureSelection
.
UniqueBuilder
(
ctx
.
inputStructure
);
const
src
=
query
(
ctx
);
ctx
.
pushCurrentLink
();
StructureSelection
.
forEach
(
src
,
(
s
,
sI
)
=>
{
let
incl
=
s
;
for
(
let
i
=
0
;
i
<
lc
;
i
++
)
{
incl
=
includeConnectedStep
(
ctx
,
bt
,
wholeResidues
,
incl
);
}
builder
.
add
(
incl
);
if
(
sI
%
10
===
0
)
ctx
.
throwIfTimedOut
();
});
ctx
.
popCurrentLink
();
return
builder
.
getSelection
();
}
}
}
}
// function defaultBondTest(ctx: QueryContext) {
function
includeConnectedStep
(
ctx
:
QueryContext
,
bondTest
:
QueryFn
<
boolean
>
,
wholeResidues
:
boolean
,
structure
:
Structure
)
{
// return true;
const
expanded
=
expandConnected
(
ctx
,
structure
,
bondTest
);
// }
if
(
wholeResidues
)
return
getWholeResidues
(
ctx
,
ctx
.
inputStructure
,
expanded
);
return
expanded
;
// interface IncludeConnectedCtx {
}
// queryCtx: QueryContext,
// input: Structure,
function
expandConnected
(
ctx
:
QueryContext
,
structure
:
Structure
,
bondTest
:
QueryFn
<
boolean
>
)
{
// bondTest: QueryFn<boolean>,
const
inputStructure
=
ctx
.
inputStructure
;
// wholeResidues: boolean
const
interLinks
=
inputStructure
.
links
;
// }
const
builder
=
new
StructureUniqueSubsetBuilder
(
inputStructure
);
// type FrontierSet = UniqueArray<StructureElement.UnitIndex, StructureElement.UnitIndex>
const
processedUnits
=
new
Set
<
number
>
();
// type Frontier = { unitIds: UniqueArray<number>, elements: Map<number /* unit id */, FrontierSet> }
// Process intra unit links
// namespace Frontier {
for
(
const
unit
of
structure
.
units
)
{
// export function has({ elements }: Frontier, unitId: number, element: StructureElement.UnitIndex) {
processedUnits
.
add
(
unit
.
id
);
// if (!elements.has(unitId)) return false;
// const xs = elements.get(unitId)!;
if
(
unit
.
kind
!==
Unit
.
Kind
.
Atomic
)
{
// return xs.keys.has(element);
// add the whole unit
// }
builder
.
beginUnit
(
unit
.
id
);
for
(
let
i
=
0
,
_i
=
unit
.
elements
.
length
;
i
<
_i
;
i
++
)
{
// export function create(pivot: Structure, input: Structure) {
builder
.
addElement
(
unit
.
elements
[
i
]);
// const unitIds = UniqueArray.create<number>();
}
// const elements: Frontier['elements'] = new Map();
builder
.
commitUnit
();
// for (const unit of pivot.units) {
continue
;
// if (!Unit.isAtomic(unit)) continue;
}
// UniqueArray.add(unitIds, unit.id, unit.id);
const
inputUnit
=
inputStructure
.
unitMap
.
get
(
unit
.
id
)
as
Unit
.
Atomic
;
// const xs: FrontierSet = UniqueArray.create();
const
{
offset
:
intraLinkOffset
,
b
:
intraLinkB
}
=
inputUnit
.
links
;
// elements.set(unit.id, xs);
// Process intra unit links
// const pivotElements = unit.elements;
ctx
.
atomicLink
.
aUnit
=
inputUnit
;
// const inputElements = input.unitMap.get(unit.id).elements;
ctx
.
atomicLink
.
bUnit
=
inputUnit
;
// for (let i = 0, _i = pivotElements.length; i < _i; i++) {
for
(
let
i
=
0
,
_i
=
unit
.
elements
.
length
;
i
<
_i
;
i
++
)
{
// const idx = SortedArray.indexOf(inputElements, pivotElements[i]) as StructureElement.UnitIndex;
// add the current element
// UniqueArray.add(xs, idx, idx);
builder
.
addToUnit
(
unit
.
id
,
unit
.
elements
[
i
]);
// }
// }
const
srcIndex
=
SortedArray
.
indexOf
(
inputUnit
.
elements
,
unit
.
elements
[
i
]);
ctx
.
atomicLink
.
aIndex
=
srcIndex
as
StructureElement
.
UnitIndex
;
// return { unitIds, elements };
// }
// check intra unit links
for
(
let
lI
=
intraLinkOffset
[
srcIndex
],
_lI
=
intraLinkOffset
[
srcIndex
+
1
];
lI
<
_lI
;
lI
++
)
{
// export function addFrontier(target: Frontier, from: Frontier) {
ctx
.
atomicLink
.
bIndex
=
intraLinkB
[
lI
]
as
StructureElement
.
UnitIndex
;
// for (const unitId of from.unitIds.array) {
if
(
bondTest
(
ctx
))
{
// let xs: FrontierSet;
builder
.
addToUnit
(
unit
.
id
,
inputUnit
.
elements
[
intraLinkB
[
lI
]]);
// if (target.elements.has(unitId)) {
}
// xs = target.elements.get(unitId)!;
}
// } else {
}
// xs = UniqueArray.create();
// target.elements.set(unitId, xs);
// Process inter unit links
// UniqueArray.add(target.unitIds, unitId, unitId);
for
(
const
linkedUnit
of
interLinks
.
getLinkedUnits
(
inputUnit
))
{
// }
if
(
processedUnits
.
has
(
linkedUnit
.
unitB
.
id
))
continue
;
// for (const e of from.elements.get(unitId)!.array) {
ctx
.
atomicLink
.
bUnit
=
linkedUnit
.
unitB
;
// UniqueArray.add(xs, e, e);
for
(
const
aI
of
linkedUnit
.
linkedElementIndices
)
{
// }
// check if the element is in the expanded structure
// }
if
(
!
SortedArray
.
has
(
unit
.
elements
,
inputUnit
.
elements
[
aI
]))
continue
;
// return target;
// }
ctx
.
atomicLink
.
aIndex
=
aI
;
for
(
const
bond
of
linkedUnit
.
getBonds
(
aI
))
{
// export function includeWholeResidues(structure: Structure, frontier: Frontier) {
ctx
.
atomicLink
.
bIndex
=
bond
.
indexB
;
// // ...
if
(
bondTest
(
ctx
))
{
// }
builder
.
addToUnit
(
linkedUnit
.
unitB
.
id
,
linkedUnit
.
unitB
.
elements
[
bond
.
indexB
]);
// }
}
}
// function expandFrontier(ctx: IncludeConnectedCtx, currentFrontier: Frontier, result: Frontier): Frontier {
}
// return 0 as any;
}
// }
}
return
builder
.
getStructure
();
}
function
defaultBondTest
(
ctx
:
QueryContext
)
{
return
true
;
}
// TODO: unionBy (skip this one?), cluster
// TODO: unionBy (skip this one?), cluster
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-script/runtime/query/table.ts
+
6
−
0
View file @
d84d5f38
...
@@ -231,6 +231,12 @@ const symbols = [
...
@@ -231,6 +231,12 @@ const symbols = [
D
(
MolScript
.
structureQuery
.
modifier
.
union
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
union
(
xs
[
0
]
as
any
)(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
union
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
union
(
xs
[
0
]
as
any
)(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
expandProperty
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
expandProperty
(
xs
[
0
]
as
any
,
xs
[
'
property
'
])(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
expandProperty
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
expandProperty
(
xs
[
0
]
as
any
,
xs
[
'
property
'
])(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
exceptBy
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
exceptBy
(
xs
[
0
]
as
any
,
xs
[
'
by
'
]
as
any
)(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
exceptBy
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
exceptBy
(
xs
[
0
]
as
any
,
xs
[
'
by
'
]
as
any
)(
ctx
)),
D
(
MolScript
.
structureQuery
.
modifier
.
includeConnected
,
(
ctx
,
xs
)
=>
Queries
.
modifiers
.
includeConnected
({
query
:
xs
[
0
]
as
any
,
bondTest
:
xs
[
'
bond-test
'
],
wholeResidues
:
!!
(
xs
[
'
as-whole-residues
'
]
&&
xs
[
'
as-whole-residues
'
](
ctx
)),
layerCount
:
(
xs
[
'
layer-count
'
]
&&
xs
[
'
layer-count
'
](
ctx
))
||
1
})(
ctx
)),
// ============= COMBINATORS ================
// ============= COMBINATORS ================
...
...
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