Browse Source

ofTable CIF converter

David Sehnal 7 years ago
parent
commit
64b724ea4f
1 changed files with 12 additions and 7 deletions
  1. 12 7
      src/mol-data/structure/export/mmcif.ts

+ 12 - 7
src/mol-data/structure/export/mmcif.ts

@@ -7,7 +7,7 @@
 import { Column, Table } from 'mol-base/collections/database'
 import Iterator from 'mol-base/collections/iterator'
 import * as Encoder from 'mol-io/writer/cif/encoder'
-import { mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif'
+//import { mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif'
 import CIFEncoder from 'mol-io/writer/cif/encoder/text'
 import { Structure, Atom, AtomSet } from '../structure'
 import { Model } from '../model'
@@ -56,13 +56,18 @@ function ofSchema(schema: Table.Schema) {
     return fields;
 }
 
-type Entity = Table.Columns<typeof mmCIF_Schema.entity>
-
-const entity: Encoder.CategoryDefinition<number, Entity> = {
-    name: 'entity',
-    fields: ofSchema(mmCIF_Schema.entity)
+function ofTable<S extends Table.Schema>(name: string, table: Table<S>): Encoder.CategoryDefinition<number> {
+    return { name, fields: ofSchema(table._schema) }
 }
 
+// type Entity = Table.Columns<typeof mmCIF_Schema.entity>
+
+// const entity: Encoder.CategoryDefinition<number, Entity> = {
+//     name: 'entity',
+//     fields: ofSchema(mmCIF_Schema.entity)
+// }
+
+
 // [
 //     str('id', (i, e) => e.id.value(i)),
 //     str('type', (i, e) => e.type.value(i)),
@@ -122,7 +127,7 @@ const atom_site: Encoder.CategoryDefinition<Atom.Location> = {
 function entityProvider({ model }: Context): Encoder.CategoryInstance {
     return {
         data: model.hierarchy.entities,
-        definition: entity,
+        definition: ofTable('entity', model.hierarchy.entities), //entity,
         keys: () => Iterator.Range(0, model.hierarchy.entities._rowCount - 1),
         rowCount: model.hierarchy.entities._rowCount
     }