Skip to content
Snippets Groups Projects
Commit f2557fe8 authored by JonStargaryen's avatar JonStargaryen
Browse files

refactor membrane orientation

parent bf904a5b
No related branches found
No related tags found
No related merge requests found
...@@ -10,10 +10,10 @@ import { Structure } from '../../mol-model/structure'; ...@@ -10,10 +10,10 @@ import { Structure } from '../../mol-model/structure';
import { CustomStructureProperty } from '../common/custom-structure-property'; import { CustomStructureProperty } from '../common/custom-structure-property';
import { CustomProperty } from '../common/custom-property'; import { CustomProperty } from '../common/custom-property';
import { CustomPropertyDescriptor } from '../../mol-model/custom-property'; import { CustomPropertyDescriptor } from '../../mol-model/custom-property';
import { ANVILParams, Membrane, ANVILProps } from './membrane/ANVIL'; import { ANVILParams, MembraneOrientation, ANVILProps } from './membrane-orientation/ANVIL';
import { AccessibleSurfaceAreaProvider } from './accessible-surface-area'; import { AccessibleSurfaceAreaProvider } from './accessible-surface-area';
function getMembraneParams(data?: Structure) { function getMembraneOrientationParams(data?: Structure) {
let defaultType = 'anvil' as 'anvil' | 'opm'; // TODO flip - OPM should be default if PDB identifier is known let defaultType = 'anvil' as 'anvil' | 'opm'; // TODO flip - OPM should be default if PDB identifier is known
return { return {
type: PD.MappedStatic(defaultType, { type: PD.MappedStatic(defaultType, {
...@@ -23,22 +23,22 @@ function getMembraneParams(data?: Structure) { ...@@ -23,22 +23,22 @@ function getMembraneParams(data?: Structure) {
}; };
} }
export const MembraneParams = getMembraneParams(); export const MembraneOrientationParams = getMembraneOrientationParams();
export type MembraneParams = typeof MembraneParams export type MembraneOrientationParams = typeof MembraneOrientationParams
export type MembraneProps = PD.Values<MembraneParams> export type MembraneOrientationProps = PD.Values<MembraneOrientationParams>
export const MembraneProvider: CustomStructureProperty.Provider<MembraneParams, Membrane> = CustomStructureProperty.createProvider({ export const MembraneOrientationProvider: CustomStructureProperty.Provider<MembraneOrientationParams, MembraneOrientation> = CustomStructureProperty.createProvider({
label: 'Predicted Membrane', label: 'Membrane Orientation',
descriptor: CustomPropertyDescriptor({ descriptor: CustomPropertyDescriptor({
name: 'molstar_membrane', name: 'molstar_computed_membrane_orientation',
// TODO `cifExport` // TODO `cifExport`
}), }),
type: 'root', type: 'root',
defaultParams: MembraneParams, defaultParams: MembraneOrientationParams,
getParams: (data: Structure) => MembraneParams, getParams: (data: Structure) => MembraneOrientationParams,
isApplicable: (data: Structure) => true, isApplicable: (data: Structure) => true,
obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneProps>) => { obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneOrientationProps>) => {
const p = { ...PD.getDefaultValues(MembraneParams), ...props }; const p = { ...PD.getDefaultValues(MembraneOrientationParams), ...props };
switch (p.type.name) { switch (p.type.name) {
case 'anvil': return { value: await computeAnvil(ctx, data, p.type.params) }; case 'anvil': return { value: await computeAnvil(ctx, data, p.type.params) };
case 'opm': return { value: await computeOpm(data) }; case 'opm': return { value: await computeOpm(data) };
...@@ -46,12 +46,12 @@ export const MembraneProvider: CustomStructureProperty.Provider<MembraneParams, ...@@ -46,12 +46,12 @@ export const MembraneProvider: CustomStructureProperty.Provider<MembraneParams,
} }
}); });
async function computeAnvil(ctx: CustomProperty.Context, data: Structure, props: ANVILProps): Promise<Membrane> { async function computeAnvil(ctx: CustomProperty.Context, data: Structure, props: ANVILProps): Promise<MembraneOrientation> {
await AccessibleSurfaceAreaProvider.attach(ctx, data); await AccessibleSurfaceAreaProvider.attach(ctx, data);
const p = { ...PD.getDefaultValues(MembraneParams), ...props }; const p = { ...PD.getDefaultValues(MembraneOrientationParams), ...props };
return await Membrane.compute(data, p).runInContext(ctx.runtime); return await MembraneOrientation.compute(data, p).runInContext(ctx.runtime);
} }
async function computeOpm(structure: Structure): Promise<Membrane> { async function computeOpm(structure: Structure): Promise<MembraneOrientation> {
throw Error('TODO impl'); throw Error('TODO impl');
} }
\ No newline at end of file
...@@ -27,10 +27,10 @@ export const ANVILParams = { ...@@ -27,10 +27,10 @@ export const ANVILParams = {
export type ANVILParams = typeof ANVILParams export type ANVILParams = typeof ANVILParams
export type ANVILProps = PD.Values<ANVILParams> export type ANVILProps = PD.Values<ANVILParams>
export { Membrane }; export { MembraneOrientation };
interface Membrane extends Array<Vec3> {} interface MembraneOrientation extends Array<Vec3> {}
namespace Membrane { namespace MembraneOrientation {
/** /**
* Implements: * Implements:
* Membrane positioning for high- and low-resolution protein structures through a binary classification approach * Membrane positioning for high- and low-resolution protein structures through a binary classification approach
...@@ -123,7 +123,7 @@ namespace Membrane { ...@@ -123,7 +123,7 @@ namespace Membrane {
}; };
} }
export async function calculate(runtime: RuntimeContext, structure: Structure, params: ANVILProps): Promise<Membrane> { export async function calculate(runtime: RuntimeContext, structure: Structure, params: ANVILProps): Promise<MembraneOrientation> {
const { label_comp_id } = StructureProperties.residue; const { label_comp_id } = StructureProperties.residue;
const ctx = initialize(structure, params); const ctx = initialize(structure, params);
......
...@@ -26,12 +26,12 @@ import { InteractionsProvider } from '../../mol-model-props/computed/interaction ...@@ -26,12 +26,12 @@ import { InteractionsProvider } from '../../mol-model-props/computed/interaction
import { SecondaryStructureProvider } from '../../mol-model-props/computed/secondary-structure'; import { SecondaryStructureProvider } from '../../mol-model-props/computed/secondary-structure';
import { SyncRuntimeContext } from '../../mol-task/execution/synchronous'; import { SyncRuntimeContext } from '../../mol-task/execution/synchronous';
import { AssetManager } from '../../mol-util/assets'; import { AssetManager } from '../../mol-util/assets';
import { MembraneProvider } from '../../mol-model-props/computed/membrane'; import { MembraneOrientationProvider } from '../../mol-model-props/computed/membrane-orientation';
import { SpheresBuilder } from '../../mol-geo/geometry/spheres/spheres-builder'; import { SpheresBuilder } from '../../mol-geo/geometry/spheres/spheres-builder';
import { Spheres } from '../../mol-geo/geometry/spheres/spheres'; import { Spheres } from '../../mol-geo/geometry/spheres/spheres';
import { Color } from '../../mol-util/color'; import { Color } from '../../mol-util/color';
import { createRenderObject } from '../../mol-gl/render-object'; import { createRenderObject } from '../../mol-gl/render-object';
import { Membrane } from '../../mol-model-props/computed/membrane/ANVIL'; import { MembraneOrientation } from '../../mol-model-props/computed/membrane-orientation/ANVIL';
const parent = document.getElementById('app')!; const parent = document.getElementById('app')!;
parent.style.width = '100%'; parent.style.width = '100%';
...@@ -122,7 +122,7 @@ function getGaussianSurfaceRepr() { ...@@ -122,7 +122,7 @@ function getGaussianSurfaceRepr() {
return GaussianSurfaceRepresentationProvider.factory(reprCtx, GaussianSurfaceRepresentationProvider.getParams); return GaussianSurfaceRepresentationProvider.factory(reprCtx, GaussianSurfaceRepresentationProvider.getParams);
} }
function getMembraneRepr(membrane: Membrane) { function getMembraneRepr(membrane: MembraneOrientation) {
// TODO is a representation provider the right place for this? // TODO is a representation provider the right place for this?
const spheresBuilder = SpheresBuilder.create(membrane.length, 1); const spheresBuilder = SpheresBuilder.create(membrane.length, 1);
for (let i = 0, il = membrane.length; i < il; i++) { for (let i = 0, il = membrane.length; i < il; i++) {
...@@ -150,7 +150,7 @@ async function init() { ...@@ -150,7 +150,7 @@ async function init() {
console.timeEnd('compute SecondaryStructure'); console.timeEnd('compute SecondaryStructure');
console.time('compute Membrane'); console.time('compute Membrane');
await MembraneProvider.attach(ctx, structure); await MembraneOrientationProvider.attach(ctx, structure);
console.timeEnd('compute Membrane'); console.timeEnd('compute Membrane');
console.time('compute Interactions'); console.time('compute Interactions');
...@@ -172,7 +172,7 @@ async function init() { ...@@ -172,7 +172,7 @@ async function init() {
const ballAndStickRepr = getBallAndStickRepr(); const ballAndStickRepr = getBallAndStickRepr();
const molecularSurfaceRepr = getMolecularSurfaceRepr(); const molecularSurfaceRepr = getMolecularSurfaceRepr();
const gaussianSurfaceRepr = getGaussianSurfaceRepr(); const gaussianSurfaceRepr = getGaussianSurfaceRepr();
const membraneRepr = getMembraneRepr(MembraneProvider.get(structure).value!); const membraneRepr = getMembraneRepr(MembraneOrientationProvider.get(structure).value!);
if (show.cartoon) { if (show.cartoon) {
cartoonRepr.setTheme({ cartoonRepr.setTheme({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment