UNPKG

molstar

Version:

A comprehensive macromolecular library.

86 lines 3.69 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 } 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 ElementSequenceWrapper = /** @class */ (function (_super) { __extends(ElementSequenceWrapper, _super); function ElementSequenceWrapper(data) { var _this = this; var length = 0; var unitIndices = new Map(); var lociElements = []; for (var i = 0, il = data.units.length; i < il; ++i) { var unit = data.units[i]; length += unit.elements.length; var indices = Interval.ofBounds(0, unit.elements.length); unitIndices.set(unit.id, indices); lociElements.push({ unit: unit, indices: indices }); } var markerArray = new Uint8Array(length); _this = _super.call(this, data, markerArray, length) || this; _this.unitIndices = unitIndices; return _this; } ElementSequenceWrapper.prototype.residueLabel = function (seqIdx) { return 'X'; }; ElementSequenceWrapper.prototype.residueColor = function (seqIdx) { return ColorNames.black; }; ElementSequenceWrapper.prototype.residueClass = function (seqIdx) { return 'msp-sequence-present'; }; ElementSequenceWrapper.prototype.mark = function (loci, action) { var changed = false; var _a = this.data, structure = _a.structure, units = _a.units; if (StructureElement.Loci.is(loci)) { if (!Structure.areRootsEquivalent(loci.structure, structure)) return false; loci = StructureElement.Loci.remap(loci, structure); for (var _i = 0, _b = loci.elements; _i < _b.length; _i++) { var e = _b[_i]; var indices = this.unitIndices.get(e.unit.id); if (indices) { if (OrderedSet.isSubset(indices, e.indices)) { if (applyMarkerAction(this.markerArray, e.indices, action)) changed = true; } } } } else if (Structure.isLoci(loci)) { if (!Structure.areRootsEquivalent(loci.structure, structure)) return false; for (var i = 0, il = units.length; i < il; ++i) { var indices = this.unitIndices.get(units[i].id); if (applyMarkerAction(this.markerArray, indices, action)) changed = true; } } return changed; }; ElementSequenceWrapper.prototype.getLoci = function (seqIdx) { var units = this.data.units; var lociElements = []; var offset = 0; for (var i = 0, il = units.length; i < il; ++i) { var unit = units[i]; if (seqIdx < offset + unit.elements.length) { lociElements.push({ unit: unit, indices: Interval.ofSingleton(seqIdx - offset) }); break; } offset += unit.elements.length; } return StructureElement.Loci(this.data.structure, lociElements); }; return ElementSequenceWrapper; }(SequenceWrapper)); export { ElementSequenceWrapper }; //# sourceMappingURL=element.js.map