From 88fecd3406714a3731abb3c08d19f4a12552f766 Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Thu, 9 Nov 2017 17:13:52 +0100
Subject: [PATCH] started symmetry

---
 src/mol-model/structure/model.ts              |  3 +-
 .../structure/model/formats/mmcif.ts          |  6 +++
 src/mol-model/structure/model/model.ts        | 10 ++--
 .../structure/model/properties/symmetry.ts    | 53 +++++++++++++++++++
 .../structure/model/properties/transforms.ts  |  9 ----
 5 files changed, 67 insertions(+), 14 deletions(-)
 create mode 100644 src/mol-model/structure/model/properties/symmetry.ts
 delete mode 100644 src/mol-model/structure/model/properties/transforms.ts

diff --git a/src/mol-model/structure/model.ts b/src/mol-model/structure/model.ts
index 0693de0df..4c0002317 100644
--- a/src/mol-model/structure/model.ts
+++ b/src/mol-model/structure/model.ts
@@ -7,5 +7,6 @@
 import Model from './model/model'
 import * as Types from './model/types'
 import Format from './model/format'
+import Symmetry from './model/properties/symmetry'
 
-export { Model, Types, Format }
\ No newline at end of file
+export { Model, Types, Format, Symmetry }
\ No newline at end of file
diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts
index b0f421ca8..01974ab7a 100644
--- a/src/mol-model/structure/model/formats/mmcif.ts
+++ b/src/mol-model/structure/model/formats/mmcif.ts
@@ -11,6 +11,7 @@ import Format from '../format'
 import Model from '../model'
 import * as Hierarchy from '../properties/hierarchy'
 import Conformation from '../properties/conformation'
+import Symmetry from '../properties/symmetry'
 import findHierarchyKeys from '../utils/hierarchy-keys'
 import { ElementSymbol} from '../types'
 
@@ -76,6 +77,10 @@ function getConformation({ data }: mmCIF_Format, bounds: Interval): Conformation
     }
 }
 
+function getSymmetry({ data }: mmCIF_Format): Symmetry {
+    return Symmetry.Empty;
+}
+
 function isHierarchyDataEqual(a: Hierarchy.Hierarchy, b: Hierarchy.Data) {
     // need to cast because of how TS handles type resolution for interfaces https://github.com/Microsoft/TypeScript/issues/15300
     return Table.areEqual(a.chains as Table<Hierarchy.ChainsSchema>, b.chains as Table<Hierarchy.ChainsSchema>)
@@ -105,6 +110,7 @@ function createModel(format: mmCIF_Format, bounds: Interval, previous?: Model):
         modelNum: format.data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)),
         hierarchy: { ...hierarchyData, ...hierarchyKeys, ...hierarchySegments },
         conformation: getConformation(format, bounds),
+        symmetry: getSymmetry(format),
         atomCount: Interval.size(bounds)
     };
 }
diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts
index c7a33db54..0a24bb472 100644
--- a/src/mol-model/structure/model/model.ts
+++ b/src/mol-model/structure/model/model.ts
@@ -6,8 +6,9 @@
 
 import UUID from 'mol-util/uuid'
 import Format from './format'
-import HierarchyProperties from './properties/hierarchy'
-import ConformationProperties from './properties/conformation'
+import Hierarchy from './properties/hierarchy'
+import Conformation from './properties/conformation'
+import Symmetry from './properties/symmetry'
 import from_mmCIF from './formats/mmcif'
 
 
@@ -23,8 +24,9 @@ interface Model extends Readonly<{
 
     sourceData: Format,
 
-    hierarchy: HierarchyProperties,
-    conformation: ConformationProperties,
+    hierarchy: Hierarchy,
+    conformation: Conformation,
+    symmetry: Symmetry,
 
     atomCount: number
 }> { }
diff --git a/src/mol-model/structure/model/properties/symmetry.ts b/src/mol-model/structure/model/properties/symmetry.ts
new file mode 100644
index 000000000..4a5403ad4
--- /dev/null
+++ b/src/mol-model/structure/model/properties/symmetry.ts
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import SymmetryOperator from 'mol-math/geometry/symmetry-operator'
+import { Query } from '../../query'
+import { Model } from '../../model'
+
+export interface OperatorGroup {
+    readonly query: Query,
+    readonly operators: ReadonlyArray<SymmetryOperator>
+}
+
+export type OperatorGroups = ReadonlyArray<ReadonlyArray<OperatorGroup>>
+
+export class Assembly {
+    readonly id: string;
+    readonly details: string;
+
+    private _operators: OperatorGroups;
+    get operators(): OperatorGroups {
+        if (this._operators) return this._operators;
+        this._operators = this.operatorsProvider();
+        return this._operators;
+    }
+
+    constructor(id: string, details: string, private operatorsProvider: () => OperatorGroups) {
+        this.id = id;
+        this.details = details;
+    }
+}
+
+export namespace Assembly {
+    export function create(id: string, details: string, operatorsProvider: () => OperatorGroups) {
+        return new Assembly(id, details, operatorsProvider);
+    }
+}
+
+interface Symmetry {
+    readonly assemblies: ReadonlyArray<Assembly>,
+}
+
+namespace Symmetry {
+    export const Empty: Symmetry = { assemblies: [] };
+
+    export function findAssembly(model: Model): Assembly | undefined {
+        return void 0;
+    }
+}
+
+export default Symmetry
\ No newline at end of file
diff --git a/src/mol-model/structure/model/properties/transforms.ts b/src/mol-model/structure/model/properties/transforms.ts
deleted file mode 100644
index 42d9b7797..000000000
--- a/src/mol-model/structure/model/properties/transforms.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-// TODO: symmetry and assebmlies descriptors
-
-//import Column from 'mol-base/collections/column'
\ No newline at end of file
-- 
GitLab