molstar
Version:
A comprehensive macromolecular library.
96 lines • 4.42 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.HydrophobicityColorThemeProvider = exports.HydrophobicityColorTheme = exports.hydrophobicity = exports.getHydrophobicityColorThemeParams = exports.HydrophobicityColorThemeParams = void 0;
var color_1 = require("../../mol-util/color");
var structure_1 = require("../../mol-model/structure");
var param_definition_1 = require("../../mol-util/param-definition");
var types_1 = require("../../mol-model/structure/model/types");
var Description = 'Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).';
exports.HydrophobicityColorThemeParams = {
list: param_definition_1.ParamDefinition.ColorList('red-yellow-green', { presetKind: 'scale' }),
scale: param_definition_1.ParamDefinition.Select('DGwif', [['DGwif', 'DG water-membrane'], ['DGwoct', 'DG water-octanol'], ['Oct-IF', 'DG difference']])
};
function getHydrophobicityColorThemeParams(ctx) {
return exports.HydrophobicityColorThemeParams; // TODO return copy
}
exports.getHydrophobicityColorThemeParams = getHydrophobicityColorThemeParams;
var scaleIndexMap = { 'DGwif': 0, 'DGwoct': 1, 'Oct-IF': 2 };
function hydrophobicity(compId, scaleIndex) {
var c = types_1.ResidueHydrophobicity[compId];
return c === undefined ? 0 : c[scaleIndex];
}
exports.hydrophobicity = hydrophobicity;
function getAtomicCompId(unit, element) {
return unit.model.atomicHierarchy.atoms.label_comp_id.value(element);
}
function getCoarseCompId(unit, element) {
var seqIdBegin = unit.coarseElements.seq_id_begin.value(element);
var seqIdEnd = unit.coarseElements.seq_id_end.value(element);
if (seqIdBegin === seqIdEnd) {
var entityKey = unit.coarseElements.entityKey[element];
var seq = unit.model.sequence.byEntityKey[entityKey].sequence;
return seq.compId.value(seqIdBegin - 1); // 1-indexed
}
}
function HydrophobicityColorTheme(ctx, props) {
var scaleIndex = scaleIndexMap[props.scale];
// get domain
var min = Infinity;
var max = -Infinity;
for (var name_1 in types_1.ResidueHydrophobicity) {
var val = types_1.ResidueHydrophobicity[name_1][scaleIndex];
min = Math.min(min, val);
max = Math.max(max, val);
}
var scale = color_1.ColorScale.create({
listOrName: props.list.colors,
domain: [max, min],
minLabel: 'Hydrophobic',
maxLabel: 'Hydrophilic'
});
function color(location) {
var compId;
if (structure_1.StructureElement.Location.is(location)) {
if (structure_1.Unit.isAtomic(location.unit)) {
compId = getAtomicCompId(location.unit, location.element);
}
else {
compId = getCoarseCompId(location.unit, location.element);
}
}
else if (structure_1.Bond.isLocation(location)) {
if (structure_1.Unit.isAtomic(location.aUnit)) {
compId = getAtomicCompId(location.aUnit, location.aUnit.elements[location.aIndex]);
}
else {
compId = getCoarseCompId(location.aUnit, location.aUnit.elements[location.aIndex]);
}
}
return scale.color(compId ? hydrophobicity(compId, scaleIndex) : 0);
}
return {
factory: HydrophobicityColorTheme,
granularity: 'group',
preferSmoothing: true,
color: color,
props: props,
description: Description,
legend: scale ? scale.legend : undefined
};
}
exports.HydrophobicityColorTheme = HydrophobicityColorTheme;
exports.HydrophobicityColorThemeProvider = {
name: 'hydrophobicity',
label: 'Hydrophobicity',
category: "Residue Property" /* Residue */,
factory: HydrophobicityColorTheme,
getParams: getHydrophobicityColorThemeParams,
defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.HydrophobicityColorThemeParams),
isApplicable: function (ctx) { return !!ctx.structure; }
};
//# sourceMappingURL=hydrophobicity.js.map
;