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

Removed Unit.label, fixed Model.label from mmCIF

parent 2aa188d3
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,7 @@ interface GroupRepresentation<T> { ...@@ -34,7 +34,7 @@ interface GroupRepresentation<T> {
function label(loc: Element.Location) { function label(loc: Element.Location) {
const model = loc.unit.model.label const model = loc.unit.model.label
const instance = loc.unit.label const instance = loc.unit.conformation.operator.name
let element = '' let element = ''
if (Unit.isAtomic(loc.unit)) { if (Unit.isAtomic(loc.unit)) {
......
...@@ -142,9 +142,13 @@ function createModel(format: mmCIF_Format, bounds: Interval, previous?: Model): ...@@ -142,9 +142,13 @@ function createModel(format: mmCIF_Format, bounds: Interval, previous?: Model):
const coarse = getIHMCoarse(format.data, entities); const coarse = getIHMCoarse(format.data, entities);
const label = format.data.entry.id.valueKind(0) === Column.ValueKind.Present
? format.data.entry.id.value(0)
: format.data._name;
return { return {
id: UUID.create(), id: UUID.create(),
label: format.data.entry.id.value(0), label,
sourceData: format, sourceData: format,
modelNum: format.data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)), modelNum: format.data.atom_site.pdbx_PDB_model_num.value(Interval.start(bounds)),
entities, entities,
......
/** /**
* Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
*/ */
...@@ -92,8 +92,7 @@ namespace Structure { ...@@ -92,8 +92,7 @@ namespace Structure {
for (let c = 0; c < chains.count; c++) { for (let c = 0; c < chains.count; c++) {
const elements = SortedArray.ofBounds(chains.segments[c], chains.segments[c + 1]); const elements = SortedArray.ofBounds(chains.segments[c], chains.segments[c + 1]);
const label = SymmetryOperator.Default.name builder.addUnit(Unit.Kind.Atomic, model, SymmetryOperator.Default, elements);
builder.addUnit(label, Unit.Kind.Atomic, model, SymmetryOperator.Default, elements);
} }
const cs = model.coarseHierarchy; const cs = model.coarseHierarchy;
...@@ -113,16 +112,15 @@ namespace Structure { ...@@ -113,16 +112,15 @@ namespace Structure {
const { chainSegments } = elements; const { chainSegments } = elements;
for (let cI = 0; cI < chainSegments.count; cI++) { for (let cI = 0; cI < chainSegments.count; cI++) {
const elements = SortedArray.ofBounds(chainSegments.segments[cI], chainSegments.segments[cI + 1]); const elements = SortedArray.ofBounds(chainSegments.segments[cI], chainSegments.segments[cI + 1]);
const label = SymmetryOperator.Default.name builder.addUnit(kind, model, SymmetryOperator.Default, elements);
builder.addUnit(label, kind, model, SymmetryOperator.Default, elements);
} }
} }
export class StructureBuilder { export class StructureBuilder {
private units: Unit[] = []; private units: Unit[] = [];
addUnit(label: string, kind: Unit.Kind, model: Model, operator: SymmetryOperator, elements: SortedArray): Unit { addUnit(kind: Unit.Kind, model: Model, operator: SymmetryOperator, elements: SortedArray): Unit {
const unit = Unit.create(this.units.length, label, kind, model, operator, elements); const unit = Unit.create(this.units.length, kind, model, operator, elements);
this.units.push(unit); this.units.push(unit);
return unit; return unit;
} }
...@@ -153,14 +151,6 @@ namespace Structure { ...@@ -153,14 +151,6 @@ namespace Structure {
return arr.array; return arr.array;
} }
export function getLookup3d(s: Structure): StructureLookup3D {
return 0 as any;
}
export function getBoundary(s: Structure) {
return getLookup3d(s).boundary;
}
export function hashCode(s: Structure) { export function hashCode(s: Structure) {
return s.hashCode; return s.hashCode;
} }
......
...@@ -25,11 +25,11 @@ namespace Unit { ...@@ -25,11 +25,11 @@ namespace Unit {
export function isSpheres(u: Unit): u is Spheres { return u.kind === Kind.Spheres; } export function isSpheres(u: Unit): u is Spheres { return u.kind === Kind.Spheres; }
export function isGaussians(u: Unit): u is Gaussians { return u.kind === Kind.Gaussians; } export function isGaussians(u: Unit): u is Gaussians { return u.kind === Kind.Gaussians; }
export function create(id: number, label: string, kind: Kind, model: Model, operator: SymmetryOperator, elements: SortedArray): Unit { export function create(id: number, kind: Kind, model: Model, operator: SymmetryOperator, elements: SortedArray): Unit {
switch (kind) { switch (kind) {
case Kind.Atomic: return new Atomic(id, unitIdFactory(), label, model, elements, SymmetryOperator.createMapping(operator, model.atomicConformation), AtomicProperties()); case Kind.Atomic: return new Atomic(id, unitIdFactory(), model, elements, SymmetryOperator.createMapping(operator, model.atomicConformation), AtomicProperties());
case Kind.Spheres: return createCoarse(id, unitIdFactory(), label, model, Kind.Spheres, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.spheres)); case Kind.Spheres: return createCoarse(id, unitIdFactory(), model, Kind.Spheres, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.spheres));
case Kind.Gaussians: return createCoarse(id, unitIdFactory(), label, model, Kind.Gaussians, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.gaussians)); case Kind.Gaussians: return createCoarse(id, unitIdFactory(), model, Kind.Gaussians, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.gaussians));
} }
} }
...@@ -40,7 +40,6 @@ namespace Unit { ...@@ -40,7 +40,6 @@ namespace Unit {
readonly id: number, readonly id: number,
// invariant ID stays the same even if the Operator/conformation changes. // invariant ID stays the same even if the Operator/conformation changes.
readonly invariantId: number, readonly invariantId: number,
readonly label: string,
readonly elements: SortedArray, readonly elements: SortedArray,
readonly model: Model, readonly model: Model,
readonly conformation: SymmetryOperator.ArrayMapping, readonly conformation: SymmetryOperator.ArrayMapping,
...@@ -65,7 +64,6 @@ namespace Unit { ...@@ -65,7 +64,6 @@ namespace Unit {
readonly id: number; readonly id: number;
readonly invariantId: number; readonly invariantId: number;
readonly label: string;
readonly elements: SortedArray; readonly elements: SortedArray;
readonly model: Model; readonly model: Model;
readonly conformation: SymmetryOperator.ArrayMapping; readonly conformation: SymmetryOperator.ArrayMapping;
...@@ -78,13 +76,12 @@ namespace Unit { ...@@ -78,13 +76,12 @@ namespace Unit {
getChild(elements: SortedArray): Unit { getChild(elements: SortedArray): Unit {
if (elements.length === this.elements.length) return this; if (elements.length === this.elements.length) return this;
return new Atomic(this.id, this.invariantId, this.label, this.model, elements, this.conformation, AtomicProperties()); return new Atomic(this.id, this.invariantId, this.model, elements, this.conformation, AtomicProperties());
} }
applyOperator(id: number, operator: SymmetryOperator, dontCompose = false): Unit { applyOperator(id: number, operator: SymmetryOperator, dontCompose = false): Unit {
const op = dontCompose ? operator : SymmetryOperator.compose(this.conformation.operator, operator); const op = dontCompose ? operator : SymmetryOperator.compose(this.conformation.operator, operator);
const label = operator.name return new Atomic(id, this.invariantId, this.model, this.elements, SymmetryOperator.createMapping(op, this.model.atomicConformation), this.props);
return new Atomic(id, this.invariantId, label, this.model, this.elements, SymmetryOperator.createMapping(op, this.model.atomicConformation), this.props);
} }
get lookup3d() { get lookup3d() {
...@@ -100,10 +97,9 @@ namespace Unit { ...@@ -100,10 +97,9 @@ namespace Unit {
return this.props.bonds.ref; return this.props.bonds.ref;
} }
constructor(id: number, invariantId: number, label: string, model: Model, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping, props: AtomicProperties) { constructor(id: number, invariantId: number, model: Model, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping, props: AtomicProperties) {
this.id = id; this.id = id;
this.invariantId = invariantId; this.invariantId = invariantId;
this.label = label;
this.model = model; this.model = model;
this.elements = elements; this.elements = elements;
this.conformation = conformation; this.conformation = conformation;
...@@ -128,7 +124,6 @@ namespace Unit { ...@@ -128,7 +124,6 @@ namespace Unit {
readonly id: number; readonly id: number;
readonly invariantId: number; readonly invariantId: number;
readonly label: string;
readonly elements: SortedArray; readonly elements: SortedArray;
readonly model: Model; readonly model: Model;
readonly conformation: SymmetryOperator.ArrayMapping; readonly conformation: SymmetryOperator.ArrayMapping;
...@@ -138,13 +133,12 @@ namespace Unit { ...@@ -138,13 +133,12 @@ namespace Unit {
getChild(elements: SortedArray): Unit { getChild(elements: SortedArray): Unit {
if (elements.length === this.elements.length) return this as any as Unit /** lets call this an ugly temporary hack */; if (elements.length === this.elements.length) return this as any as Unit /** lets call this an ugly temporary hack */;
return createCoarse(this.id, this.invariantId, this.label, this.model, this.kind, elements, this.conformation); return createCoarse(this.id, this.invariantId, this.model, this.kind, elements, this.conformation);
} }
applyOperator(id: number, operator: SymmetryOperator, dontCompose = false): Unit { applyOperator(id: number, operator: SymmetryOperator, dontCompose = false): Unit {
const op = dontCompose ? operator : SymmetryOperator.compose(this.conformation.operator, operator); const op = dontCompose ? operator : SymmetryOperator.compose(this.conformation.operator, operator);
const label = operator.name const ret = createCoarse(id, this.invariantId, this.model, this.kind, this.elements, SymmetryOperator.createMapping(op, this.getCoarseElements()));
const ret = createCoarse(id, this.invariantId, label, this.model, this.kind, this.elements, SymmetryOperator.createMapping(op, this.getCoarseElements()));
(ret as Coarse<K, C>)._lookup3d = this._lookup3d; (ret as Coarse<K, C>)._lookup3d = this._lookup3d;
return ret; return ret;
} }
...@@ -162,11 +156,10 @@ namespace Unit { ...@@ -162,11 +156,10 @@ namespace Unit {
return this.kind === Kind.Spheres ? this.model.coarseConformation.spheres : this.model.coarseConformation.gaussians; return this.kind === Kind.Spheres ? this.model.coarseConformation.spheres : this.model.coarseConformation.gaussians;
} }
constructor(id: number, invariantId: number, label: string, model: Model, kind: K, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping) { constructor(id: number, invariantId: number, model: Model, kind: K, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping) {
this.kind = kind; this.kind = kind;
this.id = id; this.id = id;
this.invariantId = invariantId; this.invariantId = invariantId;
this.label = label;
this.model = model; this.model = model;
this.elements = elements; this.elements = elements;
this.conformation = conformation; this.conformation = conformation;
...@@ -175,8 +168,8 @@ namespace Unit { ...@@ -175,8 +168,8 @@ namespace Unit {
} }
} }
function createCoarse<K extends Kind.Gaussians | Kind.Spheres>(id: number, invariantId: number, label: string, model: Model, kind: K, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping): Unit { function createCoarse<K extends Kind.Gaussians | Kind.Spheres>(id: number, invariantId: number, model: Model, kind: K, elements: SortedArray, conformation: SymmetryOperator.ArrayMapping): Unit {
return new Coarse(id, invariantId, label, model, kind, elements, conformation) as any as Unit /** lets call this an ugly temporary hack */; return new Coarse(id, invariantId, model, kind, elements, conformation) as any as Unit /** lets call this an ugly temporary hack */;
} }
export class Spheres extends Coarse<Kind.Spheres, CoarseSphereConformation> { } export class Spheres extends Coarse<Kind.Spheres, CoarseSphereConformation> { }
......
...@@ -52,11 +52,11 @@ export async function test() { ...@@ -52,11 +52,11 @@ export async function test() {
const result = lookup.find(-30.07, 8.178, -13.897, 10); const result = lookup.find(-30.07, 8.178, -13.897, 10);
console.log(result.count)//, sortArray(result.indices)); console.log(result.count)//, sortArray(result.indices));
const sl = Structure.getLookup3d(structures[0]); const sl = structures[0].lookup3d;
const result1 = sl.find(-30.07, 8.178, -13.897, 10); const result1 = sl.find(-30.07, 8.178, -13.897, 10);
console.log(result1.count);//, result1.indices); console.log(result1.count);//, result1.indices);
console.log(Structure.getBoundary(structures[0])); console.log(structures[0].boundary);
console.log(lookup.boundary); console.log(lookup.boundary);
} }
......
...@@ -52,10 +52,9 @@ const AtomSiteParameters = { ...@@ -52,10 +52,9 @@ const AtomSiteParameters = {
// } // }
function entityTest1_555(params: any): Element.Predicate | undefined { function entityTest1_555(params: any): Element.Predicate | undefined {
const oper = Queries.props.unit.operator_name; if (typeof params.entity_id === 'undefined') return Element.property(l => l.unit.conformation.operator.isIdentity);
if (typeof params.entity_id === 'undefined') return Element.property(l => oper(l) === '1_555');
const p = Queries.props.entity.id, id = '' + params.entityId; const p = Queries.props.entity.id, id = '' + params.entityId;
return Element.property(l => p(l) === id && oper(l) === '1_555'); return Element.property(l => l.unit.conformation.operator.isIdentity && p(l) === id);
} }
function chainTest(params: any): Element.Predicate | undefined { function chainTest(params: any): Element.Predicate | undefined {
......
...@@ -77,7 +77,7 @@ export async function resolveRequest(req: Request, writer: Writer) { ...@@ -77,7 +77,7 @@ export async function resolveRequest(req: Request, writer: Writer) {
const encoder = CifWriter.createEncoder({ binary: req.responseFormat.isBinary, encoderName: `ModelServer ${Version}` }); const encoder = CifWriter.createEncoder({ binary: req.responseFormat.isBinary, encoderName: `ModelServer ${Version}` });
perf.start('encode'); perf.start('encode');
encoder.startDataBlock('result'); encoder.startDataBlock(structure.units[0].model.label.toUpperCase());
encoder.writeCategory(_model_server_result, [req]); encoder.writeCategory(_model_server_result, [req]);
encoder.writeCategory(_model_server_params, [req]); encoder.writeCategory(_model_server_params, [req]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment