UNPKG

molstar

Version:

A comprehensive macromolecular library.

85 lines 3.78 kB
/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { __extends } from "tslib"; import { Structure, StructureElement, StructureProperties } from '../../mol-model/structure'; import { SequenceWrapper } from './wrapper'; import { OrderedSet, Interval } from '../../mol-data/int'; import { ColorNames } from '../../mol-util/color/names'; import { applyMarkerAction } from '../../mol-util/marker-action'; var ChainSequenceWrapper = /** @class */ (function (_super) { __extends(ChainSequenceWrapper, _super); function ChainSequenceWrapper(data) { var _this = this; var residueCount = 0; var elementCount = 0; var counts = []; var l = StructureElement.Location.create(data.structure); var unitIndices = new Map(); var lociElements = []; for (var i = 0, il = data.units.length; i < il; ++i) { var unit = data.units[i]; StructureElement.Location.set(l, data.structure, unit, unit.elements[0]); var entitySeq = unit.model.sequence.byEntityKey[StructureProperties.entity.key(l)]; if (entitySeq) residueCount += entitySeq.sequence.length; elementCount += unit.elements.length; var indices = Interval.ofBounds(0, unit.elements.length); unitIndices.set(unit.id, indices); lociElements.push({ unit: unit, indices: indices }); } if (residueCount > 0) counts.push(residueCount + " residues"); counts.push(elementCount + " elements"); var length = 1; var markerArray = new Uint8Array(length); _this = _super.call(this, data, markerArray, length) || this; _this.label = "Whole Chain (" + counts.join(', ') + ")"; _this.unitIndices = unitIndices; _this.loci = StructureElement.Loci(_this.data.structure, lociElements); return _this; } ChainSequenceWrapper.prototype.residueLabel = function (seqIdx) { return this.label; }; ChainSequenceWrapper.prototype.residueColor = function (seqIdx) { return ColorNames.black; }; ChainSequenceWrapper.prototype.residueClass = function (seqIdx) { return 'msp-sequence-present'; }; ChainSequenceWrapper.prototype.mark = function (loci, action) { var changed = false; var structure = this.data.structure; if (StructureElement.Loci.is(loci)) { if (!Structure.areRootsEquivalent(loci.structure, structure)) return false; loci = StructureElement.Loci.remap(loci, structure); for (var _i = 0, _a = loci.elements; _i < _a.length; _i++) { var e = _a[_i]; var indices = this.unitIndices.get(e.unit.id); if (indices) { if (OrderedSet.isSubset(indices, e.indices)) { if (applyMarkerAction(this.markerArray, Interval.ofSingleton(0), action)) changed = true; } } } } else if (Structure.isLoci(loci)) { if (!Structure.areRootsEquivalent(loci.structure, structure)) return false; if (applyMarkerAction(this.markerArray, Interval.ofSingleton(0), action)) changed = true; } return changed; }; ChainSequenceWrapper.prototype.getLoci = function (seqIdx) { return this.loci; }; return ChainSequenceWrapper; }(SequenceWrapper)); export { ChainSequenceWrapper }; //# sourceMappingURL=chain.js.map