Browse Source

more refactoring

David Sehnal 7 years ago
parent
commit
801e1ef035
32 changed files with 96 additions and 97 deletions
  1. 0 0
      src/mol-data/sequence/TODO
  2. 0 13
      src/mol-data/structure.ts
  3. 1 1
      src/mol-data/structure/_spec/atom-set.spec.ts
  4. 0 0
      src/mol-data/structure/model.ts
  5. 4 5
      src/mol-data/structure/model/builders/mmcif.ts
  6. 1 1
      src/mol-data/structure/model/constants.ts
  7. 1 1
      src/mol-data/structure/model/data-format.ts
  8. 1 1
      src/mol-data/structure/model/model.ts
  9. 0 0
      src/mol-data/structure/model/properties/computed.ts
  10. 2 2
      src/mol-data/structure/model/properties/conformation.ts
  11. 0 0
      src/mol-data/structure/model/properties/format-specific.ts
  12. 4 4
      src/mol-data/structure/model/properties/hierarchy.ts
  13. 0 0
      src/mol-data/structure/model/properties/transforms.ts
  14. 2 2
      src/mol-data/structure/model/utils/hierarchy-keys.ts
  15. 0 0
      src/mol-data/structure/query.ts
  16. 1 1
      src/mol-data/structure/query/generators.ts
  17. 0 0
      src/mol-data/structure/query/properties.ts
  18. 0 0
      src/mol-data/structure/query/query.ts
  19. 2 2
      src/mol-data/structure/query/selection.ts
  20. 6 51
      src/mol-data/structure/structure.ts
  21. 1 1
      src/mol-data/structure/structure/atom.ts
  22. 1 1
      src/mol-data/structure/structure/atom/set.ts
  23. 2 2
      src/mol-data/structure/structure/atom/set/builder.ts
  24. 3 3
      src/mol-data/structure/structure/atom/set/impl.ts
  25. 0 0
      src/mol-data/structure/structure/atom/set/properties.ts
  26. 1 1
      src/mol-data/structure/structure/operator.ts
  27. 58 0
      src/mol-data/structure/structure/structure.ts
  28. 0 0
      src/mol-data/structure/structure/unit.ts
  29. 0 0
      src/mol-data/volume/TODO
  30. 1 1
      src/perf-tests/sets.ts
  31. 3 3
      src/perf-tests/structure.ts
  32. 1 1
      src/script.ts

+ 0 - 0
src/mol-data/sequence/TODO


+ 0 - 13
src/mol-data/structure.ts

@@ -1,13 +0,0 @@
-/**
- * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-import Atom from './structure/atom'
-import AtomSet from './structure/atom/set'
-import Structure from './structure/structure'
-import Operator from './structure/operator'
-import Unit from './structure/unit'
-
-export { Atom, AtomSet, Structure, Operator, Unit }

+ 1 - 1
src/mol-data/_spec/atom-set.spec.ts → src/mol-data/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-base/collections/integer'
 import AtomSet from '../structure/atom/set'
 import Atom from '../structure/atom'
 

+ 0 - 0
src/mol-data/model.ts → src/mol-data/structure/model.ts


+ 4 - 5
src/mol-data/model/builders/mmcif.ts → src/mol-data/structure/model/builders/mmcif.ts

@@ -5,12 +5,11 @@
  */
 
 import { mmCIF } from '../data-format'
-//import { Frame as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif'
 import Model from '../model'
-import Column from '../../../mol-base/collections/column'
-import Table from '../../../mol-base/collections/table'
-import { Interval, Segmentation } from '../../../mol-base/collections/integer'
-import { newUUID } from '../../../mol-base/utils/uuid'
+import Column from '../../../../mol-base/collections/column'
+import Table from '../../../../mol-base/collections/table'
+import { Interval, Segmentation } from '../../../../mol-base/collections/integer'
+import { newUUID } from '../../../../mol-base/utils/uuid'
 import * as Hierarchy from '../properties/hierarchy'
 import Conformation from '../properties/conformation'
 import findHierarchyKeys from '../utils/hierarchy-keys'

+ 1 - 1
src/mol-data/model/constants.ts → src/mol-data/structure/model/constants.ts

@@ -5,7 +5,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import BitFlags from '../../mol-base/utils/bit-flags'
+import BitFlags from '../../../mol-base/utils/bit-flags'
 
 export const enum EntityType {
     Unknown = 'unknown',

+ 1 - 1
src/mol-data/model/data-format.ts → src/mol-data/structure/model/data-format.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Frame as mmCIF_Frame } from '../../mol-io/reader/cif/schema/mmcif'
+import { Frame as mmCIF_Frame } from '../../../mol-io/reader/cif/schema/mmcif'
 
 export interface mmCIF { kind: 'mmCIF', data: mmCIF_Frame }
 

+ 1 - 1
src/mol-data/model/model.ts → src/mol-data/structure/model/model.ts

@@ -7,7 +7,7 @@
 import DataFormat from './data-format'
 import HierarchyProperties from './properties/hierarchy'
 import ConformationProperties from './properties/conformation'
-import UUID from '../../mol-base/utils/uuid'
+import UUID from '../../../mol-base/utils/uuid'
 
 import buildMmCIF from './builders/mmcif'
 

+ 0 - 0
src/mol-data/model/properties/computed.ts → src/mol-data/structure/model/properties/computed.ts


+ 2 - 2
src/mol-data/model/properties/conformation.ts → src/mol-data/structure/model/properties/conformation.ts

@@ -4,8 +4,8 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import Column from '../../../mol-base/collections/column'
-import UUID from '../../../mol-base/utils/uuid'
+import Column from '../../../../mol-base/collections/column'
+import UUID from '../../../../mol-base/utils/uuid'
 
 interface Conformation {
     id: UUID,

+ 0 - 0
src/mol-data/model/properties/format-specific.ts → src/mol-data/structure/model/properties/format-specific.ts


+ 4 - 4
src/mol-data/model/properties/hierarchy.ts → src/mol-data/structure/model/properties/hierarchy.ts

@@ -4,10 +4,10 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import Column from '../../../mol-base/collections/column'
-import Table from '../../../mol-base/collections/table'
-import { Segmentation } from '../../../mol-base/collections/integer'
-import { Schema as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif'
+import Column from '../../../../mol-base/collections/column'
+import Table from '../../../../mol-base/collections/table'
+import { Segmentation } from '../../../../mol-base/collections/integer'
+import { Schema as mmCIF } from '../../../../mol-io/reader/cif/schema/mmcif'
 
 const _esCache = Object.create(null);
 export interface ElementSymbol extends String { '@type': 'element-symbol' }

+ 0 - 0
src/mol-data/model/properties/transforms.ts → src/mol-data/structure/model/properties/transforms.ts


+ 2 - 2
src/mol-data/model/utils/hierarchy-keys.ts → src/mol-data/structure/model/utils/hierarchy-keys.ts

@@ -4,9 +4,9 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import Column from '../../../mol-base/collections/column'
+import Column from '../../../../mol-base/collections/column'
 import { Data, Segments, Keys } from '../properties/hierarchy'
-import { Interval, Segmentation } from '../../../mol-base/collections/integer'
+import { Interval, Segmentation } from '../../../../mol-base/collections/integer'
 
 function getResidueId(comp_id: string, seq_id: number, ins_code: string) {
     return `${comp_id} ${seq_id} ${ins_code}`;

+ 0 - 0
src/mol-data/query.ts → src/mol-data/structure/query.ts


+ 1 - 1
src/mol-data/query/generators.ts → src/mol-data/structure/query/generators.ts

@@ -8,7 +8,7 @@ import Query from './query'
 //import Selection from './selection'
 import * as P from './properties'
 import { AtomSet, Atom } from '../structure'
-import { OrderedSet } from '../../mol-base/collections/integer'
+import { OrderedSet } from '../../../mol-base/collections/integer'
 
 export interface AtomGroupsSpec {
     entityTest: Atom.Predicate,

+ 0 - 0
src/mol-data/query/properties.ts → src/mol-data/structure/query/properties.ts


+ 0 - 0
src/mol-data/query/query.ts → src/mol-data/structure/query/query.ts


+ 2 - 2
src/mol-data/query/selection.ts → src/mol-data/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-base/collections/iterator'
+import HashSet from '../../../mol-base/collections/hash-set'
 import { Structure, Atom, AtomSet } from '../structure'
 
 type Selection =

+ 6 - 51
src/mol-data/structure/structure.ts

@@ -4,55 +4,10 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Model } from '../model'
-import Unit from './unit'
-import Operator from './operator'
-import AtomSet from './atom/set'
-import { OrderedSet } from '../../mol-base/collections/integer'
+import Atom from './structure/atom'
+import AtomSet from './structure/atom/set'
+import Structure from './structure/structure'
+import Operator from './structure/operator'
+import Unit from './structure/unit'
 
-interface Structure extends Readonly<{
-    units: { readonly [id: number]: Unit },
-    atoms: AtomSet
-}> { }
-
-namespace Structure {
-    export const Empty = { units: {}, atoms: AtomSet.Empty };
-
-    export function ofModel(model: Model): Structure {
-        const chains = model.hierarchy.chainSegments;
-        const builder = Builder();
-
-        for (let c = 0; c < chains.count; c++) {
-            const unit = Unit.create(model, Operator.Identity);
-            builder.addUnit(unit);
-            builder.addAtoms(unit.id, OrderedSet.ofBounds(chains.segments[c], chains.segments[c + 1]));
-        }
-
-        return builder.getStructure();
-    }
-
-    export interface Builder {
-        addUnit(unit: Unit): void,
-        addAtoms(unitId: number, atoms: OrderedSet): void,
-        getStructure(): Structure,
-        readonly atomCount: number
-    }
-
-    class BuilderImpl implements Builder {
-        private units = Object.create(null);
-        private atoms = Object.create(null);
-        atomCount = 0;
-
-        addUnit(unit: Unit) { this.units[unit.id] = unit; }
-        addAtoms(unitId: number, atoms: OrderedSet) { this.atoms[unitId] = atoms; this.atomCount += OrderedSet.size(atoms); }
-        getStructure(): Structure { return this.atomCount > 0 ? { units: this.units, atoms: AtomSet.create(this.atoms) } : Empty; }
-    }
-
-    export function Builder(): Builder { return new BuilderImpl(); }
-
-
-    // TODO: "lift" atom set operators?
-    // TODO: "diff"
-}
-
-export default Structure
+export { Atom, AtomSet, Structure, Operator, Unit }

+ 1 - 1
src/mol-data/structure/atom.ts → src/mol-data/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-base/collections/integer'
 import Unit from './unit'
 import Structure from './structure'
 

+ 1 - 1
src/mol-data/structure/atom/set.ts → src/mol-data/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-base/collections/integer'
 import Atom from '../atom'
 import * as Impl from './set/impl'
 import createBuilder from './set/builder'

+ 2 - 2
src/mol-data/structure/atom/set/builder.ts → src/mol-data/structure/structure/atom/set/builder.ts

@@ -5,8 +5,8 @@
  */
 
 import AtomSet from '../set'
-import { OrderedSet } from '../../../../mol-base/collections/integer'
-import { sortArray } from '../../../../mol-base/collections/sort'
+import { OrderedSet } from '../../../../../mol-base/collections/integer'
+import { sortArray } from '../../../../../mol-base/collections/sort'
 
 class Builder {
     private keys: number[] = [];

+ 3 - 3
src/mol-data/structure/atom/set/impl.ts → src/mol-data/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-base/collections/integer'
+import { sortArray } from '../../../../../mol-base/collections/sort'
+import { hash1 } from '../../../../../mol-base/collections/hash-functions'
 import Atom from '../../atom'
 
 /** Long and painful implementation starts here */

+ 0 - 0
src/mol-data/structure/atom/set/properties.ts → src/mol-data/structure/structure/atom/set/properties.ts


+ 1 - 1
src/mol-data/structure/operator.ts → src/mol-data/structure/structure/operator.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Mat4 } from '../../mol-base/math/linear-algebra'
+import { Mat4 } from '../../../mol-base/math/linear-algebra'
 
 interface Operator extends Readonly<{
     name: string,

+ 58 - 0
src/mol-data/structure/structure/structure.ts

@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import { Model } from '../model'
+import Unit from './unit'
+import Operator from './operator'
+import AtomSet from './atom/set'
+import { OrderedSet } from '../../../mol-base/collections/integer'
+
+interface Structure extends Readonly<{
+    units: { readonly [id: number]: Unit },
+    atoms: AtomSet
+}> { }
+
+namespace Structure {
+    export const Empty = { units: {}, atoms: AtomSet.Empty };
+
+    export function ofModel(model: Model): Structure {
+        const chains = model.hierarchy.chainSegments;
+        const builder = Builder();
+
+        for (let c = 0; c < chains.count; c++) {
+            const unit = Unit.create(model, Operator.Identity);
+            builder.addUnit(unit);
+            builder.addAtoms(unit.id, OrderedSet.ofBounds(chains.segments[c], chains.segments[c + 1]));
+        }
+
+        return builder.getStructure();
+    }
+
+    export interface Builder {
+        addUnit(unit: Unit): void,
+        addAtoms(unitId: number, atoms: OrderedSet): void,
+        getStructure(): Structure,
+        readonly atomCount: number
+    }
+
+    class BuilderImpl implements Builder {
+        private units = Object.create(null);
+        private atoms = Object.create(null);
+        atomCount = 0;
+
+        addUnit(unit: Unit) { this.units[unit.id] = unit; }
+        addAtoms(unitId: number, atoms: OrderedSet) { this.atoms[unitId] = atoms; this.atomCount += OrderedSet.size(atoms); }
+        getStructure(): Structure { return this.atomCount > 0 ? { units: this.units, atoms: AtomSet.create(this.atoms) } : Empty; }
+    }
+
+    export function Builder(): Builder { return new BuilderImpl(); }
+
+
+    // TODO: "lift" atom set operators?
+    // TODO: "diff"
+}
+
+export default Structure

+ 0 - 0
src/mol-data/structure/unit.ts → src/mol-data/structure/structure/unit.ts


+ 0 - 0
src/mol-data/volume/TODO


+ 1 - 1
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'
+import { AtomSet } from '../mol-data/structure/structure'
 
 export namespace Iteration {
     const U = 1000, V = 2500;

+ 3 - 3
src/perf-tests/structure.ts

@@ -10,9 +10,9 @@ import * as util from 'util'
 import * as fs from 'fs'
 import CIF from '../mol-io/reader/cif'
 
-import { Model } from '../mol-data/Model'
-import { Structure, Atom, AtomSet } from '../mol-data/structure'
-import * as Q from '../mol-data/query'
+import { Model } from '../mol-data/structure/model'
+import { Structure, Atom, AtomSet } from '../mol-data/structure/structure'
+import * as Q from '../mol-data/structure/query'
 import { OrderedSet as OrdSet, Segmentation } from '../mol-base/collections/integer'
 
 require('util.promisify').shim();

+ 1 - 1
src/script.ts

@@ -17,7 +17,7 @@ import CIF from './mol-io/reader/cif'
 
 import Computation from './mol-base/computation'
 
-import buildModels from './mol-data/model/builders/mmcif'
+import buildModels from './mol-data/structure/model/builders/mmcif'
 
 // import { toTypedFrame as applySchema } from './reader/cif/schema'
 import { generateSchema } from './mol-io/reader/cif/schema/utils'