molstar
Version:
A comprehensive macromolecular library.
113 lines • 4.75 kB
JavaScript
/**
* 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.parseHetnam = exports.parseCmpnd = void 0;
var Spec = {
'MOL_ID': '',
'MOLECULE': '',
'CHAIN': '',
'FRAGMENT': '',
'SYNONYM': '',
'EC': '',
'ENGINEERED': '',
'MUTATION': '',
'OTHER_DETAILS': ''
};
function parseCmpnd(lines, lineStart, lineEnd) {
var getLine = function (n) { return lines.data.substring(lines.indices[2 * n], lines.indices[2 * n + 1]); };
var currentSpec;
var currentCompound = { chains: [], description: '' };
var compounds = [];
for (var i = lineStart; i < lineEnd; i++) {
var line = getLine(i);
// COLUMNS DATA TYPE FIELD DEFINITION
// ----------------------------------------------------------------------------------
// 1 - 6 Record name "COMPND"
// 8 - 10 Continuation continuation Allows concatenation of multiple records.
// 11 - 80 Specification compound Description of the molecular components.
// list
var cmpnd = line.substr(10, 70).trim();
var cmpndSpecEnd = cmpnd.indexOf(':');
var cmpndSpec = cmpnd.substring(0, cmpndSpecEnd);
var value = void 0;
if (cmpndSpec in Spec) {
currentSpec = cmpndSpec;
value = cmpnd.substring(cmpndSpecEnd + 2);
}
else {
value = cmpnd;
}
value = value.replace(/;$/, '');
if (currentSpec === 'MOL_ID') {
currentCompound = {
chains: [],
description: ''
};
compounds.push(currentCompound);
}
else if (currentSpec === 'MOLECULE') {
if (currentCompound.description)
currentCompound.description += ' ';
currentCompound.description += value;
}
else if (currentSpec === 'CHAIN') {
Array.prototype.push.apply(currentCompound.chains, value.split(/\s*,\s*/));
}
}
// Define a seprate entity for each chain
// --------------------------------------
//
// This is a workaround for how sequences are currently determined for PDB files.
//
// The current approach infers the "observed sequence" from the atomic hierarchy.
// However, for example for PDB ID 3HHR, this approach fails, since chains B and C
// belong to the same entity but contain different observed sequence, which causes display
// errors in the sequence viewer (since the sequences are determined "per entity").
//
// A better approach could be to parse SEQRES categories and use it to construct
// entity_poly_seq category. However, this would require constructing label_seq_id (with gaps)
// from RES ID pdb column (auth_seq_id), which isn't a trivial exercise.
//
// (properly formatted) mmCIF structures do not exhibit this issue.
var singletons = [];
for (var _i = 0, compounds_1 = compounds; _i < compounds_1.length; _i++) {
var comp = compounds_1[_i];
for (var _a = 0, _b = comp.chains; _a < _b.length; _a++) {
var chain = _b[_a];
singletons.push({
description: comp.description,
chains: [chain]
});
}
}
return singletons;
}
exports.parseCmpnd = parseCmpnd;
function parseHetnam(lines, lineStart, lineEnd) {
var getLine = function (n) { return lines.data.substring(lines.indices[2 * n], lines.indices[2 * n + 1]); };
var hetnams = new Map();
for (var i = lineStart; i < lineEnd; i++) {
var line = getLine(i);
// COLUMNS DATA TYPE FIELD DEFINITION
// ----------------------------------------------------------------------------
// 1 - 6 Record name "HETNAM"
// 9 - 10 Continuation continuation Allows concatenation of multiple records.
// 12 - 14 LString(3) hetID Het identifier, right-justified.
// 16 - 70 String text Chemical name.
var het = line.substr(11, 3).trim();
var name_1 = line.substr(15).trim();
if (hetnams.has(het)) {
hetnams.set(het, hetnams.get(het) + " " + name_1);
}
else {
hetnams.set(het, name_1);
}
}
return hetnams;
}
exports.parseHetnam = parseHetnam;
//# sourceMappingURL=entity.js.map
;