model.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import UUID from 'mol-util/uuid'
  7. import Format from './format'
  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 } from './properties/common';
  13. import { CustomProperties } from './properties/custom';
  14. import { SecondaryStructure } from './properties/seconday-structure';
  15. // import from_gro from './formats/gro'
  16. import from_mmCIF from './formats/mmcif'
  17. /**
  18. * Interface to the "source data" of the molecule.
  19. *
  20. * "Atoms" are integers in the range [0, atomCount).
  21. */
  22. interface Model extends Readonly<{
  23. id: UUID,
  24. label: string,
  25. // for IHM, corresponds to ihm_model_list.model_id
  26. modelNum: number,
  27. sourceData: Format,
  28. symmetry: ModelSymmetry,
  29. entities: Entities,
  30. sequence: StructureSequence,
  31. atomicHierarchy: AtomicHierarchy,
  32. atomicConformation: AtomicConformation,
  33. properties: {
  34. // secondary structure provided by the input file
  35. readonly secondaryStructure: SecondaryStructure,
  36. // maps modified residue name to its parent
  37. readonly modifiedResidueNameMap: Map<string, string>,
  38. readonly asymIdSerialMap: Map<string, number>
  39. },
  40. customProperties: CustomProperties,
  41. /**
  42. * Not to be accessed directly, each custom property descriptor
  43. * defines property accessors that use this field to store the data.
  44. */
  45. _staticPropertyData: { [name: string]: any },
  46. _dynamicPropertyData: { [name: string]: any },
  47. coarseHierarchy: CoarseHierarchy,
  48. coarseConformation: CoarseConformation
  49. }> {
  50. } { }
  51. namespace Model {
  52. export function create(format: Format) {
  53. switch (format.kind) {
  54. // case 'gro': return from_gro(format);
  55. case 'mmCIF': return from_mmCIF(format);
  56. }
  57. }
  58. // TODO: figure the place to include this?
  59. // export interface Property<T, K> { (model: Model, index: number): T, _kind: K }
  60. // export interface AtomicProperty<T> extends Property<T, 'atomic'> { }
  61. // export interface CoarseProperty<T> extends Property<T, 'coarse'> { }
  62. // export interface SphereProperty<T> extends Property<T, 'sphere'> { }
  63. // export interface GaussianProperty<T> extends Property<T, 'gaussian'> { }
  64. // export function atomProp<T>(p: (model: Model, i: number) => T): AtomicProperty<T> { return p as any; }
  65. // export function residueProp<T>(p: (model: Model, residueIndex: number) => T): AtomicProperty<T> {
  66. // return p as any;
  67. // }
  68. }
  69. export default Model