|
@@ -10,12 +10,20 @@ 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 } from './membrane/ANVIL';
|
|
|
+import { ANVILParams, Membrane, ANVILProps } from './membrane/ANVIL';
|
|
|
import { AccessibleSurfaceAreaProvider } from './accessible-surface-area';
|
|
|
|
|
|
-export const MembraneParams = {
|
|
|
- ...ANVILParams
|
|
|
-};
|
|
|
+function getMembraneParams(data?: Structure) {
|
|
|
+ let defaultType = 'anvil' as 'anvil' | 'opm'; // TODO flip - OPM should be default if PDB identifier is known
|
|
|
+ return {
|
|
|
+ type: PD.MappedStatic(defaultType, {
|
|
|
+ 'opm': PD.EmptyGroup({ label: 'OPM' }),
|
|
|
+ 'anvil': PD.Group(ANVILParams, { label: 'ANVIL' })
|
|
|
+ }, { options: [['opm', 'OPM'], ['anvil', 'ANVIL']] })
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+export const MembraneParams = getMembraneParams();
|
|
|
export type MembraneParams = typeof MembraneParams
|
|
|
export type MembraneProps = PD.Values<MembraneParams>
|
|
|
|
|
@@ -29,11 +37,21 @@ export const MembraneProvider: CustomStructureProperty.Provider<MembraneParams,
|
|
|
defaultParams: MembraneParams,
|
|
|
getParams: (data: Structure) => MembraneParams,
|
|
|
isApplicable: (data: Structure) => true,
|
|
|
- // TODO needs ASA to be computed (or 'resolved' before trying computing topology) - how to achieve?
|
|
|
- // TODO potentially, this could behave like secondary structure info where data can be either parsed or computed
|
|
|
obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneProps>) => {
|
|
|
- await AccessibleSurfaceAreaProvider.attach(ctx, data);
|
|
|
const p = { ...PD.getDefaultValues(MembraneParams), ...props };
|
|
|
- return { value: await Membrane.compute(data, p).runInContext(ctx.runtime) };
|
|
|
+ switch (p.type.name) {
|
|
|
+ case 'anvil': return { value: await computeAnvil(ctx, data, p.type.params) };
|
|
|
+ case 'opm': return { value: await computeOpm(data) };
|
|
|
+ }
|
|
|
}
|
|
|
-});
|
|
|
+});
|
|
|
+
|
|
|
+async function computeAnvil(ctx: CustomProperty.Context, data: Structure, props: ANVILProps): Promise<Membrane> {
|
|
|
+ await AccessibleSurfaceAreaProvider.attach(ctx, data);
|
|
|
+ const p = { ...PD.getDefaultValues(MembraneParams), ...props };
|
|
|
+ return await Membrane.compute(data, p).runInContext(ctx.runtime);
|
|
|
+}
|
|
|
+
|
|
|
+async function computeOpm(structure: Structure): Promise<Membrane> {
|
|
|
+ throw Error('TODO impl');
|
|
|
+}
|