Browse Source

started annotations

David Sehnal 7 years ago
parent
commit
9699a23a12

+ 40 - 0
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 }

+ 17 - 0
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 }

+ 2 - 0
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,
 }> {