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

repr tweaks

parent 905ffb53
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,8 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
const { indices, x, y, z } = position
const n = OrderedSet.size(indices)
const v = Vec3.zero()
const p = Vec3.zero()
const v = Vec3()
const p = Vec3()
let maxRadius = 0
for (let i = 0; i < n; ++i) {
......@@ -49,7 +49,7 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
const densData = space.create()
const c = Vec3.zero()
const c = Vec3()
const alpha = smoothness
......@@ -58,8 +58,8 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
Vec3.mul(_radius2, _radius2, delta)
const updateChunk = Math.ceil(10000 / (_radius2[0] * _radius2[1] * _radius2[2]))
const beg = Vec3.zero()
const end = Vec3.zero()
const beg = Vec3()
const end = Vec3()
const gridPad = 1 / Math.max(...delta)
......
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
......@@ -9,6 +9,7 @@ import { Mat4 } from 'mol-math/linear-algebra';
import { TransformData, createTransform } from 'mol-geo/geometry/transform-data';
import { OrderedSet, SortedArray } from 'mol-data/int';
import { EmptyLoci, Loci } from 'mol-model/loci';
import { PhysicalSizeTheme } from 'mol-theme/size/physical';
/** Return a Loci for the elements of a whole residue the elementIndex belongs to. */
export function getResidueLoci(structure: Structure, unit: Unit.Atomic, elementIndex: ElementIndex): Loci {
......@@ -55,4 +56,68 @@ export function includesUnitKind(unitKinds: UnitKind[], unit: Unit) {
if (Unit.isGaussians(unit) && unitKinds[i] === 'gaussians') return true
}
return false
}
//
export function getConformation(unit: Unit) {
switch (unit.kind) {
case Unit.Kind.Atomic: return unit.model.atomicConformation
case Unit.Kind.Spheres: return unit.model.coarseConformation.spheres
case Unit.Kind.Gaussians: return unit.model.coarseConformation.gaussians
}
}
export function getUnitConformationAndRadius(unit: Unit) {
const conformation = getConformation(unit)
const { elements } = unit
const position = {
indices: elements,
x: conformation.x,
y: conformation.y,
z: conformation.z
}
const l = StructureElement.create(unit)
const sizeTheme = PhysicalSizeTheme({}, {})
const radius = (index: number) => {
l.element = index as ElementIndex
return sizeTheme.size(l)
}
return { position, radius }
}
export function getStructureConformationAndRadius(structure: Structure) {
const n = structure.elementCount
const xs = new Float32Array(n)
const ys = new Float32Array(n)
const zs = new Float32Array(n)
const rs = new Float32Array(n)
const l = StructureElement.create()
const sizeTheme = PhysicalSizeTheme({}, {})
let m = 0
for (let i = 0, il = structure.units.length; i < il; ++i) {
const unit = structure.units[i]
const { elements } = unit
const { x, y, z } = unit.conformation
l.unit = unit
for (let j = 0, jl = elements.length; j < jl; ++j) {
const eI = elements[j]
xs[m + j] = x(eI)
ys[m + j] = y(eI)
zs[m + j] = z(eI)
l.element = eI
rs[m + j] = sizeTheme.size(l)
}
m += elements.length
}
const position = { indices: OrderedSet.ofRange(0, n), x: xs, y: ys, z: zs }
const radius = (index: number) => rs[index]
return { position, radius }
}
\ No newline at end of file
......@@ -4,15 +4,14 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { Unit, StructureElement, ElementIndex, Structure } from 'mol-model/structure';
import { Unit, Structure } from 'mol-model/structure';
import { GaussianDensity } from 'mol-math/geometry/gaussian-density';
import { Task } from 'mol-task';
import { ParamDefinition as PD } from 'mol-util/param-definition';
import { GaussianDensityTexture, GaussianDensityTexture2d } from 'mol-math/geometry/gaussian-density/gpu';
import { Texture } from 'mol-gl/webgl/texture';
import { WebGLContext } from 'mol-gl/webgl/context';
import { PhysicalSizeTheme } from 'mol-theme/size/physical';
import { OrderedSet } from 'mol-data/int';
import { getUnitConformationAndRadius, getStructureConformationAndRadius } from './common';
export const GaussianDensityParams = {
resolution: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }),
......@@ -33,34 +32,6 @@ export type GaussianDensityTextureProps = typeof DefaultGaussianDensityTexturePr
//
function getConformation(unit: Unit) {
switch (unit.kind) {
case Unit.Kind.Atomic: return unit.model.atomicConformation
case Unit.Kind.Spheres: return unit.model.coarseConformation.spheres
case Unit.Kind.Gaussians: return unit.model.coarseConformation.gaussians
}
}
function getUnitConformationAndRadius(unit: Unit) {
const conformation = getConformation(unit)
const { elements } = unit
const position = {
indices: elements,
x: conformation.x,
y: conformation.y,
z: conformation.z
}
const l = StructureElement.create(unit)
const sizeTheme = PhysicalSizeTheme({}, {})
const radius = (index: number) => {
l.element = index as ElementIndex
return sizeTheme.size(l)
}
return { position, radius }
}
export function computeUnitGaussianDensity(unit: Unit, props: GaussianDensityProps, webgl?: WebGLContext) {
const { position, radius } = getUnitConformationAndRadius(unit)
return Task.create('Gaussian Density', async ctx => {
......@@ -84,40 +55,6 @@ export function computeUnitGaussianDensityTexture2d(unit: Unit, props: GaussianD
//
function getStructureConformationAndRadius(structure: Structure) {
const n = structure.elementCount
const xs = new Float32Array(n)
const ys = new Float32Array(n)
const zs = new Float32Array(n)
const rs = new Float32Array(n)
const l = StructureElement.create()
const sizeTheme = PhysicalSizeTheme({}, {})
let m = 0
for (let i = 0, il = structure.units.length; i < il; ++i) {
const unit = structure.units[i]
const { elements } = unit
const { x, y, z } = unit.conformation
l.unit = unit
for (let j = 0, jl = elements.length; j < jl; ++j) {
const eI = elements[j]
xs[m + j] = x(eI)
ys[m + j] = y(eI)
zs[m + j] = z(eI)
l.element = eI
rs[m + j] = sizeTheme.size(l)
}
m += elements.length
}
const position = { indices: OrderedSet.ofRange(0, n), x: xs, y: ys, z: zs }
const radius = (index: number) => rs[index]
return { position, radius }
}
export function computeStructureGaussianDensity(structure: Structure, props: GaussianDensityProps, webgl?: WebGLContext) {
const { position, radius } = getStructureConformationAndRadius(structure)
return Task.create('Gaussian Density', async ctx => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment