model.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  6. */
  7. import UUID from '../../../mol-util/uuid';
  8. import StructureSequence from './properties/sequence';
  9. import { AtomicHierarchy, AtomicConformation } from './properties/atomic';
  10. import { ModelSymmetry } from './properties/symmetry';
  11. import { CoarseHierarchy, CoarseConformation } from './properties/coarse';
  12. import { Entities, ChemicalComponentMap, MissingResidues } from './properties/common';
  13. import { CustomProperties } from '../common/custom-property';
  14. import { SecondaryStructure } from './properties/seconday-structure';
  15. import { SaccharideComponentMap } from '../structure/carbohydrates/constants';
  16. import { ModelFormat } from '../../../mol-model-formats/structure/format';
  17. import { calcModelCenter } from './util';
  18. import { Vec3 } from '../../../mol-math/linear-algebra';
  19. /**
  20. * Interface to the "source data" of the molecule.
  21. *
  22. * "Atoms" are integers in the range [0, atomCount).
  23. */
  24. export interface Model extends Readonly<{
  25. id: UUID,
  26. entryId: string,
  27. label: string,
  28. /** the name of the entry/file/collection the model is part of */
  29. entry: string,
  30. /** for IHM, corresponds to ihm_model_list.model_id */
  31. modelNum: number,
  32. sourceData: ModelFormat,
  33. symmetry: ModelSymmetry,
  34. entities: Entities,
  35. sequence: StructureSequence,
  36. atomicHierarchy: AtomicHierarchy,
  37. atomicConformation: AtomicConformation,
  38. properties: {
  39. /** secondary structure provided by the input file */
  40. readonly secondaryStructure: SecondaryStructure,
  41. /** maps modified residue name to its parent */
  42. readonly modifiedResidues: Readonly<{
  43. parentId: ReadonlyMap<string, string>,
  44. details: ReadonlyMap<string, string>
  45. }>,
  46. /** map that holds details about unobserved or zero occurrence residues */
  47. readonly missingResidues: MissingResidues,
  48. /** maps residue name to `ChemicalComponent` data */
  49. readonly chemicalComponentMap: ChemicalComponentMap
  50. /** maps residue name to `SaccharideComponent` data */
  51. readonly saccharideComponentMap: SaccharideComponentMap
  52. },
  53. customProperties: CustomProperties,
  54. /**
  55. * Not to be accessed directly, each custom property descriptor
  56. * defines property accessors that use this field to store the data.
  57. */
  58. _staticPropertyData: { [name: string]: any },
  59. _dynamicPropertyData: { [name: string]: any },
  60. coarseHierarchy: CoarseHierarchy,
  61. coarseConformation: CoarseConformation
  62. }> {
  63. } { }
  64. export namespace Model {
  65. // TODO: is this enough?
  66. export type Trajectory = ReadonlyArray<Model>
  67. const CenterProp = '__Center__'
  68. export function getCenter(model: Model): Vec3 {
  69. if (model._dynamicPropertyData[CenterProp]) return model._dynamicPropertyData[CenterProp]
  70. const center = calcModelCenter(model.atomicConformation, model.coarseConformation)
  71. model._dynamicPropertyData[CenterProp] = center
  72. return center
  73. }
  74. }