molstar
Version:
A comprehensive macromolecular library.
160 lines • 8.47 kB
JavaScript
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Michal Malý <michal.maly@ibt.cas.cz>
* @author Jiří Černý <jiri.cerny@ibt.cas.cz>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfalPyramidsProvider = exports.ConfalPyramidsParams = exports.ConfalPyramids = void 0;
var tslib_1 = require("tslib");
var types_1 = require("./types");
var db_1 = require("../../../mol-data/db");
var schema_1 = require("../../../mol-io/reader/cif/schema");
var custom_property_1 = require("../../../mol-model/custom-property");
var custom_model_property_1 = require("../../../mol-model-props/common/custom-model-property");
var wrapper_1 = require("../../../mol-model-props/common/wrapper");
var param_definition_1 = require("../../../mol-util/param-definition");
var mmcif_1 = require("../../../mol-model-formats/structure/mmcif");
var ConfalPyramids;
(function (ConfalPyramids) {
ConfalPyramids.Schema = {
ndb_struct_ntc_step: {
id: db_1.Column.Schema.int,
name: db_1.Column.Schema.str,
PDB_model_number: db_1.Column.Schema.int,
label_entity_id_1: db_1.Column.Schema.int,
label_asym_id_1: db_1.Column.Schema.str,
label_seq_id_1: db_1.Column.Schema.int,
label_comp_id_1: db_1.Column.Schema.str,
label_alt_id_1: db_1.Column.Schema.str,
label_entity_id_2: db_1.Column.Schema.int,
label_asym_id_2: db_1.Column.Schema.str,
label_seq_id_2: db_1.Column.Schema.int,
label_comp_id_2: db_1.Column.Schema.str,
label_alt_id_2: db_1.Column.Schema.str,
auth_asym_id_1: db_1.Column.Schema.str,
auth_seq_id_1: db_1.Column.Schema.int,
auth_asym_id_2: db_1.Column.Schema.str,
auth_seq_id_2: db_1.Column.Schema.int,
PDB_ins_code_1: db_1.Column.Schema.str,
PDB_ins_code_2: db_1.Column.Schema.str,
},
ndb_struct_ntc_step_summary: {
step_id: db_1.Column.Schema.int,
assigned_CANA: db_1.Column.Schema.str,
assigned_NtC: db_1.Column.Schema.str,
confal_score: db_1.Column.Schema.int,
euclidean_distance_NtC_ideal: db_1.Column.Schema.float,
cartesian_rmsd_closest_NtC_representative: db_1.Column.Schema.float,
closest_CANA: db_1.Column.Schema.str,
closest_NtC: db_1.Column.Schema.str,
closest_step_golden: db_1.Column.Schema.str
}
};
function fromCif(ctx, model, props) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
var info, data, fromCif;
return (0, tslib_1.__generator)(this, function (_a) {
info = wrapper_1.PropertyWrapper.createInfo();
data = getCifData(model);
if (data === undefined)
return [2 /*return*/, { value: { info: info, data: undefined } }];
fromCif = createPyramidsFromCif(model, data.steps, data.stepsSummary);
return [2 /*return*/, { value: { info: info, data: fromCif } }];
});
});
}
ConfalPyramids.fromCif = fromCif;
function getCifData(model) {
if (!mmcif_1.MmcifFormat.is(model.sourceData))
throw new Error('Data format must be mmCIF');
if (!hasNdbStructNtcCategories(model))
return undefined;
return {
steps: (0, schema_1.toTable)(ConfalPyramids.Schema.ndb_struct_ntc_step, model.sourceData.data.frame.categories.ndb_struct_ntc_step),
stepsSummary: (0, schema_1.toTable)(ConfalPyramids.Schema.ndb_struct_ntc_step_summary, model.sourceData.data.frame.categories.ndb_struct_ntc_step_summary)
};
}
function hasNdbStructNtcCategories(model) {
if (!mmcif_1.MmcifFormat.is(model.sourceData))
return false;
var names = (model.sourceData).data.frame.categoryNames;
return names.includes('ndb_struct_ntc_step') && names.includes('ndb_struct_ntc_step_summary');
}
function isApplicable(model) {
return !!model && hasNdbStructNtcCategories(model);
}
ConfalPyramids.isApplicable = isApplicable;
})(ConfalPyramids = exports.ConfalPyramids || (exports.ConfalPyramids = {}));
exports.ConfalPyramidsParams = {};
exports.ConfalPyramidsProvider = custom_model_property_1.CustomModelProperty.createProvider({
label: 'Confal Pyramids',
descriptor: (0, custom_property_1.CustomPropertyDescriptor)({
name: 'confal_pyramids',
}),
type: 'static',
defaultParams: exports.ConfalPyramidsParams,
getParams: function (data) { return exports.ConfalPyramidsParams; },
isApplicable: function (data) { return ConfalPyramids.isApplicable(data); },
obtain: function (ctx, data, props) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
var p;
return (0, tslib_1.__generator)(this, function (_a) {
p = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, param_definition_1.ParamDefinition.getDefaultValues(exports.ConfalPyramidsParams)), props);
return [2 /*return*/, ConfalPyramids.fromCif(ctx, data, p)];
});
}); }
});
function createPyramidsFromCif(model, steps, stepsSummary) {
var pyramids = new Array();
var names = new Map();
var locations = new Array();
var hasMultipleModels = false;
var id = steps.id, PDB_model_number = steps.PDB_model_number, name = steps.name, auth_asym_id_1 = steps.auth_asym_id_1, auth_seq_id_1 = steps.auth_seq_id_1, label_comp_id_1 = steps.label_comp_id_1, label_alt_id_1 = steps.label_alt_id_1, PDB_ins_code_1 = steps.PDB_ins_code_1, auth_asym_id_2 = steps.auth_asym_id_2, auth_seq_id_2 = steps.auth_seq_id_2, label_comp_id_2 = steps.label_comp_id_2, label_alt_id_2 = steps.label_alt_id_2, PDB_ins_code_2 = steps.PDB_ins_code_2, _rowCount = steps._rowCount;
if (_rowCount !== stepsSummary._rowCount)
throw new Error('Inconsistent mmCIF data');
for (var i = 0; i < _rowCount; i++) {
var model_num = PDB_model_number.value(i);
if (model_num !== model.modelNum) {
hasMultipleModels = true;
continue; // We are only interested in data for the current model
}
var _a = getNtCAndConfalScore(id.value(i), i, stepsSummary), _NtC = _a._NtC, _confal_score = _a._confal_score;
var pyramid = {
PDB_model_number: model_num,
name: name.value(i),
auth_asym_id_1: auth_asym_id_1.value(i),
auth_seq_id_1: auth_seq_id_1.value(i),
label_comp_id_1: label_comp_id_1.value(i),
label_alt_id_1: label_alt_id_1.value(i),
PDB_ins_code_1: PDB_ins_code_1.value(i),
auth_asym_id_2: auth_asym_id_2.value(i),
auth_seq_id_2: auth_seq_id_2.value(i),
label_comp_id_2: label_comp_id_2.value(i),
label_alt_id_2: label_alt_id_2.value(i),
PDB_ins_code_2: PDB_ins_code_2.value(i),
confal_score: _confal_score,
NtC: _NtC
};
pyramids.push(pyramid);
names.set(pyramid.name, pyramids.length - 1);
locations.push(types_1.ConfalPyramidsTypes.Location(pyramid, false));
locations.push(types_1.ConfalPyramidsTypes.Location(pyramid, true));
}
return { pyramids: pyramids, names: names, locations: locations, hasMultipleModels: hasMultipleModels };
}
function getNtCAndConfalScore(id, i, stepsSummary) {
var step_id = stepsSummary.step_id, confal_score = stepsSummary.confal_score, assigned_NtC = stepsSummary.assigned_NtC;
// Assume that step_ids in ntc_step_summary are in the same order as steps in ntc_step
for (var j = i; j < stepsSummary._rowCount; j++) {
if (id === step_id.value(j))
return { _NtC: assigned_NtC.value(j), _confal_score: confal_score.value(j) };
}
// Safety net for cases where the previous assumption is not met
for (var j = 0; j < i; j++) {
if (id === step_id.value(j))
return { _NtC: assigned_NtC.value(j), _confal_score: confal_score.value(j) };
}
throw new Error('Inconsistent mmCIF data');
}
//# sourceMappingURL=property.js.map
;