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';
import { CustomStructureProperty } from '../common/custom-structure-property';
import { CustomProperty } from '../common/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';
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
return {
type: PD.MappedStatic(defaultType, {
......@@ -23,22 +23,22 @@ function getMembraneParams(data?: Structure) {
};
}
export const MembraneParams = getMembraneParams();
export type MembraneParams = typeof MembraneParams
export type MembraneProps = PD.Values<MembraneParams>
export const MembraneOrientationParams = getMembraneOrientationParams();
export type MembraneOrientationParams = typeof MembraneOrientationParams
export type MembraneOrientationProps = PD.Values<MembraneOrientationParams>
export const MembraneProvider: CustomStructureProperty.Provider<MembraneParams, Membrane> = CustomStructureProperty.createProvider({
label: 'Predicted Membrane',
export const MembraneOrientationProvider: CustomStructureProperty.Provider<MembraneOrientationParams, MembraneOrientation> = CustomStructureProperty.createProvider({
label: 'Membrane Orientation',
descriptor: CustomPropertyDescriptor({
name: 'molstar_membrane',
name: 'molstar_computed_membrane_orientation',
// TODO `cifExport`
}),
type: 'root',
defaultParams: MembraneParams,
getParams: (data: Structure) => MembraneParams,
defaultParams: MembraneOrientationParams,
getParams: (data: Structure) => MembraneOrientationParams,
isApplicable: (data: Structure) => true,
obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneProps>) => {
const p = { ...PD.getDefaultValues(MembraneParams), ...props };
obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneOrientationProps>) => {
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(data) };
......@@ -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);
const p = { ...PD.getDefaultValues(MembraneParams), ...props };
return await Membrane.compute(data, p).runInContext(ctx.runtime);
const p = { ...PD.getDefaultValues(MembraneOrientationParams), ...props };
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');
}
\ No newline at end of file
......@@ -27,10 +27,10 @@ export const ANVILParams = {
export type ANVILParams = typeof ANVILParams
export type ANVILProps = PD.Values<ANVILParams>
export { Membrane };
interface Membrane extends Array<Vec3> {}
export { MembraneOrientation };
interface MembraneOrientation extends Array<Vec3> {}
namespace Membrane {
namespace MembraneOrientation {
/**
* Implements:
* Membrane positioning for high- and low-resolution protein structures through a binary classification approach
......@@ -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 ctx = initialize(structure, params);
......
......@@ -26,12 +26,12 @@ import { InteractionsProvider } from '../../mol-model-props/computed/interaction
import { SecondaryStructureProvider } from '../../mol-model-props/computed/secondary-structure';
import { SyncRuntimeContext } from '../../mol-task/execution/synchronous';
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 { Spheres } from '../../mol-geo/geometry/spheres/spheres';
import { Color } from '../../mol-util/color';
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')!;
parent.style.width = '100%';
......@@ -122,7 +122,7 @@ function getGaussianSurfaceRepr() {
return GaussianSurfaceRepresentationProvider.factory(reprCtx, GaussianSurfaceRepresentationProvider.getParams);
}
function getMembraneRepr(membrane: Membrane) {
function getMembraneRepr(membrane: MembraneOrientation) {
// TODO is a representation provider the right place for this?
const spheresBuilder = SpheresBuilder.create(membrane.length, 1);
for (let i = 0, il = membrane.length; i < il; i++) {
......@@ -150,7 +150,7 @@ async function init() {
console.timeEnd('compute SecondaryStructure');
console.time('compute Membrane');
await MembraneProvider.attach(ctx, structure);
await MembraneOrientationProvider.attach(ctx, structure);
console.timeEnd('compute Membrane');
console.time('compute Interactions');
......@@ -172,7 +172,7 @@ async function init() {
const ballAndStickRepr = getBallAndStickRepr();
const molecularSurfaceRepr = getMolecularSurfaceRepr();
const gaussianSurfaceRepr = getGaussianSurfaceRepr();
const membraneRepr = getMembraneRepr(MembraneProvider.get(structure).value!);
const membraneRepr = getMembraneRepr(MembraneOrientationProvider.get(structure).value!);
if (show.cartoon) {
cartoonRepr.setTheme({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment