molstar
Version:
A comprehensive macromolecular library.
185 lines • 8.48 kB
JavaScript
"use strict";
/**
* Copyright (c) 2019-2020 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.ComponentBuilder = void 0;
var db_1 = require("../../../mol-data/db");
var types_1 = require("../../../mol-model/structure/model/types");
var set_1 = require("../../../mol-util/set");
var schema_1 = require("../basic/schema");
var ProteinAtomIdsList = [
new Set(['CA']),
new Set(['C']),
new Set(['N'])
];
var RnaAtomIdsList = [
new Set(['P', 'O3\'', 'O3*']),
new Set(['C4\'', 'C4*']),
new Set(['O2\'', 'O2*', 'F2\'', 'F2*'])
];
var DnaAtomIdsList = [
new Set(['P', 'O3\'', 'O3*']),
new Set(['C3\'', 'C3*']),
new Set(['O2\'', 'O2*', 'F2\'', 'F2*'])
];
/** Used to reduce false positives for atom name-based type guessing */
var NonPolymerNames = new Set([
'FMN', 'NCN', 'FNS', 'FMA' // Mononucleotides
]);
var StandardComponents = (function () {
var map = new Map();
var components = [
{ id: 'HIS', name: 'HISTIDINE', type: 'L-peptide linking' },
{ id: 'ARG', name: 'ARGININE', type: 'L-peptide linking' },
{ id: 'LYS', name: 'LYSINE', type: 'L-peptide linking' },
{ id: 'ILE', name: 'ISOLEUCINE', type: 'L-peptide linking' },
{ id: 'PHE', name: 'PHENYLALANINE', type: 'L-peptide linking' },
{ id: 'LEU', name: 'LEUCINE', type: 'L-peptide linking' },
{ id: 'TRP', name: 'TRYPTOPHAN', type: 'L-peptide linking' },
{ id: 'ALA', name: 'ALANINE', type: 'L-peptide linking' },
{ id: 'MET', name: 'METHIONINE', type: 'L-peptide linking' },
{ id: 'CYS', name: 'CYSTEINE', type: 'L-peptide linking' },
{ id: 'ASN', name: 'ASPARAGINE', type: 'L-peptide linking' },
{ id: 'VAL', name: 'VALINE', type: 'L-peptide linking' },
{ id: 'GLY', name: 'GLYCINE', type: 'peptide linking' },
{ id: 'SER', name: 'SERINE', type: 'L-peptide linking' },
{ id: 'GLN', name: 'GLUTAMINE', type: 'L-peptide linking' },
{ id: 'TYR', name: 'TYROSINE', type: 'L-peptide linking' },
{ id: 'ASP', name: 'ASPARTIC ACID', type: 'L-peptide linking' },
{ id: 'GLU', name: 'GLUTAMIC ACID', type: 'L-peptide linking' },
{ id: 'THR', name: 'THREONINE', type: 'L-peptide linking' },
{ id: 'PRO', name: 'PROLINE', type: 'L-peptide linking' },
{ id: 'SEC', name: 'SELENOCYSTEINE', type: 'L-peptide linking' },
{ id: 'PYL', name: 'PYRROLYSINE', type: 'L-peptide linking' },
{ id: 'MSE', name: 'SELENOMETHIONINE', type: 'L-peptide linking' },
{ id: 'SEP', name: 'PHOSPHOSERINE', type: 'L-peptide linking' },
{ id: 'TPO', name: 'PHOSPHOTHREONINE', type: 'L-peptide linking' },
{ id: 'PTR', name: 'O-PHOSPHOTYROSINE', type: 'L-peptide linking' },
{ id: 'PCA', name: 'PYROGLUTAMIC ACID', type: 'L-peptide linking' },
{ id: 'A', name: 'ADENOSINE-5\'-MONOPHOSPHATE', type: 'RNA linking' },
{ id: 'C', name: 'CYTIDINE-5\'-MONOPHOSPHATE', type: 'RNA linking' },
{ id: 'T', name: 'THYMIDINE-5\'-MONOPHOSPHATE', type: 'RNA linking' },
{ id: 'G', name: 'GUANOSINE-5\'-MONOPHOSPHATE', type: 'RNA linking' },
{ id: 'I', name: 'INOSINIC ACID', type: 'RNA linking' },
{ id: 'U', name: 'URIDINE-5\'-MONOPHOSPHATE', type: 'RNA linking' },
{ id: 'DA', name: '2\'-DEOXYADENOSINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
{ id: 'DC', name: '2\'-DEOXYCYTIDINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
{ id: 'DT', name: 'THYMIDINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
{ id: 'DG', name: '2\'-DEOXYGUANOSINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
{ id: 'DI', name: '2\'-DEOXYINOSINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
{ id: 'DU', name: '2\'-DEOXYURIDINE-5\'-MONOPHOSPHATE', type: 'DNA linking' },
];
components.forEach(function (c) { return map.set(c.id, c); });
return map;
})();
var CharmmIonComponents = (function () {
var map = new Map();
var components = [
{ id: 'ZN2', name: 'ZINC ION', type: 'Ion' },
{ id: 'SOD', name: 'SODIUM ION', type: 'Ion' },
{ id: 'CES', name: 'CESIUM ION', type: 'Ion' },
{ id: 'CLA', name: 'CHLORIDE ION', type: 'Ion' },
{ id: 'CAL', name: 'CALCIUM ION', type: 'Ion' },
{ id: 'POT', name: 'POTASSIUM ION', type: 'Ion' },
];
components.forEach(function (c) { return map.set(c.id, c); });
return map;
})();
var ComponentBuilder = /** @class */ (function () {
function ComponentBuilder(seqId, atomId) {
this.seqId = seqId;
this.atomId = atomId;
this.namesMap = new Map();
this.comps = new Map();
this.ids = [];
this.names = [];
this.types = [];
this.mon_nstd_flags = [];
}
ComponentBuilder.prototype.set = function (c) {
this.comps.set(c.id, c);
this.ids.push(c.id);
this.names.push(c.name);
this.types.push(c.type);
this.mon_nstd_flags.push(types_1.PolymerNames.has(c.id) ? 'y' : 'n');
};
ComponentBuilder.prototype.getAtomIds = function (index) {
var atomIds = new Set();
var prevSeqId = this.seqId.value(index);
while (index < this.seqId.rowCount) {
var seqId = this.seqId.value(index);
if (seqId !== prevSeqId)
break;
atomIds.add(this.atomId.value(index));
prevSeqId - seqId;
index += 1;
}
return atomIds;
};
ComponentBuilder.prototype.hasAtomIds = function (atomIds, atomIdsList) {
for (var i = 0, il = atomIdsList.length; i < il; ++i) {
if (!set_1.SetUtils.areIntersecting(atomIds, atomIdsList[i])) {
return false;
}
}
return true;
};
ComponentBuilder.prototype.getType = function (atomIds) {
if (this.hasAtomIds(atomIds, ProteinAtomIdsList)) {
return 'peptide linking';
}
else if (this.hasAtomIds(atomIds, RnaAtomIdsList)) {
return 'RNA linking';
}
else if (this.hasAtomIds(atomIds, DnaAtomIdsList)) {
return 'DNA linking';
}
else {
return 'other';
}
};
ComponentBuilder.prototype.has = function (compId) { return this.comps.has(compId); };
ComponentBuilder.prototype.get = function (compId) { return this.comps.get(compId); };
ComponentBuilder.prototype.add = function (compId, index) {
if (!this.has(compId)) {
if (StandardComponents.has(compId)) {
this.set(StandardComponents.get(compId));
}
else if (types_1.WaterNames.has(compId)) {
this.set({ id: compId, name: 'WATER', type: 'non-polymer' });
}
else if (NonPolymerNames.has(compId)) {
this.set({ id: compId, name: this.namesMap.get(compId) || compId, type: 'non-polymer' });
}
else {
var atomIds = this.getAtomIds(index);
if (atomIds.size === 1 && CharmmIonComponents.has(compId)) {
this.set(CharmmIonComponents.get(compId));
}
else {
var type = this.getType(atomIds);
this.set({ id: compId, name: this.namesMap.get(compId) || compId, type: type });
}
}
}
return this.get(compId);
};
ComponentBuilder.prototype.getChemCompTable = function () {
return db_1.Table.ofPartialColumns(schema_1.BasicSchema.chem_comp, {
id: db_1.Column.ofStringArray(this.ids),
name: db_1.Column.ofStringArray(this.names),
type: db_1.Column.ofStringAliasArray(this.types),
mon_nstd_flag: db_1.Column.ofStringAliasArray(this.mon_nstd_flags),
}, this.ids.length);
};
ComponentBuilder.prototype.setNames = function (names) {
var _this = this;
names.forEach(function (n) { return _this.namesMap.set(n[0], n[1]); });
};
return ComponentBuilder;
}());
exports.ComponentBuilder = ComponentBuilder;
//# sourceMappingURL=component.js.map