interactions.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { Structure } from '../../mol-model/structure';
  7. import { ParamDefinition as PD } from '../../mol-util/param-definition';
  8. import { computeInteractions, Interactions, InteractionsParams as _InteractionsParams } from './interactions/interactions';
  9. import { CustomStructureProperty } from '../common/custom-structure-property';
  10. import { CustomProperty } from '../common/custom-property';
  11. import { CustomPropertyDescriptor } from '../../mol-model/custom-property';
  12. export const InteractionsParams = {
  13. ..._InteractionsParams
  14. };
  15. export type InteractionsParams = typeof InteractionsParams
  16. export type InteractionsProps = PD.Values<InteractionsParams>
  17. export type InteractionsValue = Interactions
  18. export const InteractionsProvider: CustomStructureProperty.Provider<InteractionsParams, InteractionsValue> = CustomStructureProperty.createProvider({
  19. label: 'Interactions',
  20. descriptor: CustomPropertyDescriptor({
  21. name: 'molstar_computed_interactions',
  22. // TODO `cifExport` and `symbol`
  23. }),
  24. type: 'local',
  25. defaultParams: InteractionsParams,
  26. getParams: (data: Structure) => InteractionsParams,
  27. isApplicable: (data: Structure) => true,
  28. obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<InteractionsProps>) => {
  29. const p = { ...PD.getDefaultValues(InteractionsParams), ...props };
  30. return { value: await computeInteractions(ctx, data, p) };
  31. }
  32. });