Skip to content

Commit

Permalink
don't use worker in local builds
Browse files Browse the repository at this point in the history
  • Loading branch information
gamcil committed Nov 11, 2024
1 parent dc49739 commit 464a208
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
44 changes: 25 additions & 19 deletions frontend/StructureViewerMSA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import StructureViewerTooltip from './StructureViewerTooltip.vue';
import StructureViewerToolbar from './StructureViewerToolbar.vue';
import StructureViewerMixin from './StructureViewerMixin.vue';
import { tmalign, parse as parseTMOutput, parseMatrix as parseTMMatrix } from 'tmalign-wasm';
import { mockPDB, makeSubPDB, makeMatrix4, interpolateMatrices, animateMatrix } from './Utilities.js';
import { download, PdbWriter, Matrix4, Quaternion, Vector3, concatStructures } from 'ngl';
import { pulchra } from 'pulchra-wasm';
Expand Down Expand Up @@ -192,26 +193,31 @@ ENDMDL
makeSubPDB(refComp.structure, aln ? `${aln.qStartPos}-${aln.qEndPos}` : ''),
makeSubPDB(newComp.structure, aln ? `${aln.dbStartPos}-${aln.dbEndPos}` : '')
]);
const dataToProcess = {
refPDB: targetPDB,
newPDB: queryPDB,
alnFasta: fasta
};
return new Promise((resolve, reject) => {
if (!__LOCAL__) {
const worker = new Worker(new URL("TMAlignWorker.js", import.meta.url));
worker.onmessage = function (e) {
const { t, u, tmResults } = e.data;
resolve({
matrix: makeMatrix4(t, u),
tmResults: tmResults
});
worker.terminate();
}
worker.onerror = function (e) {
reject(e);
worker.terminate();
}
worker.postMessage(dataToProcess);
return new Promise((resolve, reject) => {
worker.onmessage = function (e) {
const { t, u, tmResults } = e.data;
resolve({
matrix: makeMatrix4(t, u),
tmResults: tmResults
});
worker.terminate();
}
worker.onerror = function (e) {
reject(e);
worker.terminate();
}
worker.postMessage({ refPDB: targetPDB, newPDB: queryPDB, alnFasta: fasta });
});
}
const { output, matrix } = await tmalign(targetPDB, queryPDB, fasta);
const { t, u } = parseTMMatrix(matrix);
const tmResults = parseTMOutput(output);
return Promise.resolve({
matrix: makeMatrix4(t, u),
tmResults: tmResults,
alignment: aln
});
},
async addStructureToStage(index, aa, ca) {
Expand Down
32 changes: 22 additions & 10 deletions frontend/webpack.frontend.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module.exports = (env, argv) => {
},
}) : new NullPlugin(),
isLocal ? new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 2,
maxChunks: 3,
}) : new NullPlugin(),
!isProduction && isElectron ?
new webpack.HotModuleReplacementPlugin() : new NullPlugin(),
Expand All @@ -234,19 +234,31 @@ module.exports = (env, argv) => {
}
})],
splitChunks: {
minSize: 0,
minSizeReduction: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
priority: -10,
reuseExistingChunk: true,
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
priority: -10,
reuseExistingChunk: true,
enforce: true
},
workerGroup: {
test: /TMAlignWorker\.js$/,
name: 'tmworker',
chunks: 'all',
priority: -15,
reuseExistingChunk: true,
enforce: true
},
frontend: {
name: 'frontend',
chunks: 'all',
priority: -20,
reuseExistingChunk: true,
name: 'frontend',
chunks: 'all',
priority: -20,
reuseExistingChunk: true,
enforce: true
},
},
}
Expand Down

0 comments on commit 464a208

Please sign in to comment.