Forráskód Böngészése

more generic options

JonStargaryen 4 éve
szülő
commit
219d4f4d33

+ 4 - 5
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) {

+ 6 - 11
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);
 }

+ 11 - 19
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;

+ 0 - 18
src/mol-model-props/computed/membrane-orientation/OPM.ts

@@ -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');
-}

+ 1 - 0
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,

+ 1 - 1
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');
     }