From 9699a23a128b1e93f69f4a2c4f14ff69b1ae9a9d Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Sat, 7 Apr 2018 01:54:31 +0200
Subject: [PATCH] started annotations

---
 src/mol-model/annotation/annotation.ts | 40 ++++++++++++++++++++++++++
 src/mol-model/annotations.ts           | 17 +++++++++++
 src/mol-model/structure/model/model.ts |  2 ++
 3 files changed, 59 insertions(+)
 create mode 100644 src/mol-model/annotation/annotation.ts
 create mode 100644 src/mol-model/annotations.ts

diff --git a/src/mol-model/annotation/annotation.ts b/src/mol-model/annotation/annotation.ts
new file mode 100644
index 000000000..338c2de1c
--- /dev/null
+++ b/src/mol-model/annotation/annotation.ts
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import { Structure, ElementSet, Element } from '../structure'
+
+interface Annotation<E = any> {
+    definition: Annotation.Definition<E>,
+    getValue(l: Element.Location): E | undefined,
+    getAll(l: ElementSet): { annotations: E[], /* TODO: map annotations to elements */ }
+}
+
+namespace Annotation {
+    export const enum Kind {
+        Atom,
+        Residue,
+        Sequence,
+        Chain,
+        Entity,
+        Coarse,
+        Spatial
+    }
+
+    export const enum Type {
+        Num,
+        Str,
+        Obj
+    }
+
+    export interface Definition<E = any> {
+        name: string,
+        kind: Kind,
+        type: Type,
+        prepare<Data>(s: Structure, data: Data): Annotation<E>,
+    }
+}
+
+export { Annotation }
\ No newline at end of file
diff --git a/src/mol-model/annotations.ts b/src/mol-model/annotations.ts
new file mode 100644
index 000000000..828e23293
--- /dev/null
+++ b/src/mol-model/annotations.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import { Annotation } from './annotation/annotation'
+import { UUID } from 'mol-util'
+
+interface Annotations {
+    id: UUID,
+    all: Annotation[],
+    byKind: { [kind: number]: Annotation }
+    //getAll()
+}
+
+export { Annotations }
\ No newline at end of file
diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts
index e6ed614f4..3a748e1af 100644
--- a/src/mol-model/structure/model/model.ts
+++ b/src/mol-model/structure/model/model.ts
@@ -18,6 +18,7 @@ import computeBonds from './utils/compute-bonds'
 import from_gro from './formats/gro'
 import from_mmCIF from './formats/mmcif'
 
+import { Annotations } from '../../annotations'
 
 /**
  * Interface to the "source data" of the molecule.
@@ -35,6 +36,7 @@ interface Model extends Readonly<{
     conformation: Conformation,
     symmetry: Symmetry,
     coarseGrained: CoarseGrained,
+    annotations: Annotations,
 
     atomCount: number,
 }> {
-- 
GitLab