Browse Source

refactoring, bug fixes and working on queries

David Sehnal 7 years ago
parent
commit
fafe1b1841

+ 3 - 0
src/mol-base/collections/integer/_spec/interval.spec.ts

@@ -69,5 +69,8 @@ describe('interval', () => {
     test('predIndexInt', Interval.findPredecessorIndexInInterval(r05, 0, Interval.ofRange(2, 3)), 2);
     test('predIndexInt1', Interval.findPredecessorIndexInInterval(r05, 4, Interval.ofRange(2, 3)), 4);
 
+    test('predIndexInt2', Interval.findPredecessorIndex(Interval.ofRange(3, 10), 5), 2);
+    test('predIndexInt3', Interval.findPredecessorIndexInInterval(Interval.ofRange(3, 10), 5, Interval.ofRange(2, 6)), 2);
+
     testI('findRange', Interval.findRange(r05, 2, 3), Interval.ofRange(2, 3));
 });

+ 65 - 44
src/mol-base/collections/integer/_spec/segmentation.spec.ts

@@ -11,7 +11,7 @@ import Segmentation from '../segmentation'
 describe('segments', () => {
     const data = OrderedSet.ofSortedArray([4, 9, 10, 11, 14, 15, 16]);
     const segs = Segmentation.create([0, 4, 10, 12, 13, 15, 25]);
-    
+
     it('size', () => expect(Segmentation.count(segs)).toBe(6));
 
     it('project', () => {
@@ -50,47 +50,68 @@ describe('segments', () => {
         expect(count).toBe(4);
     });
 
-    // it('iteration range', () => {
-    //     const segs = Segmentation.create([0, 2, 4]);
-    //     const dataRange = OrderedSet.ofBounds(0, 4);
-
-    //     const it = Segmentation.transientSegments(segs, dataRange);
-
-    //     const t = Object.create(null);
-    //     let count = 0;
-    //     while (it.hasNext) {
-    //         count++;
-    //         const s = it.move();
-    //         for (let j = s.start; j < s.end; j++) {
-    //             const x = t[s.index];
-    //             const v = OrderedSet.getAt(dataRange, j);
-    //             if (!x) t[s.index] = [v];
-    //             else x[x.length] = v;
-    //         }
-    //     }
-    //     expect(count).toBe(2);
-    //     expect(t).toEqual({ 0: [0, 1], 1: [2, 3] });
-    // });
-
-    // it('iteration range 1', () => {
-    //     const segs = Segmentation.create([0, 2, 4]);
-    //     const dataRange = OrderedSet.ofBounds(0, 4);
-
-    //     const it = Segmentation.transientSegments(segs, dataRange, { index: 0, start: 2, end: 4 });
-
-    //     const t = Object.create(null);
-    //     let count = 0;
-    //     while (it.hasNext) {
-    //         count++;
-    //         const s = it.move();
-    //         for (let j = s.start; j < s.end; j++) {
-    //             const x = t[s.index];
-    //             const v = OrderedSet.getAt(dataRange, j);
-    //             if (!x) t[s.index] = [v];
-    //             else x[x.length] = v;
-    //         }
-    //     }
-    //     expect(count).toBe(1);
-    //     expect(t).toEqual({ 1: [2, 3] });
-    // });
+    it('units', () => {
+        const data = OrderedSet.ofBounds(0, 4);
+        const segs = Segmentation.create([0, 1, 2, 3, 4]);
+        const it = Segmentation.transientSegments(segs, data, { index: 0, start: 2, end: 4 });
+
+        const t = Object.create(null);
+        let count = 0;
+        while (it.hasNext) {
+            count++;
+            const s = it.move();
+            for (let j = s.start; j < s.end; j++) {
+                const x = t[s.index];
+                const v = OrderedSet.getAt(data, j);
+                if (!x) t[s.index] = [v];
+                else x[x.length] = v;
+            }
+        }
+        expect(t).toEqual({ 2: [2], 3: [3] });
+        expect(count).toBe(2);
+    });
+
+    it('iteration range', () => {
+        const segs = Segmentation.create([0, 2, 4]);
+        const dataRange = OrderedSet.ofBounds(0, 4);
+
+        const it = Segmentation.transientSegments(segs, dataRange);
+
+        const t = Object.create(null);
+        let count = 0;
+        while (it.hasNext) {
+            count++;
+            const s = it.move();
+            for (let j = s.start; j < s.end; j++) {
+                const x = t[s.index];
+                const v = OrderedSet.getAt(dataRange, j);
+                if (!x) t[s.index] = [v];
+                else x[x.length] = v;
+            }
+        }
+        expect(count).toBe(2);
+        expect(t).toEqual({ 0: [0, 1], 1: [2, 3] });
+    });
+
+    it('iteration range 1', () => {
+        const segs = Segmentation.create([0, 2, 4]);
+        const dataRange = OrderedSet.ofBounds(0, 4);
+
+        const it = Segmentation.transientSegments(segs, dataRange, { index: 0, start: 2, end: 4 });
+
+        const t = Object.create(null);
+        let count = 0;
+        while (it.hasNext) {
+            count++;
+            const s = it.move();
+            for (let j = s.start; j < s.end; j++) {
+                const x = t[s.index];
+                const v = OrderedSet.getAt(dataRange, j);
+                if (!x) t[s.index] = [v];
+                else x[x.length] = v;
+            }
+        }
+        expect(count).toBe(1);
+        expect(t).toEqual({ 1: [2, 3] });
+    });
 });

+ 5 - 4
src/mol-base/collections/integer/impl/interval.ts

@@ -43,11 +43,12 @@ export function findPredecessorIndex(int: Tuple, v: number) {
 }
 
 export function findPredecessorIndexInInterval(int: Tuple, v: number, bounds: Tuple) {
-    const bS = start(bounds)
-    if (v <= bS) return bS;
+    const bS = start(bounds);
+    const s = start(int);
+    if (v <= bS + s) return bS;
     const bE = end(bounds);
-    if (v >= bE) return bE;
-    return v - start(int);
+    if (v >= bE + s) return bE;
+    return v - s;
 }
 
 export function findRange(int: Tuple, min: number, max: number) {

+ 1 - 0
src/mol-base/collections/integer/impl/segmentation.ts

@@ -91,6 +91,7 @@ export class SegmentIterator implements Iterator<Segs.Segment> {
         const max = OrderedSet.getAt(this.set, sMax);
         this.segmentMin = this.getSegmentIndex(min);
         this.segmentMax = this.getSegmentIndex(max);
+
         this.hasNext = this.segmentMax >= this.segmentMin && Interval.size(this.setRange) > 0;
     }
 

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

@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+export * from './structure/model'
+export * from './structure/structure'
+export * from './structure/query'

+ 3 - 3
src/mol-data/structure/model.ts

@@ -5,7 +5,7 @@
  */
 
 import Model from './model/model'
-import ModelDataFormat from './model/data-format'
-import * as ModelConstants from './model/constants'
+import * as Constants from './model/constants'
+import Format from './model/format'
 
-export { Model, ModelConstants, ModelDataFormat }
+export { Model, Constants, Format }

+ 0 - 14
src/mol-data/structure/model/data-format.ts

@@ -1,14 +0,0 @@
-/**
- * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-import { Database as mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif'
-
-export interface mmCIF { kind: 'mmCIF', data: mmCIF_Database }
-
-type Format =
-    | mmCIF
-
-export default Format

+ 16 - 0
src/mol-data/structure/model/format.ts

@@ -0,0 +1,16 @@
+/**
+ * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author David Sehnal <david.sehnal@gmail.com>
+ */
+
+import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif'
+
+type Format =
+    | Format.mmCIF
+
+namespace Format {
+    export interface mmCIF { kind: 'mmCIF', data: mmCIF_Database }
+}
+
+export default Format

+ 12 - 12
src/mol-data/structure/model/builders/mmcif.ts → src/mol-data/structure/model/formats/mmcif.ts

@@ -4,16 +4,18 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { mmCIF } from '../data-format'
+import Format from '../format'
 import Model from '../model'
+import * as Hierarchy from '../properties/hierarchy'
+import Conformation from '../properties/conformation'
 import { Column, Table } from 'mol-base/collections/database'
 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'
 
-function findModelBounds({ data }: mmCIF, startIndex: number) {
+import mmCIF_Format = Format.mmCIF
+
+function findModelBounds({ data }: mmCIF_Format, startIndex: number) {
     const num = data.atom_site.pdbx_PDB_model_num;
     const atomCount = num.rowCount;
     if (!num.isDefined) return Interval.ofBounds(startIndex, atomCount);
@@ -22,7 +24,7 @@ function findModelBounds({ data }: mmCIF, startIndex: number) {
     return Interval.ofBounds(startIndex, endIndex);
 }
 
-function findHierarchyOffsets({ data }: mmCIF, bounds: Interval) {
+function findHierarchyOffsets({ data }: mmCIF_Format, bounds: Interval) {
     const start = Interval.start(bounds), end = Interval.end(bounds);
     const residues = [start], chains = [start];
 
@@ -37,12 +39,11 @@ function findHierarchyOffsets({ data }: mmCIF, bounds: Interval) {
 
         if (newResidue) residues[residues.length] = i;
         if (newChain) chains[chains.length] = i;
-    }
-
+    }    
     return { residues, chains };
 }
 
-function createHierarchyData({ data }: mmCIF, bounds: Interval, offsets: { residues: ArrayLike<number>, chains: ArrayLike<number> }): Hierarchy.Data {
+function createHierarchyData({ data }: mmCIF_Format, bounds: Interval, offsets: { residues: ArrayLike<number>, chains: ArrayLike<number> }): Hierarchy.Data {
     const { atom_site } = data;
     const start = Interval.start(bounds), end = Interval.end(bounds);
     const atoms = Table.ofColumns(Hierarchy.AtomsSchema, {
@@ -60,7 +61,7 @@ function createHierarchyData({ data }: mmCIF, bounds: Interval, offsets: { resid
     return { atoms, residues, chains, entities: data.entity };
 }
 
-function getConformation({ data }: mmCIF, bounds: Interval): Conformation {
+function getConformation({ data }: mmCIF_Format, bounds: Interval): Conformation {
     const start = Interval.start(bounds), end = Interval.end(bounds);
     const { atom_site } = data;
     return {
@@ -81,7 +82,7 @@ function isHierarchyDataEqual(a: Hierarchy.Hierarchy, b: Hierarchy.Data) {
         && Table.areEqual(a.atoms as Table<Hierarchy.AtomsSchema>, b.atoms as Table<Hierarchy.AtomsSchema>)
 }
 
-function createModel(format: mmCIF, bounds: Interval, previous?: Model): Model {
+function createModel(format: mmCIF_Format, bounds: Interval, previous?: Model): Model {
     const hierarchyOffsets = findHierarchyOffsets(format, bounds);
     const hierarchyData = createHierarchyData(format, bounds, hierarchyOffsets);
 
@@ -97,7 +98,6 @@ function createModel(format: mmCIF, bounds: Interval, previous?: Model): Model {
         chainSegments: Segmentation.ofOffsets(hierarchyOffsets.chains, bounds),
     }
     const hierarchyKeys = findHierarchyKeys(hierarchyData, hierarchySegments);
-
     return {
         id: newUUID(),
         sourceData: format,
@@ -108,7 +108,7 @@ function createModel(format: mmCIF, bounds: Interval, previous?: Model): Model {
     };
 }
 
-function buildModels(format: mmCIF): ReadonlyArray<Model> {
+function buildModels(format: mmCIF_Format): ReadonlyArray<Model> {
     const models: Model[] = [];
     const atomCount = format.data.atom_site._rowCount;
 

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

@@ -4,12 +4,12 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import DataFormat from './data-format'
+import UUID from 'mol-base/utils/uuid'
+import Format from './format'
 import HierarchyProperties from './properties/hierarchy'
 import ConformationProperties from './properties/conformation'
-import UUID from 'mol-base/utils/uuid'
+import from_mmCIF from './formats/mmcif'
 
-import buildMmCIF from './builders/mmcif'
 
 /**
  * Interface to the "source data" of the molecule.
@@ -21,7 +21,7 @@ interface Model extends Readonly<{
 
     modelNum: number,
 
-    sourceData: DataFormat,
+    sourceData: Format,
 
     hierarchy: HierarchyProperties,
     conformation: ConformationProperties,
@@ -30,9 +30,9 @@ interface Model extends Readonly<{
 }> { }
 
 namespace Model {
-    export function create(format: DataFormat) {
+    export function create(format: Format) {
         switch (format.kind) {
-            case 'mmCIF': return buildMmCIF(format);
+            case 'mmCIF': return from_mmCIF(format);
         }
     }
 }

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

@@ -6,7 +6,7 @@
 
 import { Column, Table } from 'mol-base/collections/database'
 import { Segmentation } from 'mol-base/collections/integer'
-import { Schema as mmCIF } from 'mol-io/reader/cif/schema/mmcif'
+import { mmCIF_Schema as mmCIF } from 'mol-io/reader/cif/schema/mmcif'
 
 const _esCache = Object.create(null);
 export interface ElementSymbol extends String { '@type': 'element-symbol' }

+ 6 - 1
src/mol-data/structure/query.ts

@@ -9,4 +9,9 @@ import Query from './query/query'
 import * as generators from './query/generators'
 import * as props from './query/properties'
 
-export { Selection, Query, generators, props }
+export const Queries = {
+    generators,
+    props
+}
+
+export { Selection, Query }

+ 37 - 5
src/mol-data/structure/query/generators.ts

@@ -5,10 +5,9 @@
  */
 
 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, Segmentation } from 'mol-base/collections/integer'
 
 export interface AtomGroupsSpec {
     entityTest: Atom.Predicate,
@@ -62,16 +61,49 @@ function atomGroupsLinear(atomTest: Atom.Predicate): Query {
 
 function atomGroupsSegmented({ entityTest, chainTest, residueTest, atomTest }: AtomGroupsSpec): Query {
     return structure => {
+        const { atoms, units } = structure;
+        const unitIds = AtomSet.unitIds(atoms);
+        const l = Atom.Location();
+        const builder = AtomSet.Builder(atoms);
 
+        for (let i = 0, _i = unitIds.length; i < _i; i++) {
+            const unitId = unitIds[i];
+            const unit = units[unitId];
+            l.unit = unit;
+            const set = AtomSet.unitGetByIndex(atoms, i);
 
-        throw 'nyi'
+            builder.beginUnit();
+            const chainsIt = Segmentation.transientSegments(unit.hierarchy.chainSegments, set);
+            const residues = unit.hierarchy.residueSegments;
+            while (chainsIt.hasNext) {
+                const chainSegment = chainsIt.move();
+                l.atom = OrderedSet.getAt(set, chainSegment.start);
+                // test entity and chain
+                if (!entityTest(l) || !chainTest(l)) continue;
+
+                const residuesIt = Segmentation.transientSegments(residues, set, chainSegment);
+                while (residuesIt.hasNext) {
+                    const residueSegment = residuesIt.move();
+                    l.atom = OrderedSet.getAt(set, residueSegment.start);
+
+                    // test residue
+                    if (!residueTest(l)) continue;
+
+                    for (let j = residueSegment.start, _j = residueSegment.end; j < _j; j++) {
+                        l.atom = OrderedSet.getAt(set, j);
+                        if (atomTest(l)) builder.addToUnit(l.atom);
+                    }
+                }
+            }
+            builder.commitUnit(unitId);
+        }
+
+        return { units, atoms: builder.getSet() };
     };
 }
 
 function atomGroupsGrouped({ entityTest, chainTest, residueTest, atomTest, groupBy }: AtomGroupsSpec): Query {
     return structure => {
-
-
         throw 'nyi'
     };
 }

+ 2 - 1
src/mol-data/structure/query/properties.ts

@@ -17,7 +17,8 @@ export const atom = {
 }
 
 export const residue = {
-    auth_seq_id: Atom.property(l => l.unit.hierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.atom]))
+    auth_seq_id: Atom.property(l => l.unit.hierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.atom])),
+    auth_comp_id: Atom.property(l => l.unit.hierarchy.residues.auth_comp_id.value(l.unit.residueIndex[l.atom]))
 }
 
 export const chain = {

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

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { Model } from '../model'
+import { Model, Format } from '../model'
 import Unit from './unit'
 import Operator from './operator'
 import AtomSet from './atom/set'
@@ -18,6 +18,11 @@ interface Structure extends Readonly<{
 namespace Structure {
     export const Empty = { units: {}, atoms: AtomSet.Empty };
 
+    export function ofData(format: Format) {
+        const models = Model.create(format);
+        return models.map(ofModel);
+    }
+
     export function ofModel(model: Model): Structure {
         const chains = model.hierarchy.chainSegments;
         const builder = Builder();

+ 1 - 1
src/mol-io/reader/cif.ts

@@ -8,7 +8,7 @@ import parseText from './cif/text/parser'
 import parseBinary from './cif/binary/parser'
 import { Frame } from './cif/data-model'
 import { toDatabase } from './cif/schema'
-import { Schema as mmCIF_Schema, Database as mmCIF_Database } from './cif/schema/mmcif'
+import { mmCIF_Schema, mmCIF_Database } from './cif/schema/mmcif'
 
 export default {
     parseText,

+ 3 - 3
src/mol-io/reader/cif/schema/dic.ts

@@ -60,7 +60,7 @@ const item_units_conversion = {
 
 // TODO save frame dic schema
 
-export const Schema = {
+export const CIFDictionary_Schema = {
     datablock,
     dictionary,
     dictionary_history,
@@ -71,5 +71,5 @@ export const Schema = {
     item_units_conversion
 }
 
-export type Schema = typeof Schema;
-export interface Database extends Database.Tables<typeof Schema> { }
+export type CIFDictionary_Schema = typeof CIFDictionary_Schema;
+export interface CIFDictionary_Database extends Database.Tables<CIFDictionary_Schema> { }

+ 3 - 3
src/mol-io/reader/cif/schema/mmcif.ts

@@ -228,7 +228,7 @@ const atom_site = {
     pdbx_PDB_model_num: int
 }
 
-export const Schema = {
+export const mmCIF_Schema = {
     entry,
     entity,
     exptl,
@@ -246,5 +246,5 @@ export const Schema = {
     atom_site
 };
 
-export type Schema = typeof Schema;
-export interface Database extends Database<typeof Schema> { }
+export type mmCIF_Schema = typeof mmCIF_Schema;
+export interface mmCIF_Database extends Database<mmCIF_Schema> { }

+ 30 - 14
src/perf-tests/structure.ts

@@ -10,9 +10,7 @@ import * as util from 'util'
 import * as fs from 'fs'
 import CIF from 'mol-io/reader/cif'
 
-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 { Structure, Model, Queries as Q, Atom, AtomSet } from 'mol-data/structure'
 import { OrderedSet as OrdSet, Segmentation } from 'mol-base/collections/integer'
 
 require('util.promisify').shim();
@@ -92,6 +90,7 @@ export namespace PropertyAccess {
 
         let s = 0;
 
+        let vA = 0, cC = 0, rC = 0;
         for (let i = 0, _i = unitIds.length; i < _i; i++) {
             const unit = units[unitIds[i]];
             l.unit = unit;
@@ -100,18 +99,26 @@ export namespace PropertyAccess {
             const chainsIt = Segmentation.transientSegments(unit.hierarchy.chainSegments, set);
             const residues = unit.hierarchy.residueSegments;
             while (chainsIt.hasNext) {
+                cC++;
+
                 const chainSegment = chainsIt.move();
                 const residuesIt = Segmentation.transientSegments(residues, set, chainSegment);
                 while (residuesIt.hasNext) {
+                    rC++;
                     const residueSegment = residuesIt.move();
+                    // l.atom = OrdSet.getAt(set, residueSegment.start);
+                    // console.log(unit.hierarchy.residues.auth_comp_id.value(unit.residueIndex[l.atom]), l.atom, OrdSet.getAt(set, residueSegment.end))
                     for (let j = residueSegment.start, _j = residueSegment.end; j < _j; j++) {
                         l.atom = OrdSet.getAt(set, j);
+                        vA++;
                         s += p(l);
                     }
                 }
             }
         }
 
+        console.log('seg atom count', vA, cC, rC);
+
         return s;
     }
 
@@ -228,8 +235,8 @@ export namespace PropertyAccess {
     // }
 
     export async function run() {
-        const { structures, models } = await readCIF('./examples/1cbs_full.bcif');
-        //const { structures, models } = await readCIF('e:/test/quick/1jj2_full.bcif');
+        //const { structures, models } = await readCIF('./examples/1cbs_full.bcif');
+        const { structures, models } = await readCIF('e:/test/quick/1jj2_full.bcif');
         //const { structures, models } = await readCIF('e:/test/quick/3j3q_updated.cif');
 
         console.log('parsed');
@@ -237,6 +244,7 @@ export namespace PropertyAccess {
         console.log(baseline(models[0]));
         console.log(sumProperty(structures[0], l => l.unit.model.conformation.atomId.value(l.atom)));
         console.log(sumPropertySegmented(structures[0], l => l.unit.model.conformation.atomId.value(l.atom)));
+
         //console.log(sumPropertySegmentedMutable(structures[0], l => l.unit.model.conformation.atomId.value(l.atom)));
         console.log(sumPropertyAtomSetIt(structures[0], l => l.unit.model.conformation.atomId.value(l.atom)));
         //console.log(sumProperty(structures[0], Property.cachedAtomColumn(m => m.conformation.atomId)));
@@ -245,25 +253,33 @@ export namespace PropertyAccess {
 
         //const authSeqId = Atom.property(l => l.unit.hierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.atom]));
 
-        const auth_seq_id = Q.props.residue.auth_seq_id;
-        const q = Q.generators.atomGroups({ atomTest: l => auth_seq_id(l) < 3 });
-        const qr = q(structures[0]);
-        console.log(qr);
+        //const auth_seq_id = Q.props.residue.auth_seq_id;
+        const auth_comp_id = Q.props.residue.auth_comp_id;
+        //const auth_asym_id = Q.props.chain.auth_asym_id;
+        //const set =  new Set(['A', 'B', 'C', 'D']);
+        //const q = Q.generators.atomGroups({ atomTest: l => auth_seq_id(l) < 3 });
+        const q = Q.generators.atomGroups({ atomTest: l => auth_comp_id(l) === 'ALA' });
+        const q1 = Q.generators.atomGroups({ residueTest: l => auth_comp_id(l) === 'ALA' });
+        //const q2 = Q.generators.atomGroups({ chainTest: l => set.has(auth_asym_id(l)),  residueTest: l => auth_comp_id(l) === 'ALA' });
+        q(structures[0]);
+        q1(structures[0]);
+        //console.log(q1(structures[0]));
 
         //const col = models[0].conformation.atomId.value;
         const suite = new B.Suite();
         suite
+            .add('test q', () => q1(structures[0]))
             //.add('test int', () => sumProperty(structures[0], l => col(l.atom)))
-            .add('sum residue', () => sumPropertyResidue(structures[0], l => l.unit.hierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.atom])))
+            // .add('sum residue', () => sumPropertyResidue(structures[0], l => l.unit.hierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.atom])))
 
-            .add('baseline', () =>  baseline(models[0]))
-            .add('direct', () =>  sumDirect(structures[0]))
+            // .add('baseline', () =>  baseline(models[0]))
+            // .add('direct', () =>  sumDirect(structures[0]))
             //.add('normal int', () => sumProperty(structures[0], l => l.unit.model.conformation.atomId.value(l.atom)))
             //.add('atom set it int', () => sumPropertyAtomSetIt(structures[0], l => l.unit.conformation.atomId.value(l.atom)))
             // .add('segmented faster int', () => sumPropertySegmented(structures[0], l => l.unit.conformation.atomId.value(l.atom)))
             // .add('faster int', () => sumProperty(structures[0], l => l.unit.conformation.atomId.value(l.atom)))
-            .add('segmented faster _x', () => sumPropertySegmented(structures[0], l => l.unit.conformation.__x[l.atom]))
-            .add('faster _x', () => sumProperty(structures[0], l => l.unit.conformation.__x[l.atom] +  l.unit.conformation.__y[l.atom] +  l.unit.conformation.__z[l.atom]))
+            //.add('segmented faster _x', () => sumPropertySegmented(structures[0], l => l.unit.conformation.__x[l.atom]))
+            //.add('faster _x', () => sumProperty(structures[0], l => l.unit.conformation.__x[l.atom] +  l.unit.conformation.__y[l.atom] +  l.unit.conformation.__z[l.atom]))
             //.add('segmented mut faster int', () => sumPropertySegmentedMutable(structures[0], l => l.unit.conformation.atomId.value(l.atom)))
             //.add('normal shortcut int', () => sumProperty(structures[0], l => l.conformation.atomId.value(l.atom)))
             //.add('cached int', () => sumProperty(structures[0], Property.cachedAtomColumn(m => m.conformation.atomId)))

+ 3 - 3
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/structure/model/builders/mmcif'
+import { Model } from 'mol-data/structure/model'
 
 // import { toTypedFrame as applySchema } from './reader/cif/schema'
 import { generateSchema } from 'mol-io/reader/cif/schema/utils'
@@ -115,11 +115,11 @@ async function runCIF(input: string | Uint8Array) {
     console.log(mmcif.pdbx_struct_oper_list.matrix.value(0));
 
     console.time('createModels');
-    const models = buildModels({ kind: 'mmCIF', data: mmcif });
+    const models = Model.create({ kind: 'mmCIF', data: mmcif });
     console.timeEnd('createModels');
 
     for (let i = 0; i < models.length; i++) {
-        console.log(models[i].id);
+        console.log(models[i].id, models[i].conformation.id);
     }
 
     // console.log(models[0].hierarchy.isMonotonous);