schema.ts 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { mmCIF_Schema } from '../../../mol-io/reader/cif/schema/mmcif';
  7. import { Table } from '../../../mol-data/db';
  8. import { mmCIF_chemComp_schema } from '../../../mol-io/reader/cif/schema/mmcif-extras';
  9. import { getNormalizedAtomSite } from './util';
  10. // TODO split into conformation and hierarchy parts
  11. export type Entry = Table<mmCIF_Schema['entry']>
  12. export type Struct = Table<mmCIF_Schema['struct']>
  13. export type StructAsym = Table<mmCIF_Schema['struct_asym']>
  14. export type IhmModelList = Table<mmCIF_Schema['ihm_model_list']>
  15. export type IhmModelGroup = Table<mmCIF_Schema['ihm_model_group']>
  16. export type IhmModelGroupLink = Table<mmCIF_Schema['ihm_model_group_link']>
  17. export type Entity = Table<mmCIF_Schema['entity']>
  18. export type EntityPoly = Table<mmCIF_Schema['entity_poly']>
  19. export type EntityPolySeq = Table<mmCIF_Schema['entity_poly_seq']>
  20. export type EntityBranch = Table<mmCIF_Schema['pdbx_entity_branch']>
  21. export type ChemComp = Table<mmCIF_chemComp_schema>
  22. export type ChemCompIdentifier = Table<mmCIF_Schema['pdbx_chem_comp_identifier']>
  23. export type AtomSite = Table<mmCIF_Schema['atom_site']>
  24. export type IhmSphereObjSite = Table<mmCIF_Schema['ihm_sphere_obj_site']>
  25. export type IhmGaussianObjSite = Table<mmCIF_Schema['ihm_gaussian_obj_site']>
  26. export type UnobsOrZeroOccResidues = Table<mmCIF_Schema['pdbx_unobs_or_zero_occ_residues']>
  27. export type Molecule = Table<mmCIF_Schema['pdbx_molecule']>
  28. export const BasicSchema = {
  29. entry: mmCIF_Schema.entry,
  30. struct: mmCIF_Schema.struct,
  31. struct_asym: mmCIF_Schema.struct_asym,
  32. ihm_model_list: mmCIF_Schema.ihm_model_list,
  33. ihm_model_group: mmCIF_Schema.ihm_model_group,
  34. ihm_model_group_link: mmCIF_Schema.ihm_model_group_link,
  35. entity: mmCIF_Schema.entity,
  36. entity_poly: mmCIF_Schema.entity_poly,
  37. entity_poly_seq: mmCIF_Schema.entity_poly_seq,
  38. pdbx_entity_branch: mmCIF_Schema.pdbx_entity_branch,
  39. chem_comp: mmCIF_chemComp_schema,
  40. pdbx_chem_comp_identifier: mmCIF_Schema.pdbx_chem_comp_identifier,
  41. atom_site: mmCIF_Schema.atom_site,
  42. ihm_sphere_obj_site: mmCIF_Schema.ihm_sphere_obj_site,
  43. ihm_gaussian_obj_site: mmCIF_Schema.ihm_gaussian_obj_site,
  44. pdbx_unobs_or_zero_occ_residues: mmCIF_Schema.pdbx_unobs_or_zero_occ_residues,
  45. pdbx_molecule: mmCIF_Schema.pdbx_molecule,
  46. };
  47. export interface BasicData {
  48. entry: Entry
  49. struct: Struct
  50. struct_asym: StructAsym
  51. ihm_model_list: IhmModelList
  52. ihm_model_group: IhmModelGroup
  53. ihm_model_group_link: IhmModelGroupLink
  54. entity: Entity
  55. entity_poly: EntityPoly
  56. entity_poly_seq: EntityPolySeq
  57. pdbx_entity_branch: EntityBranch
  58. chem_comp: ChemComp
  59. pdbx_chem_comp_identifier: ChemCompIdentifier
  60. atom_site: AtomSite
  61. ihm_sphere_obj_site: IhmSphereObjSite
  62. ihm_gaussian_obj_site: IhmGaussianObjSite
  63. pdbx_unobs_or_zero_occ_residues: UnobsOrZeroOccResidues
  64. pdbx_molecule: Molecule
  65. }
  66. export function createBasic(data: Partial<BasicData>, normalize = false): BasicData {
  67. const basic = Object.create(null);
  68. for (const name of Object.keys(BasicSchema)) {
  69. if (name in data) {
  70. basic[name] = data[name as keyof typeof BasicSchema];
  71. } else {
  72. basic[name] = Table.ofUndefinedColumns(BasicSchema[name as keyof typeof BasicSchema], 0);
  73. }
  74. }
  75. if (normalize) {
  76. basic.atom_site = getNormalizedAtomSite(basic.atom_site);
  77. }
  78. return basic;
  79. }