molstar
Version:
A comprehensive macromolecular library.
142 lines • 5.71 kB
JavaScript
/**
* Copyright (c) 2017-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>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProperties = void 0;
var types_1 = require("../../../mol-model/structure/model/types");
var constants_1 = require("../../../mol-model/structure/structure/carbohydrates/constants");
var memoize_1 = require("../../../mol-util/memoize");
var db_1 = require("../../../mol-data/db");
function getMissingResidues(data) {
var map = new Map();
var getKey = function (model_num, asym_id, seq_id) {
return model_num + "|" + asym_id + "|" + seq_id;
};
var c = data.pdbx_unobs_or_zero_occ_residues;
for (var i = 0, il = c._rowCount; i < il; ++i) {
var key = getKey(c.PDB_model_num.value(i), c.label_asym_id.value(i), c.label_seq_id.value(i));
map.set(key, { polymer_flag: c.polymer_flag.value(i), occupancy_flag: c.occupancy_flag.value(i) });
}
return {
has: function (model_num, asym_id, seq_id) {
return map.has(getKey(model_num, asym_id, seq_id));
},
get: function (model_num, asym_id, seq_id) {
return map.get(getKey(model_num, asym_id, seq_id));
},
size: map.size
};
}
function getChemicalComponentMap(data) {
var map = new Map();
if (data.chem_comp._rowCount > 0) {
var id = data.chem_comp.id;
for (var i = 0, il = id.rowCount; i < il; ++i) {
map.set(id.value(i), db_1.Table.getRow(data.chem_comp, i));
}
}
else {
var uniqueNames = getUniqueComponentNames(data);
uniqueNames.forEach(function (n) {
map.set(n, (0, types_1.getDefaultChemicalComponent)(n));
});
}
return map;
}
function getSaccharideComponentMap(data) {
var map = new Map();
if (data.pdbx_chem_comp_identifier._rowCount > 0) {
// note that `pdbx_chem_comp_identifier` does not contain
// a 'SNFG CARBOHYDRATE SYMBOL' entry for 'Unknown' saccharide components
// so we always need to check `chem_comp` for those
var _a = data.pdbx_chem_comp_identifier, comp_id = _a.comp_id, type = _a.type, identifier = _a.identifier;
for (var i = 0, il = comp_id.rowCount; i < il; ++i) {
if (type.value(i) === 'SNFG CARBOHYDRATE SYMBOL' ||
type.value(i) === 'SNFG CARB SYMBOL' // legacy, to be removed from mmCIF dictionary
) {
var snfgName = identifier.value(i);
var saccharideComp = constants_1.SaccharidesSnfgMap.get(snfgName);
if (saccharideComp) {
map.set(comp_id.value(i), saccharideComp);
}
else {
console.warn("Unknown SNFG name '" + snfgName + "'");
}
}
}
}
if (data.chem_comp._rowCount > 0) {
var _b = data.chem_comp, id = _b.id, type = _b.type;
for (var i = 0, il = id.rowCount; i < il; ++i) {
var _id = id.value(i);
if (map.has(_id))
continue;
var _type = type.value(i);
if (constants_1.SaccharideCompIdMap.has(_id)) {
map.set(_id, constants_1.SaccharideCompIdMap.get(_id));
}
else if ((0, types_1.getMoleculeType)(_type, _id) === 9 /* Saccharide */) {
map.set(_id, constants_1.UnknownSaccharideComponent);
}
}
}
else {
var uniqueNames_1 = getUniqueComponentNames(data);
constants_1.SaccharideCompIdMap.forEach(function (v, k) {
if (!map.has(k) && uniqueNames_1.has(k))
map.set(k, v);
});
}
return map;
}
var getUniqueComponentNames = (0, memoize_1.memoize1)(function (data) {
var uniqueNames = new Set();
var _a = data.atom_site, label_comp_id = _a.label_comp_id, auth_comp_id = _a.auth_comp_id;
var comp_id = label_comp_id.isDefined ? label_comp_id : auth_comp_id;
for (var i = 0, il = comp_id.rowCount; i < il; ++i) {
uniqueNames.add(comp_id.value(i));
}
return uniqueNames;
});
function getStructAsymMap(data) {
var map = new Map();
var _a = data.atom_site, label_asym_id = _a.label_asym_id, auth_asym_id = _a.auth_asym_id, label_entity_id = _a.label_entity_id;
for (var i = 0, il = label_asym_id.rowCount; i < il; ++i) {
var id = label_asym_id.value(i);
if (!map.has(id)) {
map.set(id, {
id: id,
auth_id: auth_asym_id.value(i),
entity_id: label_entity_id.value(i)
});
}
}
if (data.struct_asym._rowCount > 0) {
var _b = data.struct_asym, id = _b.id, entity_id = _b.entity_id;
for (var i = 0, il = id.rowCount; i < il; ++i) {
var _id = id.value(i);
if (!map.has(_id)) {
map.set(_id, {
id: _id,
auth_id: '',
entity_id: entity_id.value(i)
});
}
}
}
return map;
}
function getProperties(data) {
return {
missingResidues: getMissingResidues(data),
chemicalComponentMap: getChemicalComponentMap(data),
saccharideComponentMap: getSaccharideComponentMap(data),
structAsymMap: getStructAsymMap(data)
};
}
exports.getProperties = getProperties;
//# sourceMappingURL=properties.js.map
;