|
@@ -4,9 +4,9 @@
|
|
|
* @author David Sehnal <david.sehnal@gmail.com>
|
|
|
*/
|
|
|
|
|
|
-import { RawData } from '../formats'
|
|
|
-import { Frame as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif'
|
|
|
-import Model from '../../model'
|
|
|
+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'
|
|
@@ -15,7 +15,7 @@ import * as Hierarchy from '../properties/hierarchy'
|
|
|
import Conformation from '../properties/conformation'
|
|
|
import findHierarchyKeys from '../utils/hierarchy-keys'
|
|
|
|
|
|
-function findModelBounds(data: mmCIF, startIndex: number) {
|
|
|
+function findModelBounds({ data }: mmCIF, startIndex: number) {
|
|
|
const num = data.atom_site.pdbx_PDB_model_num;
|
|
|
const atomCount = num.rowCount;
|
|
|
if (!num.isDefined) return Interval.ofBounds(startIndex, atomCount);
|
|
@@ -24,7 +24,7 @@ function findModelBounds(data: mmCIF, startIndex: number) {
|
|
|
return Interval.ofBounds(startIndex, endIndex);
|
|
|
}
|
|
|
|
|
|
-function findHierarchyOffsets(data: mmCIF, bounds: Interval) {
|
|
|
+function findHierarchyOffsets({ data }: mmCIF, bounds: Interval) {
|
|
|
const start = Interval.start(bounds), end = Interval.end(bounds);
|
|
|
const residues = [start], chains = [start];
|
|
|
|
|
@@ -44,7 +44,7 @@ function findHierarchyOffsets(data: mmCIF, bounds: Interval) {
|
|
|
return { residues, chains };
|
|
|
}
|
|
|
|
|
|
-function createHierarchyData(data: mmCIF, bounds: Interval, offsets: { residues: ArrayLike<number>, chains: ArrayLike<number> }): Hierarchy.Data {
|
|
|
+function createHierarchyData({ data }: mmCIF, 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>({
|
|
@@ -62,7 +62,7 @@ function createHierarchyData(data: mmCIF, bounds: Interval, offsets: { residues:
|
|
|
return { atoms, residues, chains, entities: data.entity };
|
|
|
}
|
|
|
|
|
|
-function getConformation(data: mmCIF, bounds: Interval): Conformation {
|
|
|
+function getConformation({ data }: mmCIF, bounds: Interval): Conformation {
|
|
|
const start = Interval.start(bounds), end = Interval.end(bounds);
|
|
|
const { atom_site } = data;
|
|
|
return {
|
|
@@ -83,14 +83,14 @@ function isHierarchyDataEqual(a: Hierarchy.Hierarchy, b: Hierarchy.Data) {
|
|
|
&& Table.areEqual(a.atoms as Table<Hierarchy.AtomsSchema>, b.atoms as Table<Hierarchy.AtomsSchema>)
|
|
|
}
|
|
|
|
|
|
-function createModel(raw: RawData, data: mmCIF, bounds: Interval, previous?: Model): Model {
|
|
|
- const hierarchyOffsets = findHierarchyOffsets(data, bounds);
|
|
|
- const hierarchyData = createHierarchyData(data, bounds, hierarchyOffsets);
|
|
|
+function createModel(format: mmCIF, bounds: Interval, previous?: Model): Model {
|
|
|
+ const hierarchyOffsets = findHierarchyOffsets(format, bounds);
|
|
|
+ const hierarchyData = createHierarchyData(format, bounds, hierarchyOffsets);
|
|
|
|
|
|
if (previous && isHierarchyDataEqual(previous.hierarchy, hierarchyData)) {
|
|
|
return {
|
|
|
...previous,
|
|
|
- conformation: getConformation(data, bounds)
|
|
|
+ conformation: getConformation(format, bounds)
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -102,25 +102,24 @@ function createModel(raw: RawData, data: mmCIF, bounds: Interval, previous?: Mod
|
|
|
|
|
|
return {
|
|
|
id: newUUID(),
|
|
|
- sourceData: raw,
|
|
|
- modelNum: data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)),
|
|
|
+ sourceData: format,
|
|
|
+ modelNum: format.data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)),
|
|
|
hierarchy: { ...hierarchyData, ...hierarchyKeys, ...hierarchySegments },
|
|
|
- conformation: getConformation(data, bounds),
|
|
|
+ conformation: getConformation(format, bounds),
|
|
|
atomCount: Interval.size(bounds)
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-function buildModels(data: mmCIF): ReadonlyArray<Model> {
|
|
|
- const raw: RawData = { source: 'mmCIF', data };
|
|
|
+function buildModels(format: mmCIF): ReadonlyArray<Model> {
|
|
|
const models: Model[] = [];
|
|
|
- const atomCount = data.atom_site._rowCount;
|
|
|
+ const atomCount = format.data.atom_site._rowCount;
|
|
|
|
|
|
if (atomCount === 0) return models;
|
|
|
|
|
|
let modelStart = 0;
|
|
|
while (modelStart < atomCount) {
|
|
|
- const bounds = findModelBounds(data, modelStart);
|
|
|
- const model = createModel(raw, data, bounds, models.length > 0 ? models[models.length - 1] : void 0);
|
|
|
+ const bounds = findModelBounds(format, modelStart);
|
|
|
+ const model = createModel(format, bounds, models.length > 0 ? models[models.length - 1] : void 0);
|
|
|
models.push(model);
|
|
|
modelStart = Interval.end(bounds);
|
|
|
}
|