Просмотр исходного кода

Add optional CifFile to MmcifFormat.data (#912)

* Add optional CifFile to MmcifFormat.data

* fix
David Sehnal 1 год назад
Родитель
Сommit
6333c8073f

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Do not call `updateFocusRepr` if default `StructureFocusRepresentation` isn't present.
 - Treat "tap" as a click in `InputObserver`
+- Add optional `file?: CifFile` to `MmcifFormat.data`
 
 ## [v3.39.0] - 2023-09-02
 

+ 6 - 5
src/mol-model-formats/structure/mmcif.ts

@@ -9,7 +9,7 @@
 import { Model } from '../../mol-model/structure/model/model';
 import { RuntimeContext, Task } from '../../mol-task';
 import { ModelFormat } from '../format';
-import { CifFrame, CIF } from '../../mol-io/reader/cif';
+import { CifFrame, CIF, CifFile } from '../../mol-io/reader/cif';
 import { mmCIF_Database } from '../../mol-io/reader/cif/schema/mmcif';
 import { createModels } from './basic/parser';
 import { ModelSymmetry } from './property/symmetry';
@@ -88,6 +88,7 @@ namespace MmcifFormat {
     export type Data = {
         db: mmCIF_Database,
         frame: CifFrame,
+        file?: CifFile,
         /**
          * Original source format. Some formats, including PDB, are converted
          * to mmCIF before further processing.
@@ -98,14 +99,14 @@ namespace MmcifFormat {
         return x?.kind === 'mmCIF';
     }
 
-    export function fromFrame(frame: CifFrame, db?: mmCIF_Database, source?: ModelFormat): MmcifFormat {
+    export function fromFrame(frame: CifFrame, db?: mmCIF_Database, source?: ModelFormat, file?: CifFile): MmcifFormat {
         if (!db) db = CIF.schema.mmCIF(frame);
-        return { kind: 'mmCIF', name: db._name, data: { db, frame, source } };
+        return { kind: 'mmCIF', name: db._name, data: { db, file, frame, source } };
     }
 }
 
-export function trajectoryFromMmCIF(frame: CifFrame): Task<Trajectory> {
-    const format = MmcifFormat.fromFrame(frame);
+export function trajectoryFromMmCIF(frame: CifFrame, file?: CifFile): Task<Trajectory> {
+    const format = MmcifFormat.fromFrame(frame, undefined, undefined, file);
     const basic = createBasic(format.data.db, true);
     return Task.create('Create mmCIF Model', ctx => createModels(basic, format, ctx));
 }

+ 1 - 1
src/mol-plugin-state/transforms/model.ts

@@ -304,7 +304,7 @@ const TrajectoryFromMmCif = PluginStateTransform.BuiltIn({
                 const block = a.data.blocks.find(b => b.header === header);
                 if (!block) throw new Error(`Data block '${[header]}' not found.`);
                 const isCcd = block.categoryNames.includes('chem_comp_atom') && !block.categoryNames.includes('atom_site') && !block.categoryNames.includes('ihm_sphere_obj_site') && !block.categoryNames.includes('ihm_gaussian_obj_site');
-                trajectory = isCcd ? await trajectoryFromCCD(block).runInContext(ctx) : await trajectoryFromMmCIF(block).runInContext(ctx);
+                trajectory = isCcd ? await trajectoryFromCCD(block).runInContext(ctx) : await trajectoryFromMmCIF(block, a.data).runInContext(ctx);
             }
             if (trajectory.frameCount === 0) throw new Error('No models found.');
             const props = trajectoryProps(trajectory);