Browse Source

ihm model label improvements

Alexander Rose 6 years ago
parent
commit
215f7d0acd

+ 1 - 0
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>,

+ 10 - 3
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,

+ 6 - 2
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,

+ 3 - 4
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 });
     }
 });