Browse Source

Issue #877: fixed webpack config; optional domain and side1 params

cycle20 1 năm trước cách đây
mục cha
commit
1dabc9461b
2 tập tin đã thay đổi với 25 bổ sung10 xóa
  1. 20 9
      src/TmImageRenderer/index.ts
  2. 5 1
      webpack.config.tm-renderer.js

+ 20 - 9
src/TmImageRenderer/index.ts

@@ -2,11 +2,15 @@
  * Copyright (c) 2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Adam Midlik <midlik@gmail.com>
+ */
+/**
+ *
+ * Copyright (C) 2024, Protein Bioinformatics Research Group, HUN-REN RCNS
+ *
+ * Licensed under CC BY-NC 4.0, see LICENSE file for more info.
  *
- * Example command-line application generating images of PDB structures
- * Build: npm install --no-save gl jpeg-js pngjs  // these packages are not listed in dependencies for performance reasons
- *        npm run build
- * Run:   node lib/commonjs/examples/image-renderer 1cbs ../outputs_1cbs/
+ * @author Gabor Tusnady <tusnady.gabor@ttk.hu>
+ * @author Csongor Gerdan <gerdan.csongor@ttk.hu>
  */
 
 import { ArgumentParser } from 'argparse';
@@ -32,23 +36,30 @@ setFSModule(fs);
 
 interface Args {
     pdbId: string,
-    outDirectory: string
+    side1: string,
+    outDirectory: string,
+    domain: string
 }
 
 function parseArguments(): Args {
-    const parser = new ArgumentParser({ description: 'Example command-line application generating images of PDB structures' });
+    const parser = new ArgumentParser({ description: 'Command-line application generating PDBTM images of PDB structures' });
     parser.add_argument('pdbId', { help: 'PDB identifier' });
+    parser.add_argument('--side1', { default: 'Inside', help: 'Inside|Outside|Periplasm (default: Inside)' });
     parser.add_argument('outDirectory', { help: 'Directory for outputs' });
+    const domain = 'http://pdbtm.unitmp.botond.hu';
+    parser.add_argument('--domain', { default: domain, help: `Domain of data source site (default: ${domain})` });
     const args = parser.parse_args();
     return { ...args };
 }
 
 async function main() {
     const args = parseArguments();
-    const structureUrl = `https://pdbtm.unitmp.org/api/v1/entry/${args.pdbId}.updated.cif`;
-    const regionDescriptorUrl = `https://pdbtm.unitmp.org/api/v1/entry/${args.pdbId}.json`;
+    const domain = args.domain;
+    const structureUrl = `${domain}/api/v1/entry/${args.pdbId}.updated.cif`;
+    const regionDescriptorUrl = `${domain}/api/v1/entry/${args.pdbId}.json`;
     const fileName = `${args.pdbId}.jpg`;
     console.log('PDB ID:', args.pdbId);
+    console.log('Side1:', args.side1);
     console.log('Structure URL:', structureUrl);
     console.log('Region descriptor URL:', regionDescriptorUrl);
     console.log('Outputs:', args.outDirectory);
@@ -80,7 +91,7 @@ async function main() {
     await loadWithUNITMPMembraneRepresentation(plugin, {
         structureUrl: structureUrl,
         regionDescriptorUrl: regionDescriptorUrl,
-        side1: "Outside" // TODO
+        side1: args.side1
     });
     //
     // End of TMDET extension registration section

+ 5 - 1
webpack.config.tm-renderer.js

@@ -1,5 +1,9 @@
 const common = require('./webpack.config.common.js');
 const createNodeEntryPoint = common.createNodeEntryPoint;
+
+const rendererEntryPoint = createNodeEntryPoint('index', 'commonjs/TmImageRenderer', 'tmRenderer');
+rendererEntryPoint.externals.gl = 'require("gl")';
+
 module.exports = [
-    createNodeEntryPoint('index', 'commonjs/TmImageRenderer', 'tmRenderer')
+    rendererEntryPoint
 ];