diff --git a/src/mol-model-formats/structure/mmcif/ihm.ts b/src/mol-model-formats/structure/mmcif/ihm.ts index 405fec8cf0fab7b019f477e41ac0dea1d61a9716..e6b86f11b6d6f8982c0495f95f4ef02a7811e560 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 4c92a0b9e5c6979b26c9b051be1218bf95406c44..eee752fd2ab941c65d818a9a7548012121ba0b37 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 303048fdde6740ec47502a9c3baee05a0d927dc7..cad6d07e895cae6c8b3a3ebcfa1e2e0433441ff9 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 a8fb3fe99d0ff52d1bf0e7579a59b5acefae08f9..a5edcfbfc80ed6a4ba604f956bf741b92e3f0246 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 }); } });