diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts index abd3a7a5959269a8bd6d98fef96eb57f3efd7a4a..6bb1c356612015e4fda9b0a3ff7047f8eabd738b 100644 --- a/src/mol-model/structure/model/formats/mmcif.ts +++ b/src/mol-model/structure/model/formats/mmcif.ts @@ -135,7 +135,7 @@ function isHierarchyDataEqual(a: AtomicData, b: AtomicData) { && Table.areEqual(a.atoms as Table<AtomsSchema>, b.atoms as Table<AtomsSchema>) } -function modResMap(format: mmCIF_Format) { +function getModifiedResidueNameMap(format: mmCIF_Format) { const data = format.data.pdbx_struct_mod_residue; const map = new Map<string, string>(); const comp_id = data.label_comp_id.isDefined ? data.label_comp_id : data.auth_comp_id; @@ -148,6 +148,24 @@ function modResMap(format: mmCIF_Format) { return map; } +function getAsymIdSerialMap(format: mmCIF_Format) { + const data = format.data.struct_asym; + const map = new Map<string, number>(); + let serial = 0 + + const id = data.id + const count = data._rowCount + for (let i = 0; i < count; ++i) { + const _id = id.value(i) + if (!map.has(_id)) { + map.set(_id, serial) + serial += 1 + } + } + + return map; +} + function createModel(format: mmCIF_Format, atom_site: AtomSite, previous?: Model): Model { const hierarchyOffsets = findHierarchyOffsets(atom_site); const hierarchyData = createHierarchyData(atom_site, hierarchyOffsets); @@ -176,7 +194,8 @@ function createModel(format: mmCIF_Format, atom_site: AtomSite, previous?: Model ? format.data.entry.id.value(0) : format.data._name; - const modifiedResidueNameMap = modResMap(format); + const modifiedResidueNameMap = getModifiedResidueNameMap(format); + const asymIdSerialMap = getAsymIdSerialMap(format) return { id: UUID.create(), @@ -191,7 +210,8 @@ function createModel(format: mmCIF_Format, atom_site: AtomSite, previous?: Model coarseConformation: coarse.conformation, properties: { secondaryStructure: getSecondaryStructureMmCif(format.data, atomicHierarchy), - modifiedResidueNameMap + modifiedResidueNameMap, + asymIdSerialMap }, symmetry: getSymmetry(format) }; diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 6ade4fe45b03ca1b3642693475aadf7603e2b4e4..48a16e1339dc261cb8597046e7e75fd770d521bc 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -13,7 +13,7 @@ import { CoarseHierarchy, CoarseConformation } from './properties/coarse' import { Entities } from './properties/common'; import { SecondaryStructure } from './properties/seconday-structure'; -//import from_gro from './formats/gro' +// import from_gro from './formats/gro' import from_mmCIF from './formats/mmcif' /** * Interface to the "source data" of the molecule. @@ -40,6 +40,7 @@ interface Model extends Readonly<{ readonly secondaryStructure: SecondaryStructure, // maps modified residue name to its parent readonly modifiedResidueNameMap: Map<string, string>, + readonly asymIdSerialMap: Map<string, number>, [customName: string]: any }, @@ -54,7 +55,7 @@ interface Model extends Readonly<{ namespace Model { export function create(format: Format) { switch (format.kind) { - //case 'gro': return from_gro(format); + // case 'gro': return from_gro(format); case 'mmCIF': return from_mmCIF(format); } }