UNPKG

molstar

Version:

A comprehensive macromolecular library.

227 lines (226 loc) 12.4 kB
"use strict"; /** * Copyright (c) 2017-2018 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> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.atomIdFields = exports.entityIdFields = exports.chainIdFields = exports.residueIdFields = exports._atom_site = void 0; var cif_1 = require("../../../../mol-io/writer/cif"); var mmcif_1 = require("../../../../mol-model-formats/structure/mmcif"); var sifts_mapping_1 = require("../../../../mol-model-props/sequence/sifts-mapping"); var structure_1 = require("../../structure"); var CifField = cif_1.CifWriter.Field; var E = cif_1.CifWriter.Encodings; function atom_site_label_asym_id(e) { var l = structure_1.StructureProperties.chain.label_asym_id(e); var suffix = e.unit.conformation.operator.suffix; if (!suffix) return l; return l + suffix; } function atom_site_auth_asym_id(e) { var l = structure_1.StructureProperties.chain.auth_asym_id(e); var suffix = e.unit.conformation.operator.suffix; if (!suffix) return l; return l + suffix; } var atom_site_pdbx_label_index = { shouldInclude: function (s) { var _a; return !!((_a = s.atom_site) === null || _a === void 0 ? void 0 : _a.pdbx_label_index.isDefined); }, value: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_label_index.value(srcIndex); }, }; var SIFTS = { shouldInclude: function (s) { return sifts_mapping_1.SIFTSMapping.isAvailable(s.structure.models[0]); }, pdbx_sifts_xref_db_name: { value: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_name.value(srcIndex); }, valueKind: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_name.valueKind(srcIndex); }, }, pdbx_sifts_xref_db_acc: { value: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_acc.value(srcIndex); }, valueKind: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_acc.valueKind(srcIndex); }, }, pdbx_sifts_xref_db_num: { value: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_num.value(srcIndex); }, valueKind: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_num.valueKind(srcIndex); }, }, pdbx_sifts_xref_db_res: { value: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_res.value(srcIndex); }, valueKind: function (e, d) { var srcIndex = d.sourceIndex.value(e.element); return d.atom_site.pdbx_sifts_xref_db_res.valueKind(srcIndex); }, } }; var atom_site_fields = function () { return cif_1.CifWriter.fields() .str('group_PDB', structure_1.StructureProperties.residue.group_PDB) .index('id') .str('type_symbol', structure_1.StructureProperties.atom.type_symbol) .str('label_atom_id', structure_1.StructureProperties.atom.label_atom_id) .str('label_comp_id', structure_1.StructureProperties.atom.label_comp_id) .int('label_seq_id', structure_1.StructureProperties.residue.label_seq_id, { encoder: E.deltaRLE, valueKind: function (k, d) { var m = k.unit.model; return m.atomicHierarchy.residues.label_seq_id.valueKind(m.atomicHierarchy.residueAtomSegments.index[k.element]); } }) .str('label_alt_id', structure_1.StructureProperties.atom.label_alt_id) .str('pdbx_PDB_ins_code', structure_1.StructureProperties.residue.pdbx_PDB_ins_code) .str('label_asym_id', atom_site_label_asym_id) .str('label_entity_id', structure_1.StructureProperties.chain.label_entity_id) .float('Cartn_x', structure_1.StructureProperties.atom.x, { digitCount: 3, encoder: E.fixedPoint3 }) .float('Cartn_y', structure_1.StructureProperties.atom.y, { digitCount: 3, encoder: E.fixedPoint3 }) .float('Cartn_z', structure_1.StructureProperties.atom.z, { digitCount: 3, encoder: E.fixedPoint3 }) .float('occupancy', structure_1.StructureProperties.atom.occupancy, { digitCount: 2, encoder: E.fixedPoint2 }) .float('B_iso_or_equiv', structure_1.StructureProperties.atom.B_iso_or_equiv, { digitCount: 2, encoder: E.fixedPoint2 }) .int('pdbx_formal_charge', structure_1.StructureProperties.atom.pdbx_formal_charge, { encoder: E.deltaRLE, valueKind: function (k, d) { return k.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.valueKind(k.element); } }) .str('auth_atom_id', structure_1.StructureProperties.atom.auth_atom_id) .str('auth_comp_id', structure_1.StructureProperties.atom.auth_comp_id) .int('auth_seq_id', structure_1.StructureProperties.residue.auth_seq_id, { encoder: E.deltaRLE }) .str('auth_asym_id', atom_site_auth_asym_id) .int('pdbx_PDB_model_num', structure_1.StructureProperties.unit.model_num, { encoder: E.deltaRLE }) .int('pdbx_label_index', atom_site_pdbx_label_index.value, { shouldInclude: atom_site_pdbx_label_index.shouldInclude }) // SIFTS .str('pdbx_sifts_xref_db_name', SIFTS.pdbx_sifts_xref_db_name.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_name.valueKind }) .str('pdbx_sifts_xref_db_acc', SIFTS.pdbx_sifts_xref_db_acc.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_acc.valueKind }) .str('pdbx_sifts_xref_db_num', SIFTS.pdbx_sifts_xref_db_num.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_num.valueKind }) .str('pdbx_sifts_xref_db_res', SIFTS.pdbx_sifts_xref_db_res.value, { shouldInclude: SIFTS.shouldInclude, valueKind: SIFTS.pdbx_sifts_xref_db_res.valueKind }) // .str('operator_name', P.unit.operator_name, { // shouldInclude: structure => structure.units.some(u => !u.conformation.operator.isIdentity) // }) .getFields(); }; exports._atom_site = { name: 'atom_site', instance: function (_a) { var structures = _a.structures; return { fields: atom_site_fields(), source: structures.map(function (s) { return ({ data: { structure: s, sourceIndex: s.model.atomicHierarchy.atomSourceIndex, atom_site: mmcif_1.MmcifFormat.is(s.model.sourceData) ? s.model.sourceData.data.db.atom_site : void 0 }, rowCount: s.elementCount, keys: function () { return s.elementLocations(); } }); }) }; } }; function prepostfixed(prefix, name) { if (prefix) return "".concat(prefix, "_").concat(name); return name; } function prefixedInsCode(prefix) { if (!prefix) return 'pdbx_PDB_ins_code'; return "pdbx_".concat(prefix, "_PDB_ins_code"); } function mappedProp(loc, prop) { return function (k, d) { return prop(loc(k, d)); }; } function addModelNum(fields, getLocation, options) { if (options && options.includeModelNum) { fields.int('pdbx_PDB_model_num', mappedProp(getLocation, structure_1.StructureProperties.unit.model_num)); } } function residueIdFields(getLocation, options) { var prefix = options && options.prefix; var ret = cif_1.CifWriter.fields() .str(prepostfixed(prefix, "label_comp_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.label_comp_id)) .int(prepostfixed(prefix, "label_seq_id"), mappedProp(getLocation, structure_1.StructureProperties.residue.label_seq_id), { encoder: E.deltaRLE, valueKind: function (k, d) { var e = getLocation(k, d); var m = e.unit.model; return m.atomicHierarchy.residues.label_seq_id.valueKind(m.atomicHierarchy.residueAtomSegments.index[e.element]); } }) .str(prefixedInsCode(prefix), mappedProp(getLocation, structure_1.StructureProperties.residue.pdbx_PDB_ins_code)) .str(prepostfixed(prefix, "label_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_asym_id)) .str(prepostfixed(prefix, "label_entity_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_entity_id)) .str(prepostfixed(prefix, "auth_comp_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.auth_comp_id)) .int(prepostfixed(prefix, "auth_seq_id"), mappedProp(getLocation, structure_1.StructureProperties.residue.auth_seq_id), { encoder: E.deltaRLE }) .str(prepostfixed(prefix, "auth_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.auth_asym_id)); addModelNum(ret, getLocation, options); return ret.getFields(); } exports.residueIdFields = residueIdFields; function chainIdFields(getLocation, options) { var prefix = options && options.prefix; var ret = CifField.build() .str(prepostfixed(prefix, "label_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_asym_id)) .str(prepostfixed(prefix, "label_entity_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_entity_id)) .str(prepostfixed(prefix, "auth_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.auth_asym_id)); addModelNum(ret, getLocation, options); return ret.getFields(); } exports.chainIdFields = chainIdFields; function entityIdFields(getLocation, options) { var prefix = options && options.prefix; var ret = CifField.build() .str(prepostfixed(prefix, "label_entity_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_entity_id)); addModelNum(ret, getLocation, options); return ret.getFields(); } exports.entityIdFields = entityIdFields; function atomIdFields(getLocation, options) { var prefix = options && options.prefix; var ret = cif_1.CifWriter.fields() .str(prepostfixed(prefix, "label_atom_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.label_atom_id)) .str(prepostfixed(prefix, "label_comp_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.label_comp_id)) .int(prepostfixed(prefix, "label_seq_id"), mappedProp(getLocation, structure_1.StructureProperties.residue.label_seq_id), { encoder: E.deltaRLE, valueKind: function (k, d) { var e = getLocation(k, d); var m = e.unit.model; return m.atomicHierarchy.residues.label_seq_id.valueKind(m.atomicHierarchy.residueAtomSegments.index[e.element]); } }) .str(prepostfixed(prefix, "label_alt_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.label_alt_id)) .str(prefixedInsCode(prefix), mappedProp(getLocation, structure_1.StructureProperties.residue.pdbx_PDB_ins_code)) .str(prepostfixed(prefix, "label_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_asym_id)) .str(prepostfixed(prefix, "label_entity_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.label_entity_id)) .str(prepostfixed(prefix, "auth_atom_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.auth_atom_id)) .str(prepostfixed(prefix, "auth_comp_id"), mappedProp(getLocation, structure_1.StructureProperties.atom.auth_comp_id)) .int(prepostfixed(prefix, "auth_seq_id"), mappedProp(getLocation, structure_1.StructureProperties.residue.auth_seq_id), { encoder: E.deltaRLE }) .str(prepostfixed(prefix, "auth_asym_id"), mappedProp(getLocation, structure_1.StructureProperties.chain.auth_asym_id)); addModelNum(ret, getLocation, options); return ret.getFields(); } exports.atomIdFields = atomIdFields;