molstar
Version:
A comprehensive macromolecular library.
72 lines • 2.78 kB
JavaScript
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Fred Ludlow <Fred.Ludlow@astx.com>
*
* based in part on NGL (https://github.com/arose/ngl)
*/
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
import { Features } from './features';
import { typeSymbol, eachBondedAtom } from '../chemistry/util';
var HydrophobicParams = {
distanceMax: PD.Numeric(4.0, { min: 1, max: 5, step: 0.1 }),
};
/**
* Hydropbobic atoms
* - Carbon only bonded to carbon or hydrogen
* - Fluorine
*/
function addHydrophobicAtom(structure, unit, builder) {
var elements = unit.elements;
var _a = unit.model.atomicConformation, x = _a.x, y = _a.y, z = _a.z;
var _loop_1 = function (i, il) {
var element = typeSymbol(unit, i);
var flag = false;
if (element === "C" /* C */) {
flag = true;
eachBondedAtom(structure, unit, i, function (unitB, indexB) {
var elementB = typeSymbol(unitB, indexB);
if (elementB !== "C" /* C */ && elementB !== "H" /* H */)
flag = false;
});
}
else if (element === "F" /* F */) {
flag = true;
}
if (flag) {
builder.add(8 /* HydrophobicAtom */, 0 /* None */, x[elements[i]], y[elements[i]], z[elements[i]], i);
}
};
for (var i = 0, il = elements.length; i < il; ++i) {
_loop_1(i, il);
}
}
function isHydrophobicContact(ti, tj) {
return ti === 8 /* HydrophobicAtom */ && tj === 8 /* HydrophobicAtom */;
}
function testHydrophobic(structure, infoA, infoB, distanceSq) {
var typeA = infoA.types[infoA.feature];
var typeB = infoB.types[infoB.feature];
if (!isHydrophobicContact(typeA, typeB))
return;
var indexA = infoA.members[infoA.offsets[infoA.feature]];
var indexB = infoB.members[infoB.offsets[infoB.feature]];
if (typeSymbol(infoA.unit, indexA) === "F" /* F */ && typeSymbol(infoB.unit, indexB) === "F" /* F */)
return;
return 6 /* Hydrophobic */;
}
//
export var HydrophobicAtomProvider = Features.Provider([8 /* HydrophobicAtom */], addHydrophobicAtom);
export var HydrophobicProvider = {
name: 'hydrophobic',
params: HydrophobicParams,
createTester: function (props) {
return {
maxDistance: props.distanceMax,
requiredFeatures: new Set([8 /* HydrophobicAtom */]),
getType: function (structure, infoA, infoB, distanceSq) { return testHydrophobic(structure, infoA, infoB, distanceSq); }
};
}
};
//# sourceMappingURL=hydrophobic.js.map