Skip to content
Snippets Groups Projects
Commit e02fefa6 authored by Sebastian Bittrich's avatar Sebastian Bittrich
Browse files

4x speedup by limiting # of sphere points to original value

parent 696b188b
No related branches found
No related tags found
No related merge requests found
...@@ -42,8 +42,12 @@ function normalizeAccessibleSurfaceArea(ctx: AccessibleSurfaceAreaContext) { ...@@ -42,8 +42,12 @@ function normalizeAccessibleSurfaceArea(ctx: AccessibleSurfaceAreaContext) {
} }
// TODO compare performance of lookup and naive approach /**
function computePerResidue(ctx: AccessibleSurfaceAreaContext) { * notes on performance - scenario: compute for first 10 units of 3j3q
* lookup3d + refinement: ~5000ms
* naive approach: ~5600ms - higher variance
*/
function computePerResidue(ctx: AccessibleSurfaceAreaContext) { // runs at roughly 5000 ms
const { atomRadius, accessibleSurfaceArea, maxLookupRadius, spherePoints, cons } = ctx; const { atomRadius, accessibleSurfaceArea, maxLookupRadius, spherePoints, cons } = ctx;
const { probeSize } = ctx.params; const { probeSize } = ctx.params;
const { elements: atoms, residueIndex } = ctx.unit; const { elements: atoms, residueIndex } = ctx.unit;
...@@ -201,12 +205,34 @@ function initialize(unit: Unit.Atomic, params: AccessibleSurfaceAreaComputationP ...@@ -201,12 +205,34 @@ function initialize(unit: Unit.Atomic, params: AccessibleSurfaceAreaComputationP
} }
} }
class Count {
static count = 10;
get count(): number {
return Count.count;
}
set count(v: number) {
Count.count = v;
}
}
function computeAccessibleSurfaceArea(unit: Unit.Atomic, params?: Partial<AccessibleSurfaceAreaComputationParameters>): AccessibleSurfaceArea { function computeAccessibleSurfaceArea(unit: Unit.Atomic, params?: Partial<AccessibleSurfaceAreaComputationParameters>): AccessibleSurfaceArea {
console.log(`computing accessible surface area for unit #${ unit.id + 1 }`); const count = new Count();
return _computeAccessibleSurfaceArea(unit, { count.count = count.count - 1;
numberOfSpherePoints: (params && params.numberOfSpherePoints) || 960, if (count.count > 0) {
probeSize: (params && params.probeSize) || 1.4 console.log(`computing accessible surface area for unit #${ unit.id + 1 }`);
}); return _computeAccessibleSurfaceArea(unit, {
numberOfSpherePoints: (params && params.numberOfSpherePoints) || 92 /* original value Shrake, A. & Rupley, J. A. (1973) J. Mol. Biol. 79: 92, BioJava: 960, EPPIC: 3000 */ ,
/** 92: 1600ms, 960: 5000ms, 3000: 13000ms */
probeSize: (params && params.probeSize) || 1.4
});
} else {
return {
atomRadius: [],
accessibleSurfaceArea: [],
relativeAccessibleSurfaceArea: [],
buried: void 0
}
}
} }
/** Creates a collection of points on a sphere by the Golden Section Spiral algorithm. */ /** Creates a collection of points on a sphere by the Golden Section Spiral algorithm. */
......
...@@ -39,7 +39,7 @@ export function AccessibleSurfaceAreaColorTheme(ctx: ThemeDataContext, props: PD ...@@ -39,7 +39,7 @@ export function AccessibleSurfaceAreaColorTheme(ctx: ThemeDataContext, props: PD
color = (location: Location): Color => { color = (location: Location): Color => {
if (StructureElement.isLocation(location)) { if (StructureElement.isLocation(location)) {
if (Unit.isAtomic(location.unit)) { if (Unit.isAtomic(location.unit)) {
const value = location.unit.accessibleSurfaceArea.relativeAccessibleSurfaceArea[location.unit.residueIndex[location.element]]; const value = location.unit.accessibleSurfaceArea.accessibleSurfaceArea[location.unit.residueIndex[location.element]];
return value !== missingAccessibleSurfaceAreaValue ? scaleColor(value) : DefaultColor; return value !== missingAccessibleSurfaceAreaValue ? scaleColor(value) : DefaultColor;
} }
} }
......
...@@ -61,17 +61,19 @@ function getCartoonRepr() { ...@@ -61,17 +61,19 @@ function getCartoonRepr() {
} }
async function init() { async function init() {
const cif = await downloadFromPdb('1brr') const cif = await downloadFromPdb('3j3q')
const models = await getModels(cif) const models = await getModels(cif)
const structure = await getStructure(models[0]) const structure = await getStructure(models[0])
const cartoonRepr = getCartoonRepr() const cartoonRepr = getCartoonRepr()
console.time('ASA');
cartoonRepr.setTheme({ cartoonRepr.setTheme({
color: reprCtx.colorThemeRegistry.create('accessible-surface-area', { structure }), color: reprCtx.colorThemeRegistry.create('accessible-surface-area', { structure }),
size: reprCtx.sizeThemeRegistry.create('uniform', { structure }) size: reprCtx.sizeThemeRegistry.create('uniform', { structure })
}) })
await cartoonRepr.createOrUpdate({ ...CartoonRepresentationProvider.defaultValues, quality: 'auto' }, structure).run() await cartoonRepr.createOrUpdate({ ...CartoonRepresentationProvider.defaultValues, quality: 'auto' }, structure).run()
console.timeEnd('ASA');
// console.time('computeModelDSSP') // console.time('computeModelDSSP')
// const secondaryStructure = computeModelDSSP(models[0].atomicHierarchy, models[0].atomicConformation) // const secondaryStructure = computeModelDSSP(models[0].atomicHierarchy, models[0].atomicConformation)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment