Skip to content
Snippets Groups Projects
Commit 801e1ef0 authored by David Sehnal's avatar David Sehnal
Browse files

more refactoring

parent 35d7c196
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 84 deletions
/**
* Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
import Atom from './structure/atom'
import AtomSet from './structure/atom/set'
import Structure from './structure/structure'
import Operator from './structure/operator'
import Unit from './structure/unit'
export { Atom, AtomSet, Structure, Operator, Unit }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import { OrderedSet } from '../../mol-base/collections/integer' import { OrderedSet } from '../../../mol-base/collections/integer'
import AtomSet from '../structure/atom/set' import AtomSet from '../structure/atom/set'
import Atom from '../structure/atom' import Atom from '../structure/atom'
......
File moved
...@@ -5,12 +5,11 @@ ...@@ -5,12 +5,11 @@
*/ */
import { mmCIF } from '../data-format' import { mmCIF } from '../data-format'
//import { Frame as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif'
import Model from '../model' import Model from '../model'
import Column from '../../../mol-base/collections/column' import Column from '../../../../mol-base/collections/column'
import Table from '../../../mol-base/collections/table' import Table from '../../../../mol-base/collections/table'
import { Interval, Segmentation } from '../../../mol-base/collections/integer' import { Interval, Segmentation } from '../../../../mol-base/collections/integer'
import { newUUID } from '../../../mol-base/utils/uuid' import { newUUID } from '../../../../mol-base/utils/uuid'
import * as Hierarchy from '../properties/hierarchy' import * as Hierarchy from '../properties/hierarchy'
import Conformation from '../properties/conformation' import Conformation from '../properties/conformation'
import findHierarchyKeys from '../utils/hierarchy-keys' import findHierarchyKeys from '../utils/hierarchy-keys'
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import BitFlags from '../../mol-base/utils/bit-flags' import BitFlags from '../../../mol-base/utils/bit-flags'
export const enum EntityType { export const enum EntityType {
Unknown = 'unknown', Unknown = 'unknown',
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import { Frame as mmCIF_Frame } from '../../mol-io/reader/cif/schema/mmcif' import { Frame as mmCIF_Frame } from '../../../mol-io/reader/cif/schema/mmcif'
export interface mmCIF { kind: 'mmCIF', data: mmCIF_Frame } export interface mmCIF { kind: 'mmCIF', data: mmCIF_Frame }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import DataFormat from './data-format' import DataFormat from './data-format'
import HierarchyProperties from './properties/hierarchy' import HierarchyProperties from './properties/hierarchy'
import ConformationProperties from './properties/conformation' import ConformationProperties from './properties/conformation'
import UUID from '../../mol-base/utils/uuid' import UUID from '../../../mol-base/utils/uuid'
import buildMmCIF from './builders/mmcif' import buildMmCIF from './builders/mmcif'
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import Column from '../../../mol-base/collections/column' import Column from '../../../../mol-base/collections/column'
import UUID from '../../../mol-base/utils/uuid' import UUID from '../../../../mol-base/utils/uuid'
interface Conformation { interface Conformation {
id: UUID, id: UUID,
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import Column from '../../../mol-base/collections/column' import Column from '../../../../mol-base/collections/column'
import Table from '../../../mol-base/collections/table' import Table from '../../../../mol-base/collections/table'
import { Segmentation } from '../../../mol-base/collections/integer' import { Segmentation } from '../../../../mol-base/collections/integer'
import { Schema as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif' import { Schema as mmCIF } from '../../../../mol-io/reader/cif/schema/mmcif'
const _esCache = Object.create(null); const _esCache = Object.create(null);
export interface ElementSymbol extends String { '@type': 'element-symbol' } export interface ElementSymbol extends String { '@type': 'element-symbol' }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import Column from '../../../mol-base/collections/column' import Column from '../../../../mol-base/collections/column'
import { Data, Segments, Keys } from '../properties/hierarchy' import { Data, Segments, Keys } from '../properties/hierarchy'
import { Interval, Segmentation } from '../../../mol-base/collections/integer' import { Interval, Segmentation } from '../../../../mol-base/collections/integer'
function getResidueId(comp_id: string, seq_id: number, ins_code: string) { function getResidueId(comp_id: string, seq_id: number, ins_code: string) {
return `${comp_id} ${seq_id} ${ins_code}`; return `${comp_id} ${seq_id} ${ins_code}`;
......
File moved
...@@ -8,7 +8,7 @@ import Query from './query' ...@@ -8,7 +8,7 @@ import Query from './query'
//import Selection from './selection' //import Selection from './selection'
import * as P from './properties' import * as P from './properties'
import { AtomSet, Atom } from '../structure' import { AtomSet, Atom } from '../structure'
import { OrderedSet } from '../../mol-base/collections/integer' import { OrderedSet } from '../../../mol-base/collections/integer'
export interface AtomGroupsSpec { export interface AtomGroupsSpec {
entityTest: Atom.Predicate, entityTest: Atom.Predicate,
......
File moved
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import Iterator from '../../mol-base/collections/iterator' import Iterator from '../../../mol-base/collections/iterator'
import HashSet from '../../mol-base/collections/hash-set' import HashSet from '../../../mol-base/collections/hash-set'
import { Structure, Atom, AtomSet } from '../structure' import { Structure, Atom, AtomSet } from '../structure'
type Selection = type Selection =
......
...@@ -4,55 +4,10 @@ ...@@ -4,55 +4,10 @@
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
import { Model } from '../model' import Atom from './structure/atom'
import Unit from './unit' import AtomSet from './structure/atom/set'
import Operator from './operator' import Structure from './structure/structure'
import AtomSet from './atom/set' import Operator from './structure/operator'
import { OrderedSet } from '../../mol-base/collections/integer' import Unit from './structure/unit'
interface Structure extends Readonly<{ export { Atom, AtomSet, Structure, Operator, Unit }
units: { readonly [id: number]: Unit }, \ No newline at end of file
atoms: AtomSet
}> { }
namespace Structure {
export const Empty = { units: {}, atoms: AtomSet.Empty };
export function ofModel(model: Model): Structure {
const chains = model.hierarchy.chainSegments;
const builder = Builder();
for (let c = 0; c < chains.count; c++) {
const unit = Unit.create(model, Operator.Identity);
builder.addUnit(unit);
builder.addAtoms(unit.id, OrderedSet.ofBounds(chains.segments[c], chains.segments[c + 1]));
}
return builder.getStructure();
}
export interface Builder {
addUnit(unit: Unit): void,
addAtoms(unitId: number, atoms: OrderedSet): void,
getStructure(): Structure,
readonly atomCount: number
}
class BuilderImpl implements Builder {
private units = Object.create(null);
private atoms = Object.create(null);
atomCount = 0;
addUnit(unit: Unit) { this.units[unit.id] = unit; }
addAtoms(unitId: number, atoms: OrderedSet) { this.atoms[unitId] = atoms; this.atomCount += OrderedSet.size(atoms); }
getStructure(): Structure { return this.atomCount > 0 ? { units: this.units, atoms: AtomSet.create(this.atoms) } : Empty; }
}
export function Builder(): Builder { return new BuilderImpl(); }
// TODO: "lift" atom set operators?
// TODO: "diff"
}
export default Structure
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment