|
@@ -5,14 +5,13 @@
|
|
|
*/
|
|
|
|
|
|
import { Segmentation } from 'mol-data/int';
|
|
|
-import { RuntimeContext } from 'mol-task';
|
|
|
import { Structure, Unit } from '../../structure';
|
|
|
import { StructureQuery } from '../query';
|
|
|
import { StructureSelection } from '../selection';
|
|
|
import { UniqueStructuresBuilder } from '../utils/builders';
|
|
|
import { StructureUniqueSubsetBuilder } from '../../structure/util/unique-subset-builder';
|
|
|
|
|
|
-function getWholeResidues(ctx: RuntimeContext, source: Structure, structure: Structure) {
|
|
|
+function getWholeResidues(source: Structure, structure: Structure) {
|
|
|
const builder = source.subsetBuilder(true);
|
|
|
for (const unit of structure.units) {
|
|
|
if (unit.kind !== Unit.Kind.Atomic) {
|
|
@@ -38,17 +37,14 @@ function getWholeResidues(ctx: RuntimeContext, source: Structure, structure: Str
|
|
|
}
|
|
|
|
|
|
export function wholeResidues(query: StructureQuery, isFlat: boolean): StructureQuery {
|
|
|
- return async (ctx) => {
|
|
|
- const inner = await query(ctx);
|
|
|
+ return ctx => {
|
|
|
+ const inner = query(ctx);
|
|
|
if (StructureSelection.isSingleton(inner)) {
|
|
|
- return StructureSelection.Singletons(ctx.inputStructure, getWholeResidues(ctx.taskCtx, ctx.inputStructure, inner.structure));
|
|
|
+ return StructureSelection.Singletons(ctx.inputStructure, getWholeResidues(ctx.inputStructure, inner.structure));
|
|
|
} else {
|
|
|
const builder = new UniqueStructuresBuilder(ctx.inputStructure);
|
|
|
- let progress = 0;
|
|
|
for (const s of inner.structures) {
|
|
|
- builder.add(getWholeResidues(ctx.taskCtx, ctx.inputStructure, s));
|
|
|
- progress++;
|
|
|
- if (ctx.taskCtx.shouldUpdate) await ctx.taskCtx.update({ message: 'Whole Residues', current: progress, max: inner.structures.length });
|
|
|
+ builder.add(getWholeResidues(ctx.inputStructure, s));
|
|
|
}
|
|
|
return builder.getSelection();
|
|
|
}
|
|
@@ -64,12 +60,11 @@ export interface IncludeSurroundingsParams {
|
|
|
wholeResidues?: boolean
|
|
|
}
|
|
|
|
|
|
-async function getIncludeSurroundings(ctx: RuntimeContext, source: Structure, structure: Structure, params: IncludeSurroundingsParams) {
|
|
|
+function getIncludeSurroundings(source: Structure, structure: Structure, params: IncludeSurroundingsParams) {
|
|
|
const builder = new StructureUniqueSubsetBuilder(source);
|
|
|
const lookup = source.lookup3d;
|
|
|
const r = params.radius;
|
|
|
|
|
|
- let progress = 0;
|
|
|
for (const unit of structure.units) {
|
|
|
const { x, y, z } = unit.conformation;
|
|
|
const elements = unit.elements;
|
|
@@ -77,23 +72,21 @@ async function getIncludeSurroundings(ctx: RuntimeContext, source: Structure, st
|
|
|
const e = elements[i];
|
|
|
lookup.findIntoBuilder(x(e), y(e), z(e), r, builder);
|
|
|
}
|
|
|
- progress++;
|
|
|
- if (progress % 2500 === 0 && ctx.shouldUpdate) await ctx.update({ message: 'Include Surroudnings', isIndeterminate: true });
|
|
|
}
|
|
|
- return !!params.wholeResidues ? getWholeResidues(ctx, source, builder.getStructure()) : builder.getStructure();
|
|
|
+ return !!params.wholeResidues ? getWholeResidues(source, builder.getStructure()) : builder.getStructure();
|
|
|
}
|
|
|
|
|
|
export function includeSurroundings(query: StructureQuery, params: IncludeSurroundingsParams): StructureQuery {
|
|
|
- return async (ctx) => {
|
|
|
- const inner = await query(ctx);
|
|
|
+ return ctx => {
|
|
|
+ const inner = query(ctx);
|
|
|
if (StructureSelection.isSingleton(inner)) {
|
|
|
- const surr = await getIncludeSurroundings(ctx.taskCtx, ctx.inputStructure, inner.structure, params);
|
|
|
+ const surr = getIncludeSurroundings(ctx.inputStructure, inner.structure, params);
|
|
|
const ret = StructureSelection.Singletons(ctx.inputStructure, surr);
|
|
|
return ret;
|
|
|
} else {
|
|
|
const builder = new UniqueStructuresBuilder(ctx.inputStructure);
|
|
|
for (const s of inner.structures) {
|
|
|
- builder.add(await getIncludeSurroundings(ctx.taskCtx, ctx.inputStructure, s, params));
|
|
|
+ builder.add(getIncludeSurroundings(ctx.inputStructure, s, params));
|
|
|
}
|
|
|
return builder.getSelection();
|
|
|
}
|