Skip to content
Snippets Groups Projects
Commit ad3c07c6 authored by JonStargaryen's avatar JonStargaryen
Browse files

use correct score

parent 68525c21
Branches
Tags
No related merge requests found
...@@ -112,17 +112,16 @@ namespace Topology { ...@@ -112,17 +112,16 @@ namespace Topology {
const initialHphobHphil = HphobHphil.filtered(offsets, exposed, structure, label_comp_id); const initialHphobHphil = HphobHphil.filtered(offsets, exposed, structure, label_comp_id);
const initialMembrane = findMembrane(generateSpherePoints(params.numberOfSpherePoints, centroid, extent), centroid, params, initialHphobHphil, offsets, exposed, structure, label_comp_id); const initialMembrane = findMembrane(generateSpherePoints(params.numberOfSpherePoints, centroid, extent), centroid, params, initialHphobHphil, offsets, exposed, structure, label_comp_id);
const alternativeMembrane = findMembrane(findProximateAxes(initialMembrane, params.numberOfSpherePoints, centroid, extent), centroid, params, initialHphobHphil, offsets, exposed, structure, label_comp_id); const refinedMembrane = findMembrane(findProximateAxes(initialMembrane, params.numberOfSpherePoints, centroid, extent), centroid, params, initialHphobHphil, offsets, exposed, structure, label_comp_id);
// const membrane = initialMembrane;
const membrane = initialMembrane.qmax! > alternativeMembrane.qmax! ? initialMembrane : alternativeMembrane;
const membrane = initialMembrane.qmax! > refinedMembrane.qmax! ? initialMembrane : refinedMembrane;
return { return {
membrane: createMembraneLayers(membrane, extent, params) membrane: createMembraneLayers(membrane, extent, params)
}; };
} }
function createMembraneLayers(membrane: Membrane, extent: number, params: ANVILProps): Vec3[] { function createMembraneLayers(membrane: Membrane, extent: number, params: ANVILProps): Vec3[] {
console.time('create membrane layers');
const out: Vec3[] = []; const out: Vec3[] = [];
const radius = extent * extent; const radius = extent * extent;
const normalVector = membrane.normalVector!; const normalVector = membrane.normalVector!;
...@@ -130,6 +129,7 @@ namespace Topology { ...@@ -130,6 +129,7 @@ namespace Topology {
createMembraneLayer(out, membrane.planePoint1, normalVector, params.membranePointDensity, radius); createMembraneLayer(out, membrane.planePoint1, normalVector, params.membranePointDensity, radius);
createMembraneLayer(out, membrane.planePoint2, normalVector, params.membranePointDensity, radius); createMembraneLayer(out, membrane.planePoint2, normalVector, params.membranePointDensity, radius);
console.timeEnd('create membrane layers');
return out; return out;
} }
...@@ -151,7 +151,7 @@ namespace Topology { ...@@ -151,7 +151,7 @@ namespace Topology {
stats: HphobHphil, stats: HphobHphil,
normalVector?: Vec3, normalVector?: Vec3,
spherePoint?: Vec3, spherePoint?: Vec3,
center?: Vec3, centroid?: Vec3,
qmax?: number, qmax?: number,
membraneAtoms?: Vec3[] membraneAtoms?: Vec3[]
} }
...@@ -165,16 +165,16 @@ namespace Topology { ...@@ -165,16 +165,16 @@ namespace Topology {
} }
} }
export function scored(spherePoint: Vec3, c1: Vec3, c2: Vec3, stats: HphobHphil, qmax: number, center: Vec3): Membrane { export function scored(spherePoint: Vec3, c1: Vec3, c2: Vec3, stats: HphobHphil, qmax: number, centroid: Vec3): Membrane {
const diam_vect = Vec3(); const diam_vect = Vec3();
Vec3.sub(diam_vect, center, spherePoint); Vec3.sub(diam_vect, centroid, spherePoint);
return { return {
planePoint1: c1, planePoint1: c1,
planePoint2: c2, planePoint2: c2,
stats: stats, stats: stats,
normalVector: diam_vect, normalVector: diam_vect,
spherePoint: spherePoint, spherePoint: spherePoint,
center: center, centroid: centroid,
qmax: qmax, qmax: qmax,
membraneAtoms: [] membraneAtoms: []
} }
...@@ -183,10 +183,11 @@ namespace Topology { ...@@ -183,10 +183,11 @@ namespace Topology {
function findMembrane(spherePoints: Vec3[], centroid: Vec3, params: ANVILProps, initialStats: HphobHphil, offsets: ArrayLike<number>, exposed: ArrayLike<boolean>, structure: Structure, label_comp_id: StructureElement.Property<string>): Membrane { function findMembrane(spherePoints: Vec3[], centroid: Vec3, params: ANVILProps, initialStats: HphobHphil, offsets: ArrayLike<number>, exposed: ArrayLike<boolean>, structure: Structure, label_comp_id: StructureElement.Property<string>): Membrane {
// best performing membrane // best performing membrane
let membrane: Membrane | undefined = void 0; let membrane: Membrane;
// score of the best performing membrane // score of the best performing membrane
let qmax = 0; let qmax = 0;
console.time('membrane placement iteration');
// construct slices of thickness 1.0 along the axis connecting the centroid and the spherePoint // construct slices of thickness 1.0 along the axis connecting the centroid and the spherePoint
for (let i = 0, il = spherePoints.length; i < il; i++) { for (let i = 0, il = spherePoints.length; i < il; i++) {
const spherePoint = spherePoints[i]; const spherePoint = spherePoints[i];
...@@ -237,8 +238,7 @@ namespace Topology { ...@@ -237,8 +238,7 @@ namespace Topology {
const qvaltest = qValue(stats, initialStats); const qvaltest = qValue(stats, initialStats);
if (qvaltest > qmax) { if (qvaltest > qmax) {
qmax = qvaltest; qmax = qvaltest;
console.log(Vec3.distance(c1, c2) + ' ' + qmax); membrane = Membrane.scored(spherePoint, c1, c2, HphobHphil.of(hphob, hphil, total), qmax, centroid);
membrane = Membrane.scored(centroid, c1, c2, HphobHphil.of(hphob, hphil, total), qmax, spherePoint);
} }
} }
} }
...@@ -247,6 +247,9 @@ namespace Topology { ...@@ -247,6 +247,9 @@ namespace Topology {
} }
} }
console.timeEnd('membrane placement iteration');
console.log(`new qvalue: ${ membrane!.qmax }`);
return membrane!; return membrane!;
} }
...@@ -263,7 +266,7 @@ namespace Topology { ...@@ -263,7 +266,7 @@ namespace Topology {
const part_tot = currentStats.hphob + currentStats.hphil; const part_tot = currentStats.hphob + currentStats.hphil;
return (currentStats.hphob * (initialStats.hphil - currentStats.hphil) - currentStats.hphil * (initialStats.hphob - currentStats.hphob)) / return (currentStats.hphob * (initialStats.hphil - currentStats.hphil) - currentStats.hphil * (initialStats.hphob - currentStats.hphob)) /
(part_tot * initialStats.hphob * initialStats.hphil * (tot - part_tot)); Math.sqrt(part_tot * initialStats.hphob * initialStats.hphil * (tot - part_tot));
} }
function isInMembranePlane(testPoint: Vec3, normalVector: Vec3, planePoint1: Vec3, planePoint2: Vec3): boolean { function isInMembranePlane(testPoint: Vec3, normalVector: Vec3, planePoint1: Vec3, planePoint2: Vec3): boolean {
...@@ -297,24 +300,23 @@ namespace Topology { ...@@ -297,24 +300,23 @@ namespace Topology {
// generates sphere points close to that of the initial membrane // generates sphere points close to that of the initial membrane
function findProximateAxes(membrane: Membrane, numberOfSpherePoints: number, centroid: Vec3, extent: number): Vec3[] { function findProximateAxes(membrane: Membrane, numberOfSpherePoints: number, centroid: Vec3, extent: number): Vec3[] {
console.time('find proximate axes');
const points = generateSpherePoints(30000, centroid, extent); const points = generateSpherePoints(30000, centroid, extent);
// const sorted = points.sort((v1, v2) => Vec3.squaredDistance(v1, membrane.point!) - Vec3.squaredDistance(v2, membrane.point!));
// return sorted.splice(0, numberOfSpherePoints);
const imax = points.length;
let j = 4; let j = 4;
let sphere_pts2: Vec3[] = []; let sphere_pts2: Vec3[] = [];
while (sphere_pts2.length < numberOfSpherePoints) { while (sphere_pts2.length < numberOfSpherePoints) {
const d = 2 * extent / numberOfSpherePoints + j; const d = 2 * extent / numberOfSpherePoints + j;
const dsq = d * d; const dsq = d * d;
sphere_pts2 = []; sphere_pts2 = [];
for (let i = 0, il = imax; i < il; i++) { for (let i = 0, il = points.length; i < il; i++) {
if (Vec3.squaredDistance(points[i], centroid) < dsq) { if (Vec3.squaredDistance(points[i], membrane.spherePoint!) < dsq) {
sphere_pts2.push(points[i]); sphere_pts2.push(points[i]);
} }
} }
j += 0.2; j += 0.2;
} }
return sphere_pts2 console.timeEnd('find proximate axes');
return sphere_pts2;
} }
interface HphobHphil { interface HphobHphil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment