valence-model.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 { calcValenceModel, ValenceModel, ValenceModelParams as _ValenceModelParams } from './chemistry/valence-model';
  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 ValenceModelParams = {
  13. ..._ValenceModelParams
  14. };
  15. export type ValenceModelParams = typeof ValenceModelParams
  16. export type ValenceModelProps = PD.Values<ValenceModelParams>
  17. export type ValenceModelValue = Map<number, ValenceModel>
  18. export const ValenceModelProvider: CustomStructureProperty.Provider<ValenceModelParams, ValenceModelValue> = CustomStructureProperty.createProvider({
  19. label: 'Valence Model',
  20. descriptor: CustomPropertyDescriptor({
  21. name: 'molstar_computed_valence_model',
  22. // TODO `cifExport` and `symbol`
  23. }),
  24. type: 'local',
  25. defaultParams: ValenceModelParams,
  26. getParams: (data: Structure) => ValenceModelParams,
  27. isApplicable: (data: Structure) => true,
  28. obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<ValenceModelProps>) => {
  29. const p = { ...PD.getDefaultValues(ValenceModelParams), ...props };
  30. return { value: await calcValenceModel(ctx.runtime, data, p) };
  31. }
  32. });