123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- /**
- * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
- /**
- * Copyright (C) 2022, Protein Bioinformatics Research Group, RCNS
- *
- * Licensed under CC BY-NC 4.0, see LICENSE file for more info.
- *
- * @author Gabor Tusnady <tusnady.gabor@ttk.hu>
- * @author Csongor Gerdan <gerdan.csongor@ttk.hu>
- */
- import { ParamDefinition as PD } from 'molstar/lib/mol-util/param-definition';
- import { Structure, StructureProperties, Unit } from 'molstar/lib/mol-model/structure';
- import { CustomPropertyDescriptor } from 'molstar/lib/mol-model/custom-property';
- import { isInMembranePlane, TMDETParams } from './algorithm';
- import { CustomStructureProperty } from 'molstar/lib/mol-model-props/common/custom-structure-property';
- import { CustomProperty } from 'molstar/lib/mol-model-props/common/custom-property';
- import { Vec3 } from 'molstar/lib/mol-math/linear-algebra';
- import { QuerySymbolRuntime } from 'molstar/lib/mol-script/runtime/query/base';
- import { CustomPropSymbol } from 'molstar/lib/mol-script/language/symbol';
- import { Type } from 'molstar/lib/mol-script/language/type';
- import { membraneOrientation } from './behavior';
- import { ChainList, PDBTMDescriptor } from './types';
- export const MembraneOrientationParams = {
- ...TMDETParams
- };
- export type MembraneOrientationParams = typeof MembraneOrientationParams
- export type MembraneOrientationProps = PD.Values<MembraneOrientationParams>
- export { MembraneOrientation };
- /**
- * Simple storage to made PDBTM descriptor available globally.
- *
- * @author Csongor Gerdan <gerdan.csongor@ttk.hu>
- */
- class DescriptorCache {
- private map: Map<string, PDBTMDescriptor>;
- constructor() {
- this.map = new Map<string, PDBTMDescriptor>();
- }
- add(descriptor: PDBTMDescriptor) {
- const key = descriptor.pdb_id.toLowerCase();
- if (!this.map.has(key)) {
- this.map.set(key, descriptor);
- }
- }
- get(key: string) {
- key = key.toLowerCase();
- return this.map.get(key);
- }
- }
- export const TmDetDescriptorCache = new DescriptorCache();
- class ChainListCache {
- private map: Map<string, ChainList>;
- constructor() {
- this.map = new Map<string, ChainList>();
- }
- set(key: string, chains: ChainList) {
- key = key.toLowerCase();
- if (!this.map.has(key)) {
- this.map.set(key, chains);
- }
- }
- get(key: string) {
- key = key.toLowerCase();
- return this.map.get(key);
- }
- }
- export const TmDetChainListCache = new ChainListCache();
- interface MembraneOrientation {
- // point in membrane boundary
- readonly planePoint1: Vec3,
- // point in opposite side of membrane boundary
- readonly planePoint2: Vec3,
- // normal vector of membrane layer
- readonly normalVector: Vec3,
- // the radius of the membrane layer
- readonly radius: number,
- readonly centroid: Vec3
- }
- namespace MembraneOrientation {
- export enum Tag {
- Representation = 'membrane-orientation-3d'
- }
- const pos = Vec3();
- export const symbols = {
- isTransmembrane: QuerySymbolRuntime.Dynamic(CustomPropSymbol('computed', 'membrane-orientation.is-transmembrane', Type.Bool),
- ctx => {
- const { unit, structure } = ctx.element;
- const { x, y, z } = StructureProperties.atom;
- if (!Unit.isAtomic(unit)) return 0;
- const membraneOrientation = MembraneOrientationProvider.get(structure).value;
- if (!membraneOrientation) return 0;
- Vec3.set(pos, x(ctx.element), y(ctx.element), z(ctx.element));
- const { normalVector, planePoint1, planePoint2 } = membraneOrientation;
- return isInMembranePlane(pos, normalVector, planePoint1, planePoint2);
- })
- };
- }
- export const MembraneOrientationProvider: CustomStructureProperty.Provider<MembraneOrientationParams, MembraneOrientation> = CustomStructureProperty.createProvider({
- label: 'TMDET Membrane Orientation Provider',
- descriptor: CustomPropertyDescriptor({
- name: 'tmdet_computed_membrane_orientation',
- symbols: MembraneOrientation.symbols,
- // TODO `cifExport`
- }),
- type: 'root',
- defaultParams: MembraneOrientationParams,
- // getParams: (data: Structure) => MembraneOrientationParams,
- getParams: function(data: Structure) {
- //DebugUtil.log('getParams:: DEBUG', MembraneOrientationParams);
- return MembraneOrientationParams;
- },
- isApplicable: (data: Structure) => true,
- obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneOrientationProps>) => {
- //DebugUtil.log('obtain:: DEBUG', data.customPropertyDescriptors);
- let result = membraneOrientation;
- //DebugUtil.log("RESULT of 'obtain:'", result);
- return { value: result };
- }
- });
|