Skip to content
Snippets Groups Projects
Commit dc0e54c2 authored by Alexander Rose's avatar Alexander Rose
Browse files

Merge branch 'master' of https://github.com/molstar/molstar

parents 9bea1343 b710291d
No related branches found
No related tags found
No related merge requests found
...@@ -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) => {
// function defaultBondTest(ctx: QueryContext) { let incl = s;
// return true; for (let i = 0; i < lc; i++) {
// } incl = includeConnectedStep(ctx, bt, wholeResidues, incl);
}
// interface IncludeConnectedCtx { builder.add(incl);
// queryCtx: QueryContext, if (sI % 10 === 0) ctx.throwIfTimedOut();
// input: Structure, });
// bondTest: QueryFn<boolean>, ctx.popCurrentLink();
// wholeResidues: boolean return builder.getSelection();
// } }
}
// type FrontierSet = UniqueArray<StructureElement.UnitIndex, StructureElement.UnitIndex>
// type Frontier = { unitIds: UniqueArray<number>, elements: Map<number /* unit id */, FrontierSet> } function includeConnectedStep(ctx: QueryContext, bondTest: QueryFn<boolean>, wholeResidues: boolean, structure: Structure) {
const expanded = expandConnected(ctx, structure, bondTest);
// namespace Frontier { if (wholeResidues) return getWholeResidues(ctx, ctx.inputStructure, expanded);
// export function has({ elements }: Frontier, unitId: number, element: StructureElement.UnitIndex) { return expanded;
// if (!elements.has(unitId)) return false; }
// const xs = elements.get(unitId)!;
// return xs.keys.has(element); function expandConnected(ctx: QueryContext, structure: Structure, bondTest: QueryFn<boolean>) {
// } const inputStructure = ctx.inputStructure;
const interLinks = inputStructure.links;
// export function create(pivot: Structure, input: Structure) { const builder = new StructureUniqueSubsetBuilder(inputStructure);
// const unitIds = UniqueArray.create<number>();
// const elements: Frontier['elements'] = new Map(); const processedUnits = new Set<number>();
// for (const unit of pivot.units) {
// if (!Unit.isAtomic(unit)) continue; // Process intra unit links
for (const unit of structure.units) {
// UniqueArray.add(unitIds, unit.id, unit.id); processedUnits.add(unit.id);
// const xs: FrontierSet = UniqueArray.create();
// elements.set(unit.id, xs); if (unit.kind !== Unit.Kind.Atomic) {
// add the whole unit
// const pivotElements = unit.elements; builder.beginUnit(unit.id);
// const inputElements = input.unitMap.get(unit.id).elements; for (let i = 0, _i = unit.elements.length; i < _i; i++) {
// for (let i = 0, _i = pivotElements.length; i < _i; i++) { builder.addElement(unit.elements[i]);
// const idx = SortedArray.indexOf(inputElements, pivotElements[i]) as StructureElement.UnitIndex; }
// UniqueArray.add(xs, idx, idx); builder.commitUnit();
// } continue;
// } }
// return { unitIds, elements }; const inputUnit = inputStructure.unitMap.get(unit.id) as Unit.Atomic;
// } const { offset: intraLinkOffset, b: intraLinkB } = inputUnit.links;
// export function addFrontier(target: Frontier, from: Frontier) { // Process intra unit links
// for (const unitId of from.unitIds.array) { ctx.atomicLink.aUnit = inputUnit;
// let xs: FrontierSet; ctx.atomicLink.bUnit = inputUnit;
// if (target.elements.has(unitId)) { for (let i = 0, _i = unit.elements.length; i < _i; i++) {
// xs = target.elements.get(unitId)!; // add the current element
// } else { builder.addToUnit(unit.id, unit.elements[i]);
// xs = UniqueArray.create();
// target.elements.set(unitId, xs); const srcIndex = SortedArray.indexOf(inputUnit.elements, unit.elements[i]);
// UniqueArray.add(target.unitIds, unitId, unitId); ctx.atomicLink.aIndex = srcIndex as StructureElement.UnitIndex;
// }
// check intra unit links
// for (const e of from.elements.get(unitId)!.array) { for (let lI = intraLinkOffset[srcIndex], _lI = intraLinkOffset[srcIndex + 1]; lI < _lI; lI++) {
// UniqueArray.add(xs, e, e); ctx.atomicLink.bIndex = intraLinkB[lI] as StructureElement.UnitIndex;
// } if (bondTest(ctx)) {
// } builder.addToUnit(unit.id, inputUnit.elements[intraLinkB[lI]]);
// return target; }
// } }
}
// export function includeWholeResidues(structure: Structure, frontier: Frontier) {
// // ... // Process inter unit links
// } for (const linkedUnit of interLinks.getLinkedUnits(inputUnit)) {
// } if (processedUnits.has(linkedUnit.unitB.id)) continue;
// function expandFrontier(ctx: IncludeConnectedCtx, currentFrontier: Frontier, result: Frontier): Frontier { ctx.atomicLink.bUnit = linkedUnit.unitB;
// return 0 as any; for (const aI of linkedUnit.linkedElementIndices) {
// } // check if the element is in the expanded structure
if (!SortedArray.has(unit.elements, inputUnit.elements[aI])) continue;
ctx.atomicLink.aIndex = aI;
for (const bond of linkedUnit.getBonds(aI)) {
ctx.atomicLink.bIndex = bond.indexB;
if (bondTest(ctx)) {
builder.addToUnit(linkedUnit.unitB.id, linkedUnit.unitB.elements[bond.indexB]);
}
}
}
}
}
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
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
float: left; float: left;
margin-right: $control-spacing; margin-right: $control-spacing;
position: relative; position: relative;
background-color: $msp-form-control-background; // background-color: $msp-form-control-background;
.msp-animation-viewport-controls-select { .msp-animation-viewport-controls-select {
width: 290px; width: 290px;
......
...@@ -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 ================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment