Переглянути джерело

renamed table to category, added File and Block classes, typed category and column objects

Alexander Rose 7 роки тому
батько
коміт
b12f11af03

+ 65 - 26
dist/molio.esm.js

@@ -72,6 +72,12 @@ function parseFloat(str, start, end) {
     return neg * ret;
 }
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
 /**
  * Eat everything until a newline occurs.
  */
@@ -150,6 +156,13 @@ function skipWhitespace(state) {
     return prev;
 }
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
 var Tokens;
 (function (Tokens) {
     function resize(tokens) {
@@ -182,6 +195,12 @@ var Tokens;
     Tokens.create = create;
 })(Tokens || (Tokens = {}));
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
 /**
  * Represents a column that is not present.
  */
@@ -219,6 +238,13 @@ var ShortStringPool;
     ShortStringPool.get = get;
 })(ShortStringPool || (ShortStringPool = {}));
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
 /**
  * Represents a single column.
  */
@@ -328,10 +354,17 @@ var CifColumn = (function (TextColumn) {
     return CifColumn;
 }(TextColumn));
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
 /**
- * Represents a table backed by a string.
+ * Represents a category backed by a string.
  */
-var TextTable = function TextTable(data, name, columns, tokens) {
+var TextCategory = function TextCategory(data, name, columns, tokens) {
     this.name = name;
     this.indices = tokens.indices;
     this.data = data;
@@ -348,13 +381,13 @@ prototypeAccessors.columnNames.get = function () {
 /**
  * Get a column object that makes accessing data easier.
  */
-TextTable.prototype.getColumn = function getColumn (name) {
+TextCategory.prototype.getColumn = function getColumn (name) {
     var i = this.columnIndices.get(name);
     if (i !== void 0)
         { return new TextColumn(this, this.data, name, i); }
     return UndefinedColumn;
 };
-TextTable.prototype.initColumns = function initColumns (columns) {
+TextCategory.prototype.initColumns = function initColumns (columns) {
         var this$1 = this;
 
     this.columnIndices = new Map();
@@ -365,23 +398,23 @@ TextTable.prototype.initColumns = function initColumns (columns) {
     }
 };
 
-Object.defineProperties( TextTable.prototype, prototypeAccessors );
-var CifTable = (function (TextTable) {
-    function CifTable () {
-        TextTable.apply(this, arguments);
+Object.defineProperties( TextCategory.prototype, prototypeAccessors );
+var CifCategory = (function (TextCategory) {
+    function CifCategory () {
+        TextCategory.apply(this, arguments);
     }
 
-    if ( TextTable ) CifTable.__proto__ = TextTable;
-    CifTable.prototype = Object.create( TextTable && TextTable.prototype );
-    CifTable.prototype.constructor = CifTable;
+    if ( TextCategory ) CifCategory.__proto__ = TextCategory;
+    CifCategory.prototype = Object.create( TextCategory && TextCategory.prototype );
+    CifCategory.prototype.constructor = CifCategory;
 
-    CifTable.prototype.getColumn = function getColumn (name) {
+    CifCategory.prototype.getColumn = function getColumn (name) {
         var i = this.columnIndices.get(name);
         if (i !== void 0)
             { return new CifColumn(this, this.data, name, i); }
         return UndefinedColumn;
     };
-    CifTable.prototype.initColumns = function initColumns (columns) {
+    CifCategory.prototype.initColumns = function initColumns (columns) {
         var this$1 = this;
 
         this.columnIndices = new Map();
@@ -393,8 +426,8 @@ var CifTable = (function (TextTable) {
         }
     };
 
-    return CifTable;
-}(TextTable));
+    return CifCategory;
+}(TextCategory));
 
 /*
  * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
@@ -445,19 +478,19 @@ var GroFile = function GroFile(data) {
 };
 var GroBlock = function GroBlock(data) {
     this.data = data;
-    this.tableMap = new Map();
-    this.tableList = [];
+    this.categoryMap = new Map();
+    this.categoryList = [];
 };
 
-GroBlock.prototype.getTable = function getTable (name) {
-    return this.tableMap.get(name);
+GroBlock.prototype.getCategory = function getCategory (name) {
+    return this.categoryMap.get(name);
 };
 /**
- * Adds a table.
+ * Adds a category.
  */
-GroBlock.prototype.addTable = function addTable (table) {
-    this.tableList[this.tableList.length] = table;
-    this.tableMap.set(table.name, table);
+GroBlock.prototype.addCategory = function addCategory (category) {
+    this.categoryList[this.categoryList.length] = category;
+    this.categoryMap.set(category.name, category);
 };
 function createTokenizer(data) {
     return {
@@ -590,7 +623,7 @@ function handleAtoms(state, block) {
         state.position = valueEnd;
         eatLine(state);
     }
-    block.addTable(new TextTable(state.data, name, columns, tokens));
+    block.addCategory(new TextCategory(state.data, name, columns, tokens));
 }
 /**
  * box vectors (free format, space separated reals), values:
@@ -626,8 +659,8 @@ function parseInternal(data) {
     file.blocks.push(block);
     var headerColumns = ['title', 'timeInPs', 'numberOfAtoms', 'boxX', 'boxY', 'boxZ'];
     var headerTokens = Tokens.create(2 * headerColumns.length);
-    var header = new TextTable(state.data, 'header', headerColumns, headerTokens);
-    block.addTable(header);
+    var header = new TextCategory(state.data, 'header', headerColumns, headerTokens);
+    block.addCategory(header);
     handleTitleString(state, headerTokens);
     handleNumberOfAtoms(state, headerTokens);
     handleAtoms(state, block);
@@ -638,5 +671,11 @@ function parse(data) {
     return parseInternal(data);
 }
 
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
 export { parse as groReader };
 //# sourceMappingURL=molio.esm.js.map

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
dist/molio.js


+ 6 - 7
package.json

@@ -23,19 +23,18 @@
   "license": "MIT",
   "devDependencies": {
     "@types/jest": "latest",
-    "@types/node": "^8.0.25",
-    "jest": "^20.0.4",
-    "rollup": "^0.49.2",
+    "@types/node": "^8.0.28",
+    "jest": "^21.1.0",
+    "rollup": "^0.49.3",
     "rollup-plugin-buble": "^0.15.0",
-    "rollup-plugin-commonjs": "^8.2.0",
+    "rollup-plugin-commonjs": "^8.2.1",
     "rollup-plugin-json": "^2.3.0",
     "rollup-plugin-node-resolve": "^3.0.0",
     "rollup-watch": "^4.3.1",
-    "ts-jest": "^20.0.14",
+    "ts-jest": "^21.0.0",
     "tslint": "^5.7.0",
     "typescript": "^2.5.1",
-    "uglify-js": "^3.0.28",
-    "webpack": "^3.5.5"
+    "uglify-js": "^3.1.0"
   },
   "dependencies": {}
 }

+ 9 - 9
rollup.config.js

@@ -1,4 +1,4 @@
-import buble from 'rollup-plugin-buble';
+// import buble from 'rollup-plugin-buble';
 import json from 'rollup-plugin-json';
 import resolve from 'rollup-plugin-node-resolve';
 import commonjs from 'rollup-plugin-commonjs';
@@ -16,21 +16,21 @@ export default {
     }),
     commonjs(),
     json(),
-    buble()
+    // buble()
   ],
   output: [
     {
       file: "build/js/molio.dev.js",
       format: 'umd',
       name: 'MOLIO',
-      sourcemap: true
+      sourcemap: false
     },
-    {
-      file: "build/js/molio.esm.js",
-      format: 'es',
-      sourcemap: true
-    }
+    // {
+    //   file: "build/js/molio.esm.js",
+    //   format: 'es',
+    //   sourcemap: false
+    // }
   ],
   external: external,
-  sourcemap: true
+  sourcemap: false
 };

+ 3 - 0
src/index.d.ts

@@ -6,4 +6,7 @@
 
 export { ParserResult, ParserError, ParserSuccess } from './parser'
 
+export { Category } from './relational/category'
+export { Column } from './relational/column'
+
 export { parse as groReader } from './reader/gro'

+ 3 - 0
src/index.ts

@@ -4,4 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
+export { Category } from './relational/category'
+export { Column } from './relational/column'
+
 export { parse as groReader } from './reader/gro'

+ 42 - 52
src/reader/gro.ts

@@ -9,7 +9,9 @@ import { eatLine, eatValue, skipWhitespace } from '../utils/helper'
 import { Tokens } from '../utils/tokens'
 import { TokenizerState } from '../utils/tokenizer-state'
 
-import { TextTable } from '../relational/text-table'
+import { TextFile } from '../relational/text-file'
+import { TextBlock } from '../relational/text-block'
+import { TextCategory } from '../relational/text-category'
 
 import { ParserResult } from '../parser'
 
@@ -17,53 +19,40 @@ import { ParserResult } from '../parser'
  * http://manual.gromacs.org/current/online/gro.html
  */
 
-export interface GroFile {
-    data: string;
-    blocks: GroBlock[];
+export const GroCategories = {
+    'header': '',
+    'atoms': ''
 }
 
-export interface GroBlock {
-    getTable(name: string): TextTable
-    addTable(table: TextTable): void
-}
-
-export class GroFile implements GroFile {
-    data: string;
-    blocks: GroBlock[] = [];
+// type GroCategories = keyof typeof GroCategories
 
-    constructor(data: string) {
-        this.data = data;
-    }
+export const GroAtomBasicColumns = {
+    'residueNumber': '',
+    'residueName': '',
+    'atomName': '',
+    'atomNumber': '',
+    'x': '',
+    'y': '',
+    'z': ''
 }
-
-export class GroBlock implements GroBlock {
-    private tableMap: Map<string, TextTable>;
-    private tableList: TextTable[];
-
-    data: string;
-
-    /**
-     * Gets a table by its name.
-     */
-    getTable(name: string) {
-        return this.tableMap.get(name);
-    }
-
-    /**
-     * Adds a table.
-     */
-    addTable(table: TextTable) {
-        this.tableList[this.tableList.length] = table;
-        this.tableMap.set(table.name, table);
-    }
-
-    constructor(data: string) {
-        this.data = data;
-
-        this.tableMap = new Map()
-        this.tableList = []
-    }
+export type GroAtomBasicColumns = keyof typeof GroAtomBasicColumns
+
+export const GroAtomVelocityColumns = Object.assign({
+    'vx': '',
+    'vy': '',
+    'vz': ''
+}, GroAtomBasicColumns)
+export type GroAtomVelocityColumns = keyof typeof GroAtomVelocityColumns
+
+export const GroHeaderColumns = {
+    'title': '',
+    'timeInPs': '',
+    'numberOfAtoms': '',
+    'boxX': '',
+    'boxY': '',
+    'boxZ': ''
 }
+export type GroHeaderColumns = keyof typeof GroHeaderColumns
 
 export interface GroState extends TokenizerState {
     numberOfAtoms: number
@@ -181,7 +170,7 @@ function handleNumberOfAtoms (state: GroState, tokens: Tokens) {
  *     position (in nm, x y z in 3 columns, each 8 positions with 3 decimal places)
  *     velocity (in nm/ps (or km/s), x y z in 3 columns, each 8 positions with 4 decimal places)
  */
-function handleAtoms (state: GroState, block: GroBlock) {
+function handleAtoms (state: GroState, block: TextBlock) {
     console.log('MOINMOIN')
     const name = 'atoms'
 
@@ -218,7 +207,7 @@ function handleAtoms (state: GroState, block: GroBlock) {
         eatLine(state)
     }
 
-    block.addTable(new TextTable(state.data, name, columns, tokens));
+    block.addCategory(new TextCategory(state.data, name, columns, tokens));
 }
 
 /**
@@ -241,27 +230,28 @@ function handleBoxVectors (state: GroState, tokens: Tokens) {
  * Creates an error result.
  */
 // function error(line: number, message: string) {
-//     return ParserResult.error<GroFile>(message, line);
+//     return ParserResult.error<TextFile>(message, line);
 // }
 
 /**
  * Creates a data result.
  */
-function result(data: GroFile) {
+function result(data: TextFile) {
     return ParserResult.success(data);
 }
 
-function parseInternal(data: string): ParserResult<GroFile> {
+function parseInternal(data: string): ParserResult<TextFile> {
     const state = createTokenizer(data)
-    const file = new GroFile(data)
+    const file = new TextFile(data)
+    file.blocks
 
-    let block = new GroBlock(data)
+    let block = new TextBlock(data)
     file.blocks.push(block)
 
     const headerColumns = ['title', 'timeInPs', 'numberOfAtoms', 'boxX', 'boxY', 'boxZ']
     const headerTokens = Tokens.create(2 * headerColumns.length)
-    let header = new TextTable(state.data, 'header', headerColumns, headerTokens)
-    block.addTable(header)
+    let header = new TextCategory(state.data, 'header', headerColumns, headerTokens)
+    block.addCategory(header)
 
     handleTitleString(state, headerTokens)
     handleNumberOfAtoms(state, headerTokens)

+ 3 - 3
src/reader/spec/gro.spec.ts

@@ -5,7 +5,7 @@
  */
 
 import { parse } from '../gro'
-// import { Table } from '../../relational/table'
+// import { Category } from '../../relational/category'
 
 const groString = `MD of 2 waters, t= 4.2
     6
@@ -33,7 +33,7 @@ describe('gro reader', () => {
         } else {
             const groFile = parsed.result
 
-            const header = groFile.blocks[0].getTable('header')
+            const header = groFile.blocks[0].getCategory('header')
             if (header) {
                 expect(header.columnNames).toEqual(['title', 'timeInPs', 'numberOfAtoms', 'boxX', 'boxY', 'boxZ'])
 
@@ -58,7 +58,7 @@ describe('gro reader', () => {
         } else {
             const groFile = parsed.result
 
-            const header = groFile.blocks[0].getTable('header')
+            const header = groFile.blocks[0].getCategory('header')
             if (header) {
                 expect(header.columnNames).toEqual(['title', 'timeInPs', 'numberOfAtoms', 'boxX', 'boxY', 'boxZ'])
 

+ 24 - 0
src/relational/block.ts

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { Category, UndefinedCategory } from './category'
+
+export abstract class Block<T> {
+    abstract getCategory(name: string): T|undefined
+    abstract addCategory(category: T): void
+
+    getCategoriesFromSchema<T extends object> (schema: T) {
+        return BlockCategories(this, schema)
+    }
+}
+
+export type BlockCategories<Categories extends string> = { readonly [name in Categories]: Category }
+export function BlockCategories<T extends object>(block: Block<any> | undefined, categories: T): BlockCategories<keyof T> {
+    const ret = Object.create(null);
+    if (!block) for (const c of Object.keys(categories)) ret[c] = UndefinedCategory;
+    else for (const c of Object.keys(categories)) ret[c] = block.getCategory(c);
+    return ret;
+}

+ 61 - 0
src/relational/category.ts

@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * from https://github.com/dsehnal/CIFTools.js
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import { Column, UndefinedColumn } from './column'
+
+/**
+ * Represents a tabular category with multiple fields represented as columns.
+ *
+ * Example:
+ * _category.field1
+ * _category.field2
+ * ...
+ */
+export abstract class Category {
+    name: string;
+    rowCount: number;
+    columnCount: number;
+    columnNames: string[];
+
+    /**
+     * If a field with the given name is not present, returns UndefinedColumn.
+     *
+     * Columns are accessed by their field name only, i.e.
+     * _category.field is accessed by
+     * category.getColumn('field')
+     *
+     * Note that columns are created on demand and there is some computational
+     * cost when creating a new column. Therefore, if you need to reuse a column,
+     * it is a good idea to cache it.
+     */
+    abstract getColumn(name: string): Column;
+
+    getColumnsFromSchema<T extends object> (schema: T) {
+        return CategoryColumns(this, schema)
+    }
+}
+
+/**
+ * Represents a category that is not present.
+ */
+class _UndefinedCategory extends Category {  // tslint:disable-line:class-name
+    name: ''
+    rowCount = 0
+    columnCount = 0
+    columnNames = []
+    getColumn(name: string) { return UndefinedColumn }
+}
+export const UndefinedCategory = new _UndefinedCategory() as Category;
+
+
+export type CategoryColumns<Columns extends string> = { readonly [name in Columns]: Column }
+export function CategoryColumns<T extends object>(category: Category | undefined, columns: T): CategoryColumns<keyof T> {
+    const ret = Object.create(null);
+    if (!category) for (const c of Object.keys(columns)) ret[c] = UndefinedColumn;
+    else for (const c of Object.keys(columns)) ret[c] = category.getColumn(c);
+    return ret;
+}

+ 10 - 0
src/relational/file.ts

@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+export interface File<T> {
+    blocks: T[];
+}
+

+ 0 - 36
src/relational/table.ts

@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
- *
- * from https://github.com/dsehnal/CIFTools.js
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-import { Column } from './column'
-
-/**
- * Represents that CIF category with multiple fields represented as columns.
- *
- * Example:
- * _category.field1
- * _category.field2
- * ...
- */
-export interface Table {
-    name: string;
-    rowCount: number;
-    columnCount: number;
-    columnNames: string[];
-
-    /**
-     * If a field with the given name is not present, returns UndefinedColumn.
-     *
-     * Columns are accessed by their field name only, i.e.
-     * _category.field is accessed by
-     * category.getColumn('field')
-     *
-     * Note that columns are created on demand and there is some computational
-     * cost when creating a new column. Therefore, if you need to reuse a column,
-     * it is a good idea to cache it.
-     */
-    getColumn(name: string): Column;
-}

+ 39 - 0
src/relational/text-block.ts

@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { Block } from './block'
+import { TextCategory } from './text-category'
+
+export class TextBlock extends Block<TextCategory> {
+    private categoryMap: Map<string, TextCategory>;
+    private categoryList: TextCategory[];
+
+    data: string;
+
+    /**
+     * Gets a category by its name.
+     */
+    getCategory(name: string) {
+        return this.categoryMap.get(name);
+    }
+
+    /**
+     * Adds a category.
+     */
+    addCategory(category: TextCategory) {
+        this.categoryList[this.categoryList.length] = category;
+        this.categoryMap.set(category.name, category);
+    }
+
+    constructor(data: string) {
+        super()
+
+        this.data = data;
+
+        this.categoryMap = new Map()
+        this.categoryList = []
+    }
+}

+ 7 - 6
src/relational/text-table.ts → src/relational/text-category.ts

@@ -6,16 +6,16 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Table } from './table'
+import { Category } from './category'
 import { UndefinedColumn } from './column'
 import { TextColumn, CifColumn } from './text-column'
 
 import { Tokens } from '../utils/tokens'
 
 /**
- * Represents a table backed by a string.
+ * Represents a category backed by a string.
  */
-export class TextTable implements Table {
+export class TextCategory extends Category {
     protected data: string;
     protected columnNameList: string[];
     protected columnIndices: Map<string, number>;
@@ -66,8 +66,9 @@ export class TextTable implements Table {
         }
     }
 
-    constructor(
-        data: string, name: string, columns: string[], tokens: Tokens) {
+    constructor(data: string, name: string, columns: string[], tokens: Tokens) {
+        super()
+
         this.name = name;
         this.indices = tokens.indices;
         this.data = data;
@@ -79,7 +80,7 @@ export class TextTable implements Table {
     }
 }
 
-export class CifTable extends TextTable {
+export class CifCategory extends TextCategory {
     getColumn(name: string): CifColumn {
         let i = this.columnIndices.get(name);
         if (i !== void 0) return new CifColumn(this, this.data, name, i);

+ 2 - 2
src/relational/text-column.ts

@@ -8,7 +8,7 @@
 
 import { Column } from './column'
 import { ValuePresence } from './constants'
-import { TextTable } from './text-table'
+import { TextCategory } from './text-category'
 
 import { parseInt as fastParseInt, parseFloat as fastParseFloat } from '../utils/number-parser'
 import { ShortStringPool } from '../utils/short-string-pool'
@@ -89,7 +89,7 @@ export class TextColumn implements Column {
         return ValuePresence.Present
     }
 
-    constructor(table: TextTable, protected data: string, public name: string, public index: number) {
+    constructor(table: TextCategory, protected data: string, public name: string, public index: number) {
         this.indices = table.indices;
         this.columnCount = table.columnCount;
     }

+ 17 - 0
src/relational/text-file.ts

@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { File } from './file'
+import { TextBlock } from './text-block'
+
+export class TextFile implements File<TextBlock> {
+    data: string;
+    blocks: TextBlock[] = [];
+
+    constructor(data: string) {
+        this.data = data;
+    }
+}

+ 19 - 15
src/script.ts

@@ -7,17 +7,17 @@
 // import * as util from 'util'
 import * as fs from 'fs'
 
-import { parse } from './reader/gro'
-import { Table } from './relational/table'
+import { parse, GroCategories, GroAtomBasicColumns } from './reader/gro'
+import { Category } from './relational/category'
 
 const file = '1crn.gro'
 // const file = 'water.gro'
 // const file = 'test.gro'
 // const file = 'md_1u19_trj.gro'
 
-function getFloatArray(table: Table, name: string) {
-    const column = table.getColumn(name)
-    const n = table.rowCount
+function getFloatArray(category: Category, name: string) {
+    const column = category.getColumn(name)
+    const n = category.rowCount
     const array = new Float32Array(n)
     for (let i = 0; i < n; ++i) {
         array[i] = column.getFloat(i)
@@ -25,9 +25,9 @@ function getFloatArray(table: Table, name: string) {
     return array
 }
 
-function getIntArray(table: Table, name: string) {
-    const column = table.getColumn(name)
-    const n = table.rowCount
+function getIntArray(category: Category, name: string) {
+    const column = category.getColumn(name)
+    const n = category.rowCount
     const array = new Int32Array(n)
     for (let i = 0; i < n; ++i) {
         array[i] = column.getInteger(i)
@@ -48,8 +48,10 @@ fs.readFile(`./examples/${file}`, 'utf8', function (err,data) {
         console.log(parsed)
     } else {
         const groFile = parsed.result
+        const categories = groFile.blocks[0].getCategoriesFromSchema(GroCategories)
 
-        const header = groFile.blocks[0].getTable('header')
+        // const header = groFile.blocks[0].getCategory('header')
+        const header = categories.header
         if (header) {
             console.log(header.columnNames)
 
@@ -63,15 +65,17 @@ fs.readFile(`./examples/${file}`, 'utf8', function (err,data) {
             console.error('no header')
         }
 
-        const atoms = groFile.blocks[0].getTable('atoms')
+        const atoms = categories.atoms
         if (atoms) {
             console.log(atoms.columnNames)
 
-            console.log(`'${atoms.getColumn('residueNumber').getString(1)}'`)
-            console.log(`'${atoms.getColumn('residueName').getString(1)}'`)
-            console.log(`'${atoms.getColumn('atomName').getString(1)}'`)
-            console.log(atoms.getColumn('z').getFloat(1))
-            console.log(`'${atoms.getColumn('z').getString(1)}'`)
+            const columns = atoms.getColumnsFromSchema(GroAtomBasicColumns)
+
+            console.log(`'${columns.residueNumber.getString(1)}'`)
+            console.log(`'${columns.residueName.getString(1)}'`)
+            console.log(`'${columns.atomName.getString(1)}'`)
+            console.log(columns.z.getFloat(1))
+            console.log(`'${columns.z.getString(1)}'`)
 
             const n = atoms.rowCount
             console.log('rowCount', n)

Деякі файли не було показано, через те що забагато файлів було змінено