diff --git a/src/mol-model/sequence/sequence.ts b/src/mol-model/sequence/sequence.ts index 9401390e5b74d3efe3887f3959c9bc74864bbbf8..f40ed77d6bb397ed4b8d8f22f7a046e1af700bfe 100644 --- a/src/mol-model/sequence/sequence.ts +++ b/src/mol-model/sequence/sequence.ts @@ -49,7 +49,7 @@ namespace Sequence { return { kind: Kind.Generic, code: (v: string) => 'X' }; } - function modCode(code: (name: string) => string, map: Map<string, string>): (name: string) => string { + function modCode(code: (name: string) => string, map: ReadonlyMap<string, string>): (name: string) => string { return n => { const ret = code(n); if (ret !== 'X' || !map.has(n)) return ret; @@ -57,7 +57,7 @@ namespace Sequence { } } - export function ofResidueNames(residueName: Column<string>, seqId: Column<number>, modifiedMap?: Map<string, string>): Sequence { + export function ofResidueNames(residueName: Column<string>, seqId: Column<number>, modifiedMap?: ReadonlyMap<string, string>): Sequence { if (seqId.rowCount === 0) throw new Error('cannot be empty'); const { kind, code } = determineKind(residueName); diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts index c18e3997b84bfd4a125d198e05f161d509c75944..43e072d461944f2a18902fd29d3af69fd09605db 100644 --- a/src/mol-model/structure/model/formats/mmcif.ts +++ b/src/mol-model/structure/model/formats/mmcif.ts @@ -23,7 +23,7 @@ import { getSecondaryStructureMmCif } from './mmcif/secondary-structure'; import { getSequence } from './mmcif/sequence'; import { sortAtomSite } from './mmcif/sort'; import { StructConn } from './mmcif/bonds/struct_conn'; -import { ChemicalComponent } from '../properties/chemical-component'; +import { ChemicalComponent, ChemicalComponentMap } from '../properties/chemical-component'; import { ComponentType, getMoleculeType } from '../types'; import mmCIF_Format = Format.mmCIF @@ -86,7 +86,7 @@ function getModifiedResidueNameMap(format: mmCIF_Format): Model['properties']['m return { parentId, details }; } -function getAsymIdSerialMap(format: mmCIF_Format) { +function getAsymIdSerialMap(format: mmCIF_Format): ReadonlyMap<string, number> { const data = format.data.struct_asym; const map = new Map<string, number>(); let serial = 0 @@ -104,7 +104,7 @@ function getAsymIdSerialMap(format: mmCIF_Format) { return map; } -function getChemicalComponentMap(format: mmCIF_Format) { +function getChemicalComponentMap(format: mmCIF_Format): ChemicalComponentMap { const map = new Map<string, ChemicalComponent>(); const { id, type, name, pdbx_synonyms, formula, formula_weight } = format.data.chem_comp for (let i = 0, il = id.rowCount; i < il; ++i) { @@ -126,8 +126,8 @@ function getChemicalComponentMap(format: mmCIF_Format) { export interface FormatData { modifiedResidues: Model['properties']['modifiedResidues'] - asymIdSerialMap: Map<string, number> - chemicalComponentMap: Map<string, ChemicalComponent> + asymIdSerialMap: Model['properties']['asymIdSerialMap'] + chemicalComponentMap: Model['properties']['chemicalComponentMap'] } function getFormatData(format: mmCIF_Format): FormatData { diff --git a/src/mol-model/structure/model/formats/mmcif/sequence.ts b/src/mol-model/structure/model/formats/mmcif/sequence.ts index a279b6122979af54ae375a8be6fd394f400b49c6..70caf352fd19e0ffa1177dc0615c90b825f72417 100644 --- a/src/mol-model/structure/model/formats/mmcif/sequence.ts +++ b/src/mol-model/structure/model/formats/mmcif/sequence.ts @@ -21,7 +21,7 @@ import { Sequence } from '../../../../sequence'; // corresponding ATOM_SITE entries should reflect this // heterogeneity. -export function getSequence(cif: mmCIF, entities: Entities, hierarchy: AtomicHierarchy, modResMap: Map<string, string>): StructureSequence { +export function getSequence(cif: mmCIF, entities: Entities, hierarchy: AtomicHierarchy, modResMap: ReadonlyMap<string, string>): StructureSequence { if (!cif.entity_poly_seq._rowCount) return StructureSequence.fromAtomicHierarchy(entities, hierarchy, modResMap); const { entity_id, num, mon_id } = cif.entity_poly_seq; diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 03c962fde8304a20953a3d7906173f45d4d32de8..bd9810c1966185c2e19d42d0c80e4ddc7e5c94cb 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -15,7 +15,7 @@ import { CustomProperties } from './properties/custom'; import { SecondaryStructure } from './properties/seconday-structure'; import from_mmCIF from './formats/mmcif' -import { ChemicalComponent } from './properties/chemical-component'; +import { ChemicalComponentMap } from './properties/chemical-component'; /** * Interface to the "source data" of the molecule. @@ -42,14 +42,14 @@ export interface Model extends Readonly<{ /** secondary structure provided by the input file */ readonly secondaryStructure: SecondaryStructure, /** maps modified residue name to its parent */ - readonly modifiedResidues: { - parentId: Map<string, string>, - details: Map<string, string> - }, + readonly modifiedResidues: Readonly<{ + parentId: ReadonlyMap<string, string>, + details: ReadonlyMap<string, string> + }>, /** maps asym id to unique serial number */ - readonly asymIdSerialMap: Map<string, number> + readonly asymIdSerialMap: ReadonlyMap<string, number> /** maps residue name to `ChemicalComponent` data */ - readonly chemicalComponentMap: Map<string, ChemicalComponent> + readonly chemicalComponentMap: ChemicalComponentMap }, customProperties: CustomProperties, diff --git a/src/mol-model/structure/model/properties/chemical-component.ts b/src/mol-model/structure/model/properties/chemical-component.ts index beac7f107ba10197eebd5034eff6d994a37cc57a..35d34e571790872c8e1a110bc125705d7a4b49c4 100644 --- a/src/mol-model/structure/model/properties/chemical-component.ts +++ b/src/mol-model/structure/model/properties/chemical-component.ts @@ -15,3 +15,5 @@ export interface ChemicalComponent { formula: string formulaWeight: number } + +export type ChemicalComponentMap = ReadonlyMap<string, ChemicalComponent> \ No newline at end of file diff --git a/src/mol-model/structure/model/properties/sequence.ts b/src/mol-model/structure/model/properties/sequence.ts index b29ead3f5620b27bc5b4ca9182ee319ae74b8a18..441ffb4318a1ee32dbce8141ab8ae510da07a2da 100644 --- a/src/mol-model/structure/model/properties/sequence.ts +++ b/src/mol-model/structure/model/properties/sequence.ts @@ -24,7 +24,7 @@ namespace StructureSequence { readonly sequence: Sequence } - export function fromAtomicHierarchy(entities: Entities, hierarchy: AtomicHierarchy, modResMap?: Map<string, string>): StructureSequence { + export function fromAtomicHierarchy(entities: Entities, hierarchy: AtomicHierarchy, modResMap?: ReadonlyMap<string, string>): StructureSequence { const { label_comp_id, label_seq_id } = hierarchy.residues const { chainAtomSegments, residueAtomSegments } = hierarchy