From 215f7d0acd4e6e606e83a8c8c6f4b0901cecbe98 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Mon, 6 May 2019 14:27:00 -0700 Subject: [PATCH] ihm model label improvements --- src/mol-model-formats/structure/mmcif/ihm.ts | 1 + src/mol-model-formats/structure/mmcif/parser.ts | 13 ++++++++++--- src/mol-model/structure/model/model.ts | 8 ++++++-- src/mol-plugin/state/transforms/model.ts | 7 +++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/mol-model-formats/structure/mmcif/ihm.ts b/src/mol-model-formats/structure/mmcif/ihm.ts index 405fec8cf..e6b86f11b 100644 --- a/src/mol-model-formats/structure/mmcif/ihm.ts +++ b/src/mol-model-formats/structure/mmcif/ihm.ts @@ -19,6 +19,7 @@ import { FormatData } from './parser'; export interface IHMData { model_id: number, model_name: string, + model_group_name: string, entities: Entities, atom_site: mmCIF['atom_site'], atom_site_sourceIndex: Column<number>, diff --git a/src/mol-model-formats/structure/mmcif/parser.ts b/src/mol-model-formats/structure/mmcif/parser.ts index 4c92a0b9e..eee752fd2 100644 --- a/src/mol-model-formats/structure/mmcif/parser.ts +++ b/src/mol-model-formats/structure/mmcif/parser.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> @@ -190,6 +190,7 @@ function createStandardModel(format: mmCIF_Format, atom_site: AtomSite, sourceIn return { id: UUID.create22(), label, + entry: label, sourceData: format, modelNum: atom_site.pdbx_PDB_model_num.value(0), entities, @@ -212,10 +213,15 @@ function createStandardModel(format: mmCIF_Format, atom_site: AtomSite, sourceIn function createModelIHM(format: mmCIF_Format, data: IHMData, formatData: FormatData): Model { const atomic = getAtomicHierarchyAndConformation(data.atom_site, data.atom_site_sourceIndex, data.entities, formatData); const coarse = getIHMCoarse(data, formatData); + const entry = format.data.entry.id.valueKind(0) === Column.ValueKind.Present + ? format.data.entry.id.value(0) + : format.data._name; + const label = data.model_group_name ? `${data.model_name}: ${data.model_group_name}` : data.model_name return { id: UUID.create22(), - label: data.model_name, + label, + entry, sourceData: format, modelNum: data.model_id, entities: data.entities, @@ -339,7 +345,7 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format, formatData: Fo const models: Model[] = []; - const { model_id, model_name } = ihm_model_list; + const { model_id, model_name, model_group_name } = ihm_model_list; for (let i = 0; i < ihm_model_list._rowCount; i++) { const id = model_id.value(i); @@ -358,6 +364,7 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format, formatData: Fo const data: IHMData = { model_id: id, model_name: model_name.value(i), + model_group_name: model_group_name.value(i), entities: entities, atom_site, atom_site_sourceIndex, diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 303048fdd..cad6d07e8 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -1,7 +1,8 @@ /** - * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> + * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import UUID from 'mol-util/uuid'; @@ -25,7 +26,10 @@ export interface Model extends Readonly<{ id: UUID, label: string, - // for IHM, corresponds to ihm_model_list.model_id + /** the name of the entry/file/collection the model is part of */ + entry: string, + + /** for IHM, corresponds to ihm_model_list.model_id */ modelNum: number, sourceData: ModelFormat, diff --git a/src/mol-plugin/state/transforms/model.ts b/src/mol-plugin/state/transforms/model.ts index a8fb3fe99..a5edcfbfc 100644 --- a/src/mol-plugin/state/transforms/model.ts +++ b/src/mol-plugin/state/transforms/model.ts @@ -153,10 +153,9 @@ const ModelFromTrajectory = PluginStateTransform.BuiltIn({ apply({ a, params }) { if (params.modelIndex < 0 || params.modelIndex >= a.data.length) throw new Error(`Invalid modelIndex ${params.modelIndex}`); const model = a.data[params.modelIndex]; - const props = a.data.length === 1 - ? { label: `${model.label}` } - : { label: `${model.label}:${model.modelNum}`, description: `Model ${params.modelIndex + 1} of ${a.data.length}` }; - return new SO.Molecule.Model(model, props); + const label = a.data.length === 1 ? model.entry : `${model.entry}: ${model.modelNum}` + const description = a.data.length === 1 ? undefined : `Model ${params.modelIndex + 1} of ${a.data.length}` + return new SO.Molecule.Model(model, { label, description }); } }); -- GitLab