From 3cecb53bc588e7ebf8edbd8628f80de8a988cd82 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Wed, 26 Feb 2020 15:04:48 -0800 Subject: [PATCH] added model.properties.structAsymMap --- .../structure/basic/properties.ts | 37 ++++++++++++++++++- src/mol-model/structure/model/model.ts | 4 +- .../structure/model/properties/common.ts | 5 ++- src/mol-plugin/state/representation/model.ts | 13 +++---- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/mol-model-formats/structure/basic/properties.ts b/src/mol-model-formats/structure/basic/properties.ts index b61b2fc19..743c57c7f 100644 --- a/src/mol-model-formats/structure/basic/properties.ts +++ b/src/mol-model-formats/structure/basic/properties.ts @@ -6,7 +6,7 @@ */ import { Model } from '../../../mol-model/structure/model/model'; -import { ChemicalComponent, MissingResidue } from '../../../mol-model/structure/model/properties/common'; +import { ChemicalComponent, MissingResidue, StructAsym } from '../../../mol-model/structure/model/properties/common'; import { getMoleculeType, MoleculeType, getDefaultChemicalComponent } from '../../../mol-model/structure/model/types'; import { SaccharideComponentMap, SaccharideComponent, SaccharidesSnfgMap, SaccharideCompIdMap, UnknownSaccharideComponent } from '../../../mol-model/structure/structure/carbohydrates/constants'; import { memoize1 } from '../../../mol-util/memoize'; @@ -107,10 +107,43 @@ const getUniqueComponentNames = memoize1((data: BasicData) => { return uniqueNames }) + +function getStructAsymMap(data: BasicData): Model['properties']['structAsymMap'] { + const map = new Map<string, StructAsym>(); + + const { label_asym_id, auth_asym_id, label_entity_id } = data.atom_site + for (let i = 0, il = label_asym_id.rowCount; i < il; ++i) { + const id = label_asym_id.value(i) + if (!map.has(id)) { + map.set(id, { + id, + auth_id: auth_asym_id.value(i), + entity_id: label_entity_id.value(i) + }) + } + } + + if (data.struct_asym._rowCount > 0) { + const { id, entity_id } = data.struct_asym + for (let i = 0, il = id.rowCount; i < il; ++i) { + const _id = id.value(i) + if (!map.has(_id)) { + map.set(_id, { + id: _id, + auth_id: '', + entity_id: entity_id.value(i) + }) + } + } + } + return map +} + export function getProperties(data: BasicData): Model['properties'] { return { missingResidues: getMissingResidues(data), chemicalComponentMap: getChemicalComponentMap(data), - saccharideComponentMap: getSaccharideComponentMap(data) + saccharideComponentMap: getSaccharideComponentMap(data), + structAsymMap: getStructAsymMap(data) } } \ No newline at end of file diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 6f8d9fb9e..220fa825f 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -9,7 +9,7 @@ import UUID from '../../../mol-util/uuid'; import StructureSequence from './properties/sequence'; import { AtomicHierarchy, AtomicConformation, AtomicRanges } from './properties/atomic'; import { CoarseHierarchy, CoarseConformation } from './properties/coarse'; -import { Entities, ChemicalComponentMap, MissingResidues } from './properties/common'; +import { Entities, ChemicalComponentMap, MissingResidues, StructAsymMap } from './properties/common'; import { CustomProperties } from '../common/custom-property'; import { SaccharideComponentMap } from '../structure/carbohydrates/constants'; import { ModelFormat } from '../../../mol-model-formats/structure/format'; @@ -59,6 +59,8 @@ export interface Model extends Readonly<{ readonly chemicalComponentMap: ChemicalComponentMap /** maps residue name to `SaccharideComponent` data */ readonly saccharideComponentMap: SaccharideComponentMap + /** maps label_asym_id name to `StructAsym` data */ + readonly structAsymMap: StructAsymMap }, customProperties: CustomProperties, diff --git a/src/mol-model/structure/model/properties/common.ts b/src/mol-model/structure/model/properties/common.ts index 84809978a..f8ae77e6b 100644 --- a/src/mol-model/structure/model/properties/common.ts +++ b/src/mol-model/structure/model/properties/common.ts @@ -29,4 +29,7 @@ export interface MissingResidues { has(model_num: number, asym_id: string, seq_id: number): boolean get(model_num: number, asym_id: string, seq_id: number): MissingResidue | undefined readonly size: number -} \ No newline at end of file +} + +export type StructAsym = Table.Row<Pick<mmCIF_Schema['struct_asym'], 'id' | 'entity_id'> & { auth_id: Column.Schema.Str }> +export type StructAsymMap = ReadonlyMap<string, StructAsym> \ No newline at end of file diff --git a/src/mol-plugin/state/representation/model.ts b/src/mol-plugin/state/representation/model.ts index e658c3e42..fee6cbda0 100644 --- a/src/mol-plugin/state/representation/model.ts +++ b/src/mol-plugin/state/representation/model.ts @@ -15,7 +15,6 @@ import { PluginContext } from '../../context'; import { Assembly, Symmetry } from '../../../mol-model/structure/model/properties/symmetry'; import { PluginStateObject as SO } from '../objects'; import { ModelSymmetry } from '../../../mol-model-formats/structure/property/symmetry'; -import { MmcifFormat } from '../../../mol-model-formats/structure/mmcif'; export namespace ModelStructureRepresentation { export function getParams(model?: Model, defaultValue?: 'deposited' | 'assembly' | 'symmetry' | 'symmetry-mates' | 'symmetry-assembly') { @@ -33,13 +32,11 @@ export namespace ModelStructureRepresentation { } const asymIdsOptions: [string, string][] = [] - if (model && MmcifFormat.is(model?.sourceData)) { - // TODO make generally available for models, also include auth_asym_id - const { struct_asym } = model.sourceData.data.db - for (let i = 0, il = struct_asym._rowCount; i < il; ++i) { - const id = struct_asym.id.value(i) - asymIdsOptions.push([id, id]) - } + if (model) { + model.properties.structAsymMap.forEach(v => { + const label = v.id === v.auth_id ? v.id : `${v.id} [auth ${v.auth_id}]` + asymIdsOptions.push([v.id, label]) + }) } const modes = { -- GitLab