diff --git a/src/extensions/membrane-orientation/representation.ts b/src/extensions/membrane-orientation/representation.ts index aaad82ebc3b25c1c762af236cd7fc09b3d04cce3..b5a571ba2c5a154815a93d4748ff52da6723150a 100644 --- a/src/extensions/membrane-orientation/representation.ts +++ b/src/extensions/membrane-orientation/representation.ts @@ -22,8 +22,9 @@ import { RuntimeContext } from '../../mol-task'; const MembraneOrientationParams = { ...Spheres.Params, - color: PD.Color(ColorNames.orange), - density: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) + color: PD.Color(ColorNames.lightgrey), + size: PD.Numeric(1, { min: 0.1, max: 10, step: 0.1 }, { description: 'Size of spheres that represent membrane planes' }), + density: PD.Numeric(1, { min: 0.25, max: 10, step: 0.25 }, { description: 'Distance between spheres'}) }; export type MembraneOrientationParams = typeof MembraneOrientationParams export type MembraneOrientationProps = PD.Values<MembraneOrientationParams> @@ -61,9 +62,7 @@ function getMembraneSpheres(ctx: RuntimeContext, data: Structure, props: Membran const spheresBuilder = SpheresBuilder.create(); createMembraneLayer(spheresBuilder, p1, normal, density, radius); createMembraneLayer(spheresBuilder, p2, normal, density, radius); - const getLabel = () => '?'; // TODO - - return Shape.create(name, data, spheresBuilder.getSpheres(), () => props.color, () => 1, getLabel); + return Shape.create(name, data, spheresBuilder.getSpheres(), () => props.color, () => props.size, () => 'Membrane Boundaries'); } function createMembraneLayer(spheresBuilder: SpheresBuilder, point: Vec3, normalVector: Vec3, density: number, radius: number) { diff --git a/src/mol-model-props/computed/membrane-orientation.ts b/src/mol-model-props/computed/membrane-orientation.ts index 549635f26a4b97eb281393ca5d1749ecaab1b957..8cdf29bd03f5b220a6ebd5c51277ee023ef09d7c 100644 --- a/src/mol-model-props/computed/membrane-orientation.ts +++ b/src/mol-model-props/computed/membrane-orientation.ts @@ -13,15 +13,14 @@ import { CustomPropertyDescriptor } from '../../mol-model/custom-property'; import { ANVILParams, ANVILProps, computeANVIL } from './membrane-orientation/ANVIL'; import { AccessibleSurfaceAreaProvider } from './accessible-surface-area'; import { MembraneOrientation } from '../../mol-model/structure/model/properties/membrane-orientation'; -import { computeOPM } from './membrane-orientation/OPM'; function getMembraneOrientationParams(data?: Structure) { - let defaultType = 'anvil' as 'anvil' | 'opm'; // TODO flip - OPM (or some other db-source) should be default if PDB identifier is known + let defaultType = 'anvil' as 'anvil' | 'db'; // TODO flip - OPM (or some other db-source) should be default if PDB identifier is known return { type: PD.MappedStatic(defaultType, { - 'opm': PD.EmptyGroup({ label: 'OPM' }), + 'db': PD.EmptyGroup({ label: 'DB' }), 'anvil': PD.Group(ANVILParams, { label: 'ANVIL' }) - }, { options: [['opm', 'OPM'], ['anvil', 'ANVIL']] }) + }, { options: [['db', 'DB'], ['anvil', 'ANVIL']] }) }; } @@ -43,17 +42,13 @@ export const MembraneOrientationProvider: CustomStructureProperty.Provider<Membr const p = { ...PD.getDefaultValues(MembraneOrientationParams), ...props }; switch (p.type.name) { case 'anvil': return { value: await computeAnvil(ctx, data, p.type.params) }; - case 'opm': return { value: await computeOpm(ctx, data) }; + case 'db': throw Error('TODO impl'); } } }); -async function computeAnvil(ctx: CustomProperty.Context, data: Structure, props: ANVILProps): Promise<MembraneOrientation> { +async function computeAnvil(ctx: CustomProperty.Context, data: Structure, props: Partial<ANVILProps>): Promise<MembraneOrientation> { await AccessibleSurfaceAreaProvider.attach(ctx, data); - const p = { ...PD.getDefaultValues(MembraneOrientationParams), ...props }; + const p = { ...PD.getDefaultValues(ANVILParams), ...props }; return await computeANVIL(data, p).runInContext(ctx.runtime); -} - -async function computeOpm(ctx: CustomProperty.Context, data: Structure): Promise<MembraneOrientation> { - return await computeOPM(data).runInContext(ctx.runtime); } \ No newline at end of file diff --git a/src/mol-model-props/computed/membrane-orientation/ANVIL.ts b/src/mol-model-props/computed/membrane-orientation/ANVIL.ts index 500a345ef969e5d7cdc2734d97b9d40a7be98109..57159a4c62e62cb6205b4eac1597ff0a9e91454c 100644 --- a/src/mol-model-props/computed/membrane-orientation/ANVIL.ts +++ b/src/mol-model-props/computed/membrane-orientation/ANVIL.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> * @author Alexander Rose <alexander.rose@weirdbyte.de> @@ -35,23 +35,22 @@ export type ANVILProps = PD.Values<ANVILParams> * Protein Engineering, Design & Selection, 2015, 1–5 * doi: 10.1093/protein/gzv063 */ -export function computeANVIL(structure: Structure, props: Partial<ANVILProps> = {}) { - const p = { ...PD.getDefaultValues(ANVILParams), ...props }; +export function computeANVIL(structure: Structure, props: ANVILProps) { return Task.create('Compute Membrane Topology', async runtime => { - return await calculate(runtime, structure, p); + return await calculate(runtime, structure, props); }); } const l = StructureElement.Location.create(void 0); const centroidHelper = new CentroidHelper(); -function initialize(structure: Structure, params: ANVILProps): ANVILContext { +function initialize(structure: Structure, props: ANVILProps): ANVILContext { const { label_atom_id, x, y, z } = StructureProperties.atom; const elementCount = structure.polymerResidueCount; centroidHelper.reset(); l.structure = structure; let offsets = new Int32Array(elementCount); - let exposed: boolean[] = new Array<boolean>(elementCount); + let exposed = new Array<boolean>(elementCount); const accessibleSurfaceArea = structure && AccessibleSurfaceAreaProvider.get(structure); const asa = accessibleSurfaceArea.value!; @@ -83,7 +82,7 @@ function initialize(structure: Structure, params: ANVILProps): ANVILContext { // keep track of offsets and exposed state to reuse offsets[m] = l.element; - exposed[m] = AccessibleSurfaceArea.getValue(l, asa) > params.afilter; + exposed[m] = AccessibleSurfaceArea.getValue(l, asa) > props.afilter; m++; } @@ -104,13 +103,8 @@ function initialize(structure: Structure, params: ANVILProps): ANVILContext { const extent = 1.2 * Math.sqrt(centroidHelper.radiusSq); return { + ...props, structure: structure, - numberOfSpherePoints: params.numberOfSpherePoints, - stepSize: params.stepSize, - minThickness: params.maxThickness, - maxThickness: params.minThickness, - afilter: params.afilter, - membranePointDensity: params.membranePointDensity, offsets: offsets, exposed: exposed, @@ -139,8 +133,7 @@ interface MembraneCandidate { stats: HphobHphil, normalVector?: Vec3, spherePoint?: Vec3, - qmax?: number, - membraneAtoms?: Vec3[] + qmax?: number } namespace MembraneCandidate { @@ -161,14 +154,13 @@ namespace MembraneCandidate { stats: stats, normalVector: diam_vect, spherePoint: spherePoint, - qmax: qmax, - membraneAtoms: [] + qmax: qmax }; } } function findMembrane(ctx: ANVILContext, spherePoints: Vec3[], initialStats: HphobHphil, label_comp_id: StructureElement.Property<string>): MembraneCandidate { - const { centroid, stepSize, minThickness, maxThickness } = ctx; + const { centroid, stepSize, maxThickness } = ctx; // best performing membrane let membrane: MembraneCandidate; // score of the best performing membrane @@ -194,7 +186,7 @@ function findMembrane(ctx: ANVILContext, spherePoints: Vec3[], initialStats: Hph qvartemp.push(MembraneCandidate.initial(c1, c2, stats)); } - let jmax = (minThickness / stepSize) - 1; + let jmax = (maxThickness / stepSize) - 1; // TODO should be minThickness but causes weird results if actually in place for (let width = 0, widthl = maxThickness; width < widthl;) { const imax = qvartemp.length - 1 - jmax; diff --git a/src/mol-model-props/computed/membrane-orientation/OPM.ts b/src/mol-model-props/computed/membrane-orientation/OPM.ts deleted file mode 100644 index 17e2adbb8d32b911f7d1a6ed7aab1cc025fc794a..0000000000000000000000000000000000000000 --- a/src/mol-model-props/computed/membrane-orientation/OPM.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> - */ -import { Structure } from '../../../mol-model/structure/structure'; -import { Task, RuntimeContext } from '../../../mol-task'; -import { MembraneOrientation } from '../../../mol-model/structure/model/properties/membrane-orientation'; - -export function computeOPM(structure: Structure) { - return Task.create('Parse Membrane Topology', async runtime => { - return await calculate(runtime, structure); - }); -} - -export async function calculate(runtime: RuntimeContext, structure: Structure): Promise<MembraneOrientation> { - throw Error('impl me'); -} \ No newline at end of file diff --git a/src/mol-model-props/computed/membrane-orientation/anvil/common.ts b/src/mol-model-props/computed/membrane-orientation/anvil/common.ts index 18a25a7fc5f8c5da3bb2267a88c2bc18181d81f1..743c46a4680d2ad58f71246cf0e00cb1422115d3 100644 --- a/src/mol-model-props/computed/membrane-orientation/anvil/common.ts +++ b/src/mol-model-props/computed/membrane-orientation/anvil/common.ts @@ -9,6 +9,7 @@ import { Vec3 } from '../../../../mol-math/linear-algebra'; export interface ANVILContext { structure: Structure, + numberOfSpherePoints: number, stepSize: number, minThickness: number, diff --git a/src/tests/browser/render-structure.ts b/src/tests/browser/render-structure.ts index 875813461d836f4c57837f4a4f05111df5ff46e5..42dfaf9c731cd8e577d0f4fcedd061980a098d02 100644 --- a/src/tests/browser/render-structure.ts +++ b/src/tests/browser/render-structure.ts @@ -208,7 +208,7 @@ async function init() { size: reprCtx.sizeThemeRegistry.create('physical', { structure }) }); console.time('membrane orientation'); - await membraneOrientationRepr.createOrUpdate({}, structure).run(); + await membraneOrientationRepr.createOrUpdate({ ...MembraneOrientationRepresentationProvider.defaultValues, quality: 'auto' }, structure).run(); console.timeEnd('membrane orientation'); }