diff --git a/src/apps/cif2bcif/converter.ts b/src/apps/cif2bcif/converter.ts index 5083500e4fe753be76d483714d05e28cc8b40462..b663a301e60b8a7119875dbfac6b9fd3e850efaa 100644 --- a/src/apps/cif2bcif/converter.ts +++ b/src/apps/cif2bcif/converter.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Iterator from 'mol-base/collections/iterator' +import Iterator from 'mol-data/iterator' import CIF, { Category } from 'mol-io/reader/cif' import * as Encoder from 'mol-io/writer/cif' import * as fs from 'fs' diff --git a/src/apps/cif2bcif/field-classifier.ts b/src/apps/cif2bcif/field-classifier.ts index 0fe447382a76a41b5ede7eaa1a766998fad65b3c..145cdc6f9b0dd5e99e0d54ba7aa5839ed22e1d5e 100644 --- a/src/apps/cif2bcif/field-classifier.ts +++ b/src/apps/cif2bcif/field-classifier.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' import { Field } from 'mol-io/reader/cif/data-model' import { FieldDefinition, FieldType } from 'mol-io/writer/cif/encoder' diff --git a/src/apps/domain-annotation-server/mapping.ts b/src/apps/domain-annotation-server/mapping.ts index 419e4c270aadf0af6098eb159c808253ae24d9ac..da87d9b4698b6e8db3014c4a8dd52e8d0717095e 100644 --- a/src/apps/domain-annotation-server/mapping.ts +++ b/src/apps/domain-annotation-server/mapping.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Table } from 'mol-base/collections/database' +import { Table } from 'mol-data/db' import { CIFEncoder, create as createEncoder } from 'mol-io/writer/cif' import * as S from './schemas' import { getCategoryInstanceProvider } from './utils' diff --git a/src/apps/domain-annotation-server/schemas.ts b/src/apps/domain-annotation-server/schemas.ts index 90bbcba97f3b9f1b85682619ec1836263540e2ac..e6caffdac60c92bc2d8f364b0f89120edf011941 100644 --- a/src/apps/domain-annotation-server/schemas.ts +++ b/src/apps/domain-annotation-server/schemas.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' import Type = Column.Schema diff --git a/src/apps/domain-annotation-server/utils.ts b/src/apps/domain-annotation-server/utils.ts index 767de8fa4d6cd9a83503b3087ea45db4fc87dece..7c3e91b2a8866a051379e8b35cafdbe7d4de0022 100644 --- a/src/apps/domain-annotation-server/utils.ts +++ b/src/apps/domain-annotation-server/utils.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Table } from 'mol-base/collections/database' -import Iterator from 'mol-base/collections/iterator' +import { Table } from 'mol-data/db' +import Iterator from 'mol-data/iterator' import * as Encoder from 'mol-io/writer/cif' function columnValue(k: string) { diff --git a/src/mol-base/utils/uuid.ts b/src/mol-base/utils/uuid.ts deleted file mode 100644 index 29c7d24de7e1b2d8a662d5f3c9402e274878ce41..0000000000000000000000000000000000000000 --- a/src/mol-base/utils/uuid.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author David Sehnal <david.sehnal@gmail.com> - */ - -import now from './time' - -export default interface UUID extends String { '@type': 'uuid' } - -export function newUUID(): UUID { - let d = (+new Date()) + now(); - const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - const r = (d + Math.random()*16)%16 | 0; - d = Math.floor(d/16); - return (c==='x' ? r : (r&0x3|0x8)).toString(16); - }); - return uuid as any; -} \ No newline at end of file diff --git a/src/mol-base/collections/_spec/equiv-index.spec.ts b/src/mol-data/_spec/equiv-index.spec.ts similarity index 89% rename from src/mol-base/collections/_spec/equiv-index.spec.ts rename to src/mol-data/_spec/equiv-index.spec.ts index d2d0a2856f7b8eae587ce119d9c9c06740fa862a..9083c0145d0258be5815f9bc0c6f49c9effa5062 100644 --- a/src/mol-base/collections/_spec/equiv-index.spec.ts +++ b/src/mol-data/_spec/equiv-index.spec.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import EquivalenceClasses from '../equivalence-classes' +import EquivalenceClasses from '../util/equivalence-classes' describe('equiv-classes', () => { it('integer mod classes', () => { diff --git a/src/mol-base/collections/_spec/iterators.spec.ts b/src/mol-data/_spec/iterators.spec.ts similarity index 100% rename from src/mol-base/collections/_spec/iterators.spec.ts rename to src/mol-data/_spec/iterators.spec.ts diff --git a/src/mol-base/collections/_spec/sort.spec.ts b/src/mol-data/_spec/sort.spec.ts similarity index 98% rename from src/mol-base/collections/_spec/sort.spec.ts rename to src/mol-data/_spec/sort.spec.ts index 4bccb03cbc4d165ad297081f86c767b67dcbd971..9d2a122ccfead9d33a783df1a05c7c21e3cc8d06 100644 --- a/src/mol-base/collections/_spec/sort.spec.ts +++ b/src/mol-data/_spec/sort.spec.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import * as Sort from '../sort' +import * as Sort from '../util/sort' function shuffle<T>(data: T, len: number, clone: (s: T) => T, swap: Sort.Swapper = Sort.arraySwap) { const a = clone(data); diff --git a/src/mol-base/collections/database.ts b/src/mol-data/db.ts similarity index 53% rename from src/mol-base/collections/database.ts rename to src/mol-data/db.ts index 78818f8d85ad27872eefb9cf76fec6bcd048e5bf..367b533a0c7f22c7ce359d3112ebae25a23007f5 100644 --- a/src/mol-base/collections/database.ts +++ b/src/mol-data/db.ts @@ -4,9 +4,9 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Database from './database/database' -import Table from './database/table' -import Column from './database/column' -import * as ColumnHelpers from './database/column-helpers' +import Database from './db/database' +import Table from './db/table' +import Column from './db/column' +import * as ColumnHelpers from './db/column-helpers' export { Database, Table, Column, ColumnHelpers } \ No newline at end of file diff --git a/src/mol-base/collections/database/_spec/table.spec.ts b/src/mol-data/db/_spec/table.spec.ts similarity index 100% rename from src/mol-base/collections/database/_spec/table.spec.ts rename to src/mol-data/db/_spec/table.spec.ts diff --git a/src/mol-base/collections/database/column-helpers.ts b/src/mol-data/db/column-helpers.ts similarity index 100% rename from src/mol-base/collections/database/column-helpers.ts rename to src/mol-data/db/column-helpers.ts diff --git a/src/mol-base/collections/database/column.ts b/src/mol-data/db/column.ts similarity index 99% rename from src/mol-base/collections/database/column.ts rename to src/mol-data/db/column.ts index 4a373652bd9dd5ac70b9180fbef80b22f529febf..484411e6f5a5ed91acefbd55739727157b9f20e6 100644 --- a/src/mol-base/collections/database/column.ts +++ b/src/mol-data/db/column.ts @@ -5,7 +5,7 @@ */ import * as ColumnHelpers from './column-helpers' -import Tensors from '../../math/tensor' +import { Tensor as Tensors } from 'mol-math/linear-algebra' interface Column<T> { readonly '@type': Column.Type, diff --git a/src/mol-base/collections/database/database.ts b/src/mol-data/db/database.ts similarity index 100% rename from src/mol-base/collections/database/database.ts rename to src/mol-data/db/database.ts diff --git a/src/mol-base/collections/database/table.ts b/src/mol-data/db/table.ts similarity index 99% rename from src/mol-base/collections/database/table.ts rename to src/mol-data/db/table.ts index a7178bc1c037e1c2fc966abbbccb966600ff38b1..65b7bd1723fc670c36d6fe4777cb2cea32ea1e60 100644 --- a/src/mol-base/collections/database/table.ts +++ b/src/mol-data/db/table.ts @@ -5,7 +5,7 @@ */ import Column from './column' -import { sortArray } from '../sort' +import { sortArray } from '../util/sort' /** A collection of columns */ type Table<Schema extends Table.Schema> = { diff --git a/src/mol-data/index.ts b/src/mol-data/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..1db90c26e324d3098c0a50b16b3ec2f957f37f4e --- /dev/null +++ b/src/mol-data/index.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +import * as DB from './db' +import * as Int from './int' +import Iterator from './iterator' +import * as Util from './util' + +export { DB, Int, Iterator, Util } \ No newline at end of file diff --git a/src/mol-base/collections/integer.ts b/src/mol-data/int.ts similarity index 50% rename from src/mol-base/collections/integer.ts rename to src/mol-data/int.ts index 1abd46acc7f2b4af648dca0d77c0f05b0cb2f201..54c2795bbc6f772ebd25ee58501119ded48b35fe 100644 --- a/src/mol-base/collections/integer.ts +++ b/src/mol-data/int.ts @@ -4,12 +4,12 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Interval from './integer/interval' -import OrderedSet from './integer/ordered-set' -import Segmentation from './integer/segmentation' -import SortedArray from './integer/sorted-array' -import Tuple from './integer/tuple' -import LinkedIndex from './integer/linked-index' +import Interval from './int/interval' +import OrderedSet from './int/ordered-set' +import Segmentation from './int/segmentation' +import SortedArray from './int/sorted-array' +import Tuple from './int/tuple' +import LinkedIndex from './int/linked-index' import Iterator from './iterator' export { Interval, OrderedSet, Segmentation, SortedArray, Tuple, LinkedIndex, Iterator } \ No newline at end of file diff --git a/src/mol-base/collections/integer/_spec/interval.spec.ts b/src/mol-data/int/_spec/interval.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/interval.spec.ts rename to src/mol-data/int/_spec/interval.spec.ts diff --git a/src/mol-base/collections/integer/_spec/linked-index.spec.ts b/src/mol-data/int/_spec/linked-index.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/linked-index.spec.ts rename to src/mol-data/int/_spec/linked-index.spec.ts diff --git a/src/mol-base/collections/integer/_spec/ordered-set.spec.ts b/src/mol-data/int/_spec/ordered-set.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/ordered-set.spec.ts rename to src/mol-data/int/_spec/ordered-set.spec.ts diff --git a/src/mol-base/collections/integer/_spec/segmentation.spec.ts b/src/mol-data/int/_spec/segmentation.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/segmentation.spec.ts rename to src/mol-data/int/_spec/segmentation.spec.ts diff --git a/src/mol-base/collections/integer/_spec/sorted-array.spec.ts b/src/mol-data/int/_spec/sorted-array.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/sorted-array.spec.ts rename to src/mol-data/int/_spec/sorted-array.spec.ts diff --git a/src/mol-base/collections/integer/_spec/tuple.spec.ts b/src/mol-data/int/_spec/tuple.spec.ts similarity index 100% rename from src/mol-base/collections/integer/_spec/tuple.spec.ts rename to src/mol-data/int/_spec/tuple.spec.ts diff --git a/src/mol-base/collections/integer/impl/interval.ts b/src/mol-data/int/impl/interval.ts similarity index 100% rename from src/mol-base/collections/integer/impl/interval.ts rename to src/mol-data/int/impl/interval.ts diff --git a/src/mol-base/collections/integer/impl/ordered-set.ts b/src/mol-data/int/impl/ordered-set.ts similarity index 100% rename from src/mol-base/collections/integer/impl/ordered-set.ts rename to src/mol-data/int/impl/ordered-set.ts diff --git a/src/mol-base/collections/integer/impl/segmentation.ts b/src/mol-data/int/impl/segmentation.ts similarity index 100% rename from src/mol-base/collections/integer/impl/segmentation.ts rename to src/mol-data/int/impl/segmentation.ts diff --git a/src/mol-base/collections/integer/impl/sorted-array.ts b/src/mol-data/int/impl/sorted-array.ts similarity index 99% rename from src/mol-base/collections/integer/impl/sorted-array.ts rename to src/mol-data/int/impl/sorted-array.ts index fe0d90565959d7b3406596af78de7c46f72cbc55..f3147c7086664c7900c78db8c89f1e87b15ff509 100644 --- a/src/mol-base/collections/integer/impl/sorted-array.ts +++ b/src/mol-data/int/impl/sorted-array.ts @@ -4,8 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { sortArray } from '../../sort' -import { hash3, hash4 } from '../../hash-functions' +import { sortArray, hash3, hash4 } from '../../util' import Interval from '../interval' type Nums = ArrayLike<number> diff --git a/src/mol-base/collections/integer/interval.ts b/src/mol-data/int/interval.ts similarity index 100% rename from src/mol-base/collections/integer/interval.ts rename to src/mol-data/int/interval.ts diff --git a/src/mol-base/collections/integer/linked-index.ts b/src/mol-data/int/linked-index.ts similarity index 100% rename from src/mol-base/collections/integer/linked-index.ts rename to src/mol-data/int/linked-index.ts diff --git a/src/mol-base/collections/integer/ordered-set.ts b/src/mol-data/int/ordered-set.ts similarity index 100% rename from src/mol-base/collections/integer/ordered-set.ts rename to src/mol-data/int/ordered-set.ts diff --git a/src/mol-base/collections/integer/segmentation.ts b/src/mol-data/int/segmentation.ts similarity index 100% rename from src/mol-base/collections/integer/segmentation.ts rename to src/mol-data/int/segmentation.ts diff --git a/src/mol-base/collections/integer/sorted-array.ts b/src/mol-data/int/sorted-array.ts similarity index 100% rename from src/mol-base/collections/integer/sorted-array.ts rename to src/mol-data/int/sorted-array.ts diff --git a/src/mol-base/collections/integer/tuple.ts b/src/mol-data/int/tuple.ts similarity index 98% rename from src/mol-base/collections/integer/tuple.ts rename to src/mol-data/int/tuple.ts index 86cf4ea6bc3a1daa077f1026f04243fdd7e915dc..7967f45cff1e784ec19e0db7a32b86b6e1633dcc 100644 --- a/src/mol-base/collections/integer/tuple.ts +++ b/src/mol-data/int/tuple.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { hash2 } from '../hash-functions' +import { hash2 } from '../util' /** * Represents a pair of two integers as a double, diff --git a/src/mol-base/collections/iterator.ts b/src/mol-data/iterator.ts similarity index 100% rename from src/mol-base/collections/iterator.ts rename to src/mol-data/iterator.ts diff --git a/src/mol-data/util.ts b/src/mol-data/util.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab0c73fcfc7be65d2974c403b7fc010dc118b95a --- /dev/null +++ b/src/mol-data/util.ts @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +import ChunkedArray from './util/chunked-array' +import EquivalenceClasses from './util/chunked-array' +import HashSet from './util/hash-set' +import UniqueArray from './util/unique-array' + +export * from './util/hash-functions' +export * from './util/sort' + +export { ChunkedArray, EquivalenceClasses, HashSet, UniqueArray } \ No newline at end of file diff --git a/src/mol-base/collections/chunked-array.ts b/src/mol-data/util/chunked-array.ts similarity index 100% rename from src/mol-base/collections/chunked-array.ts rename to src/mol-data/util/chunked-array.ts diff --git a/src/mol-base/collections/equivalence-classes.ts b/src/mol-data/util/equivalence-classes.ts similarity index 100% rename from src/mol-base/collections/equivalence-classes.ts rename to src/mol-data/util/equivalence-classes.ts diff --git a/src/mol-base/collections/hash-functions.ts b/src/mol-data/util/hash-functions.ts similarity index 100% rename from src/mol-base/collections/hash-functions.ts rename to src/mol-data/util/hash-functions.ts diff --git a/src/mol-base/collections/hash-set.ts b/src/mol-data/util/hash-set.ts similarity index 100% rename from src/mol-base/collections/hash-set.ts rename to src/mol-data/util/hash-set.ts diff --git a/src/mol-base/collections/sort.ts b/src/mol-data/util/sort.ts similarity index 100% rename from src/mol-base/collections/sort.ts rename to src/mol-data/util/sort.ts diff --git a/src/mol-base/collections/unique-array.ts b/src/mol-data/util/unique-array.ts similarity index 100% rename from src/mol-base/collections/unique-array.ts rename to src/mol-data/util/unique-array.ts diff --git a/src/mol-io/common/binary-cif/array-encoder.ts b/src/mol-io/common/binary-cif/array-encoder.ts index 13f70f180b3de128739286113cfe8f73bd2ccbec..344171b8a8a910f45d32d6c6d885ab9c46b6200f 100644 --- a/src/mol-io/common/binary-cif/array-encoder.ts +++ b/src/mol-io/common/binary-cif/array-encoder.ts @@ -7,7 +7,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import ChunkedArray from 'mol-base/collections/chunked-array' +import ChunkedArray from 'mol-data/util/chunked-array' import { Encoding, EncodedData } from './encoding' export interface ArrayEncoder { diff --git a/src/mol-io/reader/_spec/cif.spec.ts b/src/mol-io/reader/_spec/cif.spec.ts index 856e1e16fb8a2fd7a084afc53639201d033f4ca9..90fae982aebd67108262b6672414c6c257c0c593 100644 --- a/src/mol-io/reader/_spec/cif.spec.ts +++ b/src/mol-io/reader/_spec/cif.spec.ts @@ -7,7 +7,7 @@ import * as Data from '../cif/data-model' import TextField from '../cif/text/field' import * as Schema from '../cif/schema' -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' const columnData = `123abc`; diff --git a/src/mol-io/reader/_spec/column.spec.ts b/src/mol-io/reader/_spec/column.spec.ts index f7df7dfc88d90a7d17329b47236494f16a8c16b5..e9e31ca993f7db515a610948d953daefcc05be52 100644 --- a/src/mol-io/reader/_spec/column.spec.ts +++ b/src/mol-io/reader/_spec/column.spec.ts @@ -7,7 +7,7 @@ import FixedColumn from '../common/text/column/fixed' import TokenColumn from '../common/text/column/token' -import { Column, ColumnHelpers } from 'mol-base/collections/database' +import { Column, ColumnHelpers } from 'mol-data/db' const lines = [ '1.123 abc', diff --git a/src/mol-io/reader/cif/binary/field.ts b/src/mol-io/reader/cif/binary/field.ts index 5847e0ab3aabe2621abe65fb7d8f5116767545f6..89e2c47af7f28c42cd7490d3a4a56bea03a5e855 100644 --- a/src/mol-io/reader/cif/binary/field.ts +++ b/src/mol-io/reader/cif/binary/field.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, ColumnHelpers } from 'mol-base/collections/database' +import { Column, ColumnHelpers } from 'mol-data/db' import * as Data from '../data-model' import { EncodedColumn, decode } from '../../../common/binary-cif' import { parseInt as fastParseInt, parseFloat as fastParseFloat } from '../../common/text/number-parser' diff --git a/src/mol-io/reader/cif/binary/parser.ts b/src/mol-io/reader/cif/binary/parser.ts index c72a9f4384550976767597498d4633635f1f8a93..4f1b705eb62810531f2d5665def1b88b189e82d4 100644 --- a/src/mol-io/reader/cif/binary/parser.ts +++ b/src/mol-io/reader/cif/binary/parser.ts @@ -9,7 +9,7 @@ import { EncodedCategory, EncodedFile } from '../../../common/binary-cif' import Field from './field' import Result from '../../result' import decodeMsgPack from '../../../common/msgpack/decode' -import Computation from 'mol-base/computation' +import Computation from 'mol-util/computation' function checkVersions(min: number[], current: number[]) { for (let i = 0; i < 2; i++) { diff --git a/src/mol-io/reader/cif/data-model.ts b/src/mol-io/reader/cif/data-model.ts index 75805537f0a87a192fb3d14df5d06965675e6922..417692342e7eb7fb1235128197a56629583c4864 100644 --- a/src/mol-io/reader/cif/data-model.ts +++ b/src/mol-io/reader/cif/data-model.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' -import Tensor from 'mol-base/math/tensor' +import { Column } from 'mol-data/db' +import { Tensor } from 'mol-math/linear-algebra' export interface File { readonly name?: string, diff --git a/src/mol-io/reader/cif/schema.ts b/src/mol-io/reader/cif/schema.ts index 441f4082c7d1c13b06604092f792c940cd12f2ad..ef0b3f5e2d5329fd4ed6653b81e1ca811535177e 100644 --- a/src/mol-io/reader/cif/schema.ts +++ b/src/mol-io/reader/cif/schema.ts @@ -5,7 +5,7 @@ */ import * as Data from './data-model' -import { Database, Table, Column, ColumnHelpers } from 'mol-base/collections/database' +import { Database, Table, Column, ColumnHelpers } from 'mol-data/db' export function toDatabase<Schema extends Database.Schema, Frame extends Database<Schema> = Database<Schema>>(schema: Schema, frame: Data.Frame): Frame { return createDatabase(schema, frame) as Frame; diff --git a/src/mol-io/reader/cif/schema/dic.ts b/src/mol-io/reader/cif/schema/dic.ts index f9a934abdb0d5a918040ed423df76f6e31f9b241..48a73dd511b81a1ce0d0e965a81e07ede48ec2eb 100644 --- a/src/mol-io/reader/cif/schema/dic.ts +++ b/src/mol-io/reader/cif/schema/dic.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { Database, Column } from 'mol-base/collections/database' +import { Database, Column } from 'mol-data/db' import Schema = Column.Schema import FP = Schema.FP diff --git a/src/mol-io/reader/cif/schema/mmcif.ts b/src/mol-io/reader/cif/schema/mmcif.ts index 59b31c1014f3fcb4485071d71ee1cdcc806bc610..5fec25ce398b79ee7b323072f505c84f9502b34e 100644 --- a/src/mol-io/reader/cif/schema/mmcif.ts +++ b/src/mol-io/reader/cif/schema/mmcif.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Database, Column } from 'mol-base/collections/database' +import { Database, Column } from 'mol-data/db' import Schema = Column.Schema import FP = Schema.FP diff --git a/src/mol-io/reader/cif/text/field.ts b/src/mol-io/reader/cif/text/field.ts index 1628da3e4461fa55d2c00abd551f3ed77662b902..6d18884942e3186b817b48aa988e3ca78538c886 100644 --- a/src/mol-io/reader/cif/text/field.ts +++ b/src/mol-io/reader/cif/text/field.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, ColumnHelpers } from 'mol-base/collections/database' +import { Column, ColumnHelpers } from 'mol-data/db' import * as TokenColumn from '../../common/text/column/token' import { Tokens } from '../../common/text/tokenizer' import * as Data from '../data-model' diff --git a/src/mol-io/reader/cif/text/parser.ts b/src/mol-io/reader/cif/text/parser.ts index 0a3f13c240c1e1d7a2b83b42f2f5aa033231fa0d..064b014a9194aaa356d06a666c4ee31f80bee723 100644 --- a/src/mol-io/reader/cif/text/parser.ts +++ b/src/mol-io/reader/cif/text/parser.ts @@ -26,7 +26,7 @@ import * as Data from '../data-model' import Field from './field' import { Tokens, TokenBuilder } from '../../common/text/tokenizer' import Result from '../../result' -import Computation from 'mol-base/computation' +import Computation from 'mol-util/computation' /** * Types of supported mmCIF tokens. diff --git a/src/mol-io/reader/common/text/column/fixed.ts b/src/mol-io/reader/common/text/column/fixed.ts index d279f3f2eb02d9867eacaeeab9fa7fc090c15b4a..5b094506abc748dfd9dceebe71ffe5db76c39ca9 100644 --- a/src/mol-io/reader/common/text/column/fixed.ts +++ b/src/mol-io/reader/common/text/column/fixed.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, ColumnHelpers } from 'mol-base/collections/database' +import { Column, ColumnHelpers } from 'mol-data/db' import { trimStr, Tokens } from '../tokenizer' import { parseIntSkipLeadingWhitespace, parseFloatSkipLeadingWhitespace } from '../number-parser' diff --git a/src/mol-io/reader/common/text/column/token.ts b/src/mol-io/reader/common/text/column/token.ts index e4dd79fe341fab5b933c23e77cf3b1ec760ccf26..21d8afd06adee270be4d38f7b5da85aa0ce96254 100644 --- a/src/mol-io/reader/common/text/column/token.ts +++ b/src/mol-io/reader/common/text/column/token.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, ColumnHelpers } from 'mol-base/collections/database' +import { Column, ColumnHelpers } from 'mol-data/db' import { Tokens } from '../tokenizer' import { parseInt as fastParseInt, parseFloat as fastParseFloat } from '../number-parser' diff --git a/src/mol-io/reader/common/text/tokenizer.ts b/src/mol-io/reader/common/text/tokenizer.ts index d8ddc0746eb72ea6431de303b6a4d1f3fe6e6b77..55b310e5d825008fa16a7b91dd443e08d3e8d768 100644 --- a/src/mol-io/reader/common/text/tokenizer.ts +++ b/src/mol-io/reader/common/text/tokenizer.ts @@ -6,7 +6,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Computation from 'mol-base/computation' +import Computation from 'mol-util/computation' export interface Tokenizer { data: string, diff --git a/src/mol-io/reader/gro/parser.ts b/src/mol-io/reader/gro/parser.ts index 531a8b2756c20c9fb0caad75bf42ef1f8653322f..47e7ea192dfe89a94abf1265e7a8770007eeb38a 100644 --- a/src/mol-io/reader/gro/parser.ts +++ b/src/mol-io/reader/gro/parser.ts @@ -5,12 +5,12 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' import Tokenizer from '../common/text/tokenizer' import FixedColumn from '../common/text/column/fixed' import * as Schema from './schema' import Result from '../result' -import Computation from 'mol-base/computation' +import Computation from 'mol-util/computation' interface State { tokenizer: Tokenizer, diff --git a/src/mol-io/reader/gro/schema.d.ts b/src/mol-io/reader/gro/schema.d.ts index bd871b6ffea6cdc127ce4b375888548ce28d1a60..9a0b1ca550718e16822320091b9500b5cef0597c 100644 --- a/src/mol-io/reader/gro/schema.d.ts +++ b/src/mol-io/reader/gro/schema.d.ts @@ -5,7 +5,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' export interface Header { title: string, diff --git a/src/mol-io/reader/mol2/schema.d.ts b/src/mol-io/reader/mol2/schema.d.ts index fbf458ce8322b10d7ad28659a886f468c9492bec..374b52d0d8063e5b0995336fb43590b0c5beae14 100644 --- a/src/mol-io/reader/mol2/schema.d.ts +++ b/src/mol-io/reader/mol2/schema.d.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' // Full format http://chemyang.ccnu.edu.cn/ccb/server/AIMMS/mol2.pdf // there are many records but for now ignore (pass over) all but the following diff --git a/src/mol-io/writer/cif/encoder.ts b/src/mol-io/writer/cif/encoder.ts index ed7b0541871db4ec8fd3be50da5da515bd4debd4..548adbf99dc67660ecec899098a5dd9ca332081e 100644 --- a/src/mol-io/writer/cif/encoder.ts +++ b/src/mol-io/writer/cif/encoder.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Iterator from 'mol-base/collections/iterator' -import { Column } from 'mol-base/collections/database' +import Iterator from 'mol-data/iterator' +import { Column } from 'mol-data/db' import Encoder from '../encoder' // TODO: support for "coordinate fields", make "coordinate precision" a parameter of the encoder diff --git a/src/mol-io/writer/cif/encoder/binary.ts b/src/mol-io/writer/cif/encoder/binary.ts index 54968e5fb06c18a28e3c496f5f03b4846ce8c4ab..5817959635d31ea62a98aa18a11dec66a16b395d 100644 --- a/src/mol-io/writer/cif/encoder/binary.ts +++ b/src/mol-io/writer/cif/encoder/binary.ts @@ -6,8 +6,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Iterator from 'mol-base/collections/iterator' -import { Column } from 'mol-base/collections/database' +import Iterator from 'mol-data/iterator' +import { Column } from 'mol-data/db' import encodeMsgPack from '../../../common/msgpack/encode' import { EncodedColumn, EncodedData, EncodedFile, EncodedDataBlock, EncodedCategory, ArrayEncoder, ArrayEncoding as E, VERSION diff --git a/src/mol-io/writer/cif/encoder/text.ts b/src/mol-io/writer/cif/encoder/text.ts index b07a54853366ec19e81ee28408debfc1a3a55d37..ef51b642404edde680123778423f0c474b3e27c8 100644 --- a/src/mol-io/writer/cif/encoder/text.ts +++ b/src/mol-io/writer/cif/encoder/text.ts @@ -6,8 +6,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' -import StringBuilder from 'mol-base/utils/string-builder' +import { Column } from 'mol-data/db' +import StringBuilder from 'mol-util/string-builder' import * as Enc from '../encoder' import Writer from '../../writer' diff --git a/src/mol-base/geometry/grid-lookup.ts b/src/mol-math/geometry/grid-lookup.ts similarity index 100% rename from src/mol-base/geometry/grid-lookup.ts rename to src/mol-math/geometry/grid-lookup.ts diff --git a/src/mol-base/geometry/sphere.ts b/src/mol-math/geometry/sphere.ts similarity index 100% rename from src/mol-base/geometry/sphere.ts rename to src/mol-math/geometry/sphere.ts diff --git a/src/mol-base/geometry/transform.ts b/src/mol-math/geometry/transform.ts similarity index 91% rename from src/mol-base/geometry/transform.ts rename to src/mol-math/geometry/transform.ts index 4eb1d64c650036f82a6dd6319d2ee32a9eb3db9c..cf9aaa6d937b378c12edb14b9ae98376a23f8e99 100644 --- a/src/mol-base/geometry/transform.ts +++ b/src/mol-math/geometry/transform.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Mat4 } from '../math/linear-algebra-3d' +import { Mat4 } from '../linear-algebra/3d' interface Transform extends Readonly<{ transform: Mat4, diff --git a/src/mol-base/graph/graph.ts b/src/mol-math/graph/graph.ts similarity index 100% rename from src/mol-base/graph/graph.ts rename to src/mol-math/graph/graph.ts diff --git a/src/mol-math/linear-algebra.ts b/src/mol-math/linear-algebra.ts new file mode 100644 index 0000000000000000000000000000000000000000..20ffdc270398f55572af9a3ca3a8f71fc67adc61 --- /dev/null +++ b/src/mol-math/linear-algebra.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +export * from './linear-algebra/3d' +export * from './linear-algebra/tensor' \ No newline at end of file diff --git a/src/mol-base/math/linear-algebra-3d.ts b/src/mol-math/linear-algebra/3d.ts similarity index 98% rename from src/mol-base/math/linear-algebra-3d.ts rename to src/mol-math/linear-algebra/3d.ts index 0f998a1260911d79c9d688b56a8126099a7e0bab..fccdb52b784f181d6d856963f875940a96447646 100644 --- a/src/mol-base/math/linear-algebra-3d.ts +++ b/src/mol-math/linear-algebra/3d.ts @@ -77,7 +77,7 @@ export namespace Mat4 { mat[15] = 1; return mat; } - + export function ofRows(rows: number[][]): Mat4 { const out = zero(); for (let i = 0; i < 4; i++) { @@ -89,11 +89,14 @@ export namespace Mat4 { return out; } + const _id = identity(); + export function isIdentity(m: Mat4, eps?: number) { + return areEqual(m, _id, typeof eps === 'undefined' ? EPSILON.Value : eps); + } + export function areEqual(a: Mat4, b: Mat4, eps: number) { for (let i = 0; i < 16; i++) { - if (Math.abs(a[i] - b[i]) > eps) { - return false; - } + if (Math.abs(a[i] - b[i]) > eps) return false; } return true; } diff --git a/src/mol-base/math/_spec/tensor.spec.ts b/src/mol-math/linear-algebra/_spec/tensor.spec.ts similarity index 98% rename from src/mol-base/math/_spec/tensor.spec.ts rename to src/mol-math/linear-algebra/_spec/tensor.spec.ts index 0d4541121b13bbd26a3b0dae874f54e67e5f0aa6..7a1780d1d12551f07b51719c99c1d25863457bc0 100644 --- a/src/mol-base/math/_spec/tensor.spec.ts +++ b/src/mol-math/linear-algebra/_spec/tensor.spec.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import T from '../tensor' -import { Mat4 } from '../linear-algebra-3d' +import { Tensor as T } from '../tensor' +import { Mat4 } from '../3d' describe('tensor', () => { it('vector', () => { diff --git a/src/mol-base/math/tensor.ts b/src/mol-math/linear-algebra/tensor.ts similarity index 82% rename from src/mol-base/math/tensor.ts rename to src/mol-math/linear-algebra/tensor.ts index d77c82b054ef106fcaaa57c4ac2c6e3fd7165ede..e5a872b9ed58f71a8b4acb992bfbd822cb58275b 100644 --- a/src/mol-base/math/tensor.ts +++ b/src/mol-math/linear-algebra/tensor.ts @@ -4,9 +4,11 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -interface Tensor extends Array<number> { '@type': 'tensor' } +import { Mat4, Vec3, Vec4 } from './3d' -namespace Tensor { +export interface Tensor extends Array<number> { '@type': 'tensor' } + +export namespace Tensor { export type ArrayCtor = { new (size: number): ArrayLike<number> } export interface Space { @@ -47,6 +49,32 @@ namespace Tensor { export function ColumnMajorMatrix(rows: number, cols: number, ctor?: ArrayCtor) { return Space([rows, cols], [1, 0], ctor); } export function RowMajorMatrix(rows: number, cols: number, ctor?: ArrayCtor) { return Space([rows, cols], [0, 1], ctor); } + export function toMat4(space: Space, data: Tensor): Mat4 { + if (space.rank !== 2) throw new Error('Invalid tensor rank'); + const mat = Mat4.zero(); + const d0 = Math.min(4, space.dimensions[0]), d1 = Math.min(4, space.dimensions[1]); + for (let i = 0; i < d0; i++) { + for (let j = 0; j < d1; j++) Mat4.setValue(mat, i, j, space.get(data, i, j)); + } + return mat; + } + + export function toVec3(space: Space, data: Tensor): Vec3 { + if (space.rank !== 1) throw new Error('Invalid tensor rank'); + const vec = Vec3.zero(); + const d0 = Math.min(3, space.dimensions[0]); + for (let i = 0; i < d0; i++) vec[i] = data[i]; + return vec; + } + + export function toVec4(space: Space, data: Tensor): Vec4 { + if (space.rank !== 1) throw new Error('Invalid tensor rank'); + const vec = Vec4.zero(); + const d0 = Math.min(4, space.dimensions[0]); + for (let i = 0; i < d0; i++) vec[i] = data[i]; + return vec; + } + function accessors(layout: Layout): { get: Space['get'], set: Space['set'] } { const { dimensions, axisOrderFastToSlow: ao } = layout; switch (dimensions.length) { @@ -113,6 +141,4 @@ namespace Tensor { } return o; } -} - -export default Tensor \ No newline at end of file +} \ No newline at end of file diff --git a/src/mol-data/sequence/TODO b/src/mol-model/sequence/TODO similarity index 100% rename from src/mol-data/sequence/TODO rename to src/mol-model/sequence/TODO diff --git a/src/mol-data/structure.ts b/src/mol-model/structure.ts similarity index 100% rename from src/mol-data/structure.ts rename to src/mol-model/structure.ts diff --git a/src/mol-data/structure/_spec/atom-set.spec.ts b/src/mol-model/structure/_spec/atom-set.spec.ts similarity index 99% rename from src/mol-data/structure/_spec/atom-set.spec.ts rename to src/mol-model/structure/_spec/atom-set.spec.ts index 03ca325564fc49352c421ae63adbf90472d7372f..d77dd5e869d41acd27f28c0f32ecaeb70525816d 100644 --- a/src/mol-data/structure/_spec/atom-set.spec.ts +++ b/src/mol-model/structure/_spec/atom-set.spec.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { OrderedSet } from 'mol-base/collections/integer' +import { OrderedSet } from 'mol-data/int' import AtomSet from '../structure/atom/set' import Atom from '../structure/atom' diff --git a/src/mol-data/structure/export/mmcif.ts b/src/mol-model/structure/export/mmcif.ts similarity index 98% rename from src/mol-data/structure/export/mmcif.ts rename to src/mol-model/structure/export/mmcif.ts index 64d86d66cc87ad7d915e7a9f5e6a6860c93f3476..c5cf31063374776b59d5030fd9a729c0642794aa 100644 --- a/src/mol-data/structure/export/mmcif.ts +++ b/src/mol-model/structure/export/mmcif.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, Table } from 'mol-base/collections/database' -import Iterator from 'mol-base/collections/iterator' +import { Column, Table } from 'mol-data/db' +import Iterator from 'mol-data/iterator' import * as Encoder from 'mol-io/writer/cif' //import { mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif' import { Structure, Atom, AtomSet } from '../structure' diff --git a/src/mol-data/structure/model.ts b/src/mol-model/structure/model.ts similarity index 100% rename from src/mol-data/structure/model.ts rename to src/mol-model/structure/model.ts diff --git a/src/mol-data/structure/model/format.ts b/src/mol-model/structure/model/format.ts similarity index 100% rename from src/mol-data/structure/model/format.ts rename to src/mol-model/structure/model/format.ts diff --git a/src/mol-data/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts similarity index 96% rename from src/mol-data/structure/model/formats/mmcif.ts rename to src/mol-model/structure/model/formats/mmcif.ts index 7c0d947e6f5566c1600e460d9ca200381f1979ee..24b91ee4075c5f519fe227e10081853e7e87bc29 100644 --- a/src/mol-data/structure/model/formats/mmcif.ts +++ b/src/mol-model/structure/model/formats/mmcif.ts @@ -4,9 +4,9 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { newUUID } from 'mol-base/utils/uuid' -import { Column, Table } from 'mol-base/collections/database' -import { Interval, Segmentation } from 'mol-base/collections/integer' +import UUID from 'mol-util/uuid' +import { Column, Table } from 'mol-data/db' +import { Interval, Segmentation } from 'mol-data/int' import Format from '../format' import Model from '../model' import * as Hierarchy from '../properties/hierarchy' @@ -66,7 +66,7 @@ function getConformation({ data }: mmCIF_Format, bounds: Interval): Conformation const start = Interval.start(bounds), end = Interval.end(bounds); const { atom_site } = data; return { - id: newUUID(), + id: UUID.create(), atomId: Column.window(atom_site.id, start, end), occupancy: Column.window(atom_site.occupancy, start, end), B_iso_or_equiv: Column.window(atom_site.B_iso_or_equiv, start, end), @@ -100,7 +100,7 @@ function createModel(format: mmCIF_Format, bounds: Interval, previous?: Model): } const hierarchyKeys = findHierarchyKeys(hierarchyData, hierarchySegments); return { - id: newUUID(), + id: UUID.create(), sourceData: format, modelNum: format.data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)), hierarchy: { ...hierarchyData, ...hierarchyKeys, ...hierarchySegments }, diff --git a/src/mol-data/structure/model/model.ts b/src/mol-model/structure/model/model.ts similarity index 95% rename from src/mol-data/structure/model/model.ts rename to src/mol-model/structure/model/model.ts index c393d2452c0d7fdf18a75ab236a7ce50ee39950d..c7a33db549de634b695c23a9baadc7ab5a4842f9 100644 --- a/src/mol-data/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import UUID from 'mol-base/utils/uuid' +import UUID from 'mol-util/uuid' import Format from './format' import HierarchyProperties from './properties/hierarchy' import ConformationProperties from './properties/conformation' diff --git a/src/mol-data/structure/model/properties/computed.ts b/src/mol-model/structure/model/properties/computed.ts similarity index 100% rename from src/mol-data/structure/model/properties/computed.ts rename to src/mol-model/structure/model/properties/computed.ts diff --git a/src/mol-data/structure/model/properties/conformation.ts b/src/mol-model/structure/model/properties/conformation.ts similarity index 88% rename from src/mol-data/structure/model/properties/conformation.ts rename to src/mol-model/structure/model/properties/conformation.ts index c53ab084438e65b141a1ba6d85256cf2ed981641..66a975d62bf73b3b17c7873544fea784a959a04f 100644 --- a/src/mol-data/structure/model/properties/conformation.ts +++ b/src/mol-model/structure/model/properties/conformation.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' -import UUID from 'mol-base/utils/uuid' +import { Column } from 'mol-data/db' +import UUID from 'mol-util/uuid' interface Conformation { id: UUID, diff --git a/src/mol-data/structure/model/properties/format-specific.ts b/src/mol-model/structure/model/properties/format-specific.ts similarity index 100% rename from src/mol-data/structure/model/properties/format-specific.ts rename to src/mol-model/structure/model/properties/format-specific.ts diff --git a/src/mol-data/structure/model/properties/hierarchy.ts b/src/mol-model/structure/model/properties/hierarchy.ts similarity index 95% rename from src/mol-data/structure/model/properties/hierarchy.ts rename to src/mol-model/structure/model/properties/hierarchy.ts index a19de7fd550a66a8c9a089faa4447c611152e8e2..f3bec187d217ec148e5833b8ee198970eb038487 100644 --- a/src/mol-data/structure/model/properties/hierarchy.ts +++ b/src/mol-model/structure/model/properties/hierarchy.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column, Table } from 'mol-base/collections/database' -import { Segmentation } from 'mol-base/collections/integer' +import { Column, Table } from 'mol-data/db' +import { Segmentation } from 'mol-data/int' import { mmCIF_Schema as mmCIF } from 'mol-io/reader/cif/schema/mmcif' import { ElementSymbol} from '../types' diff --git a/src/mol-data/structure/model/properties/transforms.ts b/src/mol-model/structure/model/properties/transforms.ts similarity index 100% rename from src/mol-data/structure/model/properties/transforms.ts rename to src/mol-model/structure/model/properties/transforms.ts diff --git a/src/mol-data/structure/model/types.ts b/src/mol-model/structure/model/types.ts similarity index 99% rename from src/mol-data/structure/model/types.ts rename to src/mol-model/structure/model/types.ts index 4a90f04c90e1d50e539ca8c7e19b2e208b404e18..d105c1f81c8e0e59ea64430ae12e815bc71a2a28 100644 --- a/src/mol-data/structure/model/types.ts +++ b/src/mol-model/structure/model/types.ts @@ -5,7 +5,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import BitFlags from 'mol-base/utils/bit-flags' +import BitFlags from 'mol-util/bit-flags' const _esCache = (function () { const cache = Object.create(null); diff --git a/src/mol-data/structure/model/utils/hierarchy-keys.ts b/src/mol-model/structure/model/utils/hierarchy-keys.ts similarity index 97% rename from src/mol-data/structure/model/utils/hierarchy-keys.ts rename to src/mol-model/structure/model/utils/hierarchy-keys.ts index cc0f4821a2fd7cab9a573d58179205c562a5cc04..c09484245f80c577b7a948624a56cc469be9adc5 100644 --- a/src/mol-data/structure/model/utils/hierarchy-keys.ts +++ b/src/mol-model/structure/model/utils/hierarchy-keys.ts @@ -4,9 +4,9 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Column } from 'mol-base/collections/database' +import { Column } from 'mol-data/db' import { Data, Segments, Keys } from '../properties/hierarchy' -import { Interval, Segmentation } from 'mol-base/collections/integer' +import { Interval, Segmentation } from 'mol-data/int' function getResidueId(comp_id: string, seq_id: number, ins_code: string) { return `${comp_id} ${seq_id} ${ins_code}`; diff --git a/src/mol-data/structure/query.ts b/src/mol-model/structure/query.ts similarity index 100% rename from src/mol-data/structure/query.ts rename to src/mol-model/structure/query.ts diff --git a/src/mol-data/structure/query/generators.ts b/src/mol-model/structure/query/generators.ts similarity index 99% rename from src/mol-data/structure/query/generators.ts rename to src/mol-model/structure/query/generators.ts index 5846eee6bedd620b6698b6c56946edcb8ce39aaa..12d43abc4ef8c40f3b0f44735a3fbc4e58d9030c 100644 --- a/src/mol-data/structure/query/generators.ts +++ b/src/mol-model/structure/query/generators.ts @@ -8,7 +8,7 @@ import Query from './query' import Selection from './selection' import P from './properties' import { Structure, AtomSet, Atom } from '../structure' -import { OrderedSet, Segmentation } from 'mol-base/collections/integer' +import { OrderedSet, Segmentation } from 'mol-data/int' export const all: Query = s => s; diff --git a/src/mol-data/structure/query/predicates.ts b/src/mol-model/structure/query/predicates.ts similarity index 100% rename from src/mol-data/structure/query/predicates.ts rename to src/mol-model/structure/query/predicates.ts diff --git a/src/mol-data/structure/query/properties.ts b/src/mol-model/structure/query/properties.ts similarity index 100% rename from src/mol-data/structure/query/properties.ts rename to src/mol-model/structure/query/properties.ts diff --git a/src/mol-data/structure/query/query.ts b/src/mol-model/structure/query/query.ts similarity index 100% rename from src/mol-data/structure/query/query.ts rename to src/mol-model/structure/query/query.ts diff --git a/src/mol-data/structure/query/selection.ts b/src/mol-model/structure/query/selection.ts similarity index 97% rename from src/mol-data/structure/query/selection.ts rename to src/mol-model/structure/query/selection.ts index 57700f93130819e001a66dd4ebb1b7f051426fee..8504e425237b3761fdb7c3704aef40f3b8fd1432 100644 --- a/src/mol-data/structure/query/selection.ts +++ b/src/mol-model/structure/query/selection.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Iterator from 'mol-base/collections/iterator' -import HashSet from 'mol-base/collections/hash-set' +import Iterator from 'mol-data/iterator' +import HashSet from 'mol-data/util/hash-set' import { Structure, Atom, AtomSet } from '../structure' type Selection = diff --git a/src/mol-data/structure/structure.ts b/src/mol-model/structure/structure.ts similarity index 100% rename from src/mol-data/structure/structure.ts rename to src/mol-model/structure/structure.ts diff --git a/src/mol-data/structure/structure/atom.ts b/src/mol-model/structure/structure/atom.ts similarity index 96% rename from src/mol-data/structure/structure/atom.ts rename to src/mol-model/structure/structure/atom.ts index ef57e121f1dcd12cfc0e67e8598dd9af0c268da8..217bbb1eb581c5d869c3c91f70d100e8c598fa8f 100644 --- a/src/mol-data/structure/structure/atom.ts +++ b/src/mol-model/structure/structure/atom.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Tuple } from 'mol-base/collections/integer' +import { Tuple } from 'mol-data/int' import Unit from './unit' import Structure from './structure' diff --git a/src/mol-data/structure/structure/atom/set.ts b/src/mol-model/structure/structure/atom/set.ts similarity index 96% rename from src/mol-data/structure/structure/atom/set.ts rename to src/mol-model/structure/structure/atom/set.ts index 6abe38108e98014014ece3185f83d18554de0560..3ce250e2477c195d6fa10ed29b12e7dd21c06371 100644 --- a/src/mol-data/structure/structure/atom/set.ts +++ b/src/mol-model/structure/structure/atom/set.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { OrderedSet, SortedArray, Iterator } from 'mol-base/collections/integer' +import { OrderedSet, SortedArray, Iterator } from 'mol-data/int' import Atom from '../atom' import * as Impl from './set/impl' import createBuilder, { Builder as AtomSetBuilder } from './set/builder' diff --git a/src/mol-data/structure/structure/atom/set/builder.ts b/src/mol-model/structure/structure/atom/set/builder.ts similarity index 95% rename from src/mol-data/structure/structure/atom/set/builder.ts rename to src/mol-model/structure/structure/atom/set/builder.ts index bf756939e99e700d0e504770b1d3f11eb41177b2..fdda1a1c5c0d658c19f93d84953122abd276a08d 100644 --- a/src/mol-data/structure/structure/atom/set/builder.ts +++ b/src/mol-model/structure/structure/atom/set/builder.ts @@ -6,8 +6,8 @@ import AtomSet from '../set' import Atom from '../../atom' -import { OrderedSet } from 'mol-base/collections/integer' -import { sortArray } from 'mol-base/collections/sort' +import { OrderedSet } from 'mol-data/int' +import { sortArray } from 'mol-data/util/sort' export class Builder { private keys: number[] = []; diff --git a/src/mol-data/structure/structure/atom/set/impl.ts b/src/mol-model/structure/structure/atom/set/impl.ts similarity index 99% rename from src/mol-data/structure/structure/atom/set/impl.ts rename to src/mol-model/structure/structure/atom/set/impl.ts index 8c0f2bcd4dfec8e3a2f57ecc92436254b19c2470..f60658f1f7ee283061f8cdd662811d714efdc804 100644 --- a/src/mol-data/structure/structure/atom/set/impl.ts +++ b/src/mol-model/structure/structure/atom/set/impl.ts @@ -4,9 +4,9 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { SortedArray, Interval, Iterator, OrderedSet } from 'mol-base/collections/integer' -import { sortArray } from 'mol-base/collections/sort' -import { hash1 } from 'mol-base/collections/hash-functions' +import { SortedArray, Interval, Iterator, OrderedSet } from 'mol-data/int' +import { sortArray } from 'mol-data/util/sort' +import { hash1 } from 'mol-data/util/hash-functions' import Atom from '../../atom' /** Long and painful implementation starts here */ diff --git a/src/mol-data/structure/structure/atom/set/properties.ts b/src/mol-model/structure/structure/atom/set/properties.ts similarity index 100% rename from src/mol-data/structure/structure/atom/set/properties.ts rename to src/mol-model/structure/structure/atom/set/properties.ts diff --git a/src/mol-data/structure/structure/operator.ts b/src/mol-model/structure/structure/operator.ts similarity index 91% rename from src/mol-data/structure/structure/operator.ts rename to src/mol-model/structure/structure/operator.ts index e6fc2fd2f5aadfd7b715f8bf71d63ce559084b41..10ba47cb8c94e46f587f5e39cb7958e980d2bcbb 100644 --- a/src/mol-data/structure/structure/operator.ts +++ b/src/mol-model/structure/structure/operator.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Mat4 } from 'mol-base/math/linear-algebra-3d' +import { Mat4 } from 'mol-math/linear-algebra' interface Operator extends Readonly<{ name: string, diff --git a/src/mol-data/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts similarity index 95% rename from src/mol-data/structure/structure/structure.ts rename to src/mol-model/structure/structure/structure.ts index 9b6c647206fd5cab2f751c0a0248dd0321b7a6ed..0d09fa4db4b252e52620feaac8050b1c1fb60aea 100644 --- a/src/mol-data/structure/structure/structure.ts +++ b/src/mol-model/structure/structure/structure.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { OrderedSet, Iterator } from 'mol-base/collections/integer' -import UniqueArray from 'mol-base/collections/unique-array' +import { OrderedSet, Iterator } from 'mol-data/int' +import UniqueArray from 'mol-data/util/unique-array' import { Model, Format } from '../model' import Unit from './unit' import Operator from './operator' diff --git a/src/mol-data/structure/structure/unit.ts b/src/mol-model/structure/structure/unit.ts similarity index 98% rename from src/mol-data/structure/structure/unit.ts rename to src/mol-model/structure/structure/unit.ts index b58145ca2d4ed29d25f0cabd1cfaceca6e62c5d6..c819836d99d6fe8e471ded60f6509d6c6dcf04b5 100644 --- a/src/mol-data/structure/structure/unit.ts +++ b/src/mol-model/structure/structure/unit.ts @@ -6,7 +6,7 @@ import { Model } from '../model' import Operator from './operator' -import { Vec3, Mat4 } from 'mol-base/math/linear-algebra-3d' +import { Vec3, Mat4 } from 'mol-math/linear-algebra' interface Unit extends Readonly<{ // Structure-level unique identifier of the unit. diff --git a/src/mol-data/volume/TODO b/src/mol-model/volume/TODO similarity index 100% rename from src/mol-data/volume/TODO rename to src/mol-model/volume/TODO diff --git a/src/mol-base/utils/_spec/string-builder.spec.ts b/src/mol-util/_spec/string-builder.spec.ts similarity index 100% rename from src/mol-base/utils/_spec/string-builder.spec.ts rename to src/mol-util/_spec/string-builder.spec.ts diff --git a/src/mol-base/utils/bit-flags.ts b/src/mol-util/bit-flags.ts similarity index 100% rename from src/mol-base/utils/bit-flags.ts rename to src/mol-util/bit-flags.ts diff --git a/src/mol-base/computation.ts b/src/mol-util/computation.ts similarity index 99% rename from src/mol-base/computation.ts rename to src/mol-util/computation.ts index d81b970a9f367527f6a03b28f0d2e30d9807b5b9..6bafb7a99b7159cc6fa0edc65554b86ab32e8458 100644 --- a/src/mol-base/computation.ts +++ b/src/mol-util/computation.ts @@ -5,8 +5,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Scheduler from './utils/scheduler' -import timeNow from './utils/time' +import Scheduler from './scheduler' +import timeNow from './time' interface Computation<A> { (ctx?: Computation.Context): Promise<A> diff --git a/src/mol-util/index.ts b/src/mol-util/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..18a0aa3cd809aab11fc83dfe015e3d99cf98c3f8 --- /dev/null +++ b/src/mol-util/index.ts @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +import BitFlags from './bit-flags' +import Computation from './computation' +import Scheduler from './scheduler' +import StringBuilder from './string-builder' +import Time from './time' +import UUID from './uuid' + +export { BitFlags, Computation, Scheduler, StringBuilder, Time, UUID } \ No newline at end of file diff --git a/src/mol-base/utils/scheduler.ts b/src/mol-util/scheduler.ts similarity index 100% rename from src/mol-base/utils/scheduler.ts rename to src/mol-util/scheduler.ts diff --git a/src/mol-base/utils/string-builder.ts b/src/mol-util/string-builder.ts similarity index 100% rename from src/mol-base/utils/string-builder.ts rename to src/mol-util/string-builder.ts diff --git a/src/mol-base/utils/time.ts b/src/mol-util/time.ts similarity index 100% rename from src/mol-base/utils/time.ts rename to src/mol-util/time.ts diff --git a/src/mol-util/uuid.ts b/src/mol-util/uuid.ts new file mode 100644 index 0000000000000000000000000000000000000000..471d349695e2ff619c8166a5066fbffc539ef652 --- /dev/null +++ b/src/mol-util/uuid.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +import now from './time' + +interface UUID extends String { '@type': 'uuid' } + +namespace UUID { + export function create(): UUID { + let d = (+new Date()) + now(); + const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = (d + Math.random()*16)%16 | 0; + d = Math.floor(d/16); + return (c==='x' ? r : (r&0x3|0x8)).toString(16); + }); + return uuid as any; + } +} + +export default UUID; \ No newline at end of file diff --git a/src/perf-tests/chunked-array-vs-native.ts b/src/perf-tests/chunked-array-vs-native.ts index 80fc3ff315971167819c67e74e7bc83bafac8afb..1b145425d76503a02dcd3e6ddad59d9496273707 100644 --- a/src/perf-tests/chunked-array-vs-native.ts +++ b/src/perf-tests/chunked-array-vs-native.ts @@ -1,5 +1,5 @@ import * as B from 'benchmark' -import ChunkedArray from 'mol-base/collections/chunked-array' +import ChunkedArray from 'mol-data/util/chunked-array' function testNative(size: number) { const xs = new Array(size); diff --git a/src/perf-tests/cif-encoder.ts b/src/perf-tests/cif-encoder.ts index 2b1193e3e0395bef22053cea2fc9ec86e5332db4..5f22508252cf5991273ced66326491b48f587b86 100644 --- a/src/perf-tests/cif-encoder.ts +++ b/src/perf-tests/cif-encoder.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Iterator from 'mol-base/collections/iterator' +import Iterator from 'mol-data/iterator' import * as Enc from 'mol-io/writer/cif' const category1: Enc.CategoryDefinition<number> = { diff --git a/src/perf-tests/column.ts b/src/perf-tests/column.ts index 0232e28e0e638798b61744746d46af1b8267d4b0..88ad89b351094374c876a1471a1a8f54e746c720 100644 --- a/src/perf-tests/column.ts +++ b/src/perf-tests/column.ts @@ -1,5 +1,5 @@ import * as B from 'benchmark' -import { Column as C } from 'mol-base/collections/database' +import { Column as C } from 'mol-data/db' export namespace Column { function createData(n: number) { diff --git a/src/perf-tests/iterators.ts b/src/perf-tests/iterators.ts index c980363089c6118fc555301f8abe3a55bf0ed0b5..a08ad0fc5279542b0f46023845904c0e59deb070 100644 --- a/src/perf-tests/iterators.ts +++ b/src/perf-tests/iterators.ts @@ -1,5 +1,5 @@ import * as B from 'benchmark' -import It from 'mol-base/collections/iterator' +import It from 'mol-data/iterator' function createData(n: number) { const data = [];//new Int32Array(n); diff --git a/src/perf-tests/sets.ts b/src/perf-tests/sets.ts index 76d8c03c7b003c8bd6ae9d38b65ab4ea8b9bb8fb..699c9037cafc14c7502954b09df33cee123854d4 100644 --- a/src/perf-tests/sets.ts +++ b/src/perf-tests/sets.ts @@ -1,6 +1,6 @@ import * as B from 'benchmark' -import { Tuple, Segmentation, OrderedSet as OrdSet } from 'mol-base/collections/integer' -import { AtomSet } from 'mol-data/structure/structure' +import { Tuple, Segmentation, OrderedSet as OrdSet } from 'mol-data/int' +import { AtomSet } from 'mol-model/structure' export namespace Iteration { const U = 1000, V = 2500; diff --git a/src/perf-tests/sort.ts b/src/perf-tests/sort.ts index d4461e91eae6caea4605ac52afdd9513654e8793..2c136f83e9d6ae53a69624c369e2e4cd7b33d1f2 100644 --- a/src/perf-tests/sort.ts +++ b/src/perf-tests/sort.ts @@ -1,5 +1,5 @@ import * as B from 'benchmark' -import * as Sort from 'mol-base/collections/sort' +import * as Sort from 'mol-data/util' function shuffle(a: number[]) { for (let i = a.length - 1; i > 0; i--) { diff --git a/src/perf-tests/string-builder.ts b/src/perf-tests/string-builder.ts index 41b269c5064c6e8da1c018f2a76d2c4c684dfc6d..fa73eb6004622dfb141488d4dc0ac9b49b9eea71 100644 --- a/src/perf-tests/string-builder.ts +++ b/src/perf-tests/string-builder.ts @@ -1,5 +1,5 @@ import * as B from 'benchmark' -import SB from 'mol-base/utils/string-builder' +import SB from 'mol-util/string-builder' export namespace Test { function createData(n: number) { diff --git a/src/perf-tests/structure.ts b/src/perf-tests/structure.ts index 801a98c7951f31b3b68ab1d98c62a99b7a7dda3c..62c780e59418929245801c1a19cda96e74ed4713 100644 --- a/src/perf-tests/structure.ts +++ b/src/perf-tests/structure.ts @@ -10,10 +10,10 @@ import * as util from 'util' import * as fs from 'fs' import CIF from 'mol-io/reader/cif' -import { Structure, Model, Queries as Q, Atom, AtomSet, Selection } from 'mol-data/structure' -import { OrderedSet as OrdSet, Segmentation } from 'mol-base/collections/integer' +import { Structure, Model, Queries as Q, Atom, AtomSet, Selection } from 'mol-model/structure' +import { OrderedSet as OrdSet, Segmentation } from 'mol-data/int' -import to_mmCIF from 'mol-data/structure/export/mmcif' +import to_mmCIF from 'mol-model/structure/export/mmcif' require('util.promisify').shim(); const readFileAsync = util.promisify(fs.readFile); diff --git a/src/script.ts b/src/script.ts index 05b1c962baec312b290d00d099f0cb1aac8c44f9..03c5d970ae0e3540eecf67b85967d1af0ecad3fa 100644 --- a/src/script.ts +++ b/src/script.ts @@ -15,9 +15,9 @@ const writeFileAsync = util.promisify(fs.writeFile); import Gro from 'mol-io/reader/gro/parser' import CIF from 'mol-io/reader/cif' -import Computation from 'mol-base/computation' +import Computation from 'mol-util/computation' -import { Model } from 'mol-data/structure/model' +import { Model } from 'mol-model/structure' // import { toTypedFrame as applySchema } from './reader/cif/schema' import { generateSchema } from 'mol-io/reader/cif/schema/utils' diff --git a/tsconfig.json b/tsconfig.json index d25a818883fa84ccdfe2aba4c5f5372cfa738fb9..c90e01741681c4b27613733792f8ef82c91bd6c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,9 +13,11 @@ "outDir": "build/node_modules", "baseUrl": "src", "paths": { - "mol-base": ["./mol-base"], - "mol-data": ["./mol-data"], - "mol-io": ["./mol-io"] + "mol-util": ["./mol-util", "./mol-util/index.ts"], + "mol-data": ["./mol-data", "./mol-data/index.ts"], + "mol-math": ["./mol-math"], + "mol-io": ["./mol-io"], + "mol-model": ["./mol-model"] } }, "include": [ "**/*" ]