Skip to content
Snippets Groups Projects
Commit 64b724ea authored by David Sehnal's avatar David Sehnal
Browse files

ofTable CIF converter

parent 598e2f84
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import { Column, Table } from 'mol-base/collections/database' import { Column, Table } from 'mol-base/collections/database'
import Iterator from 'mol-base/collections/iterator' import Iterator from 'mol-base/collections/iterator'
import * as Encoder from 'mol-io/writer/cif/encoder' 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 CIFEncoder from 'mol-io/writer/cif/encoder/text'
import { Structure, Atom, AtomSet } from '../structure' import { Structure, Atom, AtomSet } from '../structure'
import { Model } from '../model' import { Model } from '../model'
...@@ -56,13 +56,18 @@ function ofSchema(schema: Table.Schema) { ...@@ -56,13 +56,18 @@ function ofSchema(schema: Table.Schema) {
return fields; return fields;
} }
type Entity = Table.Columns<typeof mmCIF_Schema.entity> function ofTable<S extends Table.Schema>(name: string, table: Table<S>): Encoder.CategoryDefinition<number> {
return { name, fields: ofSchema(table._schema) }
const entity: Encoder.CategoryDefinition<number, Entity> = {
name: 'entity',
fields: ofSchema(mmCIF_Schema.entity)
} }
// 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('id', (i, e) => e.id.value(i)),
// str('type', (i, e) => e.type.value(i)), // str('type', (i, e) => e.type.value(i)),
...@@ -122,7 +127,7 @@ const atom_site: Encoder.CategoryDefinition<Atom.Location> = { ...@@ -122,7 +127,7 @@ const atom_site: Encoder.CategoryDefinition<Atom.Location> = {
function entityProvider({ model }: Context): Encoder.CategoryInstance { function entityProvider({ model }: Context): Encoder.CategoryInstance {
return { return {
data: model.hierarchy.entities, data: model.hierarchy.entities,
definition: entity, definition: ofTable('entity', model.hierarchy.entities), //entity,
keys: () => Iterator.Range(0, model.hierarchy.entities._rowCount - 1), keys: () => Iterator.Range(0, model.hierarchy.entities._rowCount - 1),
rowCount: model.hierarchy.entities._rowCount rowCount: model.hierarchy.entities._rowCount
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment