UNPKG

molstar

Version:

A comprehensive macromolecular library.

88 lines 4.05 kB
"use strict"; /** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ChainSequenceWrapper = void 0; var tslib_1 = require("tslib"); var structure_1 = require("../../mol-model/structure"); var wrapper_1 = require("./wrapper"); var int_1 = require("../../mol-data/int"); var names_1 = require("../../mol-util/color/names"); var marker_action_1 = require("../../mol-util/marker-action"); var ChainSequenceWrapper = /** @class */ (function (_super) { (0, tslib_1.__extends)(ChainSequenceWrapper, _super); function ChainSequenceWrapper(data) { var _this = this; var residueCount = 0; var elementCount = 0; var counts = []; var l = structure_1.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]; structure_1.StructureElement.Location.set(l, data.structure, unit, unit.elements[0]); var entitySeq = unit.model.sequence.byEntityKey[structure_1.StructureProperties.entity.key(l)]; if (entitySeq) residueCount += entitySeq.sequence.length; elementCount += unit.elements.length; var indices = int_1.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 = structure_1.StructureElement.Loci(_this.data.structure, lociElements); return _this; } ChainSequenceWrapper.prototype.residueLabel = function (seqIdx) { return this.label; }; ChainSequenceWrapper.prototype.residueColor = function (seqIdx) { return names_1.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 (structure_1.StructureElement.Loci.is(loci)) { if (!structure_1.Structure.areRootsEquivalent(loci.structure, structure)) return false; loci = structure_1.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 (int_1.OrderedSet.isSubset(indices, e.indices)) { if ((0, marker_action_1.applyMarkerAction)(this.markerArray, int_1.Interval.ofSingleton(0), action)) changed = true; } } } } else if (structure_1.Structure.isLoci(loci)) { if (!structure_1.Structure.areRootsEquivalent(loci.structure, structure)) return false; if ((0, marker_action_1.applyMarkerAction)(this.markerArray, int_1.Interval.ofSingleton(0), action)) changed = true; } return changed; }; ChainSequenceWrapper.prototype.getLoci = function (seqIdx) { return this.loci; }; return ChainSequenceWrapper; }(wrapper_1.SequenceWrapper)); exports.ChainSequenceWrapper = ChainSequenceWrapper; //# sourceMappingURL=chain.js.map