UNPKG

molstar

Version:

A comprehensive macromolecular library.

87 lines 3.88 kB
"use strict"; /** * Copyright (c) 2020 Mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ComponentAtom = void 0; var cif_1 = require("../../../../mol-io/writer/cif"); var db_1 = require("../../../../mol-data/db"); var property_1 = require("../../common/property"); var ccd_1 = require("../../../../mol-io/reader/cif/schema/ccd"); var ComponentAtom; (function (ComponentAtom) { ComponentAtom.Descriptor = { name: 'chem_comp_atom', cifExport: { prefix: '', categories: [{ name: 'chem_comp_atom', instance: function (ctx) { var p = ComponentAtom.Provider.get(ctx.firstModel); if (!p) return cif_1.CifWriter.Category.Empty; var chem_comp_atom = p.data; if (!chem_comp_atom) return cif_1.CifWriter.Category.Empty; var comp_names = ctx.structures[0].uniqueResidueNames; var comp_id = chem_comp_atom.comp_id, _rowCount = chem_comp_atom._rowCount; var indices = []; for (var i = 0; i < _rowCount; i++) { if (comp_names.has(comp_id.value(i))) indices[indices.length] = i; } return cif_1.CifWriter.Category.ofTable(chem_comp_atom, indices); } }] } }; ComponentAtom.Provider = property_1.FormatPropertyProvider.create(ComponentAtom.Descriptor); function chemCompAtomFromTable(model, table) { return db_1.Table.pick(table, ccd_1.CCD_Schema.chem_comp_atom, function (i) { return model.properties.chemicalComponentMap.has(table.comp_id.value(i)); }); } ComponentAtom.chemCompAtomFromTable = chemCompAtomFromTable; function getEntriesFromChemCompAtom(data) { var entries = new Map(); function addEntry(id) { // weird behavior when 'PRO' is requested - will report a single bond between N and H because a later operation would override real content if (entries.has(id)) { return entries.get(id); } var e = new Entry(id); entries.set(id, e); return e; } var comp_id = data.comp_id, atom_id = data.atom_id, charge = data.charge, pdbx_stereo_config = data.pdbx_stereo_config, _rowCount = data._rowCount; var entry = addEntry(comp_id.value(0)); for (var i = 0; i < _rowCount; i++) { var name_1 = atom_id.value(i); var id = comp_id.value(i); var ch = charge.value(i); var stereo = pdbx_stereo_config.value(i); if (entry.id !== id) { entry = addEntry(id); } entry.add(name_1, ch, stereo); } return entries; } ComponentAtom.getEntriesFromChemCompAtom = getEntriesFromChemCompAtom; var Entry = /** @class */ (function () { function Entry(id) { this.id = id; this.map = new Map(); } Entry.prototype.add = function (a, charge, stereo_config) { this.map.set(a, { charge: charge, stereo_config: stereo_config }); }; return Entry; }()); ComponentAtom.Entry = Entry; })(ComponentAtom = exports.ComponentAtom || (exports.ComponentAtom = {})); //# sourceMappingURL=chem_comp.js.map