hierarchy.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 { Column, Table } from 'mol-data/db'
  7. import { Segmentation } from 'mol-data/int'
  8. import { mmCIF_Schema as mmCIF } from 'mol-io/reader/cif/schema/mmcif'
  9. import { ElementSymbol } from '../../types'
  10. import { Element } from '../../../structure'
  11. export const AtomsSchema = {
  12. type_symbol: Column.Schema.Aliased<ElementSymbol>(mmCIF.atom_site.type_symbol),
  13. label_atom_id: mmCIF.atom_site.label_atom_id,
  14. auth_atom_id: mmCIF.atom_site.auth_atom_id,
  15. label_alt_id: mmCIF.atom_site.label_alt_id,
  16. pdbx_formal_charge: mmCIF.atom_site.pdbx_formal_charge
  17. // id, occupancy and B_iso_or_equiv are part of conformation
  18. };
  19. export type AtomsSchema = typeof AtomsSchema
  20. export interface Atoms extends Table<AtomsSchema> { }
  21. export const ResiduesSchema = {
  22. group_PDB: mmCIF.atom_site.group_PDB,
  23. label_comp_id: mmCIF.atom_site.label_comp_id,
  24. auth_comp_id: mmCIF.atom_site.auth_comp_id,
  25. label_seq_id: mmCIF.atom_site.label_seq_id,
  26. auth_seq_id: mmCIF.atom_site.auth_seq_id,
  27. pdbx_PDB_ins_code: mmCIF.atom_site.pdbx_PDB_ins_code
  28. };
  29. export type ResiduesSchema = typeof ResiduesSchema
  30. export interface Residues extends Table<ResiduesSchema> { }
  31. export const ChainsSchema = {
  32. label_asym_id: mmCIF.atom_site.label_asym_id,
  33. auth_asym_id: mmCIF.atom_site.auth_asym_id,
  34. label_entity_id: mmCIF.atom_site.label_entity_id
  35. }
  36. export type ChainsSchema = typeof ChainsSchema
  37. export interface Chains extends Table<ChainsSchema> { }
  38. export interface AtomicData {
  39. atoms: Atoms,
  40. residues: Residues,
  41. chains: Chains
  42. }
  43. export interface AtomicSegments {
  44. /** Maps residueIndex to a range of atoms [segments[rI], segments[rI + 1]) */
  45. residueSegments: Segmentation<Element>,
  46. /** Maps chainIndex to a range of atoms [segments[cI], segments[cI + 1]) */
  47. chainSegments: Segmentation<Element>,
  48. /**
  49. * bonded/connected stretches of polymer chains, i.e. a chain will be
  50. * broken into multiple polymer segments if there are missing residues
  51. */
  52. polymerSegments: Segmentation<Element>
  53. // TODO: include entity segments?
  54. }
  55. export interface AtomicKeys {
  56. // TODO: since Atoms must be sorted now, get rid of keys
  57. // TODO: include (lazily computed) "entity/chain/residue" indices?
  58. // assign a key to each residue index.
  59. residueKey: ArrayLike<number>,
  60. // assign a key to each chain index
  61. chainKey: ArrayLike<number>,
  62. // assigne a key to each chain index
  63. // also index to the Entities table.
  64. entityKey: ArrayLike<number>,
  65. findChainKey(entityId: string, label_asym_id: string): number,
  66. /** Unique number for each of the residue. Also the index of the 1st occurence of this residue. */
  67. findResidueKey(entityId: string, label_asym_id: string, label_comp_id: string, auth_seq_id: number, pdbx_PDB_ins_code: string): number
  68. }
  69. type _Hierarchy = AtomicData & AtomicSegments & AtomicKeys
  70. export interface AtomicHierarchy extends _Hierarchy { }