Skip to content
Snippets Groups Projects
Commit f22e9815 authored by Alexander Rose's avatar Alexander Rose
Browse files

added assemblyName to structure

parent 883c1b02
No related branches found
No related tags found
No related merge requests found
...@@ -171,7 +171,7 @@ function atomGroupsGrouped({ entityTest, chainTest, residueTest, atomTest, group ...@@ -171,7 +171,7 @@ function atomGroupsGrouped({ entityTest, chainTest, residueTest, atomTest, group
function getRingStructure(unit: Unit.Atomic, ring: UnitRing) { function getRingStructure(unit: Unit.Atomic, ring: UnitRing) {
const elements = new Int32Array(ring.length) as any as ElementIndex[]; const elements = new Int32Array(ring.length) as any as ElementIndex[];
for (let i = 0, _i = ring.length; i < _i; i++) elements[i] = unit.elements[ring[i]]; for (let i = 0, _i = ring.length; i < _i; i++) elements[i] = unit.elements[ring[i]];
return Structure.create([unit.getChild(SortedArray.ofSortedArray(elements))]) return Structure.create([unit.getChild(SortedArray.ofSortedArray(elements))], '')
} }
export function rings(fingerprints?: ArrayLike<UnitRing.Fingerprint>): StructureQuery { export function rings(fingerprints?: ArrayLike<UnitRing.Fingerprint>): StructureQuery {
......
...@@ -35,7 +35,7 @@ export function atomicSequence(): StructureQuery { ...@@ -35,7 +35,7 @@ export function atomicSequence(): StructureQuery {
units.push(unit); units.push(unit);
} }
return StructureSelection.Singletons(inputStructure, new Structure(units)); return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure.assemblyName));
}; };
} }
...@@ -54,7 +54,7 @@ export function water(): StructureQuery { ...@@ -54,7 +54,7 @@ export function water(): StructureQuery {
if (P.entity.type(l) !== 'water') continue; if (P.entity.type(l) !== 'water') continue;
units.push(unit); units.push(unit);
} }
return StructureSelection.Singletons(inputStructure, new Structure(units)); return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure.assemblyName));
}; };
} }
...@@ -84,7 +84,7 @@ export function atomicHet(): StructureQuery { ...@@ -84,7 +84,7 @@ export function atomicHet(): StructureQuery {
units.push(unit); units.push(unit);
} }
return StructureSelection.Singletons(inputStructure, new Structure(units)); return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure.assemblyName));
}; };
} }
...@@ -97,6 +97,6 @@ export function spheres(): StructureQuery { ...@@ -97,6 +97,6 @@ export function spheres(): StructureQuery {
if (unit.kind !== Unit.Kind.Spheres) continue; if (unit.kind !== Unit.Kind.Spheres) continue;
units.push(unit); units.push(unit);
} }
return StructureSelection.Singletons(inputStructure, new Structure(units)); return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure.assemblyName));
}; };
} }
...@@ -109,7 +109,7 @@ namespace StructureSelection { ...@@ -109,7 +109,7 @@ namespace StructureSelection {
const { elements } = unit; const { elements } = unit;
for (let i = 0, _i = elements.length; i < _i; i++) { for (let i = 0, _i = elements.length; i < _i; i++) {
// TODO: optimize this somehow??? // TODO: optimize this somehow???
const s = Structure.create([unit.getChild(SortedArray.ofSingleton(elements[i]))]); const s = Structure.create([unit.getChild(SortedArray.ofSingleton(elements[i]))], sel.structure.assemblyName);
fn(s, idx++); fn(s, idx++);
} }
} }
......
...@@ -80,7 +80,7 @@ export function structureIntersect(sA: Structure, sB: Structure): Structure { ...@@ -80,7 +80,7 @@ export function structureIntersect(sA: Structure, sB: Structure): Structure {
} }
} }
return Structure.create(units); return Structure.create(units, sA.assemblyName === sB.assemblyName ? sA.assemblyName : '');
} }
export function structureSubtract(a: Structure, b: Structure): Structure { export function structureSubtract(a: Structure, b: Structure): Structure {
...@@ -100,5 +100,5 @@ export function structureSubtract(a: Structure, b: Structure): Structure { ...@@ -100,5 +100,5 @@ export function structureSubtract(a: Structure, b: Structure): Structure {
} }
} }
return Structure.create(units); return Structure.create(units, a.assemblyName === b.assemblyName ? a.assemblyName : '');
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Copyright (c) 2017-2018 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>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import { IntMap, SortedArray, Iterator, Segmentation } from 'mol-data/int' import { IntMap, SortedArray, Iterator, Segmentation } from 'mol-data/int'
...@@ -48,7 +49,8 @@ class Structure { ...@@ -48,7 +49,8 @@ class Structure {
transformHash: number, transformHash: number,
elementCount: number, elementCount: number,
polymerResidueCount: number, polymerResidueCount: number,
} = { hashCode: -1, transformHash: -1, elementCount: 0, polymerResidueCount: 0 }; assemblyName: string
} = { hashCode: -1, transformHash: -1, elementCount: 0, polymerResidueCount: 0, assemblyName: '' };
subsetBuilder(isSorted: boolean) { subsetBuilder(isSorted: boolean) {
return new StructureSubsetBuilder(this, isSorted); return new StructureSubsetBuilder(this, isSorted);
...@@ -64,6 +66,11 @@ class Structure { ...@@ -64,6 +66,11 @@ class Structure {
return this._props.polymerResidueCount; return this._props.polymerResidueCount;
} }
/** Name of the assembly given by `_pdbx_struct_assembly.id` when applicable */
get assemblyName() {
return this._props.assemblyName;
}
/** Coarse structure, defined as Containing less than twice as many elements as polymer residues */ /** Coarse structure, defined as Containing less than twice as many elements as polymer residues */
get isCoarse() { get isCoarse() {
const ec = this.elementCount const ec = this.elementCount
...@@ -169,7 +176,7 @@ class Structure { ...@@ -169,7 +176,7 @@ class Structure {
return SortedArray.has(this.unitMap.get(e.unit.id).elements, e.element); return SortedArray.has(this.unitMap.get(e.unit.id).elements, e.element);
} }
constructor(units: ArrayLike<Unit>) { constructor(units: ArrayLike<Unit>, assemblyName: string) {
const map = IntMap.Mutable<Unit>(); const map = IntMap.Mutable<Unit>();
let elementCount = 0; let elementCount = 0;
let polymerResidueCount = 0; let polymerResidueCount = 0;
...@@ -188,6 +195,7 @@ class Structure { ...@@ -188,6 +195,7 @@ class Structure {
this.units = units as ReadonlyArray<Unit>; this.units = units as ReadonlyArray<Unit>;
this._props.elementCount = elementCount; this._props.elementCount = elementCount;
this._props.polymerResidueCount = polymerResidueCount; this._props.polymerResidueCount = polymerResidueCount;
this._props.assemblyName = assemblyName
} }
} }
...@@ -278,7 +286,7 @@ function getUniqueAtomicResidueIndices(structure: Structure): ReadonlyMap<UUID, ...@@ -278,7 +286,7 @@ function getUniqueAtomicResidueIndices(structure: Structure): ReadonlyMap<UUID,
} }
namespace Structure { namespace Structure {
export const Empty = new Structure([]); export const Empty = new Structure([], '');
/** Represents a single structure */ /** Represents a single structure */
export interface Loci { export interface Loci {
...@@ -297,7 +305,7 @@ namespace Structure { ...@@ -297,7 +305,7 @@ namespace Structure {
return a.structure === b.structure return a.structure === b.structure
} }
export function create(units: ReadonlyArray<Unit>): Structure { return new Structure(units); } export function create(units: ReadonlyArray<Unit>, assemblyName: string): Structure { return new Structure(units, assemblyName); }
/** /**
* Construct a Structure from a model. * Construct a Structure from a model.
...@@ -338,7 +346,7 @@ namespace Structure { ...@@ -338,7 +346,7 @@ namespace Structure {
} }
} }
return builder.getStructure(); return builder.getStructure('deposited');
} }
function isWaterChain(model: Model, chainIndex: ChainIndex, indices: SortedArray) { function isWaterChain(model: Model, chainIndex: ChainIndex, indices: SortedArray) {
...@@ -380,7 +388,7 @@ namespace Structure { ...@@ -380,7 +388,7 @@ namespace Structure {
units.push(u.applyOperator(u.id, op)); units.push(u.applyOperator(u.id, op));
} }
return new Structure(units); return new Structure(units, s.assemblyName);
} }
export class StructureBuilder { export class StructureBuilder {
...@@ -399,8 +407,8 @@ namespace Structure { ...@@ -399,8 +407,8 @@ namespace Structure {
return newUnit; return newUnit;
} }
getStructure(): Structure { getStructure(assemblyName: string): Structure {
return create(this.units); return create(this.units, assemblyName);
} }
get isEmpty() { get isEmpty() {
......
...@@ -42,7 +42,7 @@ namespace StructureSymmetry { ...@@ -42,7 +42,7 @@ namespace StructureSymmetry {
} }
} }
return assembler.getStructure(); return assembler.getStructure(asmName);
}); });
} }
...@@ -118,7 +118,7 @@ function assembleOperators(structure: Structure, operators: ReadonlyArray<Symmet ...@@ -118,7 +118,7 @@ function assembleOperators(structure: Structure, operators: ReadonlyArray<Symmet
assembler.addWithOperator(unit, oper); assembler.addWithOperator(unit, oper);
} }
} }
return assembler.getStructure(); return assembler.getStructure(structure.assemblyName);
} }
async function _buildNCS(ctx: RuntimeContext, structure: Structure) { async function _buildNCS(ctx: RuntimeContext, structure: Structure) {
...@@ -173,7 +173,7 @@ async function findMatesRadius(ctx: RuntimeContext, structure: Structure, radius ...@@ -173,7 +173,7 @@ async function findMatesRadius(ctx: RuntimeContext, structure: Structure, radius
} }
return assembler.getStructure(); return assembler.getStructure(structure.assemblyName);
} }
export default StructureSymmetry; export default StructureSymmetry;
\ No newline at end of file
...@@ -90,7 +90,7 @@ export class StructureSubsetBuilder { ...@@ -90,7 +90,7 @@ export class StructureSubsetBuilder {
newUnits[newUnits.length] = child; newUnits[newUnits.length] = child;
} }
return Structure.create(newUnits); return Structure.create(newUnits, this.parent.assemblyName);
} }
getStructure() { getStructure() {
......
...@@ -85,7 +85,7 @@ export class StructureUniqueSubsetBuilder { ...@@ -85,7 +85,7 @@ export class StructureUniqueSubsetBuilder {
newUnits[newUnits.length] = child; newUnits[newUnits.length] = child;
} }
return Structure.create(newUnits); return Structure.create(newUnits, this.parent.assemblyName);
} }
get isEmpty() { get isEmpty() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment